Completed
Push — master ( 00b8fa...130544 )
by Yannick
08:32
created
install/class.update_schema.php 1 patch
Braces   +323 added lines, -120 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 {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1608,41 +1674,65 @@  discard block
 block discarded – undo
1608 1674
 		if ($globalDBdriver == 'mysql') {
1609 1675
 			if (!$Connection->tableExists('tracker_output')) {
1610 1676
 				$error .= create_db::import_file('../db/tracker_output.sql');
1611
-				if ($error != '') return $error;
1677
+				if ($error != '') {
1678
+					return $error;
1679
+				}
1612 1680
 			}
1613 1681
 			if (!$Connection->tableExists('tracker_live')) {
1614 1682
 				$error .= create_db::import_file('../db/tracker_live.sql');
1615
-				if ($error != '') return $error;
1683
+				if ($error != '') {
1684
+					return $error;
1685
+				}
1616 1686
 			}
1617 1687
 			if (!$Connection->tableExists('marine_output')) {
1618 1688
 				$error .= create_db::import_file('../db/marine_output.sql');
1619
-				if ($error != '') return $error;
1689
+				if ($error != '') {
1690
+					return $error;
1691
+				}
1620 1692
 			}
1621 1693
 			if (!$Connection->tableExists('marine_live')) {
1622 1694
 				$error .= create_db::import_file('../db/marine_live.sql');
1623
-				if ($error != '') return $error;
1695
+				if ($error != '') {
1696
+					return $error;
1697
+				}
1624 1698
 			}
1625 1699
 			if (!$Connection->tableExists('marine_identity')) {
1626 1700
 				$error .= create_db::import_file('../db/marine_identity.sql');
1627
-				if ($error != '') return $error;
1701
+				if ($error != '') {
1702
+					return $error;
1703
+				}
1628 1704
 			}
1629 1705
 			if (!$Connection->tableExists('marine_mid')) {
1630 1706
 				$error .= create_db::import_file('../db/marine_mid.sql');
1631
-				if ($error != '') return $error;
1707
+				if ($error != '') {
1708
+					return $error;
1709
+				}
1632 1710
 			}
1633 1711
 		} else {
1634 1712
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1635
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1636 1716
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1637
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1638 1720
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1639
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1640 1724
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1641
-			if ($error != '') return $error;
1725
+			if ($error != '') {
1726
+				return $error;
1727
+			}
1642 1728
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1643
-			if ($error != '') return $error;
1729
+			if ($error != '') {
1730
+				return $error;
1731
+			}
1644 1732
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1645
-			if ($error != '') return $error;
1733
+			if ($error != '') {
1734
+				return $error;
1735
+			}
1646 1736
 		}
1647 1737
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1648 1738
 		try {
@@ -1662,8 +1752,11 @@  discard block
 block discarded – undo
1662 1752
     	    if ($Connection->tableExists('aircraft')) {
1663 1753
     		if (!$Connection->tableExists('config')) {
1664 1754
     		    $version = '1';
1665
-    		    if ($update) return self::update_from_1();
1666
-    		    else return $version;
1755
+    		    if ($update) {
1756
+    		    	return self::update_from_1();
1757
+    		    } else {
1758
+    		    	return $version;
1759
+    		    }
1667 1760
 		} else {
1668 1761
     		    $Connection = new Connection();
1669 1762
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1677,150 +1770,260 @@  discard block
 block discarded – undo
1677 1770
     		    if ($update) {
1678 1771
     			if ($result['value'] == '2') {
1679 1772
     			    $error = self::update_from_2();
1680
-    			    if ($error != '') return $error;
1681
-    			    else return self::check_version(true);
1773
+    			    if ($error != '') {
1774
+    			    	return $error;
1775
+    			    } else {
1776
+    			    	return self::check_version(true);
1777
+    			    }
1682 1778
     			} elseif ($result['value'] == '3') {
1683 1779
     			    $error = self::update_from_3();
1684
-    			    if ($error != '') return $error;
1685
-    			    else return self::check_version(true);
1780
+    			    if ($error != '') {
1781
+    			    	return $error;
1782
+    			    } else {
1783
+    			    	return self::check_version(true);
1784
+    			    }
1686 1785
     			} elseif ($result['value'] == '4') {
1687 1786
     			    $error = self::update_from_4();
1688
-    			    if ($error != '') return $error;
1689
-    			    else return self::check_version(true);
1787
+    			    if ($error != '') {
1788
+    			    	return $error;
1789
+    			    } else {
1790
+    			    	return self::check_version(true);
1791
+    			    }
1690 1792
     			} elseif ($result['value'] == '5') {
1691 1793
     			    $error = self::update_from_5();
1692
-    			    if ($error != '') return $error;
1693
-    			    else return self::check_version(true);
1794
+    			    if ($error != '') {
1795
+    			    	return $error;
1796
+    			    } else {
1797
+    			    	return self::check_version(true);
1798
+    			    }
1694 1799
     			} elseif ($result['value'] == '6') {
1695 1800
     			    $error = self::update_from_6();
1696
-    			    if ($error != '') return $error;
1697
-    			    else return self::check_version(true);
1801
+    			    if ($error != '') {
1802
+    			    	return $error;
1803
+    			    } else {
1804
+    			    	return self::check_version(true);
1805
+    			    }
1698 1806
     			} elseif ($result['value'] == '7') {
1699 1807
     			    $error = self::update_from_7();
1700
-    			    if ($error != '') return $error;
1701
-    			    else return self::check_version(true);
1808
+    			    if ($error != '') {
1809
+    			    	return $error;
1810
+    			    } else {
1811
+    			    	return self::check_version(true);
1812
+    			    }
1702 1813
     			} elseif ($result['value'] == '8') {
1703 1814
     			    $error = self::update_from_8();
1704
-    			    if ($error != '') return $error;
1705
-    			    else return self::check_version(true);
1815
+    			    if ($error != '') {
1816
+    			    	return $error;
1817
+    			    } else {
1818
+    			    	return self::check_version(true);
1819
+    			    }
1706 1820
     			} elseif ($result['value'] == '9') {
1707 1821
     			    $error = self::update_from_9();
1708
-    			    if ($error != '') return $error;
1709
-    			    else return self::check_version(true);
1822
+    			    if ($error != '') {
1823
+    			    	return $error;
1824
+    			    } else {
1825
+    			    	return self::check_version(true);
1826
+    			    }
1710 1827
     			} elseif ($result['value'] == '10') {
1711 1828
     			    $error = self::update_from_10();
1712
-    			    if ($error != '') return $error;
1713
-    			    else return self::check_version(true);
1829
+    			    if ($error != '') {
1830
+    			    	return $error;
1831
+    			    } else {
1832
+    			    	return self::check_version(true);
1833
+    			    }
1714 1834
     			} elseif ($result['value'] == '11') {
1715 1835
     			    $error = self::update_from_11();
1716
-    			    if ($error != '') return $error;
1717
-    			    else return self::check_version(true);
1836
+    			    if ($error != '') {
1837
+    			    	return $error;
1838
+    			    } else {
1839
+    			    	return self::check_version(true);
1840
+    			    }
1718 1841
     			} elseif ($result['value'] == '12') {
1719 1842
     			    $error = self::update_from_12();
1720
-    			    if ($error != '') return $error;
1721
-    			    else return self::check_version(true);
1843
+    			    if ($error != '') {
1844
+    			    	return $error;
1845
+    			    } else {
1846
+    			    	return self::check_version(true);
1847
+    			    }
1722 1848
     			} elseif ($result['value'] == '13') {
1723 1849
     			    $error = self::update_from_13();
1724
-    			    if ($error != '') return $error;
1725
-    			    else return self::check_version(true);
1850
+    			    if ($error != '') {
1851
+    			    	return $error;
1852
+    			    } else {
1853
+    			    	return self::check_version(true);
1854
+    			    }
1726 1855
     			} elseif ($result['value'] == '14') {
1727 1856
     			    $error = self::update_from_14();
1728
-    			    if ($error != '') return $error;
1729
-    			    else return self::check_version(true);
1857
+    			    if ($error != '') {
1858
+    			    	return $error;
1859
+    			    } else {
1860
+    			    	return self::check_version(true);
1861
+    			    }
1730 1862
     			} elseif ($result['value'] == '15') {
1731 1863
     			    $error = self::update_from_15();
1732
-    			    if ($error != '') return $error;
1733
-    			    else return self::check_version(true);
1864
+    			    if ($error != '') {
1865
+    			    	return $error;
1866
+    			    } else {
1867
+    			    	return self::check_version(true);
1868
+    			    }
1734 1869
     			} elseif ($result['value'] == '16') {
1735 1870
     			    $error = self::update_from_16();
1736
-    			    if ($error != '') return $error;
1737
-    			    else return self::check_version(true);
1871
+    			    if ($error != '') {
1872
+    			    	return $error;
1873
+    			    } else {
1874
+    			    	return self::check_version(true);
1875
+    			    }
1738 1876
     			} elseif ($result['value'] == '17') {
1739 1877
     			    $error = self::update_from_17();
1740
-    			    if ($error != '') return $error;
1741
-    			    else return self::check_version(true);
1878
+    			    if ($error != '') {
1879
+    			    	return $error;
1880
+    			    } else {
1881
+    			    	return self::check_version(true);
1882
+    			    }
1742 1883
     			} elseif ($result['value'] == '18') {
1743 1884
     			    $error = self::update_from_18();
1744
-    			    if ($error != '') return $error;
1745
-    			    else return self::check_version(true);
1885
+    			    if ($error != '') {
1886
+    			    	return $error;
1887
+    			    } else {
1888
+    			    	return self::check_version(true);
1889
+    			    }
1746 1890
     			} elseif ($result['value'] == '19') {
1747 1891
     			    $error = self::update_from_19();
1748
-    			    if ($error != '') return $error;
1749
-    			    else return self::check_version(true);
1892
+    			    if ($error != '') {
1893
+    			    	return $error;
1894
+    			    } else {
1895
+    			    	return self::check_version(true);
1896
+    			    }
1750 1897
     			} elseif ($result['value'] == '20') {
1751 1898
     			    $error = self::update_from_20();
1752
-    			    if ($error != '') return $error;
1753
-    			    else return self::check_version(true);
1899
+    			    if ($error != '') {
1900
+    			    	return $error;
1901
+    			    } else {
1902
+    			    	return self::check_version(true);
1903
+    			    }
1754 1904
     			} elseif ($result['value'] == '21') {
1755 1905
     			    $error = self::update_from_21();
1756
-    			    if ($error != '') return $error;
1757
-    			    else return self::check_version(true);
1906
+    			    if ($error != '') {
1907
+    			    	return $error;
1908
+    			    } else {
1909
+    			    	return self::check_version(true);
1910
+    			    }
1758 1911
     			} elseif ($result['value'] == '22') {
1759 1912
     			    $error = self::update_from_22();
1760
-    			    if ($error != '') return $error;
1761
-    			    else return self::check_version(true);
1913
+    			    if ($error != '') {
1914
+    			    	return $error;
1915
+    			    } else {
1916
+    			    	return self::check_version(true);
1917
+    			    }
1762 1918
     			} elseif ($result['value'] == '23') {
1763 1919
     			    $error = self::update_from_23();
1764
-    			    if ($error != '') return $error;
1765
-    			    else return self::check_version(true);
1920
+    			    if ($error != '') {
1921
+    			    	return $error;
1922
+    			    } else {
1923
+    			    	return self::check_version(true);
1924
+    			    }
1766 1925
     			} elseif ($result['value'] == '24') {
1767 1926
     			    $error = self::update_from_24();
1768
-    			    if ($error != '') return $error;
1769
-    			    else return self::check_version(true);
1927
+    			    if ($error != '') {
1928
+    			    	return $error;
1929
+    			    } else {
1930
+    			    	return self::check_version(true);
1931
+    			    }
1770 1932
     			} elseif ($result['value'] == '25') {
1771 1933
     			    $error = self::update_from_25();
1772
-    			    if ($error != '') return $error;
1773
-    			    else return self::check_version(true);
1934
+    			    if ($error != '') {
1935
+    			    	return $error;
1936
+    			    } else {
1937
+    			    	return self::check_version(true);
1938
+    			    }
1774 1939
     			} elseif ($result['value'] == '26') {
1775 1940
     			    $error = self::update_from_26();
1776
-    			    if ($error != '') return $error;
1777
-    			    else return self::check_version(true);
1941
+    			    if ($error != '') {
1942
+    			    	return $error;
1943
+    			    } else {
1944
+    			    	return self::check_version(true);
1945
+    			    }
1778 1946
     			} elseif ($result['value'] == '27') {
1779 1947
     			    $error = self::update_from_27();
1780
-    			    if ($error != '') return $error;
1781
-    			    else return self::check_version(true);
1948
+    			    if ($error != '') {
1949
+    			    	return $error;
1950
+    			    } else {
1951
+    			    	return self::check_version(true);
1952
+    			    }
1782 1953
     			} elseif ($result['value'] == '28') {
1783 1954
     			    $error = self::update_from_28();
1784
-    			    if ($error != '') return $error;
1785
-    			    else return self::check_version(true);
1955
+    			    if ($error != '') {
1956
+    			    	return $error;
1957
+    			    } else {
1958
+    			    	return self::check_version(true);
1959
+    			    }
1786 1960
     			} elseif ($result['value'] == '29') {
1787 1961
     			    $error = self::update_from_29();
1788
-    			    if ($error != '') return $error;
1789
-    			    else return self::check_version(true);
1962
+    			    if ($error != '') {
1963
+    			    	return $error;
1964
+    			    } else {
1965
+    			    	return self::check_version(true);
1966
+    			    }
1790 1967
     			} elseif ($result['value'] == '30') {
1791 1968
     			    $error = self::update_from_30();
1792
-    			    if ($error != '') return $error;
1793
-    			    else return self::check_version(true);
1969
+    			    if ($error != '') {
1970
+    			    	return $error;
1971
+    			    } else {
1972
+    			    	return self::check_version(true);
1973
+    			    }
1794 1974
     			} elseif ($result['value'] == '31') {
1795 1975
     			    $error = self::update_from_31();
1796
-    			    if ($error != '') return $error;
1797
-    			    else return self::check_version(true);
1976
+    			    if ($error != '') {
1977
+    			    	return $error;
1978
+    			    } else {
1979
+    			    	return self::check_version(true);
1980
+    			    }
1798 1981
     			} elseif ($result['value'] == '32') {
1799 1982
     			    $error = self::update_from_32();
1800
-    			    if ($error != '') return $error;
1801
-    			    else return self::check_version(true);
1983
+    			    if ($error != '') {
1984
+    			    	return $error;
1985
+    			    } else {
1986
+    			    	return self::check_version(true);
1987
+    			    }
1802 1988
     			} elseif ($result['value'] == '33') {
1803 1989
     			    $error = self::update_from_33();
1804
-    			    if ($error != '') return $error;
1805
-    			    else return self::check_version(true);
1990
+    			    if ($error != '') {
1991
+    			    	return $error;
1992
+    			    } else {
1993
+    			    	return self::check_version(true);
1994
+    			    }
1806 1995
     			} elseif ($result['value'] == '34') {
1807 1996
     			    $error = self::update_from_34();
1808
-    			    if ($error != '') return $error;
1809
-    			    else return self::check_version(true);
1997
+    			    if ($error != '') {
1998
+    			    	return $error;
1999
+    			    } else {
2000
+    			    	return self::check_version(true);
2001
+    			    }
1810 2002
     			} elseif ($result['value'] == '35') {
1811 2003
     			    $error = self::update_from_35();
1812
-    			    if ($error != '') return $error;
1813
-    			    else return self::check_version(true);
2004
+    			    if ($error != '') {
2005
+    			    	return $error;
2006
+    			    } else {
2007
+    			    	return self::check_version(true);
2008
+    			    }
1814 2009
     			} elseif ($result['value'] == '36') {
1815 2010
     			    $error = self::update_from_36();
1816
-    			    if ($error != '') return $error;
1817
-    			    else return self::check_version(true);
1818
-    			} else return '';
2011
+    			    if ($error != '') {
2012
+    			    	return $error;
2013
+    			    } else {
2014
+    			    	return self::check_version(true);
2015
+    			    }
2016
+    			} else {
2017
+    				return '';
2018
+    			}
2019
+    		    } else {
2020
+    		    	return $result['value'];
1819 2021
     		    }
1820
-    		    else return $result['value'];
1821 2022
 		}
1822 2023
 		
1823
-	    } else return $version;
2024
+	    } else {
2025
+	    	return $version;
2026
+	    }
1824 2027
     	}
1825 2028
     	
1826 2029
 }
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +138 added lines, -51 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,8 +33,11 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		}
36 41
 	}
37 42
 
38 43
 	/**
@@ -44,8 +49,11 @@  discard block
 block discarded – undo
44 49
 	public function getExifCopyright($url) {
45 50
 		$exif = exif_read_data($url);
46 51
 		$copyright = '';
47
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
48
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
52
+		if (isset($exif['COMPUTED']['copyright'])) {
53
+			$copyright = $exif['COMPUTED']['copyright'];
54
+		} elseif (isset($exif['copyright'])) {
55
+			$copyright = $exif['copyright'];
56
+		}
49 57
 		if ($copyright != '') {
50 58
 			$copyright = str_replace('Copyright ','',$copyright);
51 59
 			$copyright = str_replace('© ','',$copyright);
@@ -63,18 +71,29 @@  discard block
 block discarded – undo
63 71
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
64 72
 	{
65 73
 		global $globalDebug,$globalAircraftImageFetch;
66
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
74
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
75
+			return '';
76
+		}
67 77
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
68 78
 		$registration = trim($registration);
69 79
 		//getting the aircraft image
70
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
71
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
72
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
73
-		else return "success";
80
+		if ($globalDebug && $registration != '') {
81
+			echo 'Try to find an aircraft image for '.$registration.'...';
82
+		} elseif ($globalDebug && $aircraft_icao != '') {
83
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
84
+		} elseif ($globalDebug && $airline_icao != '') {
85
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
86
+		} else {
87
+			return "success";
88
+		}
74 89
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
75
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
90
+		if ($registration == '' && $aircraft_icao != '') {
91
+			$registration = $aircraft_icao.$airline_icao;
92
+		}
76 93
 		if ($image_url['original'] != '') {
77
-			if ($globalDebug) echo 'Found !'."\n";
94
+			if ($globalDebug) {
95
+				echo 'Found !'."\n";
96
+			}
78 97
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
79 98
 			try {
80 99
 				$sth = $this->db->prepare($query);
@@ -83,7 +102,9 @@  discard block
 block discarded – undo
83 102
 				echo $e->getMessage()."\n";
84 103
 				return "error";
85 104
 			}
86
-		} elseif ($globalDebug) echo "Not found :'(\n";
105
+		} elseif ($globalDebug) {
106
+			echo "Not found :'(\n";
107
+		}
87 108
 		return "success";
88 109
 	}
89 110
 
@@ -98,40 +119,84 @@  discard block
 block discarded – undo
98 119
 	{
99 120
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
100 121
 		$Spotter = new Spotter($this->db);
101
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
122
+		if (!isset($globalIVAO)) {
123
+			$globalIVAO = FALSE;
124
+		}
102 125
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
103 126
 		if ($aircraft_registration != '') {
104
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
127
+			if (strpos($aircraft_registration,'/') !== false) {
128
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
129
+			}
105 130
 			$aircraft_registration = urlencode(trim($aircraft_registration));
106 131
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
107
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
108
-			else $aircraft_name = '';
109
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
110
-			else $aircraft_icao = '';
111
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
112
-			else $airline_icao = '';
132
+			if (isset($aircraft_info[0]['aircraft_name'])) {
133
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
134
+			} else {
135
+				$aircraft_name = '';
136
+			}
137
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
138
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
139
+			} else {
140
+				$aircraft_icao = '';
141
+			}
142
+			if (isset($aircraft_info[0]['airline_icao'])) {
143
+				$airline_icao = $aircraft_info[0]['airline_icao'];
144
+			} else {
145
+				$airline_icao = '';
146
+			}
113 147
 		} elseif ($aircraft_icao != '') {
114 148
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
115
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
116
-			else $aircraft_name = '';
149
+			if (isset($aircraft_info[0]['type'])) {
150
+				$aircraft_name = $aircraft_info[0]['type'];
151
+			} else {
152
+				$aircraft_name = '';
153
+			}
117 154
 			$aircraft_registration = $aircraft_icao;
118
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
119
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
155
+		} else {
156
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
157
+		}
158
+		if (!isset($globalAircraftImageSources)) {
159
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
160
+		}
120 161
 		foreach ($globalAircraftImageSources as $source) {
121 162
 			$source = strtolower($source);
122
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
123
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
124
-			if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
125
-			if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name);
126
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
127
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
128
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
129
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
130
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
131
-			if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
132
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
163
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
164
+				$images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao);
165
+			}
166
+			if ($source == 'planespotters' && !$globalIVAO) {
167
+				$images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name);
168
+			}
169
+			if ($source == 'flickr') {
170
+				$images_array = $this->fromFlickr($aircraft_registration,$aircraft_name);
171
+			}
172
+			if ($source == 'bing') {
173
+				$images_array = $this->fromBing($aircraft_registration,$aircraft_name);
174
+			}
175
+			if ($source == 'deviantart') {
176
+				$images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name);
177
+			}
178
+			if ($source == 'wikimedia') {
179
+				$images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name);
180
+			}
181
+			if ($source == 'jetphotos' && !$globalIVAO) {
182
+				$images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name);
183
+			}
184
+			if ($source == 'planepictures' && !$globalIVAO) {
185
+				$images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name);
186
+			}
187
+			if ($source == 'airportdata' && !$globalIVAO) {
188
+				$images_array = $this->fromAirportData($aircraft_registration,$aircraft_name);
189
+			}
190
+			if ($source == 'customsources') {
191
+				$images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name);
192
+			}
193
+			if (isset($images_array) && $images_array['original'] != '') {
194
+				return $images_array;
195
+			}
196
+		}
197
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
198
+			return $this->findAircraftImage($aircraft_icao);
133 199
 		}
134
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
135 200
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
136 201
 	}
137 202
 
@@ -288,8 +353,11 @@  discard block
 block discarded – undo
288 353
 	*/
289 354
 	public function fromFlickr($aircraft_registration,$aircraft_name='') {
290 355
 		$Common = new Common();
291
-		if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
292
-		else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
356
+		if ($aircraft_name != '') {
357
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name);
358
+		} else {
359
+			$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft';
360
+		}
293 361
 		$data = $Common->getData($url);
294 362
 		if ($xml = simplexml_load_string($data)) {
295 363
 			if (isset($xml->channel->item)) {
@@ -333,9 +401,14 @@  discard block
 block discarded – undo
333 401
 	public function fromBing($aircraft_registration,$aircraft_name='') {
334 402
 		global $globalImageBingKey;
335 403
 		$Common = new Common();
336
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
337
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
338
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
404
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
405
+			return false;
406
+		}
407
+		if ($aircraft_name != '') {
408
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
409
+		} else {
410
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
411
+		}
339 412
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
340 413
 		$data = $Common->getData($url,'get','',$headers);
341 414
 		$result = json_decode($data);
@@ -389,13 +462,18 @@  discard block
 block discarded – undo
389 462
 	*/
390 463
 	public function fromWikimedia($aircraft_registration,$aircraft_name='') {
391 464
 		$Common = new Common();
392
-		if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
393
-		else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
465
+		if ($aircraft_name != '') {
466
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name);
467
+		} else {
468
+			$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft';
469
+		}
394 470
 		$data = $Common->getData($url);
395 471
 		$result = json_decode($data);
396 472
 		if (isset($result->query->search[0]->title)) {
397 473
 			$fileo = $result->query->search[0]->title;
398
-			if (substr($fileo,-3) == 'pdf') return false;
474
+			if (substr($fileo,-3) == 'pdf') {
475
+				return false;
476
+			}
399 477
 			$file = urlencode($fileo);
400 478
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
401 479
 			$data2 = $Common->getData($url2);
@@ -466,18 +544,27 @@  discard block
 block discarded – undo
466 544
 					$image_url = array();
467 545
 					$image_url['thumbnail'] = $url_thumbnail;
468 546
 					$image_url['original'] = $url;
469
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
470
-					else $exifCopyright = '';
471
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
472
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
473
-					else $image_url['copyright'] = $source['source_website'];
547
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
548
+						$exifCopyright = $this->getExifCopyright($url);
549
+					} else {
550
+						$exifCopyright = '';
551
+					}
552
+					if ($exifCopyright  != '') {
553
+						$image_url['copyright'] = $exifCopyright;
554
+					} elseif (isset($source['copyright'])) {
555
+						$image_url['copyright'] = $source['copyright'];
556
+					} else {
557
+						$image_url['copyright'] = $source['source_website'];
558
+					}
474 559
 					$image_url['source_website'] = $source['source_website'];
475 560
 					$image_url['source'] = $source['source'];
476 561
 					return $image_url;
477 562
 				}
478 563
 			}
479 564
 			return false;
480
-		} else return false;
565
+		} else {
566
+			return false;
567
+		}
481 568
 	}
482 569
 }
483 570
 
Please login to merge, or discard this patch.
live-czml.php 1 patch
Braces   +89 added lines, -31 removed lines patch added patch discarded remove patch
@@ -3,8 +3,12 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Common.php');
4 4
 $tracker = false;
5 5
 $marine = false;
6
-if (isset($_GET['tracker'])) $tracker = true;
7
-if (isset($_GET['marine'])) $marine = true;
6
+if (isset($_GET['tracker'])) {
7
+	$tracker = true;
8
+}
9
+if (isset($_GET['marine'])) {
10
+	$marine = true;
11
+}
8 12
 if ($tracker) {
9 13
 	require_once('require/class.Tracker.php');
10 14
 	require_once('require/class.TrackerLive.php');
@@ -61,23 +65,46 @@  discard block
 block discarded – undo
61 65
 }
62 66
 header('Content-Type: text/javascript');
63 67
 
64
-if (!isset($globalJsonCompress)) $compress = true;
65
-else $compress = $globalJsonCompress;
68
+if (!isset($globalJsonCompress)) {
69
+	$compress = true;
70
+} else {
71
+	$compress = $globalJsonCompress;
72
+}
66 73
 
67 74
 $from_archive = false;
68 75
 $min = false;
69 76
 $allhistory = false;
70 77
 $filter['source'] = array();
71
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
72
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
73
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
74
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
75
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
76
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
79
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
80
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
80
+}
81
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
83
+}
84
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
86
+}
87
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
88
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
89
+}
90
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
91
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
92
+}
93
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
94
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
97
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
100
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
103
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
106
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
107
+}
81 108
 /*
82 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
83 110
 	$min = true;
@@ -162,8 +189,12 @@  discard block
 block discarded – undo
162 189
 	} else {
163 190
 		$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
164 191
 	}
165
-	if ($flightcnt == '') $flightcnt = 0;
166
-} else $flightcnt = 0;
192
+	if ($flightcnt == '') {
193
+		$flightcnt = 0;
194
+	}
195
+	} else {
196
+	$flightcnt = 0;
197
+}
167 198
 
168 199
 $sqltime = round(microtime(true)-$begintime,2);
169 200
 $minitime = time();
@@ -186,7 +217,9 @@  discard block
 block discarded – undo
186 217
 $j = 0;
187 218
 $prev_flightaware_id = '';
188 219
 $speed = 1;
189
-if (isset($archivespeed)) $speed = $archivespeed;
220
+if (isset($archivespeed)) {
221
+	$speed = $archivespeed;
222
+}
190 223
 $output = '[';
191 224
 if ($tracker) {
192 225
 	$output .= '{"id" : "document", "name" : "tracker","version" : "1.0"';
@@ -220,9 +253,13 @@  discard block
 block discarded – undo
220 253
 			$image = "images/placeholder_thumb.png";
221 254
 		}
222 255
 
223
-                if (isset($spotter_item['flightaware_id'])) $id = $spotter_item['flightaware_id'];
224
-                elseif (isset($spotter_item['famtrackid'])) $id = $spotter_item['famtrackid'];
225
-                elseif (isset($spotter_item['fammarine_id'])) $id = $spotter_item['fammarine_id'];
256
+                if (isset($spotter_item['flightaware_id'])) {
257
+                	$id = $spotter_item['flightaware_id'];
258
+                } elseif (isset($spotter_item['famtrackid'])) {
259
+                	$id = $spotter_item['famtrackid'];
260
+                } elseif (isset($spotter_item['fammarine_id'])) {
261
+                	$id = $spotter_item['fammarine_id'];
262
+                }
226 263
                 if ($prev_flightaware_id != $id) {
227 264
 			if ($prev_flightaware_id != '') {
228 265
 				$output .= ']';
@@ -268,7 +305,9 @@  discard block
 block discarded – undo
268 305
 						$spotter_item['engine_type'] = $aircraft_info[0]['engine_type'];
269 306
 						$spotter_item['wake_category'] = $aircraft_info[0]['wake_category'];
270 307
 						$spotter_item['engine_count'] = $aircraft_info[0]['engine_count'];
271
-					} else $aircraft_shadow = '';
308
+					} else {
309
+						$aircraft_shadow = '';
310
+					}
272 311
 					if ($aircraft_shadow != '') {
273 312
 						if (isset($modelsdb[$aircraft_shadow])) {
274 313
 							$output .= '"model": {"gltf" : "'.$globalURL.'/models/'.$modelsdb[$aircraft_shadow].'","scale" : 1.0,"minimumPixelSize": 20';
@@ -405,7 +444,9 @@  discard block
 block discarded – undo
405 444
 							}
406 445
 							$output .= '},';
407 446
 								//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
408
-							if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
447
+							if ($spotter_item['aircraft_icao'] != '') {
448
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
449
+							}
409 450
 							$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
410 451
 						}
411 452
 					} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
@@ -427,7 +468,9 @@  discard block
 block discarded – undo
427 468
 						}
428 469
 						$output .= '},';
429 470
 						//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
430
-						if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
471
+						if ($spotter_item['aircraft_icao'] != '') {
472
+							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
473
+						}
431 474
 						$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
432 475
 					}
433 476
 				} else {
@@ -440,7 +483,9 @@  discard block
 block discarded – undo
440 483
 					}
441 484
 					$output .= '},';
442 485
 					//if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
443
-					if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
486
+					if ($spotter_item['aircraft_icao'] != '') {
487
+						$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
488
+					}
444 489
 					$modelsdb[$aircraft_icao] = 'Cesium_Air.glb';
445 490
 				}
446 491
 			} elseif ($tracker && isset($spotter_item['type'])) {
@@ -495,8 +540,12 @@  discard block
 block discarded – undo
495 540
 	//		$output .= '"interpolationDegree" : 5,';
496 541
 	//		$output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", ';
497 542
 			$output .= '"cartographicDegrees": [';
498
-			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
499
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
543
+			if ($minitime > strtotime($spotter_item['date'])) {
544
+				$minitime = strtotime($spotter_item['date']);
545
+			}
546
+			if ($maxitime < strtotime($spotter_item['date'])) {
547
+				$maxitime = strtotime($spotter_item['date']);
548
+			}
500 549
 			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
501 550
 			$output .= $spotter_item['longitude'].', ';
502 551
 			$output .= $spotter_item['latitude'];
@@ -505,19 +554,26 @@  discard block
 block discarded – undo
505 554
 			if (!$tracker && !$marine) {
506 555
 				$output .= ', '.round($spotter_item['altitude']*30.48);
507 556
 				$prevalt = round($spotter_item['altitude']*30.48);
508
-			} else $output .= ', 0';
557
+			} else {
558
+				$output .= ', 0';
559
+			}
509 560
 			//$orientation = '"orientation" : { ';
510 561
 			//$orientation .= '"unitQuaternion": [';
511 562
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
512 563
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
513 564
 		} else {
514 565
 			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
515
-			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
566
+			if ($maxitime < strtotime($spotter_item['date'])) {
567
+				$maxitime = strtotime($spotter_item['date']);
568
+			}
516 569
 			if ($spotter_item['ground_speed'] == 0) {
517 570
 				$output .= $prevlong.', ';
518 571
 				$output .= $prevlat;
519
-				if (!$tracker && !$marine) $output .= ', '.$prevalt;
520
-				else $output .= ', 0';
572
+				if (!$tracker && !$marine) {
573
+					$output .= ', '.$prevalt;
574
+				} else {
575
+					$output .= ', 0';
576
+				}
521 577
 			} else {
522 578
 				$output .= $spotter_item['longitude'].', ';
523 579
 				$output .= $spotter_item['latitude'];
@@ -531,7 +587,9 @@  discard block
 block discarded – undo
531 587
 					} else {
532 588
 						$output .= ', '.round($spotter_item['altitude']*30.48);
533 589
 					}
534
-				} else $output .= ', 0';
590
+				} else {
591
+					$output .= ', 0';
592
+				}
535 593
 			}
536 594
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
537 595
 			//$orientation .= ',"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +373 added lines, -98 removed lines patch added patch discarded remove patch
@@ -150,11 +150,26 @@  discard block
 block discarded – undo
150 150
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
151 151
 				<li><?php echo _("NOTAM scope:"); ?>
152 152
 					<select class="selectpicker" onchange="notamscope(this);">
153
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
154
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
155
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
156
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
157
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
153
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
154
+	print ' selected';
155
+}
156
+?>>All</option>
157
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
158
+	print ' selected';
159
+}
160
+?>>Airport/Enroute warning</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
166
+	print ' selected';
167
+}
168
+?>>Navigation warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
170
+	print ' selected';
171
+}
172
+?>>Enroute warning</option>
158 173
 					</select
159 174
 				</li>
160 175
 			</ul>
@@ -182,7 +197,12 @@  discard block
 block discarded – undo
182 197
 		        <div class="form-group">
183 198
 			    <label>From (UTC):</label>
184 199
 		            <div class='input-group date' id='datetimepicker1'>
185
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
200
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
201
+	print $_POST['start_date'];
202
+} elseif (isset($_COOKIE['archive_begin'])) {
203
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
204
+}
205
+?>" required />
186 206
 		                <span class="input-group-addon">
187 207
             			    <span class="glyphicon glyphicon-calendar"></span>
188 208
 		                </span>
@@ -191,7 +211,12 @@  discard block
 block discarded – undo
191 211
 		        <div class="form-group">
192 212
 			    <label>To (UTC):</label>
193 213
 		            <div class='input-group date' id='datetimepicker2'>
194
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
214
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
215
+	print $_POST['end_date'];
216
+} elseif (isset($_COOKIE['archive_end'])) {
217
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
218
+}
219
+?>" />
195 220
             			<span class="input-group-addon">
196 221
 		                    <span class="glyphicon glyphicon-calendar"></span>
197 222
             			</span>
@@ -217,8 +242,20 @@  discard block
 block discarded – undo
217 242
 
218 243
 		    <li><?php echo _("Playback speed:"); ?>
219 244
 			<div class="range">
220
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
221
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
245
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
246
+	print $_POST['archivespeed'];
247
+} elseif (isset($_COOKIE['archive_speed'])) {
248
+	print $_COOKIE['archive_speed'];
249
+} else {
250
+	print '1';
251
+}
252
+?>">
253
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
254
+	print $_COOKIE['archive_speed'];
255
+} else {
256
+	print '1';
257
+}
258
+?></output>
222 259
 			</div>
223 260
 		    </li>
224 261
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -240,15 +277,27 @@  discard block
 block discarded – undo
240 277
 		    <li><?php echo _("Type of Map:"); ?>
241 278
 			<select  class="selectpicker" onchange="mapType(this);">
242 279
 			    <?php
243
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244
-				else $MapType = $_COOKIE['MapType'];
280
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
281
+					$MapType = $globalMapProvider;
282
+				} else {
283
+					$MapType = $_COOKIE['MapType'];
284
+				}
245 285
 			    ?>
246 286
 			    <?php
247 287
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248 288
 			    ?>
249
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
289
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
290
+	print ' selected';
291
+}
292
+?>>Bing-Aerial</option>
293
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Hybrid</option>
297
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Road</option>
252 301
 			    <?php
253 302
 				}
254 303
 			    ?>
@@ -258,56 +307,131 @@  discard block
 block discarded – undo
258 307
 			    <?php
259 308
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260 309
 			    ?>
261
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
310
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
311
+	print ' selected';
312
+}
313
+?>>Here-Aerial</option>
314
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Hybrid</option>
318
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Road</option>
264 322
 			    <?php
265 323
 				    }
266 324
 			    ?>
267 325
 			    <?php
268 326
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269 327
 			    ?>
270
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
328
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
329
+	print ' selected';
330
+}
331
+?>>Google Roadmap</option>
332
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
333
+	print ' selected';
334
+}
335
+?>>Google Satellite</option>
336
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
337
+	print ' selected';
338
+}
339
+?>>Google Hybrid</option>
340
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
341
+	print ' selected';
342
+}
343
+?>>Google Terrain</option>
274 344
 			    <?php
275 345
 				    }
276 346
 			    ?>
277 347
 			    <?php
278 348
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279 349
 			    ?>
280
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
350
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
351
+	print ' selected';
352
+}
353
+?>>MapQuest-OSM</option>
354
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-Aerial</option>
358
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Hybrid</option>
283 362
 			    <?php
284 363
 				    }
285 364
 			    ?>
286
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
365
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
366
+	print ' selected';
367
+}
368
+?>>Yandex</option>
287 369
 			    <?php
288 370
 				}
289 371
 			    ?>
290 372
 			    <?php
291 373
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293
-					else $MapBoxId = $_COOKIE['MapTypeId'];
374
+					if (!isset($_COOKIE['MapTypeId'])) {
375
+						$MapBoxId = 'default';
376
+					} else {
377
+						$MapBoxId = $_COOKIE['MapTypeId'];
378
+					}
294 379
 			    ?>
295
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
298
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
299
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
300
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
301
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
302
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
303
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
304
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
305
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
380
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
381
+	print ' selected';
382
+}
383
+?>>Mapbox default</option>
384
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox streets</option>
388
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox light</option>
392
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox dark</option>
396
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox satellite</option>
400
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox streets-satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-basic</option>
408
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox comic</option>
412
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox outdoors</option>
416
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox pencil</option>
420
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pirates</option>
424
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox emerald</option>
307 428
 			    <?php
308 429
 				    }
309 430
 			    ?>
310
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
431
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
432
+	print ' selected';
433
+}
434
+?>>OpenStreetMap</option>
311 435
 			</select>
312 436
 		    </li>
313 437
 <?php
@@ -315,9 +439,18 @@  discard block
 block discarded – undo
315 439
 ?>
316 440
 		    <li><?php echo _("Type of Terrain:"); ?>
317 441
 			<select  class="selectpicker" onchange="terrainType(this);">
318
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
319
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
320
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
442
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
443
+	print ' selected';
444
+}
445
+?>>stk terrain</option>
446
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
447
+	print ' selected';
448
+}
449
+?>>ellipsoid</option>
450
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
451
+	print ' selected';
452
+}
453
+?>>vr terrain</option>
321 454
 			</select>
322 455
 		    </li>
323 456
 <?php
@@ -327,18 +460,36 @@  discard block
 block discarded – undo
327 460
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 461
 ?>
329 462
 		    
330
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
331
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
332
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
463
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
464
+	print 'checked';
465
+}
466
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || !isset($_COOKIE['flightpath'])) {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight path"); ?></label></div></li>
471
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
475
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 479
 <?php
335 480
     }
336 481
 ?>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
482
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
483
+	print 'checked';
484
+}
485
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 486
 <?php
339 487
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 488
 ?>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
489
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
490
+	print 'checked';
491
+}
492
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 493
 <?php
343 494
     }
344 495
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -352,17 +503,25 @@  discard block
 block discarded – undo
352 503
 			if (function_exists('array_column')) {
353 504
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354 505
 		    ?>
355
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
506
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
507
+	print 'checked';
508
+}
509
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 510
 		    <?php
357 511
 			    }
358 512
 			} elseif (isset($globalSources)) {
359 513
 			    $dispolar = false;
360 514
 			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
515
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
516
+			        	$dispolar = true;
517
+			        }
362 518
 			    }
363 519
 			    if ($dispolar) {
364 520
 		    ?>
365
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
521
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
522
+	print 'checked';
523
+}
524
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 525
 		    <?php
367 526
 			    }
368 527
 		        }
@@ -374,12 +533,22 @@  discard block
 block discarded – undo
374 533
 		    <?php
375 534
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
376 535
 		    ?>
377
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
536
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
537
+	print 'checked';
538
+}
539
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 540
 		    <?php 
379 541
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380 542
 		    ?>
381 543
 		    <li><?php echo _("Aircraft icon color:"); ?>
382
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
544
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
545
+	print $_COOKIE['IconColor'];
546
+} elseif (isset($globalAircraftIconColor)) {
547
+	print $globalAircraftIconColor;
548
+} else {
549
+	print '1a3151';
550
+}
551
+?>">
383 552
 		    </li>
384 553
 		    <?php
385 554
 			    }
@@ -387,38 +556,86 @@  discard block
 block discarded – undo
387 556
 		    ?>
388 557
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
389 558
 			<div class="range">
390
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
391
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
559
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
560
+	print $_COOKIE['AirportZoom'];
561
+} elseif (isset($globalAirportZoom)) {
562
+	print $globalAirportZoom;
563
+} else {
564
+	print '7';
565
+}
566
+?>">
567
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
568
+	print $_COOKIE['AirportZoom'];
569
+} elseif (isset($globalAirportZoom)) {
570
+	print $globalAirportZoom;
571
+} else {
572
+	print '7';
573
+}
574
+?></output>
392 575
 			</div>
393 576
 		    </li>
394 577
 <?php
395 578
     } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
396 579
 ?>
397
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
580
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
581
+	print 'checked';
582
+}
583
+?> ><?php echo _("Force Aircraft color"); ?></li>
398 584
 		    <li><?php echo _("Aircraft icon color:"); ?>
399
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
585
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
586
+	print $_COOKIE['IconColor'];
587
+} elseif (isset($globalAircraftIconColor)) {
588
+	print $globalAircraftIconColor;
589
+} else {
590
+	print 'ff0000';
591
+}
592
+?>">
400 593
 		    </li>
401 594
 <?php
402 595
     }
403 596
 ?>
404 597
 		    <li><?php echo _("Distance unit:"); ?>
405 598
 			<select class="selectpicker" onchange="unitdistance(this);">
406
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
407
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
408
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
599
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
600
+	echo ' selected';
601
+}
602
+?>>km</option>
603
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
604
+	echo ' selected';
605
+}
606
+?>>nm</option>
607
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
608
+	echo ' selected';
609
+}
610
+?>>mi</option>
409 611
 		        </select>
410 612
 		    </li>
411 613
 		    <li><?php echo _("Altitude unit:"); ?>
412 614
 			<select class="selectpicker" onchange="unitaltitude(this);">
413
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
414
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
615
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
616
+	echo ' selected';
617
+}
618
+?>>m</option>
619
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
620
+	echo ' selected';
621
+}
622
+?>>feet</option>
415 623
 		        </select>
416 624
 		    </li>
417 625
 		    <li><?php echo _("Speed unit:"); ?>
418 626
 			<select class="selectpicker" onchange="unitspeed(this);">
419
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
420
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
421
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
627
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
628
+	echo ' selected';
629
+}
630
+?>>km/h</option>
631
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
632
+	echo ' selected';
633
+}
634
+?>>mph</option>
635
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
636
+	echo ' selected';
637
+}
638
+?>>knots</option>
422 639
 		        </select>
423 640
 		    </li>
424 641
 
@@ -433,9 +650,18 @@  discard block
 block discarded – undo
433 650
 		    <?php
434 651
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
435 652
 		    ?>
436
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
437
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
438
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
653
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
654
+	print 'checked';
655
+}
656
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
657
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
658
+	print 'checked';
659
+}
660
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
661
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
662
+	print 'checked';
663
+}
664
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
439 665
 		    <?php
440 666
 			}
441 667
 		    ?>
@@ -443,10 +669,16 @@  discard block
 block discarded – undo
443 669
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
444 670
 		    ?>
445 671
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
446
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
672
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
673
+	print 'checked';
674
+}
675
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
447 676
 			<?php } ?>
448 677
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
449
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
678
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
679
+	print 'checked';
680
+}
681
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
450 682
 			<?php } ?>
451 683
 		    <?php
452 684
 			}
@@ -463,7 +695,9 @@  discard block
 block discarded – undo
463 695
 				}
464 696
 				foreach($allairlinenames as $airline) {
465 697
 					$airline_name = $airline['airline_name'];
466
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
698
+					if (strlen($airline_name) > 30) {
699
+						$airline_name = substr($airline_name,0,30).'...';
700
+					}
467 701
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
468 702
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
469 703
 					} else {
@@ -481,7 +715,10 @@  discard block
 block discarded – undo
481 715
 		    <li><?php echo _("Display alliance:"); ?>
482 716
 		    <br/>
483 717
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
484
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
718
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
719
+	echo ' selected';
720
+}
721
+?>><?php echo _("All"); ?></option>
485 722
 			    <?php
486 723
 				foreach($allalliancenames as $alliance) {
487 724
 					$alliance_name = $alliance['alliance'];
@@ -522,10 +759,22 @@  discard block
 block discarded – undo
522 759
 		    ?>
523 760
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
524 761
 			<select class="selectpicker" onchange="airlinestype(this);">
525
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
526
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
527
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
528
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
762
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
763
+	echo ' selected';
764
+}
765
+?>><?php echo _("All"); ?></option>
766
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
767
+	echo ' selected';
768
+}
769
+?>><?php echo _("Passenger"); ?></option>
770
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
771
+	echo ' selected';
772
+}
773
+?>><?php echo _("Cargo"); ?></option>
774
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
775
+	echo ' selected';
776
+}
777
+?>><?php echo _("Military"); ?></option>
529 778
 			</select>
530 779
 		    </li>
531 780
 		    <?php
@@ -533,7 +782,10 @@  discard block
 block discarded – undo
533 782
 		    ?>
534 783
 		    <li>
535 784
 			<?php echo _("Display flight with ident:"); ?>
536
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
785
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
786
+	print $_COOKIE['filter_ident'];
787
+}
788
+?>" />
537 789
 		    </li>
538 790
 		</ul>
539 791
 	    </form>
@@ -549,7 +801,10 @@  discard block
 block discarded – undo
549 801
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
550 802
 	    <form>
551 803
 		<ul>
552
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
804
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
805
+	print 'checked';
806
+}
807
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
553 808
 		    <li><?php echo _("Type:"); ?>
554 809
 			<select class="selectpicker" multiple onchange="sattypes(this);">
555 810
 			    <?php
@@ -557,25 +812,45 @@  discard block
 block discarded – undo
557 812
 				$types = $Satellite->get_tle_types();
558 813
 				foreach ($types as $type) {
559 814
 					$type_name = $type['tle_type'];
560
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
561
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
562
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
563
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
564
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
565
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
566
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
567
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
568
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
569
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
570
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
571
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
572
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
573
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
574
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
575
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
576
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
577
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
578
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
815
+					if ($type_name == 'musson') {
816
+						$type_name = 'Russian LEO Navigation';
817
+					} else if ($type_name == 'nnss') {
818
+						$type_name = 'Navi Navigation Satellite System';
819
+					} else if ($type_name == 'sbas') {
820
+						$type_name = 'Satellite-Based Augmentation System';
821
+					} else if ($type_name == 'glo-ops') {
822
+						$type_name = 'Glonass Operational';
823
+					} else if ($type_name == 'gps-ops') {
824
+						$type_name = 'GPS Operational';
825
+					} else if ($type_name == 'argos') {
826
+						$type_name = 'ARGOS Data Collection System';
827
+					} else if ($type_name == 'tdrss') {
828
+						$type_name = 'Tracking and Data Relay Satellite System';
829
+					} else if ($type_name == 'sarsat') {
830
+						$type_name = 'Search & Rescue';
831
+					} else if ($type_name == 'dmc') {
832
+						$type_name = 'Disaster Monitoring';
833
+					} else if ($type_name == 'resource') {
834
+						$type_name = 'Earth Resources';
835
+					} else if ($type_name == 'stations') {
836
+						$type_name = 'Space Stations';
837
+					} else if ($type_name == 'geo') {
838
+						$type_name = 'Geostationary';
839
+					} else if ($type_name == 'amateur') {
840
+						$type_name = 'Amateur Radio';
841
+					} else if ($type_name == 'x-comm') {
842
+						$type_name = 'Experimental';
843
+					} else if ($type_name == 'other-comm') {
844
+						$type_name = 'Other Comm';
845
+					} else if ($type_name == 'science') {
846
+						$type_name = 'Space & Earth Science';
847
+					} else if ($type_name == 'military') {
848
+						$type_name = 'Miscellaneous Military';
849
+					} else if ($type_name == 'radar') {
850
+						$type_name = 'Radar Calibration';
851
+					} else if ($type_name == 'tle-new') {
852
+						$type_name = 'Last 30 days launches';
853
+					}
579 854
 					
580 855
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
581 856
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +273 added lines, -107 removed lines patch added patch discarded remove patch
@@ -48,27 +48,52 @@  discard block
 block discarded – undo
48 48
 }
49 49
 header('Content-Type: text/javascript');
50 50
 
51
-if (!isset($globalJsonCompress)) $compress = true;
52
-else $compress = $globalJsonCompress;
51
+if (!isset($globalJsonCompress)) {
52
+	$compress = true;
53
+} else {
54
+	$compress = $globalJsonCompress;
55
+}
53 56
 
54 57
 $from_archive = false;
55 58
 $min = true;
56 59
 $allhistory = false;
57 60
 $filter['source'] = array();
58
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
59
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
60
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
61
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs'));
62
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
63
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
64
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
65
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
66
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
67
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
61
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
62
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
63
+}
64
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
65
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
66
+}
67
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
68
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
69
+}
70
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
71
+	$filter['source'] = array_merge($filter['source'],array('sbs'));
72
+}
73
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
74
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
75
+}
76
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
77
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
78
+}
79
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
80
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
81
+}
82
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
83
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
+}
85
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
86
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
87
+}
88
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
89
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
90
+}
68 91
 
69 92
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
70 93
 	$min = true;
71
-} else $min = false;
94
+} else {
95
+	$min = false;
96
+}
72 97
 
73 98
 if (isset($_GET['ident'])) {
74 99
 	$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
@@ -157,21 +182,33 @@  discard block
 block discarded – undo
157 182
 		} else {
158 183
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
159 184
 		}
160
-	} else $flightcnt = count($spotter_array);
161
-	if ($flightcnt == '') $flightcnt = 0;
162
-} else $flightcnt = 0;
185
+	} else {
186
+		$flightcnt = count($spotter_array);
187
+	}
188
+	if ($flightcnt == '') {
189
+		$flightcnt = 0;
190
+	}
191
+	} else {
192
+	$flightcnt = 0;
193
+}
163 194
 
164 195
 $sqltime = round(microtime(true)-$begintime,2);
165 196
 
166
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
167
-else $usenextlatlon = true;
197
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
198
+	$usenextlatlon = false;
199
+} else {
200
+	$usenextlatlon = true;
201
+}
168 202
 $j = 0;
169 203
 $prev_flightaware_id = '';
170 204
 $aircrafts_shadow = array();
171 205
 $output = '{';
172 206
 	$output .= '"type": "FeatureCollection",';
173
-		if ($min) $output .= '"minimal": "true",';
174
-		else $output .= '"minimal": "false",';
207
+		if ($min) {
208
+			$output .= '"minimal": "true",';
209
+		} else {
210
+			$output .= '"minimal": "false",';
211
+		}
175 212
 		$output .= '"fc": "'.$flightcnt.'",';
176 213
 		$output .= '"sqt": "'.$sqltime.'",';
177 214
 
@@ -215,18 +252,29 @@  discard block
 block discarded – undo
215 252
 						}
216 253
 						$output .= '"properties": {';
217 254
 						if (isset($spotter_item['flightaware_id'])) {
218
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
219
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
255
+							if ($compress) {
256
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
257
+							} else {
258
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
259
+							}
220 260
 						} elseif (isset($spotter_item['famtrackid'])) {
221
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
222
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
261
+							if ($compress) {
262
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
263
+							} else {
264
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
265
+							}
223 266
 						} elseif (isset($spotter_item['fammarine_id'])) {
224
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
225
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
267
+							if ($compress) {
268
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
269
+							} else {
270
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
271
+							}
226 272
 						}
227 273
 							$output .= '"fc": "'.$flightcnt.'",';
228 274
 							$output .= '"sqt": "'.$sqltime.'",';
229
-							if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
275
+							if (isset($begindate)) {
276
+								$output .= '"archive_date": "'.$begindate.'",';
277
+							}
230 278
 
231 279
 /*
232 280
 							if ($min) $output .= '"minimal": "true",';
@@ -234,13 +282,21 @@  discard block
 block discarded – undo
234 282
 */
235 283
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
236 284
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
237
-							if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",';
238
-							else $output .= '"callsign": "'.$spotter_item['ident'].'",';
285
+							if ($compress) {
286
+								$output .= '"c": "'.$spotter_item['ident'].'",';
287
+							} else {
288
+								$output .= '"callsign": "'.$spotter_item['ident'].'",';
289
+							}
239 290
 						} else {
240
-							if ($compress) $output .= '"c": "NA",';
241
-							else $output .= '"callsign": "NA",';
291
+							if ($compress) {
292
+								$output .= '"c": "NA",';
293
+							} else {
294
+								$output .= '"callsign": "NA",';
295
+							}
296
+						}
297
+						if (isset($spotter_item['registration'])) {
298
+							$output .= '"registration": "'.$spotter_item['registration'].'",';
242 299
 						}
243
-						if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",';
244 300
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
245 301
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
246 302
 							$output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",';
@@ -253,15 +309,21 @@  discard block
 block discarded – undo
253 309
 							$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
254 310
 						}
255 311
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker) {
256
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
257
-							else {
312
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
313
+								$spotter_item['aircraft_shadow'] = '';
314
+							} else {
258 315
 								$aircraft_icao = $spotter_item['aircraft_icao'];
259
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
260
-								else {
316
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
317
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
318
+								} else {
261 319
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
262
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
263
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
264
-									else $spotter_item['aircraft_shadow'] = '';
320
+									if (count($aircraft_info) > 0) {
321
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
322
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
323
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
324
+									} else {
325
+										$spotter_item['aircraft_shadow'] = '';
326
+									}
265 327
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
266 328
 								}
267 329
 							}
@@ -269,73 +331,139 @@  discard block
 block discarded – undo
269 331
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
270 332
 							if ($tracker) {
271 333
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
272
-									if ($compress) $output .= '"as": "ambulance.png",';
273
-									else $output .= '"aircraft_shadow": "ambulance.png",';
334
+									if ($compress) {
335
+										$output .= '"as": "ambulance.png",';
336
+									} else {
337
+										$output .= '"aircraft_shadow": "ambulance.png",';
338
+									}
274 339
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
275
-									if ($compress) $output .= '"as": "police.png",';
276
-									else $output .= '"aircraft_shadow": "police.png",';
340
+									if ($compress) {
341
+										$output .= '"as": "police.png",';
342
+									} else {
343
+										$output .= '"aircraft_shadow": "police.png",';
344
+									}
277 345
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
278
-									if ($compress) $output .= '"as": "ship.png",';
279
-									else $output .= '"aircraft_shadow": "ship.png",';
346
+									if ($compress) {
347
+										$output .= '"as": "ship.png",';
348
+									} else {
349
+										$output .= '"aircraft_shadow": "ship.png",';
350
+									}
280 351
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
281
-									if ($compress) $output .= '"as": "ship.png",';
282
-									else $output .= '"aircraft_shadow": "ship.png",';
352
+									if ($compress) {
353
+										$output .= '"as": "ship.png",';
354
+									} else {
355
+										$output .= '"aircraft_shadow": "ship.png",';
356
+									}
283 357
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
284
-									if ($compress) $output .= '"as": "ship.png",';
285
-									else $output .= '"aircraft_shadow": "ship.png",';
358
+									if ($compress) {
359
+										$output .= '"as": "ship.png",';
360
+									} else {
361
+										$output .= '"aircraft_shadow": "ship.png",';
362
+									}
286 363
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
287
-									if ($compress) $output .= '"as": "truck.png",';
288
-									else $output .= '"aircraft_shadow": "truck.png",';
364
+									if ($compress) {
365
+										$output .= '"as": "truck.png",';
366
+									} else {
367
+										$output .= '"aircraft_shadow": "truck.png",';
368
+									}
289 369
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
290
-									if ($compress) $output .= '"as": "truck.png",';
291
-									else $output .= '"aircraft_shadow": "truck.png",';
370
+									if ($compress) {
371
+										$output .= '"as": "truck.png",';
372
+									} else {
373
+										$output .= '"aircraft_shadow": "truck.png",';
374
+									}
292 375
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
293
-									if ($compress) $output .= '"as": "aircraft.png",';
294
-									else $output .= '"aircraft_shadow": "aircraft.png",';
376
+									if ($compress) {
377
+										$output .= '"as": "aircraft.png",';
378
+									} else {
379
+										$output .= '"aircraft_shadow": "aircraft.png",';
380
+									}
295 381
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
296
-									if ($compress) $output .= '"as": "aircraft.png",';
297
-									else $output .= '"aircraft_shadow": "aircraft.png",';
382
+									if ($compress) {
383
+										$output .= '"as": "aircraft.png",';
384
+									} else {
385
+										$output .= '"aircraft_shadow": "aircraft.png",';
386
+									}
298 387
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
299
-									if ($compress) $output .= '"as": "helico.png",';
300
-									else $output .= '"aircraft_shadow": "helico.png",';
388
+									if ($compress) {
389
+										$output .= '"as": "helico.png",';
390
+									} else {
391
+										$output .= '"aircraft_shadow": "helico.png",';
392
+									}
301 393
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
302
-									if ($compress) $output .= '"as": "rail.png",';
303
-									else $output .= '"aircraft_shadow": "rail.png",';
394
+									if ($compress) {
395
+										$output .= '"as": "rail.png",';
396
+									} else {
397
+										$output .= '"aircraft_shadow": "rail.png",';
398
+									}
304 399
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
305
-									if ($compress) $output .= '"as": "firetruck.png",';
306
-									else $output .= '"aircraft_shadow": "firetruck.png",';
400
+									if ($compress) {
401
+										$output .= '"as": "firetruck.png",';
402
+									} else {
403
+										$output .= '"aircraft_shadow": "firetruck.png",';
404
+									}
307 405
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
308
-									if ($compress) $output .= '"as": "bus.png",';
309
-									else $output .= '"aircraft_shadow": "bus.png",';
406
+									if ($compress) {
407
+										$output .= '"as": "bus.png",';
408
+									} else {
409
+										$output .= '"aircraft_shadow": "bus.png",';
410
+									}
310 411
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
311
-									if ($compress) $output .= '"as": "phone.png",';
312
-									else $output .= '"aircraft_shadow": "phone.png",';
412
+									if ($compress) {
413
+										$output .= '"as": "phone.png",';
414
+									} else {
415
+										$output .= '"aircraft_shadow": "phone.png",';
416
+									}
313 417
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
314
-									if ($compress) $output .= '"as": "jogger.png",';
315
-									else $output .= '"aircraft_shadow": "jogger.png",';
418
+									if ($compress) {
419
+										$output .= '"as": "jogger.png",';
420
+									} else {
421
+										$output .= '"aircraft_shadow": "jogger.png",';
422
+									}
316 423
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
317
-									if ($compress) $output .= '"as": "bike.png",';
318
-									else $output .= '"aircraft_shadow": "bike.png",';
424
+									if ($compress) {
425
+										$output .= '"as": "bike.png",';
426
+									} else {
427
+										$output .= '"aircraft_shadow": "bike.png",';
428
+									}
319 429
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
320
-									if ($compress) $output .= '"as": "motorcycle.png",';
321
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
430
+									if ($compress) {
431
+										$output .= '"as": "motorcycle.png",';
432
+									} else {
433
+										$output .= '"aircraft_shadow": "motorcycle.png",';
434
+									}
322 435
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
323
-									if ($compress) $output .= '"as": "balloon.png",';
324
-									else $output .= '"aircraft_shadow": "balloon.png",';
436
+									if ($compress) {
437
+										$output .= '"as": "balloon.png",';
438
+									} else {
439
+										$output .= '"aircraft_shadow": "balloon.png",';
440
+									}
325 441
 								} else {
326
-									if ($compress) $output .= '"as": "car.png",';
327
-									else $output .= '"aircraft_shadow": "car.png",';
442
+									if ($compress) {
443
+										$output .= '"as": "car.png",';
444
+									} else {
445
+										$output .= '"aircraft_shadow": "car.png",';
446
+									}
328 447
 								}
329 448
 							} elseif ($marine) {
330
-								if ($compress) $output .= '"as": "ship.png",';
331
-								else $output .= '"aircraft_shadow": "ship.png",';
449
+								if ($compress) {
450
+									$output .= '"as": "ship.png",';
451
+								} else {
452
+									$output .= '"aircraft_shadow": "ship.png",';
453
+								}
332 454
 							} else {
333
-								if ($compress) $output .= '"as": "default.png",';
334
-								else $output .= '"aircraft_shadow": "default.png",';
455
+								if ($compress) {
456
+									$output .= '"as": "default.png",';
457
+								} else {
458
+									$output .= '"aircraft_shadow": "default.png",';
459
+								}
335 460
 							}
336 461
 						} else {
337
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
338
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
462
+							if ($compress) {
463
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
464
+							} else {
465
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
466
+							}
339 467
 						}
340 468
 						if (isset($spotter_item['airline_name'])) {
341 469
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -343,8 +471,11 @@  discard block
 block discarded – undo
343 471
 							$output .= '"airline_name": "NA",';
344 472
 						}
345 473
 						if (isset($spotter_item['departure_airport'])) {
346
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
347
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
474
+							if ($compress) {
475
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
476
+							} else {
477
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
478
+							}
348 479
 						}
349 480
 						if (isset($spotter_item['departure_airport_city'])) {
350 481
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -356,8 +487,11 @@  discard block
 block discarded – undo
356 487
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
357 488
 						}
358 489
 						if (isset($spotter_item['arrival_airport'])) {
359
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
360
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
490
+							if ($compress) {
491
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
492
+							} else {
493
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
494
+							}
361 495
 						}
362 496
 						if (isset($spotter_item['arrival_airport_city'])) {
363 497
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -376,11 +510,17 @@  discard block
 block discarded – undo
376 510
 						}
377 511
 						
378 512
 						if (isset($spotter_item['altitude'])) {
379
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
380
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
513
+							if ($compress) {
514
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
515
+							} else {
516
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
517
+							}
518
+						}
519
+						if ($compress) {
520
+							$output .= '"h": "'.$spotter_item['heading'].'",';
521
+						} else {
522
+							$output .= '"heading": "'.$spotter_item['heading'].'",';
381 523
 						}
382
-						if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",';
383
-						else $output .= '"heading": "'.$spotter_item['heading'].'",';
384 524
 						
385 525
 						if (isset($archivespeed)) {
386 526
 							$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed);
@@ -390,7 +530,9 @@  discard block
 block discarded – undo
390 530
 							$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
391 531
 						}
392 532
 
393
-						if (!$min) $output .= '"image": "'.$image.'",';
533
+						if (!$min) {
534
+							$output .= '"image": "'.$image.'",';
535
+						}
394 536
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
395 537
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
396 538
 						}
@@ -398,8 +540,11 @@  discard block
 block discarded – undo
398 540
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
399 541
 						}
400 542
 						if (isset($spotter_item['squawk'])) {
401
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
402
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
543
+							if ($compress) {
544
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
545
+							} else {
546
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
547
+							}
403 548
 						}
404 549
 						if (isset($spotter_item['squawk_usage'])) {
405 550
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -418,14 +563,23 @@  discard block
 block discarded – undo
418 563
 						}
419 564
 						// type when not aircraft ?
420 565
 						if (isset($spotter_item['type'])) {
421
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
422
-							else $output .= '"type": "'.$spotter_item['type'].'"';
566
+							if ($compress) {
567
+								$output .= '"t": "'.$spotter_item['type'].'"';
568
+							} else {
569
+								$output .= '"type": "'.$spotter_item['type'].'"';
570
+							}
423 571
 						} elseif ($marine) {
424
-							if ($compress) $output .= '"t": "ship"';
425
-							else $output .= '"type": "ship"';
572
+							if ($compress) {
573
+								$output .= '"t": "ship"';
574
+							} else {
575
+								$output .= '"type": "ship"';
576
+							}
426 577
 						} else {
427
-							if ($compress) $output .= '"t": "aircraft"';
428
-							else $output .= '"type": "aircraft"';
578
+							if ($compress) {
579
+								$output .= '"t": "aircraft"';
580
+							} else {
581
+								$output .= '"type": "aircraft"';
582
+							}
429 583
 						}
430 584
 						$output .= '},';
431 585
 						$output .= '"geometry": {';
@@ -493,7 +647,9 @@  discard block
 block discarded – undo
493 647
 			}
494 648
 */
495 649
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
496
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
650
+				if ($history == '' && isset($_COOKIE['history'])) {
651
+					$history = $_COOKIE['history'];
652
+				}
497 653
 				
498 654
 				if (
499 655
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -525,8 +681,11 @@  discard block
 block discarded – undo
525 681
 									$output_history .= ']}},';
526 682
 									$output .= $output_history;
527 683
 								}
528
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
529
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
684
+								if ($compress) {
685
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
686
+								} else {
687
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
688
+								}
530 689
 							}
531 690
 							$output_history .= '[';
532 691
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -536,9 +695,14 @@  discard block
 block discarded – undo
536 695
 							$prev_alt = $alt;
537 696
 						} else {
538 697
 							if ($d == false) {
539
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
540
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
541
-							} else $d = true;
698
+								if ($compress) {
699
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history"},"geometry": {"type": "LineString","coordinates": [';
700
+								} else {
701
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
702
+								}
703
+							} else {
704
+								$d = true;
705
+							}
542 706
 							$output_history .= '[';
543 707
 							$output_history .=  $spotter_history['longitude'].', ';
544 708
 							$output_history .=  $spotter_history['latitude'];
@@ -581,7 +745,9 @@  discard block
 block discarded – undo
581 745
 			$output .= ']';
582 746
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
583 747
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
584
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
748
+			if (isset($begindate)) {
749
+				$output .= '"archive_date": "'.$begindate.'",';
750
+			}
585 751
 			$output .= '"fc": "'.$j.'"';
586 752
 		} else {
587 753
 			$output .= '"features": ';
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +77 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -161,7 +166,9 @@  discard block
 block discarded – undo
161 166
 			}
162 167
 		}
163 168
 
164
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
165 172
 		if ($globalDBdriver == 'mysql') {
166 173
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
167 174
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -186,7 +193,9 @@  discard block
 block discarded – undo
186 193
 
187 194
 		$filter_query = $this->getFilter($filter,true,true);
188 195
 
189
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
196
+		if (!isset($globalLiveInterval)) {
197
+			$globalLiveInterval = '200';
198
+		}
190 199
 		if ($globalDBdriver == 'mysql') {
191 200
 //			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
192 201
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
@@ -243,7 +252,9 @@  discard block
 block discarded – undo
243 252
 
244 253
 		$filter_query = $this->getFilter($filter,true,true);
245 254
 
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
247 258
 		if ($globalDBdriver == 'mysql') {
248 259
 /*
249 260
 			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -287,7 +298,9 @@  discard block
 block discarded – undo
287 298
 		global $globalDBdriver, $globalLiveInterval;
288 299
 		$filter_query = $this->getFilter($filter,true,true);
289 300
 
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
301
+		if (!isset($globalLiveInterval)) {
302
+			$globalLiveInterval = '200';
303
+		}
291 304
 		if ($globalDBdriver == 'mysql') {
292 305
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
293 306
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -317,7 +330,9 @@  discard block
 block discarded – undo
317 330
 	{
318 331
 		global $globalDBdriver, $globalLiveInterval;
319 332
 		$Spotter = new Spotter($this->db);
320
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
333
+		if (!isset($globalLiveInterval)) {
334
+			$globalLiveInterval = '200';
335
+		}
321 336
 		$filter_query = $this->getFilter($filter);
322 337
 
323 338
 		if (is_array($coord)) {
@@ -325,7 +340,9 @@  discard block
 block discarded – undo
325 340
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326 341
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327 342
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
328
-		} else return array();
343
+		} else {
344
+			return array();
345
+		}
329 346
 		if ($globalDBdriver == 'mysql') {
330 347
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
331 348
 		} else {
@@ -346,7 +363,9 @@  discard block
 block discarded – undo
346 363
 	{
347 364
 		global $globalDBdriver, $globalLiveInterval;
348 365
 		$Spotter = new Spotter($this->db);
349
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
366
+		if (!isset($globalLiveInterval)) {
367
+			$globalLiveInterval = '200';
368
+		}
350 369
 		$filter_query = $this->getFilter($filter,true,true);
351 370
 
352 371
 		if (is_array($coord)) {
@@ -354,7 +373,9 @@  discard block
 block discarded – undo
354 373
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355 374
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356 375
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357
-		} else return array();
376
+		} else {
377
+			return array();
378
+		}
358 379
 		if ($globalDBdriver == 'mysql') {
359 380
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
360 381
 			FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'';
@@ -561,11 +582,15 @@  discard block
 block discarded – undo
561 582
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
562 583
 		if ($globalDBdriver == 'mysql') {
563 584
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
564
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
585
+			if ($liveinterval) {
586
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
587
+			}
565 588
 			$query .= ' ORDER BY date';
566 589
 		} else {
567 590
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
568
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
591
+			if ($liveinterval) {
592
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
593
+			}
569 594
 			$query .= ' ORDER BY date';
570 595
 		}
571 596
 
@@ -660,7 +685,9 @@  discard block
 block discarded – undo
660 685
 				$i++;
661 686
 				$j++;
662 687
 				if ($j == 30) {
663
-					if ($globalDebug) echo ".";
688
+					if ($globalDebug) {
689
+						echo ".";
690
+					}
664 691
 				    	try {
665 692
 						
666 693
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -967,7 +994,9 @@  discard block
 block discarded – undo
967 994
 			{
968 995
 				return false;
969 996
 			}
970
-		} else return '';
997
+		} else {
998
+			return '';
999
+		}
971 1000
 
972 1001
 		if ($longitude != '')
973 1002
 		{
@@ -975,7 +1004,9 @@  discard block
 block discarded – undo
975 1004
 			{
976 1005
 				return false;
977 1006
 			}
978
-		} else return '';
1007
+		} else {
1008
+			return '';
1009
+		}
979 1010
 
980 1011
 		if ($waypoints != '')
981 1012
 		{
@@ -991,7 +1022,9 @@  discard block
 block discarded – undo
991 1022
 			{
992 1023
 				return false;
993 1024
 			}
994
-		} else $altitude = 0;
1025
+		} else {
1026
+			$altitude = 0;
1027
+		}
995 1028
 
996 1029
 		if ($heading != '')
997 1030
 		{
@@ -999,7 +1032,9 @@  discard block
 block discarded – undo
999 1032
 			{
1000 1033
 				return false;
1001 1034
 			}
1002
-		} else $heading = 0;
1035
+		} else {
1036
+			$heading = 0;
1037
+		}
1003 1038
 
1004 1039
 		if ($groundspeed != '')
1005 1040
 		{
@@ -1007,9 +1042,13 @@  discard block
 block discarded – undo
1007 1042
 			{
1008 1043
 				return false;
1009 1044
 			}
1010
-		} else $groundspeed = 0;
1045
+		} else {
1046
+			$groundspeed = 0;
1047
+		}
1011 1048
 		date_default_timezone_set('UTC');
1012
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1049
+		if ($date == '') {
1050
+			$date = date("Y-m-d H:i:s", time());
1051
+		}
1013 1052
 
1014 1053
         
1015 1054
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1053,10 +1092,18 @@  discard block
 block discarded – undo
1053 1092
 		$arrival_airport_country = '';
1054 1093
 		
1055 1094
             	
1056
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1057
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1058
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1059
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1095
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1096
+            		$squawk = NULL;
1097
+            	}
1098
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1099
+            		$verticalrate = NULL;
1100
+            	}
1101
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1102
+            		$groundspeed = 0;
1103
+            	}
1104
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1105
+            		$heading = 0;
1106
+            	}
1060 1107
             	
1061 1108
 		$query  = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
1062 1109
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
@@ -1070,10 +1117,14 @@  discard block
 block discarded – undo
1070 1117
                 	return "error : ".$e->getMessage();
1071 1118
                 }
1072 1119
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1073
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1120
+		    if ($globalDebug) {
1121
+		    	echo '(Add to SBS archive : ';
1122
+		    }
1074 1123
 		    $SpotterArchive = new SpotterArchive($this->db);
1075 1124
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1076
-		    if ($globalDebug) echo $result.')';
1125
+		    if ($globalDebug) {
1126
+		    	echo $result.')';
1127
+		    }
1077 1128
 		}
1078 1129
 		return "success";
1079 1130
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +346 added lines, -122 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
275 326
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
276
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
327
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,17 +355,27 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$icao = $line['aircraft_icao'];
310 375
 			$Spotter = new Spotter($this->db);
311
-			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
376
+			if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
377
+				$icao = $Spotter->aircraft_correct_icaotype[$icao];
378
+			}
312 379
 			$Spotter->db = null;
313 380
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
314 381
 		}
@@ -318,15 +385,24 @@  discard block
 block discarded – undo
318 385
 				$Spotter = new Spotter($this->db);
319 386
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
320 387
 				$Spotter->db = null;
321
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+				if ($aircraft_icao != '') {
389
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
390
+				}
322 391
 			}
323 392
 		}
324 393
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
325
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
326
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
327
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
328
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
329
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
394
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
395
+				$aircraft_icao = 'GLID';
396
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
397
+				$aircraft_icao = 'UHEL';
398
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
399
+				$aircraft_icao = 'TOWPLANE';
400
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
401
+				$aircraft_icao = 'POWAIRC';
402
+			}
403
+			if (isset($aircraft_icao)) {
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
405
+			}
330 406
 		}
331 407
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
332 408
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -336,8 +412,11 @@  discard block
 block discarded – undo
336 412
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
337 413
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
338 414
 		    } else {
339
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
340
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
415
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
416
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
417
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
418
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
419
+				}
341 420
 				/*
342 421
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
343 422
 				print_r($this->all_flights[$id]);
@@ -370,15 +449,25 @@  discard block
 block discarded – undo
370 449
 			    $timeelapsed = microtime(true);
371 450
             		    $Spotter = new Spotter($this->db);
372 451
             		    $fromsource = NULL;
373
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
374
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
375
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
376
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
377
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
452
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
453
+            		    	$fromsource = $globalAirlinesSource;
454
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
455
+            		    	$fromsource = 'vatsim';
456
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
457
+			    	$fromsource = 'ivao';
458
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
459
+			    	$fromsource = 'vatsim';
460
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
461
+			    	$fromsource = 'ivao';
462
+			    }
378 463
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
379
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
464
+			    if ($globalDebug && $result != 'success') {
465
+			    	echo '!!! ERROR : '.$result."\n";
466
+			    }
380 467
 			    $Spotter->db = null;
381
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			    if ($globalDebugTimeElapsed) {
469
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
470
+			    }
382 471
 			}
383 472
 		    }
384 473
 
@@ -390,7 +479,9 @@  discard block
 block discarded – undo
390 479
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
391 480
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
392 481
   */
393
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
482
+		    if (!isset($this->all_flights[$id]['id'])) {
483
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
484
+		    }
394 485
 
395 486
 		    //$putinarchive = true;
396 487
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -408,7 +499,9 @@  discard block
 block discarded – undo
408 499
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
409 500
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
410 501
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
411
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
502
+				if ($globalDebugTimeElapsed) {
503
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
504
+				}
412 505
                         }
413 506
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
414 507
 			$timeelapsed = microtime(true);
@@ -422,7 +515,9 @@  discard block
 block discarded – undo
422 515
 				$Translation->db = null;
423 516
 			    }
424 517
 			    $Spotter->db = null;
425
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
518
+			    if ($globalDebugTimeElapsed) {
519
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
520
+			    }
426 521
                     	}
427 522
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
428 523
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -431,9 +526,13 @@  discard block
 block discarded – undo
431 526
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
432 527
 		    	    }
433 528
 			}
434
-			if (!isset($globalFork)) $globalFork = TRUE;
529
+			if (!isset($globalFork)) {
530
+				$globalFork = TRUE;
531
+			}
435 532
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
436
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
533
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
534
+					$this->get_Schedule($id,trim($line['ident']));
535
+				}
437 536
 			}
438 537
 		    }
439 538
 		}
@@ -449,16 +548,23 @@  discard block
 block discarded – undo
449 548
 		    // use datetime
450 549
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
451 550
 			$speed = $speed*3.6;
452
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
453
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
551
+			if ($speed < 1000) {
552
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
553
+			}
554
+  			if ($globalDebug) {
555
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
556
+  			}
454 557
 		    }
455 558
 		}
456 559
 
457 560
 
458 561
 
459 562
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
460
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
461
-	    	    else unset($timediff);
563
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
564
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
565
+	    	    } else {
566
+	    	    	unset($timediff);
567
+	    	    }
462 568
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
463 569
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
464 570
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -467,15 +573,23 @@  discard block
 block discarded – undo
467 573
 				$this->all_flights[$id]['putinarchive'] = true;
468 574
 				$this->tmd = 0;
469 575
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
470
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
576
+				    if ($globalDebug) {
577
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
578
+				    }
471 579
 				    $timeelapsed = microtime(true);
472 580
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
473 581
 					$Spotter = new Spotter($this->db);
474 582
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
475
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
583
+					if (!empty($all_country)) {
584
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
585
+					}
476 586
 					$Spotter->db = null;
477
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
478
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
587
+					if ($globalDebugTimeElapsed) {
588
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
589
+					}
590
+					if ($globalDebug) {
591
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
592
+					}
479 593
 				    }
480 594
 				}
481 595
 			    }
@@ -483,7 +597,9 @@  discard block
 block discarded – undo
483 597
 
484 598
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
485 599
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
486
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
600
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
601
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
602
+				}
487 603
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
488 604
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
489 605
 				    $dataFound = true;
@@ -505,9 +621,13 @@  discard block
 block discarded – undo
505 621
 			    */
506 622
 			}
507 623
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
508
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
624
+			    if ($line['longitude'] > 180) {
625
+			    	$line['longitude'] = $line['longitude'] - 360;
626
+			    }
509 627
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
510
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
628
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
629
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
630
+				}
511 631
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
512 632
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
513 633
 				    $dataFound = true;
@@ -538,7 +658,9 @@  discard block
 block discarded – undo
538 658
 		    }
539 659
 		}
540 660
 		if (isset($line['last_update']) && $line['last_update'] != '') {
541
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
661
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
662
+		    	$dataFound = true;
663
+		    }
542 664
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
543 665
 		}
544 666
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -560,41 +682,61 @@  discard block
 block discarded – undo
560 682
 			// Here we force archive of flight because after ground it's a new one (or should be)
561 683
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
562 684
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
563
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
564
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
565
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
685
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
686
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
687
+			} elseif (isset($line['id'])) {
688
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
689
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
690
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
691
+			}
692
+		    }
693
+		    if ($line['ground'] != 1) {
694
+		    	$line['ground'] = 0;
566 695
 		    }
567
-		    if ($line['ground'] != 1) $line['ground'] = 0;
568 696
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
569 697
 		    //$dataFound = true;
570 698
 		}
571 699
 		if (isset($line['squawk']) && $line['squawk'] != '') {
572 700
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
573
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
701
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
702
+			    	$this->all_flights[$id]['putinarchive'] = true;
703
+			    }
574 704
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
575 705
 			    $highlight = '';
576
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
577
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
578
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
706
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
707
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
708
+			    }
709
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
710
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
711
+			    }
712
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
713
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
714
+			    }
579 715
 			    if ($highlight != '') {
580 716
 				$timeelapsed = microtime(true);
581 717
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
582 718
 				    $Spotter = new Spotter($this->db);
583 719
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
584 720
 				    $Spotter->db = null;
585
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
+				    if ($globalDebugTimeElapsed) {
722
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
723
+				    }
586 724
 				}
587 725
 				//$putinarchive = true;
588 726
 				//$highlight = '';
589 727
 			    }
590 728
 			    
591
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
729
+		    } else {
730
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
731
+		    }
592 732
 		    //$dataFound = true;
593 733
 		}
594 734
 
595 735
 		if (isset($line['altitude']) && $line['altitude'] != '') {
596 736
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
597
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
737
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
738
+				$this->all_flights[$id]['putinarchive'] = true;
739
+			}
598 740
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
599 741
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
600 742
 			//$dataFound = true;
@@ -606,21 +748,30 @@  discard block
 block discarded – undo
606 748
 		}
607 749
 		
608 750
 		if (isset($line['heading']) && $line['heading'] != '') {
609
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
751
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
752
+		    	$this->all_flights[$id]['putinarchive'] = true;
753
+		    }
610 754
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
611 755
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
612 756
 		    //$dataFound = true;
613 757
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
614 758
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
615 759
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
616
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
617
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
760
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
761
+		    	$this->all_flights[$id]['putinarchive'] = true;
762
+		    }
763
+  		    if ($globalDebug) {
764
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
765
+  		    }
618 766
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
619 767
   		    // If not enough messages and ACARS set heading to 0
620 768
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
621 769
   		}
622
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
623
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
770
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
771
+			$dataFound = false;
772
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
773
+			$dataFound = false;
774
+		}
624 775
 
625 776
 //		print_r($this->all_flights[$id]);
626 777
 		//gets the callsign from the last hour
@@ -636,23 +787,38 @@  discard block
 block discarded – undo
636 787
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
637 788
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
638 789
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
639
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
790
+				    if ($globalDebug) {
791
+				    	echo "Check if aircraft is already in DB...";
792
+				    }
640 793
 				    $timeelapsed = microtime(true);
641 794
 				    $SpotterLive = new SpotterLive($this->db);
642 795
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
643 796
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
644
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
797
+					if ($globalDebugTimeElapsed) {
798
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
799
+					}
645 800
 				    } elseif (isset($line['id'])) {
646 801
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
647
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
802
+					if ($globalDebugTimeElapsed) {
803
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
804
+					}
648 805
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
649 806
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
650
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
651
-				    } else $recent_ident = '';
807
+					if ($globalDebugTimeElapsed) {
808
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
809
+					}
810
+				    } else {
811
+				    	$recent_ident = '';
812
+				    }
652 813
 				    $SpotterLive->db=null;
653
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
654
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
655
-				} else $recent_ident = '';
814
+				    if ($globalDebug && $recent_ident == '') {
815
+				    	echo " Not in DB.\n";
816
+				    } elseif ($globalDebug && $recent_ident != '') {
817
+				    	echo " Already in DB.\n";
818
+				    }
819
+				} else {
820
+					$recent_ident = '';
821
+				}
656 822
 			    } else {
657 823
 				$recent_ident = '';
658 824
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -660,7 +826,9 @@  discard block
 block discarded – undo
660 826
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
661 827
 			    if($recent_ident == "")
662 828
 			    {
663
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
829
+				if ($globalDebug) {
830
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
831
+				}
664 832
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
665 833
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
666 834
 				//adds the spotter data for the archive
@@ -704,31 +872,49 @@  discard block
 block discarded – undo
704 872
 				
705 873
 				if (!$ignoreImport) {
706 874
 				    $highlight = '';
707
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
708
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
709
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
710
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
875
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
876
+				    	$highlight = 'Squawk 7500 : Hijack';
877
+				    }
878
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
879
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
880
+				    }
881
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
882
+				    	$highlight = 'Squawk 7700 : Emergency';
883
+				    }
884
+				    if (!isset($this->all_flights[$id]['id'])) {
885
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
886
+				    }
711 887
 				    $timeelapsed = microtime(true);
712 888
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
713 889
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
714 890
 					    $Spotter = new Spotter($this->db);
715 891
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
716 892
 					    $Spotter->db = null;
717
-					    if ($globalDebug && isset($result)) echo $result."\n";
893
+					    if ($globalDebug && isset($result)) {
894
+					    	echo $result."\n";
895
+					    }
718 896
 					}
719 897
 				    }
720
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
898
+				    if ($globalDebugTimeElapsed) {
899
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
900
+				    }
721 901
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
722 902
 
723 903
 				    // Add source stat in DB
724 904
 				    $Stats = new Stats($this->db);
725 905
 				    if (!empty($this->stats)) {
726
-					if ($globalDebug) echo 'Add source stats : ';
906
+					if ($globalDebug) {
907
+						echo 'Add source stats : ';
908
+					}
727 909
 				        foreach($this->stats as $date => $data) {
728 910
 					    foreach($data as $source => $sourced) {
729 911
 					        //print_r($sourced);
730
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
731
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
912
+				    	        if (isset($sourced['polar'])) {
913
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
914
+				    	        }
915
+				    	        if (isset($sourced['hist'])) {
916
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
917
+				    	        }
732 918
 				    		if (isset($sourced['msg'])) {
733 919
 				    		    if (time() - $sourced['msg']['date'] > 10) {
734 920
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -741,13 +927,17 @@  discard block
 block discarded – undo
741 927
 			    			unset($this->stats[$date]);
742 928
 			    		    }
743 929
 				    	}
744
-				    	if ($globalDebug) echo 'Done'."\n";
930
+				    	if ($globalDebug) {
931
+				    		echo 'Done'."\n";
932
+				    	}
745 933
 
746 934
 				    }
747 935
 				    $Stats->db = null;
748 936
 				    }
749 937
 				    $this->del();
750
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
938
+				} elseif ($globalDebug) {
939
+					echo 'Ignore data'."\n";
940
+				}
751 941
 				//$ignoreImport = false;
752 942
 				$this->all_flights[$id]['addedSpotter'] = 1;
753 943
 				//print_r($this->all_flights[$id]);
@@ -764,7 +954,9 @@  discard block
 block discarded – undo
764 954
 			*/
765 955
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
766 956
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
767
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
957
+				    if ($globalDebug) {
958
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
959
+				    }
768 960
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
769 961
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
770 962
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -773,7 +965,9 @@  discard block
 block discarded – undo
773 965
 					    $SpotterLive->db=null;
774 966
 					}
775 967
 				    }
776
-				    if ($globalDebug) echo " Done\n";
968
+				    if ($globalDebug) {
969
+				    	echo " Done\n";
970
+				    }
777 971
 				    $this->last_delete = time();
778 972
 				}
779 973
 			    } else {
@@ -800,11 +994,17 @@  discard block
 block discarded – undo
800 994
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
801 995
 		    if ($globalDebug) {
802 996
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
803
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
804
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
997
+				if (isset($this->all_flights[$id]['source_name'])) {
998
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
999
+				} else {
1000
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1001
+				}
805 1002
 			} else {
806
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
807
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1003
+				if (isset($this->all_flights[$id]['source_name'])) {
1004
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1005
+				} else {
1006
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1007
+				}
808 1008
 			}
809 1009
 		    }
810 1010
 		    $ignoreImport = false;
@@ -850,22 +1050,30 @@  discard block
 block discarded – undo
850 1050
 
851 1051
 		    if (!$ignoreImport) {
852 1052
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
853
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1053
+				if (!isset($this->all_flights[$id]['id'])) {
1054
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1055
+				}
854 1056
 				$timeelapsed = microtime(true);
855 1057
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 1058
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
857
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1059
+					if ($globalDebug) {
1060
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1061
+					}
858 1062
 					$SpotterLive = new SpotterLive($this->db);
859 1063
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
860 1064
 					$SpotterLive->db = null;
861
-					if ($globalDebug) echo $result."\n";
1065
+					if ($globalDebug) {
1066
+						echo $result."\n";
1067
+					}
862 1068
 				    }
863 1069
 				}
864 1070
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
865 1071
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
866 1072
 				}
867 1073
 				$this->all_flights[$id]['putinarchive'] = false;
868
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1074
+				if ($globalDebugTimeElapsed) {
1075
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1076
+				}
869 1077
 
870 1078
 				// Put statistics in $this->stats variable
871 1079
 				//if ($line['format_source'] != 'aprs') {
@@ -873,7 +1081,9 @@  discard block
 block discarded – undo
873 1081
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
874 1082
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
875 1083
 					$source = $this->all_flights[$id]['source_name'];
876
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1084
+					if ($source == '') {
1085
+						$source = $this->all_flights[$id]['format_source'];
1086
+					}
877 1087
 					if (!isset($this->source_location[$source])) {
878 1088
 						$Location = new Source();
879 1089
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -894,7 +1104,9 @@  discard block
 block discarded – undo
894 1104
 					$stats_heading = round($stats_heading/22.5);
895 1105
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
896 1106
 					$current_date = date('Y-m-d');
897
-					if ($stats_heading == 16) $stats_heading = 0;
1107
+					if ($stats_heading == 16) {
1108
+						$stats_heading = 0;
1109
+					}
898 1110
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
899 1111
 						for ($i=0;$i<=15;$i++) {
900 1112
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -912,7 +1124,9 @@  discard block
 block discarded – undo
912 1124
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
913 1125
 						    end($this->stats[$current_date][$source]['hist']);
914 1126
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
915
-						} else $mini = 0;
1127
+						} else {
1128
+							$mini = 0;
1129
+						}
916 1130
 						for ($i=$mini;$i<=$distance;$i+=10) {
917 1131
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
918 1132
 						}
@@ -924,19 +1138,27 @@  discard block
 block discarded – undo
924 1138
 				}
925 1139
 
926 1140
 				$this->all_flights[$id]['lastupdate'] = time();
927
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1141
+				if ($this->all_flights[$id]['putinarchive']) {
1142
+					$send = true;
1143
+				}
928 1144
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
929
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1145
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1146
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1147
+			}
930 1148
 			//$this->del();
931 1149
 			
932 1150
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
933 1151
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
934
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1152
+				if ($globalDebug) {
1153
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1154
+				}
935 1155
 				$SpotterLive = new SpotterLive($this->db);
936 1156
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
937 1157
 				$SpotterLive->db = null;
938 1158
 				//SpotterLive->deleteLiveSpotterData();
939
-				if ($globalDebug) echo " Done\n";
1159
+				if ($globalDebug) {
1160
+					echo " Done\n";
1161
+				}
940 1162
 				$this->last_delete_hourly = time();
941 1163
 			    } else {
942 1164
 				$this->del();
@@ -948,7 +1170,9 @@  discard block
 block discarded – undo
948 1170
 		    //$ignoreImport = false;
949 1171
 		}
950 1172
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
951
-		if ($send) return $this->all_flights[$id];
1173
+		if ($send) {
1174
+			return $this->all_flights[$id];
1175
+		}
952 1176
 	    }
953 1177
 	}
954 1178
     }
Please login to merge, or discard this patch.
aircraft-data.php 1 patch
Braces   +34 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 {
56 56
 	if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
57 57
 		$image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
58
-	} else $image = $spotter_item['image_thumbnail'];
58
+	} else {
59
+		$image = $spotter_item['image_thumbnail'];
60
+	}
59 61
 
60 62
 }
61 63
 /* else {
@@ -67,7 +69,9 @@  discard block
 block discarded – undo
67 69
 	print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
68 70
 }
69 71
 print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
70
-if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
72
+if (isset($spotter_item['airline_name'])) {
73
+	print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
74
+}
71 75
 print '</div>';
72 76
 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
73 77
 if (isset($spotter_item['departure_airport_time'])) {
@@ -95,9 +99,14 @@  discard block
 block discarded – undo
95 99
 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
96 100
 print '</div></div><div id="aircraft">';
97 101
 print '<span>'._("Aircraft").'</span>';
98
-if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
99
-if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
100
-else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
102
+if (isset($spotter_item['aircraft_wiki'])) {
103
+	print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
104
+}
105
+if (isset($spotter_item['aircraft_type'])) {
106
+	print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
107
+} else {
108
+	print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
109
+}
101 110
 print '</div>';
102 111
 print '<div id ="altitude"><span>'._("Altitude").'</span>';
103 112
 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
@@ -106,7 +115,9 @@  discard block
 block discarded – undo
106 115
 	print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
107 116
 }
108 117
 print '</div>';
109
-if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
118
+if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') {
119
+	print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
120
+}
110 121
 print '<div id="speed"><span>'._("Speed").'</span>';
111 122
 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
112 123
 	print round($spotter_item['ground_speed']*1.15078).' mph';
@@ -120,8 +131,11 @@  discard block
 block discarded – undo
120 131
 print '<div id="heading"><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>';
121 132
 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
122 133
 	print '<div id="pilot"><span>'._("Pilot").'</span>';
123
-	if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
124
-	else print $spotter_item['pilot_name'];
134
+	if (isset($spotter_item['pilot_id'])) {
135
+		print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
136
+	} else {
137
+		print $spotter_item['pilot_name'];
138
+	}
125 139
 	print '</div>';
126 140
 }
127 141
 
@@ -149,10 +163,18 @@  discard block
 block discarded – undo
149 163
 print '</div>';
150 164
 print '</div>';
151 165
 
152
-if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
153
-if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
154
-if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
155
-if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
166
+if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') {
167
+	print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
168
+}
169
+if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') {
170
+	print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
171
+}
172
+if (isset($spotter_item['acars']['message'])) {
173
+	print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
174
+}
175
+if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) {
176
+	print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
177
+}
156 178
 print '</div>';
157 179
 ?>
158 180
 </div>
159 181
\ No newline at end of file
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +791 added lines, -270 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -59,24 +63,45 @@  discard block
 block discarded – undo
59 63
     $globalSources = array();
60 64
     $globalSources[] = array('host' => $options['source']);
61 65
 }
62
-if (isset($options['aprsserverhost'])) $globalServerAPRShost = $options['aprsserverhost'];
63
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
64
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
65
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
66
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
67
-if (isset($options['server'])) $globalServer = TRUE;
68
-if (isset($options['idsource'])) $id_source = $options['idsource'];
69
-else $id_source = 1;
66
+if (isset($options['aprsserverhost'])) {
67
+	$globalServerAPRShost = $options['aprsserverhost'];
68
+}
69
+if (isset($options['aprsserverport'])) {
70
+	$globalServerAPRSport = $options['aprsserverport'];
71
+}
72
+if (isset($options['aprsserverssid'])) {
73
+	$globalServerAPRSssid = $options['aprsserverssid'];
74
+}
75
+if (isset($options['aprsserverpass'])) {
76
+	$globalServerAPRSpass = $options['aprsserverpass'];
77
+}
78
+if (isset($options['nodaemon'])) {
79
+	$globalDaemon = FALSE;
80
+}
81
+if (isset($options['server'])) {
82
+	$globalServer = TRUE;
83
+}
84
+if (isset($options['idsource'])) {
85
+	$id_source = $options['idsource'];
86
+} else {
87
+	$id_source = 1;
88
+}
70 89
 if (isset($globalServer) && $globalServer) {
71
-    if ($globalDebug) echo "Using Server Mode\n";
90
+    if ($globalDebug) {
91
+    	echo "Using Server Mode\n";
92
+    }
72 93
     $SI=new SpotterServer();
73 94
 /*
74 95
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
75 96
     $SI = new adsb2aprs();
76 97
     $SI->connect();
77 98
 */
78
-} else $SI=new SpotterImport($Connection->db);
79
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
99
+} else {
100
+	$SI=new SpotterImport($Connection->db);
101
+}
102
+if (isset($globalTracker) && $globalTracker) {
103
+	$TI = new TrackerImport($Connection->db);
104
+}
80 105
 if (isset($globalMarine) && $globalMarine) {
81 106
     $AIS = new AIS();
82 107
     $MI = new MarineImport($Connection->db);
@@ -98,7 +123,9 @@  discard block
 block discarded – undo
98 123
 }
99 124
 
100 125
 // let's try and connect
101
-if ($globalDebug) echo "Connecting...\n";
126
+if ($globalDebug) {
127
+	echo "Connecting...\n";
128
+}
102 129
 $use_aprs = false;
103 130
 $aprs_full = false;
104 131
 $reset = 0;
@@ -107,7 +134,9 @@  discard block
 block discarded – undo
107 134
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
108 135
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
109 136
     $reset++;
110
-    if ($globalDebug) echo 'Connect to all...'."\n";
137
+    if ($globalDebug) {
138
+    	echo 'Connect to all...'."\n";
139
+    }
111 140
     foreach ($hosts as $id => $value) {
112 141
 	$host = $value['host'];
113 142
 	$globalSources[$id]['last_exec'] = 0;
@@ -117,27 +146,37 @@  discard block
 block discarded – undo
117 146
         	//$formats[$id] = 'deltadbtxt';
118 147
         	$globalSources[$id]['format'] = 'deltadbtxt';
119 148
         	//$last_exec['deltadbtxt'] = 0;
120
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
149
+        	if ($globalDebug) {
150
+        		echo "Connect to deltadb source (".$host.")...\n";
151
+        	}
121 152
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
122 153
         	//$formats[$id] = 'vatsimtxt';
123 154
         	$globalSources[$id]['format'] = 'vatsimtxt';
124 155
         	//$last_exec['vatsimtxt'] = 0;
125
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
156
+        	if ($globalDebug) {
157
+        		echo "Connect to vatsim source (".$host.")...\n";
158
+        	}
126 159
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
127 160
         	//$formats[$id] = 'aircraftlistjson';
128 161
         	$globalSources[$id]['format'] = 'aircraftlistjson';
129 162
         	//$last_exec['aircraftlistjson'] = 0;
130
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
165
+        	}
131 166
     	    } else if (preg_match('/opensky/i',$host)) {
132 167
         	//$formats[$id] = 'aircraftlistjson';
133 168
         	$globalSources[$id]['format'] = 'opensky';
134 169
         	//$last_exec['aircraftlistjson'] = 0;
135
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to opensky source (".$host.")...\n";
172
+        	}
136 173
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
137 174
         	//$formats[$id] = 'radarvirtueljson';
138 175
         	$globalSources[$id]['format'] = 'radarvirtueljson';
139 176
         	//$last_exec['radarvirtueljson'] = 0;
140
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
179
+        	}
141 180
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
142 181
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
143 182
         	    exit(0);
@@ -146,7 +185,9 @@  discard block
 block discarded – undo
146 185
         	//$formats[$id] = 'planeupdatefaa';
147 186
         	$globalSources[$id]['format'] = 'planeupdatefaa';
148 187
         	//$last_exec['planeupdatefaa'] = 0;
149
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
188
+        	if ($globalDebug) {
189
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
190
+        	}
150 191
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
151 192
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
152 193
         	    exit(0);
@@ -155,26 +196,36 @@  discard block
 block discarded – undo
155 196
         	//$formats[$id] = 'phpvmacars';
156 197
         	$globalSources[$id]['format'] = 'phpvmacars';
157 198
         	//$last_exec['phpvmacars'] = 0;
158
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
199
+        	if ($globalDebug) {
200
+        		echo "Connect to phpvmacars source (".$host.")...\n";
201
+        	}
159 202
             } else if (preg_match('/VAM-json.php$/i',$host)) {
160 203
         	//$formats[$id] = 'phpvmacars';
161 204
         	$globalSources[$id]['format'] = 'vam';
162
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
205
+        	if ($globalDebug) {
206
+        		echo "Connect to Vam source (".$host.")...\n";
207
+        	}
163 208
             } else if (preg_match('/whazzup/i',$host)) {
164 209
         	//$formats[$id] = 'whazzup';
165 210
         	$globalSources[$id]['format'] = 'whazzup';
166 211
         	//$last_exec['whazzup'] = 0;
167
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
212
+        	if ($globalDebug) {
213
+        		echo "Connect to whazzup source (".$host.")...\n";
214
+        	}
168 215
             } else if (preg_match('/recentpireps/i',$host)) {
169 216
         	//$formats[$id] = 'pirepsjson';
170 217
         	$globalSources[$id]['format'] = 'pirepsjson';
171 218
         	//$last_exec['pirepsjson'] = 0;
172
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
219
+        	if ($globalDebug) {
220
+        		echo "Connect to pirepsjson source (".$host.")...\n";
221
+        	}
173 222
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
174 223
         	//$formats[$id] = 'fr24json';
175 224
         	$globalSources[$id]['format'] = 'fr24json';
176 225
         	//$last_exec['fr24json'] = 0;
177
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
226
+        	if ($globalDebug) {
227
+        		echo "Connect to fr24 source (".$host.")...\n";
228
+        	}
178 229
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
179 230
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
180 231
         	    exit(0);
@@ -183,7 +234,9 @@  discard block
 block discarded – undo
183 234
         	//$formats[$id] = 'fr24json';
184 235
         	$globalSources[$id]['format'] = 'myshiptracking';
185 236
         	//$last_exec['fr24json'] = 0;
186
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
237
+        	if ($globalDebug) {
238
+        		echo "Connect to myshiptracking source (".$host.")...\n";
239
+        	}
187 240
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188 241
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 242
         	    exit(0);
@@ -192,17 +245,24 @@  discard block
 block discarded – undo
192 245
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
193 246
         	//$formats[$id] = 'tsv';
194 247
         	$globalSources[$id]['format'] = 'tsv';
195
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
248
+        	if ($globalDebug) {
249
+        		echo "Connect to tsv source (".$host.")...\n";
250
+        	}
196 251
             }
197 252
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
198 253
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
199 254
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
200 255
     		    if ($idf !== false) {
201 256
     			$httpfeeds[$id] = $idf;
202
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
+        		if ($globalDebug) {
258
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
259
+        		}
260
+    		    } elseif ($globalDebug) {
261
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
203 262
     		    }
204
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
205
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
263
+    		} elseif ($globalDebug) {
264
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
265
+    		}
206 266
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
207 267
 	    $hostport = explode(':',$host);
208 268
 	    if (isset($hostport[1])) {
@@ -242,17 +302,25 @@  discard block
 block discarded – undo
242 302
         		//$formats[$id] = 'beast';
243 303
         		$globalSources[$id]['format'] = 'beast';
244 304
 		    //} else $formats[$id] = 'sbs';
245
-		    } else $globalSources[$id]['format'] = 'sbs';
305
+		    } else {
306
+		    	$globalSources[$id]['format'] = 'sbs';
307
+		    }
246 308
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
247 309
 		}
248
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
310
+		if ($globalDebug) {
311
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
312
+		}
249 313
             } else {
250
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
314
+		if ($globalDebug) {
315
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
316
+		}
251 317
     	    }
252 318
         }
253 319
     }
254 320
 }
255
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
321
+if (!isset($globalMinFetch)) {
322
+	$globalMinFetch = 15;
323
+}
256 324
 
257 325
 // Initialize all
258 326
 $status = array();
@@ -261,13 +329,19 @@  discard block
 block discarded – undo
261 329
 $formats = array();
262 330
 $last_exec = array();
263 331
 $time = time();
264
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
265
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
266
-else $timeout = 20;
332
+if (isset($globalSourcesTimeout)) {
333
+	$timeout = $globalSourcesTimeOut;
334
+} else if (isset($globalSBS1TimeOut)) {
335
+	$timeout = $globalSBS1TimeOut;
336
+} else {
337
+	$timeout = 20;
338
+}
267 339
 $errno = '';
268 340
 $errstr='';
269 341
 
270
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
342
+if (!isset($globalDaemon)) {
343
+	$globalDaemon = TRUE;
344
+}
271 345
 /* Initiate connections to all the hosts simultaneously */
272 346
 //connect_all($hosts);
273 347
 //connect_all($globalSources);
@@ -293,7 +367,9 @@  discard block
 block discarded – undo
293 367
     if (isset($source['format']) && $source['format'] == 'aprs') {
294 368
 	$aprs_connect = 0;
295 369
 	$use_aprs = true;
296
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
370
+	if (isset($source['port']) && $source['port'] == '10152') {
371
+		$aprs_full = true;
372
+	}
297 373
 	break;
298 374
     }
299 375
 }
@@ -304,25 +380,48 @@  discard block
 block discarded – undo
304 380
 	$aprs_connect = 0;
305 381
 	$aprs_keep = 120;
306 382
 	$aprs_last_tx = time();
307
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
308
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
309
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
310
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
311
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
312
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
313
-	if ($aprs_full) $aprs_filter = '';
314
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
315
-	else $aprs_pass = '-1';
383
+	if (isset($globalAPRSversion)) {
384
+		$aprs_version = $globalAPRSversion;
385
+	} else {
386
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
387
+	}
388
+	if (isset($globalAPRSssid)) {
389
+		$aprs_ssid = $globalAPRSssid;
390
+	} else {
391
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
392
+	}
393
+	if (isset($globalAPRSfilter)) {
394
+		$aprs_filter = $globalAPRSfilter;
395
+	} else {
396
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
397
+	}
398
+	if ($aprs_full) {
399
+		$aprs_filter = '';
400
+	}
401
+	if (isset($globalAPRSpass)) {
402
+		$aprs_pass = $globalAPRSpass;
403
+	} else {
404
+		$aprs_pass = '-1';
405
+	}
316 406
 
317
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
318
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
319
-}
407
+	if ($aprs_filter != '') {
408
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
409
+	} else {
410
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
411
+	}
412
+	}
320 413
 
321 414
 // connected - lets do some work
322
-if ($globalDebug) echo "Connected!\n";
415
+if ($globalDebug) {
416
+	echo "Connected!\n";
417
+}
323 418
 sleep(1);
324
-if ($globalDebug) echo "SCAN MODE \n\n";
325
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
419
+if ($globalDebug) {
420
+	echo "SCAN MODE \n\n";
421
+}
422
+if (!isset($globalCronEnd)) {
423
+	$globalCronEnd = 60;
424
+}
326 425
 $endtime = time()+$globalCronEnd;
327 426
 $i = 1;
328 427
 $tt = array();
@@ -336,10 +435,14 @@  discard block
 block discarded – undo
336 435
 
337 436
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
338 437
 while ($i > 0) {
339
-    if (!$globalDaemon) $i = $endtime-time();
438
+    if (!$globalDaemon) {
439
+    	$i = $endtime-time();
440
+    }
340 441
     // Delete old ATC
341 442
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
342
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
443
+	if ($globalDebug) {
444
+		echo 'Delete old ATC...'."\n";
445
+	}
343 446
         $ATC->deleteOldATC();
344 447
     }
345 448
     
@@ -347,10 +450,14 @@  discard block
 block discarded – undo
347 450
     if (count($last_exec) == count($globalSources)) {
348 451
 	$max = $globalMinFetch;
349 452
 	foreach ($last_exec as $last) {
350
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
453
+	    if ((time() - $last['last']) < $max) {
454
+	    	$max = time() - $last['last'];
455
+	    }
351 456
 	}
352 457
 	if ($max != $globalMinFetch) {
353
-	    if ($globalDebug) echo 'Sleeping...'."\n";
458
+	    if ($globalDebug) {
459
+	    	echo 'Sleeping...'."\n";
460
+	    }
354 461
 	    sleep($globalMinFetch-$max+2);
355 462
 	}
356 463
     }
@@ -359,11 +466,15 @@  discard block
 block discarded – undo
359 466
     //foreach ($formats as $id => $value) {
360 467
     foreach ($globalSources as $id => $value) {
361 468
 	date_default_timezone_set('UTC');
362
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
469
+	if (!isset($last_exec[$id]['last'])) {
470
+		$last_exec[$id]['last'] = 0;
471
+	}
363 472
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
364 473
 	    //$buffer = $Common->getData($hosts[$id]);
365 474
 	    $buffer = $Common->getData($value['host']);
366
-	    if ($buffer != '') $reset = 0;
475
+	    if ($buffer != '') {
476
+	    	$reset = 0;
477
+	    }
367 478
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
368 479
 	    $buffer = explode('\n',$buffer);
369 480
 	    foreach ($buffer as $line) {
@@ -372,19 +483,38 @@  discard block
 block discarded – undo
372 483
 	            $data = array();
373 484
 	            $data['hex'] = $line[1]; // hex
374 485
 	            $data['ident'] = $line[2]; // ident
375
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
376
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
377
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
378
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
379
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
486
+	            if (isset($line[3])) {
487
+	            	$data['altitude'] = $line[3];
488
+	            }
489
+	            // altitude
490
+	            if (isset($line[4])) {
491
+	            	$data['speed'] = $line[4];
492
+	            }
493
+	            // speed
494
+	            if (isset($line[5])) {
495
+	            	$data['heading'] = $line[5];
496
+	            }
497
+	            // heading
498
+	            if (isset($line[6])) {
499
+	            	$data['latitude'] = $line[6];
500
+	            }
501
+	            // lat
502
+	            if (isset($line[7])) {
503
+	            	$data['longitude'] = $line[7];
504
+	            }
505
+	            // long
380 506
 	            $data['verticalrate'] = ''; // vertical rate
381 507
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
382 508
 	            $data['emergency'] = ''; // emergency
383 509
 		    $data['datetime'] = date('Y-m-d H:i:s');
384 510
 		    $data['format_source'] = 'deltadbtxt';
385 511
     		    $data['id_source'] = $id_source;
386
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
387
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
512
+		    if (isset($value['name']) && $value['name'] != '') {
513
+		    	$data['source_name'] = $value['name'];
514
+		    }
515
+		    if (isset($value['sourcestats'])) {
516
+		    	$data['sourcestats'] = $value['sourcestats'];
517
+		    }
388 518
     		    $SI->add($data);
389 519
 		    unset($data);
390 520
     		}
@@ -394,7 +524,9 @@  discard block
 block discarded – undo
394 524
 	    date_default_timezone_set('CET');
395 525
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
396 526
 	    date_default_timezone_set('UTC');
397
-	    if ($buffer != '') $reset = 0;
527
+	    if ($buffer != '') {
528
+	    	$reset = 0;
529
+	    }
398 530
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
399 531
 	    $buffer = explode('\n',$buffer);
400 532
 	    foreach ($buffer as $line) {
@@ -403,16 +535,36 @@  discard block
 block discarded – undo
403 535
 		    $add = false;
404 536
 		    $ais_data = $AIS->parse_line(trim($line));
405 537
 		    $data = array();
406
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
407
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
408
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
409
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
410
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
411
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
412
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
413
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
414
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
415
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
538
+		    if (isset($ais_data['ident'])) {
539
+		    	$data['ident'] = $ais_data['ident'];
540
+		    }
541
+		    if (isset($ais_data['mmsi'])) {
542
+		    	$data['mmsi'] = $ais_data['mmsi'];
543
+		    }
544
+		    if (isset($ais_data['speed'])) {
545
+		    	$data['speed'] = $ais_data['speed'];
546
+		    }
547
+		    if (isset($ais_data['heading'])) {
548
+		    	$data['heading'] = $ais_data['heading'];
549
+		    }
550
+		    if (isset($ais_data['latitude'])) {
551
+		    	$data['latitude'] = $ais_data['latitude'];
552
+		    }
553
+		    if (isset($ais_data['longitude'])) {
554
+		    	$data['longitude'] = $ais_data['longitude'];
555
+		    }
556
+		    if (isset($ais_data['status'])) {
557
+		    	$data['status'] = $ais_data['status'];
558
+		    }
559
+		    if (isset($ais_data['type'])) {
560
+		    	$data['type'] = $ais_data['type'];
561
+		    }
562
+		    if (isset($ais_data['imo'])) {
563
+		    	$data['imo'] = $ais_data['imo'];
564
+		    }
565
+		    if (isset($ais_data['callsign'])) {
566
+		    	$data['callsign'] = $ais_data['callsign'];
567
+		    }
416 568
 		    if (isset($ais_data['timestamp'])) {
417 569
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
418 570
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -427,7 +579,9 @@  discard block
 block discarded – undo
427 579
     		    $data['id_source'] = $id_source;
428 580
 		    print_r($data);
429 581
 		    echo 'Add...'."\n";
430
-		    if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
582
+		    if ($add && $ais_data['mmsi_type'] == 'Ship') {
583
+		    	$MI->add($data);
584
+		    }
431 585
 		    unset($data);
432 586
 		}
433 587
     	    }
@@ -447,18 +601,42 @@  discard block
 block discarded – undo
447 601
 			if ($line != '') {
448 602
 			    $ais_data = $AIS->parse_line(trim($line));
449 603
 			    $data = array();
450
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
451
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
452
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
453
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
454
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
455
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
456
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
457
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
458
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
459
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
460
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
461
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
604
+			    if (isset($ais_data['ident'])) {
605
+			    	$data['ident'] = $ais_data['ident'];
606
+			    }
607
+			    if (isset($ais_data['mmsi'])) {
608
+			    	$data['mmsi'] = $ais_data['mmsi'];
609
+			    }
610
+			    if (isset($ais_data['speed'])) {
611
+			    	$data['speed'] = $ais_data['speed'];
612
+			    }
613
+			    if (isset($ais_data['heading'])) {
614
+			    	$data['heading'] = $ais_data['heading'];
615
+			    }
616
+			    if (isset($ais_data['latitude'])) {
617
+			    	$data['latitude'] = $ais_data['latitude'];
618
+			    }
619
+			    if (isset($ais_data['longitude'])) {
620
+			    	$data['longitude'] = $ais_data['longitude'];
621
+			    }
622
+			    if (isset($ais_data['status'])) {
623
+			    	$data['status'] = $ais_data['status'];
624
+			    }
625
+			    if (isset($ais_data['type'])) {
626
+			    	$data['type'] = $ais_data['type'];
627
+			    }
628
+			    if (isset($ais_data['imo'])) {
629
+			    	$data['imo'] = $ais_data['imo'];
630
+			    }
631
+			    if (isset($ais_data['callsign'])) {
632
+			    	$data['callsign'] = $ais_data['callsign'];
633
+			    }
634
+			    if (isset($ais_data['destination'])) {
635
+			    	$data['arrival_code'] = $ais_data['destination'];
636
+			    }
637
+			    if (isset($ais_data['eta_ts'])) {
638
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
639
+			    }
462 640
 			    if (isset($ais_data['timestamp'])) {
463 641
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
464 642
 			    } else {
@@ -466,7 +644,9 @@  discard block
 block discarded – undo
466 644
 			    }
467 645
 			    $data['format_source'] = 'aisnmeahttp';
468 646
 			    $data['id_source'] = $id_source;
469
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
647
+			    if ($ais_data['mmsi_type'] == 'Ship') {
648
+			    	$MI->add($data);
649
+			    }
470 650
 			    unset($data);
471 651
 			}
472 652
 		    }
@@ -515,7 +695,9 @@  discard block
 block discarded – undo
515 695
 			    $data['callsign'] = $line['callsign'];
516 696
 			    $data['mmsi'] = $line['mmsi'];
517 697
 			    $data['speed'] = $line['sog'];
518
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
698
+			    if ($line['heading'] != '511') {
699
+			    	$data['heading'] = $line['heading'];
700
+			    }
519 701
 			    $data['latitude'] = $line['latitude'];
520 702
 			    $data['longitude'] = $line['longitude'];
521 703
 			    $data['type_id'] = $line['shiptype'];
@@ -535,7 +717,9 @@  discard block
 block discarded – undo
535 717
 	    echo 'download...';
536 718
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
537 719
 	    echo 'done !'."\n";
538
-	    if ($buffer != '') $reset = 0;
720
+	    if ($buffer != '') {
721
+	    	$reset = 0;
722
+	    }
539 723
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
540 724
 	    $buffer = explode('\n',$buffer);
541 725
 	    foreach ($buffer as $line) {
@@ -579,16 +763,28 @@  discard block
 block discarded – undo
579 763
     		    $line = explode(':', $line);
580 764
     		    if (count($line) > 30 && $line[0] != 'callsign') {
581 765
 			$data = array();
582
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
583
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
766
+			if (isset($line[37]) && $line[37] != '') {
767
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
768
+			} else {
769
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
770
+			}
584 771
 			$data['pilot_id'] = $line[1];
585 772
 			$data['pilot_name'] = $line[2];
586 773
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
587 774
 			$data['ident'] = $line[0]; // ident
588
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
775
+			if ($line[7] != '' && $line[7] != 0) {
776
+				$data['altitude'] = $line[7];
777
+			}
778
+			// altitude
589 779
 			$data['speed'] = $line[8]; // speed
590
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
591
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
780
+			if (isset($line[45])) {
781
+				$data['heading'] = $line[45];
782
+			}
783
+			// heading
784
+			elseif (isset($line[38])) {
785
+				$data['heading'] = $line[38];
786
+			}
787
+			// heading
592 788
 			$data['latitude'] = $line[5]; // lat
593 789
 	        	$data['longitude'] = $line[6]; // long
594 790
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -604,7 +800,9 @@  discard block
 block discarded – undo
604 800
 			$data['frequency'] = $line[4];
605 801
 			$data['type'] = $line[18];
606 802
 			$data['range'] = $line[19];
607
-			if (isset($line[35])) $data['info'] = $line[35];
803
+			if (isset($line[35])) {
804
+				$data['info'] = $line[35];
805
+			}
608 806
     			$data['id_source'] = $id_source;
609 807
 	    		//$data['arrival_airport_time'] = ;
610 808
 	    		if ($line[9] != '') {
@@ -618,24 +816,41 @@  discard block
 block discarded – undo
618 816
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
619 817
 	    		*/
620 818
 	    		$data['format_source'] = $value['format'];
621
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622
-    			if ($line[3] == 'PILOT') $SI->add($data);
623
-			elseif ($line[3] == 'ATC') {
819
+			if (isset($value['name']) && $value['name'] != '') {
820
+				$data['source_name'] = $value['name'];
821
+			}
822
+    			if ($line[3] == 'PILOT') {
823
+    				$SI->add($data);
824
+    			} elseif ($line[3] == 'ATC') {
624 825
 				//print_r($data);
625 826
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
626 827
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
627 828
 				$typec = substr($data['ident'],-3);
628
-				if ($typec == 'APP') $data['type'] = 'Approach';
629
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
630
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
631
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
632
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
633
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
634
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
635
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
636
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
637
-				if (!isset($data['source_name'])) $data['source_name'] = '';
638
-				if (isset($ATC)) 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']);
829
+				if ($typec == 'APP') {
830
+					$data['type'] = 'Approach';
831
+				} elseif ($typec == 'TWR') {
832
+					$data['type'] = 'Tower';
833
+				} elseif ($typec == 'OBS') {
834
+					$data['type'] = 'Observer';
835
+				} elseif ($typec == 'GND') {
836
+					$data['type'] = 'Ground';
837
+				} elseif ($typec == 'DEL') {
838
+					$data['type'] = 'Delivery';
839
+				} elseif ($typec == 'DEP') {
840
+					$data['type'] = 'Departure';
841
+				} elseif ($typec == 'FSS') {
842
+					$data['type'] = 'Flight Service Station';
843
+				} elseif ($typec == 'CTR') {
844
+					$data['type'] = 'Control Radar or Centre';
845
+				} elseif ($data['type'] == '') {
846
+					$data['type'] = 'Observer';
847
+				}
848
+				if (!isset($data['source_name'])) {
849
+					$data['source_name'] = '';
850
+				}
851
+				if (isset($ATC)) {
852
+					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']);
853
+				}
639 854
 			}
640 855
     			unset($data);
641 856
     		    }
@@ -654,26 +869,55 @@  discard block
 block discarded – undo
654 869
 		foreach ($all_data['acList'] as $line) {
655 870
 		    $data = array();
656 871
 		    $data['hex'] = $line['Icao']; // hex
657
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
658
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
659
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
660
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
661
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
662
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
872
+		    if (isset($line['Call'])) {
873
+		    	$data['ident'] = $line['Call'];
874
+		    }
875
+		    // ident
876
+		    if (isset($line['Alt'])) {
877
+		    	$data['altitude'] = $line['Alt'];
878
+		    }
879
+		    // altitude
880
+		    if (isset($line['Spd'])) {
881
+		    	$data['speed'] = $line['Spd'];
882
+		    }
883
+		    // speed
884
+		    if (isset($line['Trak'])) {
885
+		    	$data['heading'] = $line['Trak'];
886
+		    }
887
+		    // heading
888
+		    if (isset($line['Lat'])) {
889
+		    	$data['latitude'] = $line['Lat'];
890
+		    }
891
+		    // lat
892
+		    if (isset($line['Long'])) {
893
+		    	$data['longitude'] = $line['Long'];
894
+		    }
895
+		    // long
663 896
 		    //$data['verticalrate'] = $line['']; // verticale rate
664
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
897
+		    if (isset($line['Sqk'])) {
898
+		    	$data['squawk'] = $line['Sqk'];
899
+		    }
900
+		    // squawk
665 901
 		    $data['emergency'] = ''; // emergency
666
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
902
+		    if (isset($line['Reg'])) {
903
+		    	$data['registration'] = $line['Reg'];
904
+		    }
667 905
 		    /*
668 906
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
669 907
 		    else $data['datetime'] = date('Y-m-d H:i:s');
670 908
 		    */
671 909
 		    $data['datetime'] = date('Y-m-d H:i:s');
672
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
910
+		    if (isset($line['Type'])) {
911
+		    	$data['aircraft_icao'] = $line['Type'];
912
+		    }
673 913
 	    	    $data['format_source'] = 'aircraftlistjson';
674 914
 		    $data['id_source'] = $id_source;
675
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
676
-		    if (isset($data['latitude'])) $SI->add($data);
915
+		    if (isset($value['name']) && $value['name'] != '') {
916
+		    	$data['source_name'] = $value['name'];
917
+		    }
918
+		    if (isset($data['latitude'])) {
919
+		    	$SI->add($data);
920
+		    }
677 921
 		    unset($data);
678 922
 		}
679 923
 	    } elseif (is_array($all_data)) {
@@ -693,7 +937,9 @@  discard block
 block discarded – undo
693 937
 		    $data['datetime'] = date('Y-m-d H:i:s');
694 938
 	    	    $data['format_source'] = 'aircraftlistjson';
695 939
     		    $data['id_source'] = $id_source;
696
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
940
+		    if (isset($value['name']) && $value['name'] != '') {
941
+		    	$data['source_name'] = $value['name'];
942
+		    }
697 943
 		    $SI->add($data);
698 944
 		    unset($data);
699 945
 		}
@@ -729,7 +975,9 @@  discard block
 block discarded – undo
729 975
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
730 976
 	    	    $data['format_source'] = 'planeupdatefaa';
731 977
     		    $data['id_source'] = $id_source;
732
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
978
+		    if (isset($value['name']) && $value['name'] != '') {
979
+		    	$data['source_name'] = $value['name'];
980
+		    }
733 981
 		    $SI->add($data);
734 982
 		    unset($data);
735 983
 		}
@@ -769,7 +1017,9 @@  discard block
 block discarded – undo
769 1017
 	    //$buffer = $Common->getData($hosts[$id]);
770 1018
 	    $buffer = $Common->getData($value['host']);
771 1019
 	    $all_data = json_decode($buffer,true);
772
-	    if (!empty($all_data)) $reset = 0;
1020
+	    if (!empty($all_data)) {
1021
+	    	$reset = 0;
1022
+	    }
773 1023
 	    foreach ($all_data as $key => $line) {
774 1024
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
775 1025
 		    $data = array();
@@ -790,7 +1040,9 @@  discard block
 block discarded – undo
790 1040
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
791 1041
 	    	    $data['format_source'] = 'fr24json';
792 1042
     		    $data['id_source'] = $id_source;
793
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1043
+		    if (isset($value['name']) && $value['name'] != '') {
1044
+		    	$data['source_name'] = $value['name'];
1045
+		    }
794 1046
 		    $SI->add($data);
795 1047
 		    unset($data);
796 1048
 		}
@@ -814,23 +1066,39 @@  discard block
 block discarded – undo
814 1066
 		    if (isset($line['inf'])) {
815 1067
 			$data = array();
816 1068
 			$data['hex'] = $line['inf']['ia'];
817
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1069
+			if (isset($line['inf']['cs'])) {
1070
+				$data['ident'] = $line['inf']['cs'];
1071
+			}
1072
+			//$line[13]
818 1073
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
819
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
820
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1074
+	    		if (isset($line['inf']['gs'])) {
1075
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1076
+	    		}
1077
+	    		// speed
1078
+	    		if (isset($line['inf']['tr'])) {
1079
+	    			$data['heading'] = $line['inf']['tr'];
1080
+	    		}
1081
+	    		// heading
821 1082
 	    		$data['latitude'] = $line['pt'][0]; // lat
822 1083
 	    		$data['longitude'] = $line['pt'][1]; // long
823 1084
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
824
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1085
+	    		if (isset($line['inf']['sq'])) {
1086
+	    			$data['squawk'] = $line['inf']['sq'];
1087
+	    		}
1088
+	    		// squawk
825 1089
 	    		//$data['aircraft_icao'] = $line[8];
826
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1090
+	    		if (isset($line['inf']['rc'])) {
1091
+	    			$data['registration'] = $line['inf']['rc'];
1092
+	    		}
827 1093
 			//$data['departure_airport_iata'] = $line[11];
828 1094
 			//$data['arrival_airport_iata'] = $line[12];
829 1095
 	    		//$data['emergency'] = ''; // emergency
830 1096
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
831 1097
 	    		$data['format_source'] = 'radarvirtueljson';
832 1098
     			$data['id_source'] = $id_source;
833
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1099
+			if (isset($value['name']) && $value['name'] != '') {
1100
+				$data['source_name'] = $value['name'];
1101
+			}
834 1102
 			$SI->add($data);
835 1103
 			unset($data);
836 1104
 		    }
@@ -851,29 +1119,62 @@  discard block
 block discarded – undo
851 1119
 		    $data['id'] = $line['id'];
852 1120
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
853 1121
 		    $data['ident'] = $line['callsign']; // ident
854
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
855
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
856
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
857
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
858
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
859
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1122
+		    if (isset($line['pilotid'])) {
1123
+		    	$data['pilot_id'] = $line['pilotid'];
1124
+		    }
1125
+		    // pilot id
1126
+		    if (isset($line['name'])) {
1127
+		    	$data['pilot_name'] = $line['name'];
1128
+		    }
1129
+		    // pilot name
1130
+		    if (isset($line['alt'])) {
1131
+		    	$data['altitude'] = $line['alt'];
1132
+		    }
1133
+		    // altitude
1134
+		    if (isset($line['gs'])) {
1135
+		    	$data['speed'] = $line['gs'];
1136
+		    }
1137
+		    // speed
1138
+		    if (isset($line['heading'])) {
1139
+		    	$data['heading'] = $line['heading'];
1140
+		    }
1141
+		    // heading
1142
+		    if (isset($line['route'])) {
1143
+		    	$data['waypoints'] = $line['route'];
1144
+		    }
1145
+		    // route
860 1146
 		    $data['latitude'] = $line['lat']; // lat
861 1147
 		    $data['longitude'] = $line['lon']; // long
862 1148
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
863 1149
 		    //$data['squawk'] = $line['squawk']; // squawk
864 1150
 		    //$data['emergency'] = ''; // emergency
865
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
866
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
867
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1151
+		    if (isset($line['depicao'])) {
1152
+		    	$data['departure_airport_icao'] = $line['depicao'];
1153
+		    }
1154
+		    if (isset($line['deptime'])) {
1155
+		    	$data['departure_airport_time'] = $line['deptime'];
1156
+		    }
1157
+		    if (isset($line['arricao'])) {
1158
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1159
+		    }
868 1160
 		    //$data['arrival_airport_time'] = $line['arrtime'];
869
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
870
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
871
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
872
-		    else $data['info'] = '';
1161
+		    if (isset($line['aircraft'])) {
1162
+		    	$data['aircraft_icao'] = $line['aircraft'];
1163
+		    }
1164
+		    if (isset($line['transponder'])) {
1165
+		    	$data['squawk'] = $line['transponder'];
1166
+		    }
1167
+		    if (isset($line['atis'])) {
1168
+		    	$data['info'] = $line['atis'];
1169
+		    } else {
1170
+		    	$data['info'] = '';
1171
+		    }
873 1172
 		    $data['format_source'] = 'pireps';
874 1173
     		    $data['id_source'] = $id_source;
875 1174
 		    $data['datetime'] = date('Y-m-d H:i:s');
876
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1175
+		    if (isset($value['name']) && $value['name'] != '') {
1176
+		    	$data['source_name'] = $value['name'];
1177
+		    }
877 1178
 		    if ($line['icon'] == 'plane') {
878 1179
 			$SI->add($data);
879 1180
 		    //    print_r($data);
@@ -882,16 +1183,28 @@  discard block
 block discarded – undo
882 1183
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
883 1184
 			$typec = substr($data['ident'],-3);
884 1185
 			$data['type'] = '';
885
-			if ($typec == 'APP') $data['type'] = 'Approach';
886
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
887
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
888
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
889
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
890
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
891
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
892
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
893
-			else $data['type'] = 'Observer';
894
-			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']);
1186
+			if ($typec == 'APP') {
1187
+				$data['type'] = 'Approach';
1188
+			} elseif ($typec == 'TWR') {
1189
+				$data['type'] = 'Tower';
1190
+			} elseif ($typec == 'OBS') {
1191
+				$data['type'] = 'Observer';
1192
+			} elseif ($typec == 'GND') {
1193
+				$data['type'] = 'Ground';
1194
+			} elseif ($typec == 'DEL') {
1195
+				$data['type'] = 'Delivery';
1196
+			} elseif ($typec == 'DEP') {
1197
+				$data['type'] = 'Departure';
1198
+			} elseif ($typec == 'FSS') {
1199
+				$data['type'] = 'Flight Service Station';
1200
+			} elseif ($typec == 'CTR') {
1201
+				$data['type'] = 'Control Radar or Centre';
1202
+			} else {
1203
+				$data['type'] = 'Observer';
1204
+			}
1205
+			if (isset($ATC)) {
1206
+				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']);
1207
+			}
895 1208
 		    }
896 1209
 		    unset($data);
897 1210
 		}
@@ -901,7 +1214,9 @@  discard block
 block discarded – undo
901 1214
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
902 1215
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
903 1216
 	    //$buffer = $Common->getData($hosts[$id]);
904
-	    if ($globalDebug) echo 'Get Data...'."\n";
1217
+	    if ($globalDebug) {
1218
+	    	echo 'Get Data...'."\n";
1219
+	    }
905 1220
 	    $buffer = $Common->getData($value['host']);
906 1221
 	    $all_data = json_decode($buffer,true);
907 1222
 	    if ($buffer != '' && is_array($all_data)) {
@@ -909,10 +1224,16 @@  discard block
 block discarded – undo
909 1224
 		foreach ($all_data as $line) {
910 1225
 	    	    $data = array();
911 1226
 	    	    //$data['id'] = $line['id']; // id not usable
912
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1227
+	    	    if (isset($line['pilotid'])) {
1228
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1229
+	    	    }
913 1230
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
914
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
915
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1231
+	    	    if (isset($line['pilotname'])) {
1232
+	    	    	$data['pilot_name'] = $line['pilotname'];
1233
+	    	    }
1234
+	    	    if (isset($line['pilotid'])) {
1235
+	    	    	$data['pilot_id'] = $line['pilotid'];
1236
+	    	    }
916 1237
 	    	    $data['ident'] = $line['flightnum']; // ident
917 1238
 	    	    $data['altitude'] = $line['alt']; // altitude
918 1239
 	    	    $data['speed'] = $line['gs']; // speed
@@ -930,27 +1251,41 @@  discard block
 block discarded – undo
930 1251
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
931 1252
     		    $data['arrival_airport_time'] = $line['arrtime'];
932 1253
     		    $data['registration'] = $line['aircraft'];
933
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1254
+		    if (isset($line['route'])) {
1255
+		    	$data['waypoints'] = $line['route'];
1256
+		    }
1257
+		    // route
934 1258
 		    if (isset($line['aircraftname'])) {
935 1259
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
936 1260
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
937 1261
 	    		$aircraft_data = explode('-',$line['aircraftname']);
938
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
939
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
940
-	    		else {
1262
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1263
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1264
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1265
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1266
+	    		} else {
941 1267
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
942
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
943
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1268
+	    		    if (isset($aircraft_data[1])) {
1269
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1270
+	    		    } else {
1271
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1272
+	    		    }
944 1273
 	    		}
945 1274
 	    	    }
946
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1275
+    		    if (isset($line['route'])) {
1276
+    		    	$data['waypoints'] = $line['route'];
1277
+    		    }
947 1278
     		    $data['id_source'] = $id_source;
948 1279
 	    	    $data['format_source'] = 'phpvmacars';
949
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1280
+		    if (isset($value['name']) && $value['name'] != '') {
1281
+		    	$data['source_name'] = $value['name'];
1282
+		    }
950 1283
 		    $SI->add($data);
951 1284
 		    unset($data);
952 1285
 		}
953
-		if ($globalDebug) echo 'No more data...'."\n";
1286
+		if ($globalDebug) {
1287
+			echo 'No more data...'."\n";
1288
+		}
954 1289
 		unset($buffer);
955 1290
 		unset($all_data);
956 1291
 	    }
@@ -958,7 +1293,9 @@  discard block
 block discarded – undo
958 1293
     	    $last_exec[$id]['last'] = time();
959 1294
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
960 1295
 	    //$buffer = $Common->getData($hosts[$id]);
961
-	    if ($globalDebug) echo 'Get Data...'."\n";
1296
+	    if ($globalDebug) {
1297
+	    	echo 'Get Data...'."\n";
1298
+	    }
962 1299
 	    $buffer = $Common->getData($value['host']);
963 1300
 	    $all_data = json_decode($buffer,true);
964 1301
 	    if ($buffer != '' && is_array($all_data)) {
@@ -987,15 +1324,22 @@  discard block
 block discarded – undo
987 1324
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
988 1325
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
989 1326
     		    //$data['registration'] = $line['aircraft'];
990
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1327
+		    if (isset($line['route'])) {
1328
+		    	$data['waypoints'] = $line['route'];
1329
+		    }
1330
+		    // route
991 1331
 	    	    $data['aircraft_icao'] = $line['plane_type'];
992 1332
     		    $data['id_source'] = $id_source;
993 1333
 	    	    $data['format_source'] = 'vam';
994
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1334
+		    if (isset($value['name']) && $value['name'] != '') {
1335
+		    	$data['source_name'] = $value['name'];
1336
+		    }
995 1337
 		    $SI->add($data);
996 1338
 		    unset($data);
997 1339
 		}
998
-		if ($globalDebug) echo 'No more data...'."\n";
1340
+		if ($globalDebug) {
1341
+			echo 'No more data...'."\n";
1342
+		}
999 1343
 		unset($buffer);
1000 1344
 		unset($all_data);
1001 1345
 	    }
@@ -1003,7 +1347,9 @@  discard block
 block discarded – undo
1003 1347
     	    $last_exec[$id]['last'] = time();
1004 1348
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1005 1349
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1006
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1350
+	    if (function_exists('pcntl_fork')) {
1351
+	    	pcntl_signal_dispatch();
1352
+	    }
1007 1353
     	    //$last_exec[$id]['last'] = time();
1008 1354
 
1009 1355
 	    //$read = array( $sockets[$id] );
@@ -1011,7 +1357,9 @@  discard block
 block discarded – undo
1011 1357
 	    $write = NULL;
1012 1358
 	    $e = NULL;
1013 1359
 	    $n = socket_select($read, $write, $e, $timeout);
1014
-	    if ($e != NULL) var_dump($e);
1360
+	    if ($e != NULL) {
1361
+	    	var_dump($e);
1362
+	    }
1015 1363
 	    if ($n > 0) {
1016 1364
 		$reset = 0;
1017 1365
 		foreach ($read as $nb => $r) {
@@ -1032,12 +1380,16 @@  discard block
 block discarded – undo
1032 1380
 		    //$SI::del();
1033 1381
 		    if ($format == 'vrstcp') {
1034 1382
 			$buffer = explode('},{',$buffer);
1035
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1383
+		    } else {
1384
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1385
+		    }
1036 1386
 		    // SBS format is CSV format
1037 1387
 		    if ($buffer !== FALSE && $buffer != '') {
1038 1388
 			$tt[$format] = 0;
1039 1389
 			if ($format == 'acarssbs3') {
1040
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1390
+			    if ($globalDebug) {
1391
+			    	echo 'ACARS : '.$buffer."\n";
1392
+			    }
1041 1393
 			    $ACARS->add(trim($buffer));
1042 1394
 			    $ACARS->deleteLiveAcarsData();
1043 1395
 			} elseif ($format == 'raw') {
@@ -1046,25 +1398,55 @@  discard block
 block discarded – undo
1046 1398
 			    if (is_array($data)) {
1047 1399
 				$data['datetime'] = date('Y-m-d H:i:s');
1048 1400
 				$data['format_source'] = 'raw';
1049
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1050
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1051
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1401
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1402
+					$data['source_name'] = $globalSources[$nb]['name'];
1403
+				}
1404
+				if (isset($globalSources[$nb]['sourcestats'])) {
1405
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1406
+				}
1407
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1408
+					$SI->add($data);
1409
+				}
1052 1410
 			    }
1053 1411
 			} elseif ($format == 'ais') {
1054 1412
 			    $ais_data = $AIS->parse_line(trim($buffer));
1055 1413
 			    $data = array();
1056
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1057
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1058
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1059
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1060
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1061
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1062
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1063
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1064
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1065
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1066
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1067
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1414
+			    if (isset($ais_data['ident'])) {
1415
+			    	$data['ident'] = $ais_data['ident'];
1416
+			    }
1417
+			    if (isset($ais_data['mmsi'])) {
1418
+			    	$data['mmsi'] = $ais_data['mmsi'];
1419
+			    }
1420
+			    if (isset($ais_data['speed'])) {
1421
+			    	$data['speed'] = $ais_data['speed'];
1422
+			    }
1423
+			    if (isset($ais_data['heading'])) {
1424
+			    	$data['heading'] = $ais_data['heading'];
1425
+			    }
1426
+			    if (isset($ais_data['latitude'])) {
1427
+			    	$data['latitude'] = $ais_data['latitude'];
1428
+			    }
1429
+			    if (isset($ais_data['longitude'])) {
1430
+			    	$data['longitude'] = $ais_data['longitude'];
1431
+			    }
1432
+			    if (isset($ais_data['status'])) {
1433
+			    	$data['status'] = $ais_data['status'];
1434
+			    }
1435
+			    if (isset($ais_data['type'])) {
1436
+			    	$data['type'] = $ais_data['type'];
1437
+			    }
1438
+			    if (isset($ais_data['imo'])) {
1439
+			    	$data['imo'] = $ais_data['imo'];
1440
+			    }
1441
+			    if (isset($ais_data['callsign'])) {
1442
+			    	$data['callsign'] = $ais_data['callsign'];
1443
+			    }
1444
+			    if (isset($ais_data['destination'])) {
1445
+			    	$data['arrival_code'] = $ais_data['destination'];
1446
+			    }
1447
+			    if (isset($ais_data['eta_ts'])) {
1448
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1449
+			    }
1068 1450
 
1069 1451
 			    if (isset($ais_data['timestamp'])) {
1070 1452
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1073,7 +1455,9 @@  discard block
 block discarded – undo
1073 1455
 			    }
1074 1456
 			    $data['format_source'] = 'aisnmea';
1075 1457
     			    $data['id_source'] = $id_source;
1076
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1458
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1459
+			    	$MI->add($data);
1460
+			    }
1077 1461
 			    unset($data);
1078 1462
                         } elseif ($format == 'flightgearsp') {
1079 1463
                     	    //echo $buffer."\n";
@@ -1091,11 +1475,15 @@  discard block
 block discarded – undo
1091 1475
 				$data['speed'] = round($line[5]*1.94384);
1092 1476
 				$data['datetime'] = date('Y-m-d H:i:s');
1093 1477
 				$data['format_source'] = 'flightgearsp';
1094
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1478
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1479
+					$SI->add($data);
1480
+				}
1095 1481
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1096 1482
 			    }
1097 1483
                         } elseif ($format == 'acars') {
1098
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1484
+                    	    if ($globalDebug) {
1485
+                    	    	echo 'ACARS : '.$buffer."\n";
1486
+                    	    }
1099 1487
 			    $ACARS->add(trim($buffer));
1100 1488
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1101 1489
 			    $ACARS->deleteLiveAcarsData();
@@ -1116,7 +1504,9 @@  discard block
 block discarded – undo
1116 1504
 				    $aircraft_type = $line[10];
1117 1505
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1118 1506
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1119
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1507
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1508
+				    	$SI->add($data);
1509
+				    }
1120 1510
 				}
1121 1511
 			    }
1122 1512
 			} elseif ($format == 'beast') {
@@ -1126,27 +1516,59 @@  discard block
 block discarded – undo
1126 1516
 			    foreach($buffer as $all_data) {
1127 1517
 				$line = json_decode('{'.$all_data.'}',true);
1128 1518
 				$data = array();
1129
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1130
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1131
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1132
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1133
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1134
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1135
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1519
+				if (isset($line['Icao'])) {
1520
+					$data['hex'] = $line['Icao'];
1521
+				}
1522
+				// hex
1523
+				if (isset($line['Call'])) {
1524
+					$data['ident'] = $line['Call'];
1525
+				}
1526
+				// ident
1527
+				if (isset($line['Alt'])) {
1528
+					$data['altitude'] = $line['Alt'];
1529
+				}
1530
+				// altitude
1531
+				if (isset($line['Spd'])) {
1532
+					$data['speed'] = $line['Spd'];
1533
+				}
1534
+				// speed
1535
+				if (isset($line['Trak'])) {
1536
+					$data['heading'] = $line['Trak'];
1537
+				}
1538
+				// heading
1539
+				if (isset($line['Lat'])) {
1540
+					$data['latitude'] = $line['Lat'];
1541
+				}
1542
+				// lat
1543
+				if (isset($line['Long'])) {
1544
+					$data['longitude'] = $line['Long'];
1545
+				}
1546
+				// long
1136 1547
 				//$data['verticalrate'] = $line['']; // verticale rate
1137
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1548
+				if (isset($line['Sqk'])) {
1549
+					$data['squawk'] = $line['Sqk'];
1550
+				}
1551
+				// squawk
1138 1552
 				$data['emergency'] = ''; // emergency
1139
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1553
+				if (isset($line['Reg'])) {
1554
+					$data['registration'] = $line['Reg'];
1555
+				}
1140 1556
 				/*
1141 1557
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1142 1558
 				else $data['datetime'] = date('Y-m-d H:i:s');
1143 1559
 				*/
1144 1560
 				$data['datetime'] = date('Y-m-d H:i:s');
1145
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1561
+				if (isset($line['Type'])) {
1562
+					$data['aircraft_icao'] = $line['Type'];
1563
+				}
1146 1564
 		    		$data['format_source'] = 'vrstcp';
1147 1565
 				$data['id_source'] = $id_source;
1148
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1149
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1566
+				if (isset($value['name']) && $value['name'] != '') {
1567
+					$data['source_name'] = $value['name'];
1568
+				}
1569
+				if (isset($data['latitude']) && isset($data['hex'])) {
1570
+					$SI->add($data);
1571
+				}
1150 1572
 				unset($data);
1151 1573
 			    }
1152 1574
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1159,21 +1581,43 @@  discard block
 block discarded – undo
1159 1581
     				$data['hex'] = $lined['hexid'];
1160 1582
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1161 1583
     				$data['datetime'] = date('Y-m-d H:i:s');;
1162
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1163
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1164
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1165
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1166
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1167
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1168
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1584
+    				if (isset($lined['ident'])) {
1585
+    					$data['ident'] = $lined['ident'];
1586
+    				}
1587
+    				if (isset($lined['lat'])) {
1588
+    					$data['latitude'] = $lined['lat'];
1589
+    				}
1590
+    				if (isset($lined['lon'])) {
1591
+    					$data['longitude'] = $lined['lon'];
1592
+    				}
1593
+    				if (isset($lined['speed'])) {
1594
+    					$data['speed'] = $lined['speed'];
1595
+    				}
1596
+    				if (isset($lined['squawk'])) {
1597
+    					$data['squawk'] = $lined['squawk'];
1598
+    				}
1599
+    				if (isset($lined['alt'])) {
1600
+    					$data['altitude'] = $lined['alt'];
1601
+    				}
1602
+    				if (isset($lined['heading'])) {
1603
+    					$data['heading'] = $lined['heading'];
1604
+    				}
1169 1605
     				$data['id_source'] = $id_source;
1170 1606
     				$data['format_source'] = 'tsv';
1171
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1172
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1173
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1607
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1608
+    					$data['source_name'] = $globalSources[$nb]['name'];
1609
+    				}
1610
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1611
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1612
+    				}
1613
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1614
+    					$SI->add($data);
1615
+    				}
1174 1616
     				unset($lined);
1175 1617
     				unset($data);
1176
-    			    } else $error = true;
1618
+    			    } else {
1619
+    			    	$error = true;
1620
+    			    }
1177 1621
 			} elseif ($format == 'aprs' && $use_aprs) {
1178 1622
 			    if ($aprs_connect == 0) {
1179 1623
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1199,49 +1643,82 @@  discard block
 block discarded – undo
1199 1643
 				    $aprs_last_tx = time();
1200 1644
 				    $data = array();
1201 1645
 				    //print_r($line);
1202
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1203
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1204
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1646
+				    if (isset($line['address'])) {
1647
+				    	$data['hex'] = $line['address'];
1648
+				    }
1649
+				    if (isset($line['timestamp'])) {
1650
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1651
+				    } else {
1652
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1653
+				    }
1205 1654
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1206
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1655
+				    if (isset($line['ident'])) {
1656
+				    	$data['ident'] = $line['ident'];
1657
+				    }
1207 1658
 				    $data['latitude'] = $line['latitude'];
1208 1659
 				    $data['longitude'] = $line['longitude'];
1209 1660
 				    //$data['verticalrate'] = $line[16];
1210
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1211
-				    else $data['speed'] = 0;
1212
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1213
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1214
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1215
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1661
+				    if (isset($line['speed'])) {
1662
+				    	$data['speed'] = $line['speed'];
1663
+				    } else {
1664
+				    	$data['speed'] = 0;
1665
+				    }
1666
+				    if (isset($line['altitude'])) {
1667
+				    	$data['altitude'] = $line['altitude'];
1668
+				    }
1669
+				    if (isset($line['comment'])) {
1670
+				    	$data['comment'] = $line['comment'];
1671
+				    }
1672
+				    if (isset($line['symbol'])) {
1673
+				    	$data['type'] = $line['symbol'];
1674
+				    }
1675
+				    if (isset($line['heading'])) {
1676
+				    	$data['heading'] = $line['heading'];
1677
+				    }
1216 1678
 				    //else $data['heading'] = 0;
1217
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1218
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1679
+				    if (isset($line['stealth'])) {
1680
+				    	$data['aircraft_type'] = $line['stealth'];
1681
+				    }
1682
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1683
+				    	$data['noarchive'] = true;
1684
+				    }
1219 1685
     				    $data['id_source'] = $id_source;
1220
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1221
-				    else $data['format_source'] = 'aprs';
1686
+    				    if (isset($line['format_source'])) {
1687
+    				    	$data['format_source'] = $line['format_source'];
1688
+    				    } else {
1689
+				    	$data['format_source'] = 'aprs';
1690
+				    }
1222 1691
 				    $data['source_name'] = $line['source'];
1223
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1224
-				    else $data['source_type'] = 'flarm';
1225
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1692
+				    if (isset($line['source_type'])) {
1693
+				    	$data['source_type'] = $line['source_type'];
1694
+				    } else {
1695
+				    	$data['source_type'] = 'flarm';
1696
+				    }
1697
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1698
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1699
+    				    }
1226 1700
 				    $currentdate = date('Y-m-d H:i:s');
1227 1701
 				    $aprsdate = strtotime($data['datetime']);
1228 1702
 				    // Accept data if time <= system time + 20s
1229 1703
 				    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'])))) {
1230 1704
 					$send = $SI->add($data);
1231 1705
 				    } elseif (isset($line['stealth'])) {
1232
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1233
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1706
+					if ($line['stealth'] != 0) {
1707
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1708
+					} else {
1709
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1710
+					}
1234 1711
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1235 1712
 				    } 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') {
1236 1713
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1237
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1714
+					if (isset($globalTracker) && $globalTracker) {
1715
+						$send = $TI->add($data);
1716
+					}
1238 1717
 				    }
1239 1718
 				    unset($data);
1240
-				} 
1241
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1719
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1242 1720
 					echo '!! Weather Station not yet supported'."\n";
1243
-				}
1244
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1721
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1245 1722
 					echo '!! Car & Trucks not yet supported'."\n";
1246 1723
 				}
1247 1724
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1274,25 +1751,42 @@  discard block
 block discarded – undo
1274 1751
     				$data['ground'] = $line[21];
1275 1752
     				$data['emergency'] = $line[19];
1276 1753
     				$data['format_source'] = 'sbs';
1277
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1278
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1754
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1755
+					$data['source_name'] = $globalSources[$nb]['name'];
1756
+				}
1757
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1758
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1759
+    				}
1279 1760
     				$data['id_source'] = $id_source;
1280
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1281
-    				else $error = true;
1761
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1762
+    					$send = $SI->add($data);
1763
+    				} else {
1764
+    					$error = true;
1765
+    				}
1282 1766
     				unset($data);
1283
-    			    } else $error = true;
1767
+    			    } else {
1768
+    			    	$error = true;
1769
+    			    }
1284 1770
 			    if ($error) {
1285 1771
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1286
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1772
+					if ($globalDebug) {
1773
+						echo "Not a message. Ignoring... \n";
1774
+					}
1287 1775
 				} else {
1288
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1776
+					if ($globalDebug) {
1777
+						echo "Wrong line format. Ignoring... \n";
1778
+					}
1289 1779
 					if ($globalDebug) {
1290 1780
 						echo $buffer;
1291 1781
 						print_r($line);
1292 1782
 					}
1293 1783
 					//socket_close($r);
1294
-					if ($globalDebug) echo "Reconnect after an error...\n";
1295
-					if ($format == 'aprs') $aprs_connect = 0;
1784
+					if ($globalDebug) {
1785
+						echo "Reconnect after an error...\n";
1786
+					}
1787
+					if ($format == 'aprs') {
1788
+						$aprs_connect = 0;
1789
+					}
1296 1790
 					$sourceer[$nb] = $globalSources[$nb];
1297 1791
 					connect_all($sourceer);
1298 1792
 					$sourceer = array();
@@ -1300,10 +1794,14 @@  discard block
 block discarded – undo
1300 1794
 			    }
1301 1795
 			}
1302 1796
 			// Sleep for xxx microseconds
1303
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1797
+			if (isset($globalSBSSleep)) {
1798
+				usleep($globalSBSSleep);
1799
+			}
1304 1800
 		    } else {
1305 1801
 			if ($format == 'flightgearmp') {
1306
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1802
+			    	if ($globalDebug) {
1803
+			    		echo "Reconnect FlightGear MP...";
1804
+			    	}
1307 1805
 				//@socket_close($r);
1308 1806
 				sleep($globalMinFetch);
1309 1807
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1312,10 +1810,15 @@  discard block
 block discarded – undo
1312 1810
 				break;
1313 1811
 				
1314 1812
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1315
-			    if (isset($tt[$format])) $tt[$format]++;
1316
-			    else $tt[$format] = 0;
1813
+			    if (isset($tt[$format])) {
1814
+			    	$tt[$format]++;
1815
+			    } else {
1816
+			    	$tt[$format] = 0;
1817
+			    }
1317 1818
 			    if ($tt[$format] > 30) {
1318
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1819
+				if ($globalDebug) {
1820
+					echo "ERROR : Reconnect ".$format."...";
1821
+				}
1319 1822
 				//@socket_close($r);
1320 1823
 				sleep(2);
1321 1824
 				$aprs_connect = 0;
@@ -1332,11 +1835,17 @@  discard block
 block discarded – undo
1332 1835
 	    } else {
1333 1836
 		$error = socket_strerror(socket_last_error());
1334 1837
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1335
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1336
-			if (isset($globalDebug)) echo "Restarting...\n";
1838
+			if ($globalDebug) {
1839
+				echo "ERROR : socket_select give this error ".$error . "\n";
1840
+			}
1841
+			if (isset($globalDebug)) {
1842
+				echo "Restarting...\n";
1843
+			}
1337 1844
 			// Restart the script if possible
1338 1845
 			if (is_array($sockets)) {
1339
-			    if ($globalDebug) echo "Shutdown all sockets...";
1846
+			    if ($globalDebug) {
1847
+			    	echo "Shutdown all sockets...";
1848
+			    }
1340 1849
 			    
1341 1850
 			    foreach ($sockets as $sock) {
1342 1851
 				@socket_shutdown($sock,2);
@@ -1344,21 +1853,33 @@  discard block
 block discarded – undo
1344 1853
 			    }
1345 1854
 			    
1346 1855
 			}
1347
-			if ($globalDebug) echo "Restart all connections...";
1856
+			if ($globalDebug) {
1857
+				echo "Restart all connections...";
1858
+			}
1348 1859
 			sleep(2);
1349 1860
 			$time = time();
1350 1861
 			//connect_all($hosts);
1351 1862
 			$aprs_connect = 0;
1352
-			if ($reset%5 == 0) sleep(20);
1353
-			if ($reset%10 == 0) sleep(100);
1354
-			if ($reset%20 == 0) sleep(200);
1355
-			if ($reset > 100) exit('Too many attempts...');
1863
+			if ($reset%5 == 0) {
1864
+				sleep(20);
1865
+			}
1866
+			if ($reset%10 == 0) {
1867
+				sleep(100);
1868
+			}
1869
+			if ($reset%20 == 0) {
1870
+				sleep(200);
1871
+			}
1872
+			if ($reset > 100) {
1873
+				exit('Too many attempts...');
1874
+			}
1356 1875
 			connect_all($globalSources);
1357 1876
 		}
1358 1877
 	    }
1359 1878
 	}
1360 1879
 	if ($globalDaemon === false) {
1361
-	    if ($globalDebug) echo 'Check all...'."\n";
1880
+	    if ($globalDebug) {
1881
+	    	echo 'Check all...'."\n";
1882
+	    }
1362 1883
 	    $SI->checkAll();
1363 1884
 	}
1364 1885
     }
Please login to merge, or discard this patch.