Completed
Push — master ( 7b2761...d4dde6 )
by Yannick
29:28
created
statistics-country.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Stats = new Stats();
6 6
 
7
-if (!isset($filter_name)) $filter_name = '';
7
+if (!isset($filter_name)) {
8
+	$filter_name = '';
9
+}
8 10
 $type = 'aircraft';
9 11
 if (isset($_GET['marine'])) {
10 12
 	$type = 'marine';
@@ -21,8 +23,10 @@  discard block
 block discarded – undo
21 23
 }
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($airline_icao == '' && isset($globalFilter)) {
24
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+    if (isset($globalFilter['airline'])) {
27
+    	$airline_icao = $globalFilter['airline'][0];
28
+    }
29
+    }
26 30
 
27 31
 require_once('header.php');
28 32
 include('statistics-sub-menu.php'); 
@@ -64,10 +68,14 @@  discard block
 block discarded – undo
64 68
 $flightover_data = '';
65 69
 foreach($flightover_array as $flightover_item)
66 70
 {
67
-	if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
68
-	elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
69
-	elseif ($type == 'tracker') $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
70
-}
71
+	if ($type == 'aircraft') {
72
+		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
73
+	} elseif ($type == 'marine') {
74
+		$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
75
+	} elseif ($type == 'tracker') {
76
+		$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
77
+	}
78
+	}
71 79
 $flightover_data = substr($flightover_data, 0, -1);
72 80
 print $flightover_data;
73 81
 print '];';
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +457 added lines, -168 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2209,8 +2353,11 @@  discard block
 block discarded – undo
2209 2353
 			if ($Connection->tableExists('aircraft')) {
2210 2354
 				if (!$Connection->tableExists('config')) {
2211 2355
 					$version = '1';
2212
-					if ($update) return self::update_from_1();
2213
-					else return $version;
2356
+					if ($update) {
2357
+						return self::update_from_1();
2358
+					} else {
2359
+						return $version;
2360
+					}
2214 2361
 				} else {
2215 2362
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2216 2363
 					try {
@@ -2223,191 +2370,333 @@  discard block
 block discarded – undo
2223 2370
 					if ($update) {
2224 2371
 						if ($result['value'] == '2') {
2225 2372
 							$error = self::update_from_2();
2226
-							if ($error != '') return $error;
2227
-							else return self::check_version(true);
2373
+							if ($error != '') {
2374
+								return $error;
2375
+							} else {
2376
+								return self::check_version(true);
2377
+							}
2228 2378
 						} elseif ($result['value'] == '3') {
2229 2379
 							$error = self::update_from_3();
2230
-							if ($error != '') return $error;
2231
-							else return self::check_version(true);
2380
+							if ($error != '') {
2381
+								return $error;
2382
+							} else {
2383
+								return self::check_version(true);
2384
+							}
2232 2385
 						} elseif ($result['value'] == '4') {
2233 2386
 							$error = self::update_from_4();
2234
-							if ($error != '') return $error;
2235
-							else return self::check_version(true);
2387
+							if ($error != '') {
2388
+								return $error;
2389
+							} else {
2390
+								return self::check_version(true);
2391
+							}
2236 2392
 						} elseif ($result['value'] == '5') {
2237 2393
 							$error = self::update_from_5();
2238
-							if ($error != '') return $error;
2239
-							else return self::check_version(true);
2394
+							if ($error != '') {
2395
+								return $error;
2396
+							} else {
2397
+								return self::check_version(true);
2398
+							}
2240 2399
 						} elseif ($result['value'] == '6') {
2241 2400
 							$error = self::update_from_6();
2242
-							if ($error != '') return $error;
2243
-							else return self::check_version(true);
2401
+							if ($error != '') {
2402
+								return $error;
2403
+							} else {
2404
+								return self::check_version(true);
2405
+							}
2244 2406
 						} elseif ($result['value'] == '7') {
2245 2407
 							$error = self::update_from_7();
2246
-							if ($error != '') return $error;
2247
-							else return self::check_version(true);
2408
+							if ($error != '') {
2409
+								return $error;
2410
+							} else {
2411
+								return self::check_version(true);
2412
+							}
2248 2413
 						} elseif ($result['value'] == '8') {
2249 2414
 							$error = self::update_from_8();
2250
-							if ($error != '') return $error;
2251
-							else return self::check_version(true);
2415
+							if ($error != '') {
2416
+								return $error;
2417
+							} else {
2418
+								return self::check_version(true);
2419
+							}
2252 2420
 						} elseif ($result['value'] == '9') {
2253 2421
 							$error = self::update_from_9();
2254
-							if ($error != '') return $error;
2255
-							else return self::check_version(true);
2422
+							if ($error != '') {
2423
+								return $error;
2424
+							} else {
2425
+								return self::check_version(true);
2426
+							}
2256 2427
 						} elseif ($result['value'] == '10') {
2257 2428
 							$error = self::update_from_10();
2258
-							if ($error != '') return $error;
2259
-							else return self::check_version(true);
2429
+							if ($error != '') {
2430
+								return $error;
2431
+							} else {
2432
+								return self::check_version(true);
2433
+							}
2260 2434
 						} elseif ($result['value'] == '11') {
2261 2435
 							$error = self::update_from_11();
2262
-							if ($error != '') return $error;
2263
-							else return self::check_version(true);
2436
+							if ($error != '') {
2437
+								return $error;
2438
+							} else {
2439
+								return self::check_version(true);
2440
+							}
2264 2441
 						} elseif ($result['value'] == '12') {
2265 2442
 							$error = self::update_from_12();
2266
-							if ($error != '') return $error;
2267
-							else return self::check_version(true);
2443
+							if ($error != '') {
2444
+								return $error;
2445
+							} else {
2446
+								return self::check_version(true);
2447
+							}
2268 2448
 						} elseif ($result['value'] == '13') {
2269 2449
 							$error = self::update_from_13();
2270
-							if ($error != '') return $error;
2271
-							else return self::check_version(true);
2450
+							if ($error != '') {
2451
+								return $error;
2452
+							} else {
2453
+								return self::check_version(true);
2454
+							}
2272 2455
 						} elseif ($result['value'] == '14') {
2273 2456
 							$error = self::update_from_14();
2274
-							if ($error != '') return $error;
2275
-							else return self::check_version(true);
2457
+							if ($error != '') {
2458
+								return $error;
2459
+							} else {
2460
+								return self::check_version(true);
2461
+							}
2276 2462
 						} elseif ($result['value'] == '15') {
2277 2463
 							$error = self::update_from_15();
2278
-							if ($error != '') return $error;
2279
-							else return self::check_version(true);
2464
+							if ($error != '') {
2465
+								return $error;
2466
+							} else {
2467
+								return self::check_version(true);
2468
+							}
2280 2469
 						} elseif ($result['value'] == '16') {
2281 2470
 							$error = self::update_from_16();
2282
-							if ($error != '') return $error;
2283
-							else return self::check_version(true);
2471
+							if ($error != '') {
2472
+								return $error;
2473
+							} else {
2474
+								return self::check_version(true);
2475
+							}
2284 2476
 						} elseif ($result['value'] == '17') {
2285 2477
 							$error = self::update_from_17();
2286
-							if ($error != '') return $error;
2287
-							else return self::check_version(true);
2478
+							if ($error != '') {
2479
+								return $error;
2480
+							} else {
2481
+								return self::check_version(true);
2482
+							}
2288 2483
 						} elseif ($result['value'] == '18') {
2289 2484
 							$error = self::update_from_18();
2290
-							if ($error != '') return $error;
2291
-							else return self::check_version(true);
2485
+							if ($error != '') {
2486
+								return $error;
2487
+							} else {
2488
+								return self::check_version(true);
2489
+							}
2292 2490
 						} elseif ($result['value'] == '19') {
2293 2491
 							$error = self::update_from_19();
2294
-							if ($error != '') return $error;
2295
-							else return self::check_version(true);
2492
+							if ($error != '') {
2493
+								return $error;
2494
+							} else {
2495
+								return self::check_version(true);
2496
+							}
2296 2497
 						} elseif ($result['value'] == '20') {
2297 2498
 							$error = self::update_from_20();
2298
-							if ($error != '') return $error;
2299
-							else return self::check_version(true);
2499
+							if ($error != '') {
2500
+								return $error;
2501
+							} else {
2502
+								return self::check_version(true);
2503
+							}
2300 2504
 						} elseif ($result['value'] == '21') {
2301 2505
 							$error = self::update_from_21();
2302
-							if ($error != '') return $error;
2303
-							else return self::check_version(true);
2506
+							if ($error != '') {
2507
+								return $error;
2508
+							} else {
2509
+								return self::check_version(true);
2510
+							}
2304 2511
 						} elseif ($result['value'] == '22') {
2305 2512
 							$error = self::update_from_22();
2306
-							if ($error != '') return $error;
2307
-							else return self::check_version(true);
2513
+							if ($error != '') {
2514
+								return $error;
2515
+							} else {
2516
+								return self::check_version(true);
2517
+							}
2308 2518
 						} elseif ($result['value'] == '23') {
2309 2519
 							$error = self::update_from_23();
2310
-							if ($error != '') return $error;
2311
-							else return self::check_version(true);
2520
+							if ($error != '') {
2521
+								return $error;
2522
+							} else {
2523
+								return self::check_version(true);
2524
+							}
2312 2525
 						} elseif ($result['value'] == '24') {
2313 2526
 							$error = self::update_from_24();
2314
-							if ($error != '') return $error;
2315
-							else return self::check_version(true);
2527
+							if ($error != '') {
2528
+								return $error;
2529
+							} else {
2530
+								return self::check_version(true);
2531
+							}
2316 2532
 						} elseif ($result['value'] == '25') {
2317 2533
 							$error = self::update_from_25();
2318
-							if ($error != '') return $error;
2319
-							else return self::check_version(true);
2534
+							if ($error != '') {
2535
+								return $error;
2536
+							} else {
2537
+								return self::check_version(true);
2538
+							}
2320 2539
 						} elseif ($result['value'] == '26') {
2321 2540
 							$error = self::update_from_26();
2322
-							if ($error != '') return $error;
2323
-							else return self::check_version(true);
2541
+							if ($error != '') {
2542
+								return $error;
2543
+							} else {
2544
+								return self::check_version(true);
2545
+							}
2324 2546
 						} elseif ($result['value'] == '27') {
2325 2547
 							$error = self::update_from_27();
2326
-							if ($error != '') return $error;
2327
-							else return self::check_version(true);
2548
+							if ($error != '') {
2549
+								return $error;
2550
+							} else {
2551
+								return self::check_version(true);
2552
+							}
2328 2553
 						} elseif ($result['value'] == '28') {
2329 2554
 							$error = self::update_from_28();
2330
-							if ($error != '') return $error;
2331
-							else return self::check_version(true);
2555
+							if ($error != '') {
2556
+								return $error;
2557
+							} else {
2558
+								return self::check_version(true);
2559
+							}
2332 2560
 						} elseif ($result['value'] == '29') {
2333 2561
 							$error = self::update_from_29();
2334
-							if ($error != '') return $error;
2335
-							else return self::check_version(true);
2562
+							if ($error != '') {
2563
+								return $error;
2564
+							} else {
2565
+								return self::check_version(true);
2566
+							}
2336 2567
 						} elseif ($result['value'] == '30') {
2337 2568
 							$error = self::update_from_30();
2338
-							if ($error != '') return $error;
2339
-							else return self::check_version(true);
2569
+							if ($error != '') {
2570
+								return $error;
2571
+							} else {
2572
+								return self::check_version(true);
2573
+							}
2340 2574
 						} elseif ($result['value'] == '31') {
2341 2575
 							$error = self::update_from_31();
2342
-							if ($error != '') return $error;
2343
-							else return self::check_version(true);
2576
+							if ($error != '') {
2577
+								return $error;
2578
+							} else {
2579
+								return self::check_version(true);
2580
+							}
2344 2581
 						} elseif ($result['value'] == '32') {
2345 2582
 							$error = self::update_from_32();
2346
-							if ($error != '') return $error;
2347
-							else return self::check_version(true);
2583
+							if ($error != '') {
2584
+								return $error;
2585
+							} else {
2586
+								return self::check_version(true);
2587
+							}
2348 2588
 						} elseif ($result['value'] == '33') {
2349 2589
 							$error = self::update_from_33();
2350
-							if ($error != '') return $error;
2351
-							else return self::check_version(true);
2590
+							if ($error != '') {
2591
+								return $error;
2592
+							} else {
2593
+								return self::check_version(true);
2594
+							}
2352 2595
 						} elseif ($result['value'] == '34') {
2353 2596
 							$error = self::update_from_34();
2354
-							if ($error != '') return $error;
2355
-							else return self::check_version(true);
2597
+							if ($error != '') {
2598
+								return $error;
2599
+							} else {
2600
+								return self::check_version(true);
2601
+							}
2356 2602
 						} elseif ($result['value'] == '35') {
2357 2603
 							$error = self::update_from_35();
2358
-							if ($error != '') return $error;
2359
-							else return self::check_version(true);
2604
+							if ($error != '') {
2605
+								return $error;
2606
+							} else {
2607
+								return self::check_version(true);
2608
+							}
2360 2609
 						} elseif ($result['value'] == '36') {
2361 2610
 							$error = self::update_from_36();
2362
-							if ($error != '') return $error;
2363
-							else return self::check_version(true);
2611
+							if ($error != '') {
2612
+								return $error;
2613
+							} else {
2614
+								return self::check_version(true);
2615
+							}
2364 2616
 						} elseif ($result['value'] == '37') {
2365 2617
 							$error = self::update_from_37();
2366
-							if ($error != '') return $error;
2367
-							else return self::check_version(true);
2618
+							if ($error != '') {
2619
+								return $error;
2620
+							} else {
2621
+								return self::check_version(true);
2622
+							}
2368 2623
 						} elseif ($result['value'] == '38') {
2369 2624
 							$error = self::update_from_38();
2370
-							if ($error != '') return $error;
2371
-							else return self::check_version(true);
2625
+							if ($error != '') {
2626
+								return $error;
2627
+							} else {
2628
+								return self::check_version(true);
2629
+							}
2372 2630
 						} elseif ($result['value'] == '39') {
2373 2631
 							$error = self::update_from_39();
2374
-							if ($error != '') return $error;
2375
-							else return self::check_version(true);
2632
+							if ($error != '') {
2633
+								return $error;
2634
+							} else {
2635
+								return self::check_version(true);
2636
+							}
2376 2637
 						} elseif ($result['value'] == '40') {
2377 2638
 							$error = self::update_from_40();
2378
-							if ($error != '') return $error;
2379
-							else return self::check_version(true);
2639
+							if ($error != '') {
2640
+								return $error;
2641
+							} else {
2642
+								return self::check_version(true);
2643
+							}
2380 2644
 						} elseif ($result['value'] == '41') {
2381 2645
 							$error = self::update_from_41();
2382
-							if ($error != '') return $error;
2383
-							else return self::check_version(true);
2646
+							if ($error != '') {
2647
+								return $error;
2648
+							} else {
2649
+								return self::check_version(true);
2650
+							}
2384 2651
 						} elseif ($result['value'] == '42') {
2385 2652
 							$error = self::update_from_42();
2386
-							if ($error != '') return $error;
2387
-							else return self::check_version(true);
2653
+							if ($error != '') {
2654
+								return $error;
2655
+							} else {
2656
+								return self::check_version(true);
2657
+							}
2388 2658
 						} elseif ($result['value'] == '43') {
2389 2659
 							$error = self::update_from_43();
2390
-							if ($error != '') return $error;
2391
-							else return self::check_version(true);
2660
+							if ($error != '') {
2661
+								return $error;
2662
+							} else {
2663
+								return self::check_version(true);
2664
+							}
2392 2665
 						} elseif ($result['value'] == '44') {
2393 2666
 							$error = self::update_from_44();
2394
-							if ($error != '') return $error;
2395
-							else return self::check_version(true);
2667
+							if ($error != '') {
2668
+								return $error;
2669
+							} else {
2670
+								return self::check_version(true);
2671
+							}
2396 2672
 						} elseif ($result['value'] == '45') {
2397 2673
 							$error = self::update_from_45();
2398
-							if ($error != '') return $error;
2399
-							else return self::check_version(true);
2674
+							if ($error != '') {
2675
+								return $error;
2676
+							} else {
2677
+								return self::check_version(true);
2678
+							}
2400 2679
 						} elseif ($result['value'] == '46') {
2401 2680
 							$error = self::update_from_46();
2402
-							if ($error != '') return $error;
2403
-							else return self::check_version(true);
2404
-						} else return '';
2681
+							if ($error != '') {
2682
+								return $error;
2683
+							} else {
2684
+								return self::check_version(true);
2685
+							}
2686
+						} else {
2687
+							return '';
2688
+						}
2405 2689
 					} else {
2406
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2407
-						else return 0;
2690
+						if (isset($result['value']) && $result['value'] != '') {
2691
+							return $result['value'];
2692
+						} else {
2693
+							return 0;
2694
+						}
2408 2695
 					}
2409 2696
 				}
2410
-			} else return $version;
2697
+			} else {
2698
+				return $version;
2699
+			}
2411 2700
 		}
2412 2701
 	}
2413 2702
 }
Please login to merge, or discard this patch.
search.php 1 patch
Braces   +142 added lines, -39 removed lines patch added patch discarded remove patch
@@ -46,8 +46,10 @@  discard block
 block discarded – undo
46 46
 			$end_date = date("Y-m-d H:i:s", strtotime("2014-04-12")).",".date("Y-m-d",strtotime($_GET['end_date']))." 00:00:00";
47 47
 			$sql_date = $end_date;
48 48
 		}
49
-	} else $sql_date = '';
50
-}
49
+	} else {
50
+		$sql_date = '';
51
+	}
52
+	}
51 53
 
52 54
 if (isset($_GET['highest_altitude'])) {
53 55
 	//for altitude manipulation
@@ -61,8 +63,12 @@  discard block
 block discarded – undo
61 63
 	} else if($_GET['highest_altitude'] == "" && $_GET['lowest_altitude'] != ""){
62 64
 		$start_altitude = filter_input(INPUT_GET,'lowest_altitude',FILTER_SANITIZE_NUMBER_INT).",60000";
63 65
 		$sql_altitude = $start_altitude;
64
-	} else $sql_altitude = '';
65
-} else $sql_altitude = '';
66
+	} else {
67
+		$sql_altitude = '';
68
+	}
69
+	} else {
70
+	$sql_altitude = '';
71
+}
66 72
 
67 73
 //calculuation for the pagination
68 74
 if(!isset($_GET['limit']))
@@ -80,7 +86,7 @@  discard block
 block discarded – undo
80 86
 		$limit_end = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
81 87
 		$absolute_difference = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
82 88
 	}
83
-}  else {
89
+} else {
84 90
 	$limit_explode = explode(",", $_GET['limit']);
85 91
 	$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
86 92
 	$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -138,10 +144,15 @@  discard block
 block discarded – undo
138 144
 	$dist = filter_input(INPUT_GET,'dist',FILTER_SANITIZE_NUMBER_INT);
139 145
 	$number_results = filter_input(INPUT_GET,'number_results',FILTER_SANITIZE_NUMBER_INT);
140 146
 	if ($dist != '') {
141
-		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') $dist = $dist*1.60934;
142
-		elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') $dist = $dist*1.852;
147
+		if (isset($globalDistanceUnit) && $globalDistanceUnit == 'mi') {
148
+			$dist = $dist*1.60934;
149
+		} elseif (isset($globalDistanceUnit) && $globalDistanceUnit == 'nm') {
150
+			$dist = $dist*1.852;
151
+		}
152
+	}
153
+	if (!isset($sql_date)) {
154
+		$sql_date = '';
143 155
 	}
144
-	if (!isset($sql_date)) $sql_date = '';
145 156
 	if ($archive == 1) {
146 157
 		if ($type == 'aircraft') {
147 158
 			$SpotterArchive = new SpotterArchive();
@@ -219,7 +230,10 @@  discard block
 block discarded – undo
219 230
 		if (isset($_GET['aircraft']) && $_GET['aircraft'] != ""){ print _("Aircraft:").' <span>'.$aircraft.'</span> '; }
220 231
 		if (isset($_GET['manufacturer']) && $_GET['manufacturer'] != ""){ print _("Manufacturer:").' <span>'.$manufacturer.'</span> '; }
221 232
 		if (isset($_GET['registration']) && $_GET['registration'] != ""){ print _("Registration:").' <span>'.$registration.'</span> '; }
222
-		if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> '; }
233
+		if (isset($_GET['highlights'])) {
234
+			if ($_GET['highlights'] == "true"){ print _("Highlights:").' <span>'.$highlights.'</span> ';
235
+		}
236
+		}
223 237
 		if (isset($_GET['airline']) && $_GET['airline'] != ""){ print _("Airline:").' <span>'.$airline.'</span> '; }
224 238
 		if (isset($_GET['airline_country']) && $_GET['airline_country'] != ""){ print _("Airline country:").' <span>'.$airline_country.'</span> '; }
225 239
 		if (isset($_GET['airline_type']) && $_GET['airline_type'] != ""){ print _("Airline type:").' <span>'.$airline_type.'</span> '; }
@@ -355,7 +369,10 @@  discard block
 block discarded – undo
355 369
 			<div class="form-group">
356 370
 				<label class="control-label col-sm-2"><?php echo _("Keywords"); ?></label>
357 371
 				<div class="col-sm-10">
358
-					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) print $q; ?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
372
+					<input type="text" class="form-control" id="q" name="q" value="<?php if (isset($_GET['q'])) {
373
+	print $q;
374
+}
375
+?>" size="10" placeholder="<?php echo _("Keywords"); ?>" />
359 376
 				</div>
360 377
 			</div>
361 378
 		</fieldset>
@@ -374,7 +391,10 @@  discard block
 block discarded – undo
374 391
 					    </select>
375 392
 					</div>
376 393
 				</div>
377
-				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) print $manufacturer; ?>')</script>
394
+				<script type="text/javascript">getSelect('manufacturer','<?php if(isset($_GET['manufacturer'])) {
395
+	print $manufacturer;
396
+}
397
+?>')</script>
378 398
 				<div class="form-group">
379 399
 					<label class="control-label col-sm-2"><?php echo _("Type"); ?></label>
380 400
 						<div class="col-sm-10">
@@ -383,11 +403,17 @@  discard block
 block discarded – undo
383 403
 							</select>
384 404
 						</div>
385 405
 				</div>
386
-				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) print $aircraft_icao; ?>');</script>
406
+				<script type="text/javascript">getSelect('aircrafttypes','<?php if(isset($_GET['aircraft_icao'])) {
407
+	print $aircraft_icao;
408
+}
409
+?>');</script>
387 410
 				<div class="form-group">
388 411
 					<label class="control-label col-sm-2"><?php echo _("Registration"); ?></label> 
389 412
 					<div class="col-sm-10">
390
-						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) print $registration; ?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
413
+						<input type="text" class="form-control" name="registration" value="<?php if (isset($_GET['registration'])) {
414
+	print $registration;
415
+}
416
+?>" size="8" placeholder="<?php echo _("Registration"); ?>" />
391 417
 					</div>
392 418
 				</div>
393 419
 <?php
@@ -396,22 +422,31 @@  discard block
 block discarded – undo
396 422
 				<div class="form-group">
397 423
 					<label class="control-label col-sm-2"><?php echo _("Pilot id"); ?></label> 
398 424
 					<div class="col-sm-10">
399
-						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) print $pilot_id; ?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
425
+						<input type="text" class="form-control" name="pilot_id" value="<?php if (isset($_GET['pilot_id'])) {
426
+	print $pilot_id;
427
+}
428
+?>" size="15" placeholder="<?php echo _("Pilot id"); ?>" />
400 429
 					</div>
401 430
 				</div>
402 431
 				<div class="form-group">
403 432
 					<label class="control-label col-sm-2"><?php echo _("Pilot name"); ?></label> 
404 433
 					<div class="col-sm-10">
405
-						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) print $pilot_name; ?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
434
+						<input type="text" class="form-control" name="pilot_name" value="<?php if (isset($_GET['pilot_name'])) {
435
+	print $pilot_name;
436
+}
437
+?>" size="15" placeholder="<?php echo _("Pilot name"); ?>" />
406 438
 					</div>
407 439
 				</div>
408 440
 <?php
409
-	}else {
441
+	} else {
410 442
 ?>
411 443
 				<div class="form-group">
412 444
 					<label class="control-label col-sm-2"><?php echo _("Owner name"); ?></label> 
413 445
 					<div class="col-sm-10">
414
-						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) print $owner; ?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
446
+						<input type="text" class="form-control" name="owner" value="<?php if (isset($_GET['owner'])) {
447
+	print $owner;
448
+}
449
+?>" size="15" placeholder="<?php echo _("Owner name"); ?>" />
415 450
 					</div>
416 451
 				</div>
417 452
 <?php
@@ -419,8 +454,14 @@  discard block
 block discarded – undo
419 454
 ?>
420 455
 				<div class="form-group">
421 456
 					<div class="col-sm-offset-2 col-sm-10">
422
-					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
423
-					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) if ($_GET['highlights'] == "true"){ print 'checked="checked"'; } ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
457
+					<!--<div><input type="checkbox" class="form-control" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
458
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
459
+}
460
+} ?>> <label for="highlights"><?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label></div>-->
461
+					<label class="checkbox-inline"><input type="checkbox" name="highlights" value="true" id="highlights" <?php if (isset($_GET['highlights'])) {
462
+	if ($_GET['highlights'] == "true"){ print 'checked="checked"';
463
+}
464
+} ?>> <?php echo _("Include only aircrafts with special highlights (unique liveries, destinations etc.)"); ?></label>
424 465
 					</div>
425 466
 				</div>
426 467
 			</fieldset>
@@ -434,7 +475,10 @@  discard block
 block discarded – undo
434 475
 						</select>
435 476
 					</div>
436 477
 				</div>
437
-				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) print $airline; ?>');</script>
478
+				<script type="text/javascript">getSelect('airlinenames','<?php if(isset($_GET['airline'])) {
479
+	print $airline;
480
+}
481
+?>');</script>
438 482
 				<div class="form-group">
439 483
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
440 484
 					<div class="col-sm-10">
@@ -443,19 +487,34 @@  discard block
 block discarded – undo
443 487
 						</select>
444 488
 					</div>
445 489
 				</div>
446
-				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) print $airline_country; ?>');</script>
490
+				<script type="text/javascript">getSelect('airlinecountries','<?php if(isset($_GET['airline_country'])) {
491
+	print $airline_country;
492
+}
493
+?>');</script>
447 494
 				<div class="form-group">
448 495
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
449 496
 					<div class="col-sm-10">
450
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
497
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
498
+	print $callsign;
499
+}
500
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
451 501
 					</div>
452 502
 				</div>
453 503
 				<div class="form-group">
454 504
 					<div class="col-sm-offset-2 col-sm-10">
455 505
 						<label class="radio-inline"><input type="radio" name="airline_type" value="all" id="airline_type_all" <?php if (!isset($_GET['airline_type']) || $_GET['airline_type'] == "all"){ print 'checked="checked"'; } ?>> <?php echo _("All airlines types"); ?></label>
456
-						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"'; } ?>> <?php echo _("Only Passenger airlines"); ?></label>
457
-						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"'; } ?>> <?php echo _("Only Cargo airlines"); ?></label>
458
-						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) if ( $_GET['airline_type'] == "military"){ print 'checked="checked"'; } ?>> <?php echo _("Only Military airlines"); ?></label>
506
+						<label class="radio-inline"><input type="radio" name="airline_type" value="passenger" id="airline_type_passenger" <?php if (isset($_GET['airline_type'])) {
507
+	if ($_GET['airline_type'] == "passenger"){ print 'checked="checked"';
508
+}
509
+} ?>> <?php echo _("Only Passenger airlines"); ?></label>
510
+						<label class="radio-inline"><input type="radio" name="airline_type" value="cargo" id="airline_type_cargo" <?php if (isset($_GET['airline_type'])) {
511
+	if ( $_GET['airline_type'] == "cargo"){ print 'checked="checked"';
512
+}
513
+} ?>> <?php echo _("Only Cargo airlines"); ?></label>
514
+						<label class="radio-inline"><input type="radio" name="airline_type" value="military" id="airline_type_military" <?php if (isset($_GET['airline_type'])) {
515
+	if ( $_GET['airline_type'] == "military"){ print 'checked="checked"';
516
+}
517
+} ?>> <?php echo _("Only Military airlines"); ?></label>
459 518
 					</div>
460 519
 				</div>
461 520
 			</fieldset>
@@ -469,7 +528,10 @@  discard block
 block discarded – undo
469 528
 						</select>
470 529
 					</div>
471 530
 				</div>
472
-				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) print $airport_icao; ?>');</script>
531
+				<script type="text/javascript">getSelect('airportnames','<?php if(isset($_GET['airport_icao'])) {
532
+	print $airport_icao;
533
+}
534
+?>');</script>
473 535
 				<div class="form-group">
474 536
 					<label class="control-label col-sm-2"><?php echo _("Country"); ?></label> 
475 537
 					<div class="col-sm-10">
@@ -478,7 +540,10 @@  discard block
 block discarded – undo
478 540
 						</select>
479 541
 					</div>
480 542
 				</div>
481
-				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) print $airport_country; ?>');</script>
543
+				<script type="text/javascript">getSelect('airportcountries','<?php if(isset($_GET['airport_country'])) {
544
+	print $airport_country;
545
+}
546
+?>');</script>
482 547
 			</fieldset>
483 548
 			<fieldset>
484 549
 				<legend><?php echo _("Route"); ?></legend>
@@ -490,7 +555,10 @@  discard block
 block discarded – undo
490 555
 						</select>
491 556
 					</div>
492 557
 				</div>
493
-				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) print $departure_airport_route; ?>');</script>
558
+				<script type="text/javascript">getSelect('departureairportnames','<?php if(isset($_GET['departure_airport_route'])) {
559
+	print $departure_airport_route;
560
+}
561
+?>');</script>
494 562
 				<div class="form-group">
495 563
 					<label class="control-label col-sm-2"><?php echo _("Arrival Airport"); ?></label> 
496 564
 					<div class="col-sm-10">
@@ -499,7 +567,10 @@  discard block
 block discarded – undo
499 567
 						</select>
500 568
 					</div>
501 569
 				</div>
502
-				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) print $arrival_airport_route; ?>');</script>
570
+				<script type="text/javascript">getSelect('arrivalairportnames','<?php if(isset($_GET['arrival_airport_route'])) {
571
+	print $arrival_airport_route;
572
+}
573
+?>');</script>
503 574
 			</fieldset>
504 575
 			<fieldset>
505 576
 				<legend>Altitude</legend>
@@ -549,19 +620,33 @@  discard block
 block discarded – undo
549 620
 				<div class="form-group">
550 621
 					<label class="control-label col-sm-2"><?php echo _("Latitude"); ?></label>
551 622
 					<div class="col-sm-10">
552
-						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) print $origlat; ?>" />
623
+						<input type="text" name="origlat" class="form-control" placeholder="<?php echo _("Center point latitude"); ?>" value="<?php if (isset($_GET['origlat'])) {
624
+	print $origlat;
625
+}
626
+?>" />
553 627
 					</div>
554 628
 				</div>
555 629
 				<div class="form-group">
556 630
 					<label class="control-label col-sm-2"><?php echo _("Longitude"); ?></label>
557 631
 					<div class="col-sm-10">
558
-						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) print $origlon; ?>" />
632
+						<input type="text" name="origlon" class="form-control" placeholder="<?php echo _("Center point longitude"); ?>" value="<?php if (isset($_GET['origlon'])) {
633
+	print $origlon;
634
+}
635
+?>" />
559 636
 					</div>
560 637
 				</div>
561 638
 				<div class="form-group">
562
-					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) print $globalDistanceUnit; else print 'km'; print ')'; ?></label>
639
+					<label class="control-label col-sm-2"><?php echo _("Distance").' ('; if (isset($globalDistanceUnit)) {
640
+	print $globalDistanceUnit;
641
+} else {
642
+	print 'km';
643
+}
644
+print ')'; ?></label>
563 645
 					<div class="col-sm-10">
564
-						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) print $distance; ?>" />
646
+						<input type="text" name="dist" class="form-control" placeholder="<?php echo _("Distance from center point"); ?>" value="<?php if (isset($_GET['distance'])) {
647
+	print $distance;
648
+}
649
+?>" />
565 650
 					</div>
566 651
 				</div>
567 652
 			</fieldset>
@@ -572,7 +657,10 @@  discard block
 block discarded – undo
572 657
 				<div class="form-group">
573 658
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
574 659
 					<div class="col-sm-10">
575
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
660
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
661
+	print $callsign;
662
+}
663
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
576 664
 					</div>
577 665
 				</div>
578 666
 			</fieldset>
@@ -583,7 +671,10 @@  discard block
 block discarded – undo
583 671
 				<div class="form-group">
584 672
 					<label class="control-label col-sm-2"><?php echo _("Callsign"); ?></label> 
585 673
 					<div class="col-sm-10">
586
-						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) print $callsign; ?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
674
+						<input type="text" name="callsign" class="form-control" value="<?php if (isset($_GET['callsign'])) {
675
+	print $callsign;
676
+}
677
+?>" size="8" placeholder="<?php echo _("Callsign"); ?>" />
587 678
 					</div>
588 679
 				</div>
589 680
 			</fieldset>
@@ -591,7 +682,10 @@  discard block
 block discarded – undo
591 682
 				<div class="form-group">
592 683
 					<label class="control-label col-sm-2"><?php echo _("MMSI"); ?></label> 
593 684
 					<div class="col-sm-10">
594
-						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) print $mmsi; ?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
685
+						<input type="text" name="mmsi" class="form-control" value="<?php if (isset($_GET['mmsi'])) {
686
+	print $mmsi;
687
+}
688
+?>" size="8" placeholder="<?php echo _("MMSI"); ?>" />
595 689
 					</div>
596 690
 				</div>
597 691
 			</fieldset>
@@ -599,7 +693,10 @@  discard block
 block discarded – undo
599 693
 				<div class="form-group">
600 694
 					<label class="control-label col-sm-2"><?php echo _("IMO"); ?></label> 
601 695
 					<div class="col-sm-10">
602
-						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) print $imo; ?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
696
+						<input type="text" name="imo" class="form-control" value="<?php if (isset($_GET['imo'])) {
697
+	print $imo;
698
+}
699
+?>" size="8" placeholder="<?php echo _("IMO"); ?>" />
603 700
 					</div>
604 701
 				</div>
605 702
 			</fieldset>
@@ -612,7 +709,10 @@  discard block
 block discarded – undo
612 709
 					<label class="control-label col-sm-2"><?php echo _("Start Date"); ?></label>
613 710
 					<div class="col-sm-10">
614 711
 						<div class='input-group date' id='datetimepicker1'>
615
-							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') print $start_date; ?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
712
+							<input type='text' name="start_date" class="form-control" value="<?php if (isset($_GET['start_date']) && $_GET['start_date'] != '') {
713
+	print $start_date;
714
+}
715
+?>" placeholder="<?php echo _("Start Date/Time"); ?>" />
616 716
 							<span class="input-group-addon">
617 717
 								<span class="glyphicon glyphicon-calendar"></span>
618 718
 							</span>
@@ -623,7 +723,10 @@  discard block
 block discarded – undo
623 723
 					<label class="control-label col-sm-2"><?php echo _("End Date"); ?></label>
624 724
 					<div class="col-sm-10">
625 725
 						<div class='input-group date' id='datetimepicker2'>
626
-						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') print $end_date; ?>" placeholder="<?php echo _("End Date/Time"); ?>" />
726
+						<input type='text' name="end_date" class="form-control" value="<?php if (isset($_GET['end_date']) && $_GET['end_date'] != '') {
727
+	print $end_date;
728
+}
729
+?>" placeholder="<?php echo _("End Date/Time"); ?>" />
627 730
 						<span class="input-group-addon">
628 731
 							<span class="glyphicon glyphicon-calendar"></span>
629 732
 						</span>
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +169 added lines, -80 removed lines patch added patch discarded remove patch
@@ -22,11 +22,15 @@  discard block
 block discarded – undo
22 22
 	require_once('require/class.Spotter.php');
23 23
 }
24 24
 
25
-if (!isset($filter_name)) $filter_name = '';
25
+if (!isset($filter_name)) {
26
+	$filter_name = '';
27
+}
26 28
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
27 29
 if ($type == 'aircraft' && $airline_icao == '' && isset($globalFilter)) {
28
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
29
-}
30
+	if (isset($globalFilter['airline'])) {
31
+		$airline_icao = $globalFilter['airline'][0];
32
+	}
33
+	}
30 34
 if ($type == 'aircraft' && $airline_icao != '' && $airline_icao != 'all') {
31 35
 	$Spotter = new Spotter();
32 36
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -61,7 +65,12 @@  discard block
 block discarded – undo
61 65
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
62 66
 <div class="column">
63 67
     <div class="info">
64
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
68
+            <h1><?php if (isset($airline_name)) {
69
+	echo _("Statistics for ").$airline_name;
70
+} else {
71
+	echo _("Statistics");
72
+}
73
+?></h1>
65 74
 <?php 
66 75
 if ($type == 'aircraft') {
67 76
 	$last_update = $Stats->getLastStatsUpdate();
@@ -73,7 +82,9 @@  discard block
 block discarded – undo
73 82
 if (isset($last_update[0]['value'])) {
74 83
 	date_default_timezone_set('UTC');
75 84
 	$lastupdate = strtotime($last_update[0]['value']);
76
-	if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
85
+	if (isset($globalTimezone) && $globalTimezone != '') {
86
+		date_default_timezone_set($globalTimezone);
87
+	}
77 88
 	print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
78 89
 }
79 90
 
@@ -158,8 +169,11 @@  discard block
 block discarded – undo
158 169
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
159 170
 		$aircraft_data = '';
160 171
 		foreach($aircraft_array as $aircraft_item) {
161
-			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') $aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
162
-			else $aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
172
+			if ($aircraft_item['aircraft_manufacturer'] == 'Not Available') {
173
+				$aircraft_data .= '[" ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
174
+			} else {
175
+				$aircraft_data .= '["'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
176
+			}
163 177
 		}
164 178
 		$aircraft_data = substr($aircraft_data, 0, -1);
165 179
 		print 'var series = ['.$aircraft_data.'];';
@@ -176,11 +190,17 @@  discard block
 block discarded – undo
176 190
 <?php
177 191
 	if ($year != '' && $month != '') {
178 192
 ?>
179
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
193
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
194
+	echo '/'.$airline_icao;
195
+}
196
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
180 197
 <?php
181 198
 	} else {
182 199
 ?>
183
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
200
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
201
+	echo '/'.$airline_icao;
202
+}
203
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
184 204
 <?php
185 205
 	}
186 206
 ?>
@@ -209,11 +229,15 @@  discard block
 block discarded – undo
209 229
 			print '</script>';
210 230
 			if ($year != '' && $month != '') {
211 231
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
212
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
232
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
233
+					echo '/'.$airline_icao;
234
+				}
213 235
 				print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
214 236
 			} else {
215 237
 				print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
216
-				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
238
+				if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
239
+					echo '/'.$airline_icao;
240
+				}
217 241
 				print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
218 242
 			}
219 243
 			print '</div>';
@@ -233,8 +257,9 @@  discard block
 block discarded – undo
233 257
                 <h2><?php echo _("Top 10 Most Common Vessel Type"); ?></h2>
234 258
 <?php
235 259
 	$marine_array = $Marine->countAllMarineTypes(true,0,'',array(),$year,$month);
236
-	if (count($marine_array) == 0) print _("No data available");
237
-	else {
260
+	if (count($marine_array) == 0) {
261
+		print _("No data available");
262
+	} else {
238 263
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
239 264
 		$marine_data = '';
240 265
 		foreach($marine_array as $marine_item) {
@@ -278,8 +303,9 @@  discard block
 block discarded – undo
278 303
                 <h2><?php echo _("Top 10 Most Common Tracker Type"); ?></h2>
279 304
 <?php
280 305
 	$tracker_array = $Tracker->countAllTrackerTypes(true,0,'',array(),$year,$month);
281
-	if (count($tracker_array) == 0) print _("No data available");
282
-	else {
306
+	if (count($tracker_array) == 0) {
307
+		print _("No data available");
308
+	} else {
283 309
 		print '<div id="chart1" class="chart" width="100%"></div><script>';
284 310
 		$tracker_data = '';
285 311
 		foreach($tracker_array as $tracker_item) {
@@ -323,8 +349,9 @@  discard block
 block discarded – undo
323 349
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
324 350
 <?php
325 351
 		$owner_array = $Satellite->countAllOwners(true);
326
-		if (count($owner_array) == 0) print _("No data available");
327
-		else {
352
+		if (count($owner_array) == 0) {
353
+			print _("No data available");
354
+		} else {
328 355
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
329 356
 			$owner_data = '';
330 357
 			foreach($owner_array as $owner_item) {
@@ -343,7 +370,10 @@  discard block
 block discarded – undo
343 370
 ?>
344 371
                <!--
345 372
                 <div class="more">
346
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
373
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
374
+	echo '/'.$airline_icao;
375
+}
376
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
347 377
                 </div>
348 378
                 -->
349 379
             </div>
@@ -352,8 +382,9 @@  discard block
 block discarded – undo
352 382
                 <h2><?php echo _("Top 10 Most Common Countries Owners"); ?></h2>
353 383
 <?php
354 384
 		$countries_array = $Satellite->countAllCountriesOwners(true);
355
-		if (count($countries_array) == 0) print _("No data available");
356
-		else {
385
+		if (count($countries_array) == 0) {
386
+			print _("No data available");
387
+		} else {
357 388
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
358 389
 			$owner_data = '';
359 390
 			foreach($countries_array as $owner_item) {
@@ -372,7 +403,10 @@  discard block
 block discarded – undo
372 403
 ?>
373 404
 	    <!--
374 405
                 <div class="more">
375
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
406
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
407
+	echo '/'.$airline_icao;
408
+}
409
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
376 410
                 </div>
377 411
                 -->
378 412
             </div>
@@ -384,8 +418,9 @@  discard block
 block discarded – undo
384 418
                 <h2><?php echo _("Top 10 Most Common Launch Sites"); ?></h2>
385 419
 <?php
386 420
 		$launch_site_array = $Satellite->countAllLaunchSite(true);
387
-		if (count($launch_site_array) == 0) print _("No data available");
388
-		else {
421
+		if (count($launch_site_array) == 0) {
422
+			print _("No data available");
423
+		} else {
389 424
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
390 425
 			$launch_site_data = '';
391 426
 			foreach($launch_site_array as $launch_site_item) {
@@ -404,7 +439,10 @@  discard block
 block discarded – undo
404 439
 ?>
405 440
                <!--
406 441
                 <div class="more">
407
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
442
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
443
+	echo '/'.$airline_icao;
444
+}
445
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
408 446
                 </div>
409 447
                 -->
410 448
             </div>
@@ -427,8 +465,9 @@  discard block
 block discarded – undo
427 465
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
428 466
 <?php
429 467
 		$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
430
-		if (count($pilot_array) == 0) print _("No data available");
431
-		else {
468
+		if (count($pilot_array) == 0) {
469
+			print _("No data available");
470
+		} else {
432 471
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
433 472
 			$pilot_data = '';
434 473
 			foreach($pilot_array as $pilot_item) {
@@ -446,7 +485,9 @@  discard block
 block discarded – undo
446 485
 		}
447 486
 		print '<div class="more">';
448 487
 		print '<a href="'.$globalURL.'/statistics/pilot'; 
449
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
488
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
489
+			echo '/'.$airline_icao;
490
+		}
450 491
 		print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
451 492
 		print '</div>';
452 493
 ?>
@@ -462,8 +503,9 @@  discard block
 block discarded – undo
462 503
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
463 504
 <?php
464 505
 		$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
465
-		if (count($owner_array) == 0) print _("No data available");
466
-		else {
506
+		if (count($owner_array) == 0) {
507
+			print _("No data available");
508
+		} else {
467 509
 			print '<div id="chart7" class="chart" width="100%"></div><script>';
468 510
 			$owner_data = '';
469 511
 			foreach($owner_array as $owner_item) {
@@ -481,7 +523,10 @@  discard block
 block discarded – undo
481 523
 		}
482 524
 ?>
483 525
                 <div class="more">
484
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
526
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
527
+	echo '/'.$airline_icao;
528
+}
529
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
485 530
                 </div>
486 531
             </div>
487 532
         
@@ -494,8 +539,9 @@  discard block
 block discarded – undo
494 539
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
495 540
 <?php
496 541
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
497
-		if (count($flightover_array) == 0) print _("No data available");
498
-		else {
542
+		if (count($flightover_array) == 0) {
543
+			print _("No data available");
544
+		} else {
499 545
 			print '<div id="chart10" class="chart" width="100%"></div><script>';
500 546
 			print 'var series = [';
501 547
 			$flightover_data = '';
@@ -537,7 +583,10 @@  discard block
 block discarded – undo
537 583
 		}
538 584
 ?>
539 585
                 <div class="more">
540
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
587
+	echo '/'.$airline_icao;
588
+}
589
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
541 590
                 </div>
542 591
             </div>
543 592
 <?php
@@ -555,8 +604,9 @@  discard block
 block discarded – undo
555 604
 	<div class="col-md-6">
556 605
             <h2><?php echo _("Top 20 Most Common Country a Vessel was inside"); ?></h2>
557 606
 <?php
558
-	if (count($flightover_array) == 0) print _("No data available");
559
-	else {
607
+	if (count($flightover_array) == 0) {
608
+		print _("No data available");
609
+	} else {
560 610
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
561 611
 		print 'var series = [';
562 612
 		$flightover_data = '';
@@ -612,8 +662,9 @@  discard block
 block discarded – undo
612 662
 	<div class="col-md-6">
613 663
             <h2><?php echo _("Top 20 Most Common Country a Tracker was inside"); ?></h2>
614 664
 <?php
615
-	if (count($flightover_array) == 0) print _("No data available");
616
-	else {
665
+	if (count($flightover_array) == 0) {
666
+		print _("No data available");
667
+	} else {
617 668
 		print '<div id="chart10" class="chart" width="100%"></div><script>';
618 669
 		print 'var series = [';
619 670
 		$flightover_data = '';
@@ -719,7 +770,9 @@  discard block
 block discarded – undo
719 770
 		});";
720 771
 		print '</script>';
721 772
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
722
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
773
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
774
+			echo '/'.$airline_icao;
775
+		}
723 776
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
724 777
 	}
725 778
 ?>
@@ -781,7 +834,9 @@  discard block
 block discarded – undo
781 834
 		});";
782 835
 		print '</script>';
783 836
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
784
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
837
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
838
+			echo '/'.$airline_icao;
839
+		}
785 840
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
786 841
 	}
787 842
 ?>
@@ -800,8 +855,9 @@  discard block
 block discarded – undo
800 855
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
801 856
 <?php
802 857
 		$year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
803
-		if (count($year_array) == 0) print _("No data available");
804
-		else {
858
+		if (count($year_array) == 0) {
859
+			print _("No data available");
860
+		} else {
805 861
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
806 862
 			$year_data = '';
807 863
 			$year_cnt = '';
@@ -820,7 +876,10 @@  discard block
 block discarded – undo
820 876
 		}
821 877
 ?>
822 878
                 <div class="more">
823
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
879
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
880
+	echo '/'.$airline_icao;
881
+}
882
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
824 883
                 </div>
825 884
             </div>
826 885
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -828,8 +887,9 @@  discard block
 block discarded – undo
828 887
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
829 888
 <?php
830 889
 		$month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
831
-		if (count($month_array) == 0) print _("No data available");
832
-		else {
890
+		if (count($month_array) == 0) {
891
+			print _("No data available");
892
+		} else {
833 893
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
834 894
 			$month_data = '';
835 895
 			$month_cnt = '';
@@ -848,7 +908,10 @@  discard block
 block discarded – undo
848 908
 		}
849 909
 ?>
850 910
                 <div class="more">
851
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
911
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
912
+	echo '/'.$airline_icao;
913
+}
914
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
852 915
                 </div>
853 916
             </div>
854 917
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -857,8 +920,9 @@  discard block
 block discarded – undo
857 920
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
858 921
 <?php
859 922
 		$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
860
-		if (empty($date_array)) print _("No data available");
861
-		else {
923
+		if (empty($date_array)) {
924
+			print _("No data available");
925
+		} else {
862 926
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
863 927
 			$date_data = '';
864 928
 			$date_cnt = '';
@@ -877,7 +941,10 @@  discard block
 block discarded – undo
877 941
 		}
878 942
 ?>
879 943
                 <div class="more">
880
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
944
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
945
+	echo '/'.$airline_icao;
946
+}
947
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
881 948
                 </div>
882 949
             </div>
883 950
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -885,8 +952,9 @@  discard block
 block discarded – undo
885 952
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
886 953
 <?php
887 954
 		$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
888
-		if (empty($hour_array)) print _("No data available");
889
-		else {
955
+		if (empty($hour_array)) {
956
+			print _("No data available");
957
+		} else {
890 958
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
891 959
 			$hour_data = '';
892 960
 			$hour_cnt = '';
@@ -905,7 +973,10 @@  discard block
 block discarded – undo
905 973
 		}
906 974
 ?>
907 975
                 <div class="more">
908
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
976
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
977
+	echo '/'.$airline_icao;
978
+}
979
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
909 980
                 </div>
910 981
             </div>
911 982
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -925,8 +996,9 @@  discard block
 block discarded – undo
925 996
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
926 997
 <?php
927 998
 		$year_array = $Marine->countAllMonthsLastYear(true,$airline_icao,$filter_name);
928
-		if (count($year_array) == 0) print _("No data available");
929
-		else {
999
+		if (count($year_array) == 0) {
1000
+			print _("No data available");
1001
+		} else {
930 1002
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
931 1003
 			$year_data = '';
932 1004
 			$year_cnt = '';
@@ -954,8 +1026,9 @@  discard block
 block discarded – undo
954 1026
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
955 1027
 <?php
956 1028
 		$month_array = $Marine->countAllDatesLastMonth($airline_icao,$filter_name);
957
-		if (count($month_array) == 0) print _("No data available");
958
-		else {
1029
+		if (count($month_array) == 0) {
1030
+			print _("No data available");
1031
+		} else {
959 1032
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
960 1033
 			$month_data = '';
961 1034
 			$month_cnt = '';
@@ -983,8 +1056,9 @@  discard block
 block discarded – undo
983 1056
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
984 1057
 <?php
985 1058
 		$date_array = $Marine->countAllDatesLast7Days($airline_icao,$filter_name);
986
-		if (empty($date_array)) print _("No data available");
987
-		else {
1059
+		if (empty($date_array)) {
1060
+			print _("No data available");
1061
+		} else {
988 1062
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
989 1063
 			$date_data = '';
990 1064
 			$date_cnt = '';
@@ -1011,8 +1085,9 @@  discard block
 block discarded – undo
1011 1085
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1012 1086
 <?php
1013 1087
 		$hour_array = $Marine->countAllHours('hour',true,$airline_icao,$filter_name);
1014
-		if (empty($hour_array)) print _("No data available");
1015
-		else {
1088
+		if (empty($hour_array)) {
1089
+			print _("No data available");
1090
+		} else {
1016 1091
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1017 1092
 			$hour_data = '';
1018 1093
 			$hour_cnt = '';
@@ -1051,8 +1126,9 @@  discard block
 block discarded – undo
1051 1126
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
1052 1127
 <?php
1053 1128
 		$year_array = $Tracker->countAllMonthsLastYear(true);
1054
-		if (count($year_array) == 0) print _("No data available");
1055
-		else {
1129
+		if (count($year_array) == 0) {
1130
+			print _("No data available");
1131
+		} else {
1056 1132
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
1057 1133
 			$year_data = '';
1058 1134
 			$year_cnt = '';
@@ -1080,8 +1156,9 @@  discard block
 block discarded – undo
1080 1156
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
1081 1157
 <?php
1082 1158
 		$month_array = $Tracker->countAllDatesLastMonth();
1083
-		if (count($month_array) == 0) print _("No data available");
1084
-		else {
1159
+		if (count($month_array) == 0) {
1160
+			print _("No data available");
1161
+		} else {
1085 1162
 			print '<div id="chart9" class="chart" width="100%"></div><script>';
1086 1163
 			$month_data = '';
1087 1164
 			$month_cnt = '';
@@ -1109,8 +1186,9 @@  discard block
 block discarded – undo
1109 1186
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
1110 1187
 <?php
1111 1188
 		$date_array = $Tracker->countAllDatesLast7Days();
1112
-		if (empty($date_array)) print _("No data available");
1113
-		else {
1189
+		if (empty($date_array)) {
1190
+			print _("No data available");
1191
+		} else {
1114 1192
 			print '<div id="chart5" class="chart" width="100%"></div><script>';
1115 1193
 			$date_data = '';
1116 1194
 			$date_cnt = '';
@@ -1137,8 +1215,9 @@  discard block
 block discarded – undo
1137 1215
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
1138 1216
 <?php
1139 1217
 		$hour_array = $Tracker->countAllHours('hour',true);
1140
-		if (empty($hour_array)) print _("No data available");
1141
-		else {
1218
+		if (empty($hour_array)) {
1219
+			print _("No data available");
1220
+		} else {
1142 1221
 			print '<div id="chart6" class="chart" width="100%"></div><script>';
1143 1222
 			$hour_data = '';
1144 1223
 			$hour_cnt = '';
@@ -1177,8 +1256,9 @@  discard block
 block discarded – undo
1177 1256
                 <h2><?php echo _("Busiest Launch Months of the last 12 Months"); ?></h2>
1178 1257
 <?php
1179 1258
 		$year_array = $Satellite->countAllMonthsLastYear();
1180
-		if (count($year_array) == 0) print _("No data available");
1181
-		else {
1259
+		if (count($year_array) == 0) {
1260
+			print _("No data available");
1261
+		} else {
1182 1262
 			print '<div id="chart21" class="chart" width="100%"></div><script>';
1183 1263
 			$year_data = '';
1184 1264
 			$year_cnt = '';
@@ -1208,8 +1288,9 @@  discard block
 block discarded – undo
1208 1288
                 <h2><?php echo _("Busiest Launch Years of the last 10 Years"); ?></h2>
1209 1289
 <?php
1210 1290
 		$year_array = $Satellite->countAllYears();
1211
-		if (count($year_array) == 0) print _("No data available");
1212
-		else {
1291
+		if (count($year_array) == 0) {
1292
+			print _("No data available");
1293
+		} else {
1213 1294
 			print '<div id="chart22" class="chart" width="100%"></div><script>';
1214 1295
 			$year_data = '';
1215 1296
 			$year_cnt = '';
@@ -1251,8 +1332,9 @@  discard block
 block discarded – undo
1251 1332
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
1252 1333
 <?php
1253 1334
 		$year_array = $Stats->countFatalitiesByYear();
1254
-		if (count($year_array) == 0) print _("No data available");
1255
-		else {
1335
+		if (count($year_array) == 0) {
1336
+			print _("No data available");
1337
+		} else {
1256 1338
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
1257 1339
 			$year_data = '';
1258 1340
 			$year_cnt = '';
@@ -1281,8 +1363,9 @@  discard block
 block discarded – undo
1281 1363
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
1282 1364
 <?php
1283 1365
 		$year_array = $Stats->countFatalitiesLast12Months();
1284
-		if (count($year_array) == 0) print _("No data available");
1285
-		else {
1366
+		if (count($year_array) == 0) {
1367
+			print _("No data available");
1368
+		} else {
1286 1369
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
1287 1370
 			$year_data = '';
1288 1371
 			$year_cnt = '';
@@ -1353,8 +1436,11 @@  discard block
 block discarded – undo
1353 1436
 					$distance = $distance;
1354 1437
 					$unit = 'km';
1355 1438
 				}
1356
-				if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1357
-				else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1439
+				if (!isset($polar_data)) {
1440
+					$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1441
+				} else {
1442
+					$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
1443
+				}
1358 1444
 			}
1359 1445
 ?>
1360 1446
             <div class="col-md-6">
@@ -1418,9 +1504,12 @@  discard block
 block discarded – undo
1418 1504
 		foreach ($msg as $eachmsg) {
1419 1505
 			//$eachmsg = $msg[0];
1420 1506
 			$data = $eachmsg['source_data'];
1421
-			if ($data > 500) $max = (round(($data+100)/100))*100;
1422
-			else $max = 500;
1423
-?>
1507
+			if ($data > 500) {
1508
+				$max = (round(($data+100)/100))*100;
1509
+			} else {
1510
+				$max = 500;
1511
+			}
1512
+			?>
1424 1513
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
1425 1514
         	<script>
1426 1515
 		      var g = new JustGage({
Please login to merge, or discard this patch.
scripts/update_db.php 1 patch
Braces   +30 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,7 +9,9 @@  discard block
 block discarded – undo
9 9
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
10 10
 	exec("ps ux", $output, $result);
11 11
 	$j = 0;
12
-	foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
12
+	foreach ($output as $line) {
13
+		if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ")) $j++;
14
+	}
13 15
 	if ($j > 1) {
14 16
 		echo "Script is already runnning...";
15 17
 		die();
@@ -29,14 +31,18 @@  discard block
 block discarded – undo
29 31
 			$update_db->update_notam();
30 32
 		}
31 33
 		$update_db->insert_last_notam_update();
32
-	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) echo "NOTAM are only updated once a day.\n";
34
+	} elseif (isset($globalDebug) && $globalDebug && isset($globalNOTAM) && $globalNOTAM) {
35
+		echo "NOTAM are only updated once a day.\n";
36
+	}
33 37
 	if ($update_db->check_last_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
34 38
 		$update_db->update_all();
35 39
 	//	require_once(dirname(__FILE__).'/../require/class.Spotter.php');
36 40
 	//	$Spotter = new Spotter();
37 41
 	//	$Spotter->updateFieldsFromOtherTables();
38 42
 		$update_db->insert_last_update();
39
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
43
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM)) {
44
+		echo "DB are populated with external data only every 15 days ! Files are not updated more often.\n";
45
+	}
40 46
 	if (isset($globalWaypoints) && $globalWaypoints && $update_db->check_last_airspace_update()) {
41 47
 		echo "Check if new airspace version exist...";
42 48
 		echo $update_db->update_airspace_fam();
@@ -45,8 +51,11 @@  discard block
 block discarded – undo
45 51
 	if (isset($globalGeoid) && $globalGeoid && $update_db->check_last_geoid_update()) {
46 52
 		echo "Check if new geoid version exist...";
47 53
 		$error = $update_db->update_geoid_fam();
48
-		if ($error == '') $update_db->insert_last_geoid_update();
49
-		else echo $error;
54
+		if ($error == '') {
55
+			$update_db->insert_last_geoid_update();
56
+		} else {
57
+			echo $error;
58
+		}
50 59
 	}
51 60
 	if (isset($globalMarine) && $globalMarine && $update_db->check_last_marine_identity_update()) {
52 61
 		echo "Check if new marine identity version exist...";
@@ -64,13 +73,17 @@  discard block
 block discarded – undo
64 73
 			//echo "Done";
65 74
 		}
66 75
 		$update_db->insert_last_owner_update();
67
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Owner are only updated every 15 days.\n";
76
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
77
+		echo "Owner are only updated every 15 days.\n";
78
+	}
68 79
 
69 80
 	if ($update_db->check_last_airlines_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
70 81
 		echo "Updating airlines...\n";
71 82
 		echo $update_db->update_airlines_fam();
72 83
 		$update_db->insert_last_airlines_update();
73
-	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Airlines are only updated every 15 days.\n";
84
+	} elseif (isset($globalDebug) && $globalDebug && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
85
+		echo "Airlines are only updated every 15 days.\n";
86
+	}
74 87
 
75 88
 	if (isset($globalAccidents) && $globalAccidents && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
76 89
 		require_once(dirname(__FILE__).'/../require/class.Accident.php');
@@ -79,7 +92,9 @@  discard block
 block discarded – undo
79 92
 		if ($Accident->check_last_accidents_update()) {
80 93
 			$Accident->download_update();
81 94
 			$Accident->insert_last_accidents_update();
82
-		} else echo "Accidents are updated once a day.\n";
95
+		} else {
96
+			echo "Accidents are updated once a day.\n";
97
+		}
83 98
 	}
84 99
   
85 100
 }
@@ -92,15 +107,19 @@  discard block
 block discarded – undo
92 107
 	if ($METAR->check_last_update()) {
93 108
 		$METAR->addMETARCycle();
94 109
 		$METAR->insert_last_update();
95
-	} else echo "METAR are only updated every 30 minutes.\n";
96
-}
110
+	} else {
111
+		echo "METAR are only updated every 30 minutes.\n";
112
+	}
113
+	}
97 114
 
98 115
 if (isset($globalSchedules) && $globalSchedules && $update_db->check_last_schedules_update() && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
99 116
 	echo "Updating schedules...";
100 117
 	//$update_db->update_oneworld();
101 118
 	$update_db->update_skyteam();
102 119
 	$update_db->insert_last_schedules_update();
103
-} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) echo "Schedules are only updated every 15 days.\n";
120
+} elseif (isset($globalDebug) && $globalDebug && isset($globalOwner) && $globalOwner && (!isset($globalVA) || !$globalVA) && (!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS)) {
121
+	echo "Schedules are only updated every 15 days.\n";
122
+}
104 123
 
105 124
 if (isset($globalArchiveMonths) && $globalArchiveMonths > 0) {
106 125
 	echo "Updating statistics and archive old data...\n";
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection. (Tracker)');
15
+		}
14 16
 	}
15 17
 
16 18
 	/**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 		if (isset($filter[0]['source'])) {
33 35
 			$filters = array_merge($filters,$filter);
34 36
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
37
+		if (is_array($globalFilter)) {
38
+			$filter = array_merge($filter,$globalFilter);
39
+		}
36 40
 		$filter_query_join = '';
37 41
 		$filter_query_where = '';
38 42
 		foreach($filters as $flt) {
@@ -71,8 +75,11 @@  discard block
 block discarded – undo
71 75
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 76
 			}
73 77
 		}
74
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78
+		if ($filter_query_where == '' && $where) {
79
+			$filter_query_where = ' WHERE';
80
+		} elseif ($filter_query_where != '' && $and) {
81
+			$filter_query_where .= ' AND';
82
+		}
76 83
 		if ($filter_query_where != '') {
77 84
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78 85
 		}
@@ -126,26 +133,43 @@  discard block
 block discarded – undo
126 133
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
127 134
 			} elseif (isset($row['tracker_archive_output_id'])) {
128 135
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
129
-			*/} 
130
-			elseif (isset($row['trackerid'])) {
136
+			*/} elseif (isset($row['trackerid'])) {
131 137
 				$temp_array['trackerid'] = $row['trackerid'];
132 138
 			} else {
133 139
 				$temp_array['trackerid'] = '';
134 140
 			}
135
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
137
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
141
+			if (isset($row['famtrackid'])) {
142
+				$temp_array['famtrackid'] = $row['famtrackid'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
147
+			if (isset($row['comment'])) {
148
+				$temp_array['comment'] = $row['comment'];
149
+			}
138 150
 			$temp_array['ident'] = $row['ident'];
139
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
140
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
141
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
160
+			if (isset($row['altitude'])) {
161
+				$temp_array['altitude'] = $row['altitude'];
162
+			}
143 163
 			if (isset($row['heading'])) {
144 164
 				$temp_array['heading'] = $row['heading'];
145 165
 				$heading_direction = $this->parseDirection($row['heading']);
146
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
147 172
 			}
148
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
149 173
 			
150 174
 			if (isset($row['date'])) {
151 175
 				$dateArray = $this->parseDateString($row['date']);
@@ -188,13 +212,21 @@  discard block
 block discarded – undo
188 212
 			}
189 213
 			
190 214
 			$fromsource = NULL;
191
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
192
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
193
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
215
+			if (isset($row['source_name']) && $row['source_name'] != '') {
216
+				$temp_array['source_name'] = $row['source_name'];
217
+			}
218
+			if (isset($row['over_country']) && $row['over_country'] != '') {
219
+				$temp_array['over_country'] = $row['over_country'];
220
+			}
221
+			if (isset($row['distance']) && $row['distance'] != '') {
222
+				$temp_array['distance'] = $row['distance'];
223
+			}
194 224
 			$temp_array['query_number_rows'] = $num_rows;
195 225
 			$tracker_array[] = $temp_array;
196 226
 		}
197
-		if ($num_rows == 0) return array();
227
+		if ($num_rows == 0) {
228
+			return array();
229
+		}
198 230
 		$tracker_array[0]['query_number_rows'] = $num_rows;
199 231
 		return $tracker_array;
200 232
 	}	
@@ -225,8 +257,12 @@  discard block
 block discarded – undo
225 257
 			{
226 258
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
227 259
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
228
-			} else $limit_query = "";
229
-		} else $limit_query = "";
260
+			} else {
261
+				$limit_query = "";
262
+			}
263
+		} else {
264
+			$limit_query = "";
265
+		}
230 266
 		
231 267
 		if ($sort != "")
232 268
 		{
@@ -254,7 +290,9 @@  discard block
 block discarded – undo
254 290
 		global $global_query;
255 291
 		
256 292
 		date_default_timezone_set('UTC');
257
-		if ($id == '') return array();
293
+		if ($id == '') {
294
+			return array();
295
+		}
258 296
 		$additional_query = "tracker_output.famtrackid = :id";
259 297
 		$query_values = array(':id' => $id);
260 298
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -397,8 +435,11 @@  discard block
 block discarded – undo
397 435
 		$query .= " ORDER BY tracker_output.source_name ASC";
398 436
 
399 437
 		$sth = $this->db->prepare($query);
400
-		if (!empty($query_values)) $sth->execute($query_values);
401
-		else $sth->execute();
438
+		if (!empty($query_values)) {
439
+			$sth->execute($query_values);
440
+		} else {
441
+			$sth->execute();
442
+		}
402 443
 
403 444
 		$source_array = array();
404 445
 		$temp_array = array();
@@ -453,7 +494,9 @@  discard block
 block discarded – undo
453 494
 			date_default_timezone_set($globalTimezone);
454 495
 			$datetime = new DateTime();
455 496
 			$offset = $datetime->format('P');
456
-		} else $offset = '+00:00';
497
+		} else {
498
+			$offset = '+00:00';
499
+		}
457 500
 
458 501
 		if ($globalDBdriver == 'mysql') {
459 502
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -609,7 +652,9 @@  discard block
 block discarded – undo
609 652
 			{
610 653
 				return false;
611 654
 			}
612
-		} else $altitude = 0;
655
+		} else {
656
+			$altitude = 0;
657
+		}
613 658
 		
614 659
 		if ($heading != "")
615 660
 		{
@@ -648,8 +693,12 @@  discard block
 block discarded – undo
648 693
             		$latitude = 0;
649 694
             		$longitude = 0;
650 695
             	}
651
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
696
+                if ($heading == '' || $Common->isInteger($heading) === false) {
697
+                	$heading = 0;
698
+                }
699
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
700
+                	$groundspeed = 0;
701
+                }
653 702
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 703
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 704
 
@@ -753,7 +802,9 @@  discard block
 block discarded – undo
753 802
 		global $globalDBdriver, $globalArchive;
754 803
 		//$filter_query = $this->getFilter($filters,true,true);
755 804
 		$Connection= new Connection($this->db);
756
-		if (!$Connection->tableExists('countries')) return array();
805
+		if (!$Connection->tableExists('countries')) {
806
+			return array();
807
+		}
757 808
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
758 809
 			require_once('class.TrackerLive.php');
759 810
 			$TrackerLive = new TrackerLive($this->db);
@@ -796,7 +847,9 @@  discard block
 block discarded – undo
796 847
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
797 848
 		}
798 849
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
799
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
850
+		if ($limit) {
851
+			$query .= " LIMIT 10 OFFSET 0";
852
+		}
800 853
       
801 854
 		
802 855
 		$sth = $this->db->prepare($query);
@@ -829,12 +882,18 @@  discard block
 block discarded – undo
829 882
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
830 883
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
831 884
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
885
+			if ($globalDBdriver == 'mysql') {
886
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
887
+			} else {
888
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
889
+			}
834 890
 		}
835 891
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
837
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
892
+			if ($globalDBdriver == 'mysql') {
893
+				$query .= " AND tracker_output.date > '".$sincedate."'";
894
+			} else {
895
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
896
+			}
838 897
 		}
839 898
 		$query_values = array();
840 899
 		if ($year != '') {
@@ -865,7 +924,9 @@  discard block
 block discarded – undo
865 924
 			}
866 925
 		}
867 926
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
927
+		if ($limit) {
928
+			$query .= " LIMIT 10 OFFSET 0";
929
+		}
869 930
       		
870 931
 		$sth = $this->db->prepare($query);
871 932
 		$sth->execute($query_values);
@@ -900,7 +961,9 @@  discard block
 block discarded – undo
900 961
 			date_default_timezone_set($globalTimezone);
901 962
 			$datetime = new DateTime();
902 963
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
964
+		} else {
965
+			$offset = '+00:00';
966
+		}
904 967
 
905 968
 		if ($globalDBdriver == 'mysql') {
906 969
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1013,9 @@  discard block
 block discarded – undo
950 1013
 			date_default_timezone_set($globalTimezone);
951 1014
 			$datetime = new DateTime();
952 1015
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1016
+		} else {
1017
+			$offset = '+00:00';
1018
+		}
954 1019
 		$filter_query = $this->getFilter($filters,true,true);
955 1020
 		if ($globalDBdriver == 'mysql') {
956 1021
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1061,9 @@  discard block
 block discarded – undo
996 1061
 			date_default_timezone_set($globalTimezone);
997 1062
 			$datetime = new DateTime();
998 1063
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1064
+		} else {
1065
+			$offset = '+00:00';
1066
+		}
1000 1067
 		$filter_query = $this->getFilter($filters,true,true);
1001 1068
 		if ($globalDBdriver == 'mysql') {
1002 1069
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1111,9 @@  discard block
 block discarded – undo
1044 1111
 			date_default_timezone_set($globalTimezone);
1045 1112
 			$datetime = new DateTime();
1046 1113
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1114
+		} else {
1115
+			$offset = '+00:00';
1116
+		}
1048 1117
 
1049 1118
 		if ($globalDBdriver == 'mysql') {
1050 1119
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1093,7 +1162,9 @@  discard block
 block discarded – undo
1093 1162
 			date_default_timezone_set($globalTimezone);
1094 1163
 			$datetime = new DateTime();
1095 1164
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1165
+		} else {
1166
+			$offset = '+00:00';
1167
+		}
1097 1168
 		$filter_query = $this->getFilter($filters,true,true);
1098 1169
 		if ($globalDBdriver == 'mysql') {
1099 1170
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1142,7 +1213,9 @@  discard block
 block discarded – undo
1142 1213
 			date_default_timezone_set($globalTimezone);
1143 1214
 			$datetime = new DateTime();
1144 1215
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1216
+		} else {
1217
+			$offset = '+00:00';
1218
+		}
1146 1219
 
1147 1220
 		$orderby_sql = '';
1148 1221
 		if ($orderby == "hour")
@@ -1211,7 +1284,9 @@  discard block
 block discarded – undo
1211 1284
 			date_default_timezone_set($globalTimezone);
1212 1285
 			$datetime = new DateTime($date);
1213 1286
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1215 1290
 
1216 1291
 		if ($globalDBdriver == 'mysql') {
1217 1292
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1334,9 @@  discard block
 block discarded – undo
1259 1334
 			date_default_timezone_set($globalTimezone);
1260 1335
 			$datetime = new DateTime();
1261 1336
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1337
+		} else {
1338
+			$offset = '+00:00';
1339
+		}
1263 1340
 
1264 1341
 		if ($globalDBdriver == 'mysql') {
1265 1342
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1324,8 +1401,11 @@  discard block
 block discarded – undo
1324 1401
 				$query_values = array_merge($query_values,array(':month' => $month));
1325 1402
 			}
1326 1403
 		}
1327
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1328
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1404
+		if (empty($query_values)) {
1405
+			$queryi .= $this->getFilter($filters);
1406
+		} else {
1407
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1408
+		}
1329 1409
 		
1330 1410
 		$sth = $this->db->prepare($queryi);
1331 1411
 		$sth->execute($query_values);
@@ -1362,8 +1442,11 @@  discard block
 block discarded – undo
1362 1442
 				$query_values = array_merge($query_values,array(':month' => $month));
1363 1443
 			}
1364 1444
 		}
1365
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1366
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1445
+		if (empty($query_values)) {
1446
+			$queryi .= $this->getFilter($filters);
1447
+		} else {
1448
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1449
+		}
1367 1450
 		
1368 1451
 		$sth = $this->db->prepare($queryi);
1369 1452
 		$sth->execute($query_values);
@@ -1385,7 +1468,9 @@  discard block
 block discarded – undo
1385 1468
 			date_default_timezone_set($globalTimezone);
1386 1469
 			$datetime = new DateTime();
1387 1470
 			$offset = $datetime->format('P');
1388
-		} else $offset = '+00:00';
1471
+		} else {
1472
+			$offset = '+00:00';
1473
+		}
1389 1474
 
1390 1475
 		if ($globalDBdriver == 'mysql') {
1391 1476
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1489,7 +1574,9 @@  discard block
 block discarded – undo
1489 1574
 	*/
1490 1575
 	public function parseDirection($direction = 0)
1491 1576
 	{
1492
-		if ($direction == '') $direction = 0;
1577
+		if ($direction == '') {
1578
+			$direction = 0;
1579
+		}
1493 1580
 		$direction_array = array();
1494 1581
 		$temp_array = array();
1495 1582
 
@@ -1578,7 +1665,9 @@  discard block
 block discarded – undo
1578 1665
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1579 1666
 	
1580 1667
 		$Connection = new Connection($this->db);
1581
-		if (!$Connection->tableExists('countries')) return '';
1668
+		if (!$Connection->tableExists('countries')) {
1669
+			return '';
1670
+		}
1582 1671
 	
1583 1672
 		try {
1584 1673
 			/*
@@ -1598,9 +1687,13 @@  discard block
 block discarded – undo
1598 1687
 			$sth->closeCursor();
1599 1688
 			if (count($row) > 0) {
1600 1689
 				return $row;
1601
-			} else return '';
1690
+			} else {
1691
+				return '';
1692
+			}
1602 1693
 		} catch (PDOException $e) {
1603
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1694
+			if (isset($globalDebug) && $globalDebug) {
1695
+				echo 'Error : '.$e->getMessage()."\n";
1696
+			}
1604 1697
 			return '';
1605 1698
 		}
1606 1699
 	
@@ -1618,7 +1711,9 @@  discard block
 block discarded – undo
1618 1711
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1619 1712
 	
1620 1713
 		$Connection = new Connection($this->db);
1621
-		if (!$Connection->tableExists('countries')) return '';
1714
+		if (!$Connection->tableExists('countries')) {
1715
+			return '';
1716
+		}
1622 1717
 	
1623 1718
 		try {
1624 1719
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1630,9 +1725,13 @@  discard block
 block discarded – undo
1630 1725
 			$sth->closeCursor();
1631 1726
 			if (count($row) > 0) {
1632 1727
 				return $row;
1633
-			} else return '';
1728
+			} else {
1729
+				return '';
1730
+			}
1634 1731
 		} catch (PDOException $e) {
1635
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1732
+			if (isset($globalDebug) && $globalDebug) {
1733
+				echo 'Error : '.$e->getMessage()."\n";
1734
+			}
1636 1735
 			return '';
1637 1736
 		}
1638 1737
 	
@@ -1693,7 +1792,9 @@  discard block
 block discarded – undo
1693 1792
 			}
1694 1793
 		}
1695 1794
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1696
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1795
+		if ($limit) {
1796
+			$query .= " LIMIT 10 OFFSET 0";
1797
+		}
1697 1798
 		$sth = $this->db->prepare($query);
1698 1799
 		$sth->execute($query_values);
1699 1800
 		$tracker_array = array();
@@ -1730,7 +1831,9 @@  discard block
 block discarded – undo
1730 1831
 				foreach ($q_array as $q_item){
1731 1832
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1732 1833
 					$additional_query .= " AND (";
1733
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1834
+					if (is_int($q_item)) {
1835
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1836
+					}
1734 1837
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1735 1838
 					$additional_query .= ")";
1736 1839
 				}
@@ -1756,7 +1859,9 @@  discard block
 block discarded – undo
1756 1859
 				date_default_timezone_set($globalTimezone);
1757 1860
 				$datetime = new DateTime();
1758 1861
 				$offset = $datetime->format('P');
1759
-			} else $offset = '+00:00';
1862
+			} else {
1863
+				$offset = '+00:00';
1864
+			}
1760 1865
 			if ($date_array[1] != "")
1761 1866
 			{
1762 1867
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1783,8 +1888,12 @@  discard block
 block discarded – undo
1783 1888
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1784 1889
 			{
1785 1890
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1786
-			} else $limit_query = "";
1787
-		} else $limit_query = "";
1891
+			} else {
1892
+				$limit_query = "";
1893
+			}
1894
+		} else {
1895
+			$limit_query = "";
1896
+		}
1788 1897
 		if ($sort != "")
1789 1898
 		{
1790 1899
 			$search_orderby_array = $this->getOrderBy();
@@ -1827,7 +1936,9 @@  discard block
 block discarded – undo
1827 1936
 	{
1828 1937
 		global $globalBitlyAccessToken;
1829 1938
 		
1830
-		if ($globalBitlyAccessToken == '') return $url;
1939
+		if ($globalBitlyAccessToken == '') {
1940
+			return $url;
1941
+		}
1831 1942
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1832 1943
 		$ch = curl_init();
1833 1944
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1047 added lines, -357 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,22 +211,30 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/opensky/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftlistjson';
178 233
         	$globalSources[$id]['format'] = 'opensky';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to opensky source (".$host.")...\n";
237
+        	}
181 238
     	    /*
182 239
     	    // Disabled for now, site change source format
183 240
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -194,7 +251,9 @@  discard block
 block discarded – undo
194 251
         	//$formats[$id] = 'planeupdatefaa';
195 252
         	$globalSources[$id]['format'] = 'planeupdatefaa';
196 253
         	//$last_exec['planeupdatefaa'] = 0;
197
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
254
+        	if ($globalDebug) {
255
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
256
+        	}
198 257
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
199 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
200 259
         	    exit(0);
@@ -203,32 +262,46 @@  discard block
 block discarded – undo
203 262
         	//$formats[$id] = 'phpvmacars';
204 263
         	$globalSources[$id]['format'] = 'phpvmacars';
205 264
         	//$last_exec['phpvmacars'] = 0;
206
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
265
+        	if ($globalDebug) {
266
+        		echo "Connect to phpvmacars source (".$host.")...\n";
267
+        	}
207 268
             } else if (preg_match('/VAM-json.php$/i',$host)) {
208 269
         	//$formats[$id] = 'phpvmacars';
209 270
         	$globalSources[$id]['format'] = 'vam';
210
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
271
+        	if ($globalDebug) {
272
+        		echo "Connect to Vam source (".$host.")...\n";
273
+        	}
211 274
             } else if (preg_match('/whazzup/i',$host)) {
212 275
         	//$formats[$id] = 'whazzup';
213 276
         	$globalSources[$id]['format'] = 'whazzup';
214 277
         	//$last_exec['whazzup'] = 0;
215
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
278
+        	if ($globalDebug) {
279
+        		echo "Connect to whazzup source (".$host.")...\n";
280
+        	}
216 281
             } else if (preg_match('/blitzortung/i',$host)) {
217 282
         	$globalSources[$id]['format'] = 'blitzortung';
218
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
283
+        	if ($globalDebug) {
284
+        		echo "Connect to blitzortung source (".$host.")...\n";
285
+        	}
219 286
             } else if (preg_match('/airwhere/i',$host)) {
220 287
         	$globalSources[$id]['format'] = 'airwhere';
221
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
288
+        	if ($globalDebug) {
289
+        		echo "Connect to airwhere source (".$host.")...\n";
290
+        	}
222 291
             } else if (preg_match('/recentpireps/i',$host)) {
223 292
         	//$formats[$id] = 'pirepsjson';
224 293
         	$globalSources[$id]['format'] = 'pirepsjson';
225 294
         	//$last_exec['pirepsjson'] = 0;
226
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
295
+        	if ($globalDebug) {
296
+        		echo "Connect to pirepsjson source (".$host.")...\n";
297
+        	}
227 298
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
228 299
         	//$formats[$id] = 'fr24json';
229 300
         	$globalSources[$id]['format'] = 'fr24json';
230 301
         	//$last_exec['fr24json'] = 0;
231
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
302
+        	if ($globalDebug) {
303
+        		echo "Connect to fr24 source (".$host.")...\n";
304
+        	}
232 305
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
233 306
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
234 307
         	    exit(0);
@@ -237,7 +310,9 @@  discard block
 block discarded – undo
237 310
         	//$formats[$id] = 'fr24json';
238 311
         	$globalSources[$id]['format'] = 'myshiptracking';
239 312
         	//$last_exec['fr24json'] = 0;
240
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
313
+        	if ($globalDebug) {
314
+        		echo "Connect to myshiptracking source (".$host.")...\n";
315
+        	}
241 316
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
242 317
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
243 318
         	    exit(0);
@@ -246,16 +321,24 @@  discard block
 block discarded – undo
246 321
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
247 322
         	//$formats[$id] = 'tsv';
248 323
         	$globalSources[$id]['format'] = 'tsv';
249
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to tsv source (".$host.")...\n";
326
+        	}
250 327
             }
251 328
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
252 329
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
253 330
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
254 331
     		    if ($idf !== false) {
255 332
     			$httpfeeds[$id] = $idf;
256
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
258
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
333
+        		if ($globalDebug) {
334
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
335
+        		}
336
+    		    } elseif ($globalDebug) {
337
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
338
+    		    }
339
+    		} elseif ($globalDebug) {
340
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
341
+    		}
259 342
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
260 343
 	    $hostport = explode(':',$host);
261 344
 	    if (isset($hostport[1])) {
@@ -295,17 +378,25 @@  discard block
 block discarded – undo
295 378
         		//$formats[$id] = 'beast';
296 379
         		$globalSources[$id]['format'] = 'beast';
297 380
 		    //} else $formats[$id] = 'sbs';
298
-		    } else $globalSources[$id]['format'] = 'sbs';
381
+		    } else {
382
+		    	$globalSources[$id]['format'] = 'sbs';
383
+		    }
299 384
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
300 385
 		}
301
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
386
+		if ($globalDebug) {
387
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
388
+		}
302 389
             } else {
303
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
390
+		if ($globalDebug) {
391
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
392
+		}
304 393
     	    }
305 394
         }
306 395
     }
307 396
 }
308
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
397
+if (!isset($globalMinFetch)) {
398
+	$globalMinFetch = 15;
399
+}
309 400
 
310 401
 // Initialize all
311 402
 $status = array();
@@ -314,13 +405,19 @@  discard block
 block discarded – undo
314 405
 $formats = array();
315 406
 $last_exec = array();
316 407
 $time = time();
317
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
318
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
319
-else $timeout = 20;
408
+if (isset($globalSourcesTimeout)) {
409
+	$timeout = $globalSourcesTimeOut;
410
+} else if (isset($globalSBS1TimeOut)) {
411
+	$timeout = $globalSBS1TimeOut;
412
+} else {
413
+	$timeout = 20;
414
+}
320 415
 $errno = '';
321 416
 $errstr='';
322 417
 
323
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
418
+if (!isset($globalDaemon)) {
419
+	$globalDaemon = TRUE;
420
+}
324 421
 /* Initiate connections to all the hosts simultaneously */
325 422
 //connect_all($hosts);
326 423
 //connect_all($globalSources);
@@ -349,7 +446,9 @@  discard block
 block discarded – undo
349 446
     if (isset($source['format']) && $source['format'] == 'aprs') {
350 447
 	$aprs_connect = 0;
351 448
 	$use_aprs = true;
352
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
449
+	if (isset($source['port']) && $source['port'] == '10152') {
450
+		$aprs_full = true;
451
+	}
353 452
 	break;
354 453
     }
355 454
 }
@@ -360,25 +459,46 @@  discard block
 block discarded – undo
360 459
 	$aprs_connect = 0;
361 460
 	$aprs_keep = 120;
362 461
 	$aprs_last_tx = time();
363
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
364
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
365
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
366
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
367
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
368
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
369
-	if ($aprs_full) $aprs_filter = '';
370
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
371
-	else $aprs_pass = '-1';
462
+	if (isset($globalAPRSversion)) {
463
+		$aprs_version = $globalAPRSversion;
464
+	} else {
465
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
466
+	}
467
+	if (isset($globalAPRSssid)) {
468
+		$aprs_ssid = $globalAPRSssid;
469
+	} else {
470
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
471
+	}
472
+	if (isset($globalAPRSfilter)) {
473
+		$aprs_filter = $globalAPRSfilter;
474
+	} else {
475
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
476
+	}
477
+	if ($aprs_full) {
478
+		$aprs_filter = '';
479
+	}
480
+	if (isset($globalAPRSpass)) {
481
+		$aprs_pass = $globalAPRSpass;
482
+	} else {
483
+		$aprs_pass = '-1';
484
+	}
372 485
 
373
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
374
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
375
-}
486
+	if ($aprs_filter != '') {
487
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
488
+	} else {
489
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
490
+	}
491
+	}
376 492
 
377 493
 // connected - lets do some work
378 494
 //if ($globalDebug) echo "Connected!\n";
379 495
 sleep(1);
380
-if ($globalDebug) echo "SCAN MODE \n\n";
381
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
496
+if ($globalDebug) {
497
+	echo "SCAN MODE \n\n";
498
+}
499
+if (!isset($globalCronEnd)) {
500
+	$globalCronEnd = 60;
501
+}
382 502
 $endtime = time()+$globalCronEnd;
383 503
 $i = 1;
384 504
 $tt = array();
@@ -392,20 +512,28 @@  discard block
 block discarded – undo
392 512
 
393 513
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
394 514
 while ($i > 0) {
395
-    if (!$globalDaemon) $i = $endtime-time();
515
+    if (!$globalDaemon) {
516
+    	$i = $endtime-time();
517
+    }
396 518
     // Delete old ATC
397 519
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
398
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
520
+	if ($globalDebug) {
521
+		echo 'Delete old ATC...'."\n";
522
+	}
399 523
         $ATC->deleteOldATC();
400 524
     }
401 525
     
402 526
     if (count($last_exec) == count($globalSources)) {
403 527
 	$max = $globalMinFetch;
404 528
 	foreach ($last_exec as $last) {
405
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
529
+	    if ((time() - $last['last']) < $max) {
530
+	    	$max = time() - $last['last'];
531
+	    }
406 532
 	}
407 533
 	if ($max != $globalMinFetch) {
408
-	    if ($globalDebug) echo 'Sleeping...'."\n";
534
+	    if ($globalDebug) {
535
+	    	echo 'Sleeping...'."\n";
536
+	    }
409 537
 	    sleep($globalMinFetch-$max+2);
410 538
 	}
411 539
     }
@@ -415,7 +543,9 @@  discard block
 block discarded – undo
415 543
     foreach ($globalSources as $id => $value) {
416 544
 	date_default_timezone_set('UTC');
417 545
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
418
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
546
+	if (!isset($last_exec[$id]['last'])) {
547
+		$last_exec[$id]['last'] = 0;
548
+	}
419 549
 	if ($value['format'] == 'deltadbtxt' && 
420 550
 	    (
421 551
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -424,7 +554,9 @@  discard block
 block discarded – undo
424 554
 	) {
425 555
 	    //$buffer = $Common->getData($hosts[$id]);
426 556
 	    $buffer = $Common->getData($value['host']);
427
-	    if ($buffer != '') $reset = 0;
557
+	    if ($buffer != '') {
558
+	    	$reset = 0;
559
+	    }
428 560
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
429 561
 	    $buffer = explode('\n',$buffer);
430 562
 	    foreach ($buffer as $line) {
@@ -433,20 +565,41 @@  discard block
 block discarded – undo
433 565
 	            $data = array();
434 566
 	            $data['hex'] = $line[1]; // hex
435 567
 	            $data['ident'] = $line[2]; // ident
436
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
437
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
438
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
439
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
440
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
568
+	            if (isset($line[3])) {
569
+	            	$data['altitude'] = $line[3];
570
+	            }
571
+	            // altitude
572
+	            if (isset($line[4])) {
573
+	            	$data['speed'] = $line[4];
574
+	            }
575
+	            // speed
576
+	            if (isset($line[5])) {
577
+	            	$data['heading'] = $line[5];
578
+	            }
579
+	            // heading
580
+	            if (isset($line[6])) {
581
+	            	$data['latitude'] = $line[6];
582
+	            }
583
+	            // lat
584
+	            if (isset($line[7])) {
585
+	            	$data['longitude'] = $line[7];
586
+	            }
587
+	            // long
441 588
 	            $data['verticalrate'] = ''; // vertical rate
442 589
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
443 590
 	            $data['emergency'] = ''; // emergency
444 591
 		    $data['datetime'] = date('Y-m-d H:i:s');
445 592
 		    $data['format_source'] = 'deltadbtxt';
446 593
     		    $data['id_source'] = $id_source;
447
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
448
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
449
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
594
+		    if (isset($value['name']) && $value['name'] != '') {
595
+		    	$data['source_name'] = $value['name'];
596
+		    }
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if (isset($value['sourcestats'])) {
601
+		    	$data['sourcestats'] = $value['sourcestats'];
602
+		    }
450 603
     		    $SI->add($data);
451 604
 		    unset($data);
452 605
     		}
@@ -461,7 +614,9 @@  discard block
 block discarded – undo
461 614
 	    date_default_timezone_set('CET');
462 615
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
463 616
 	    date_default_timezone_set('UTC');
464
-	    if ($buffer != '') $reset = 0;
617
+	    if ($buffer != '') {
618
+	    	$reset = 0;
619
+	    }
465 620
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
466 621
 	    $buffer = explode('\n',$buffer);
467 622
 	    foreach ($buffer as $line) {
@@ -470,16 +625,36 @@  discard block
 block discarded – undo
470 625
 		    $add = false;
471 626
 		    $ais_data = $AIS->parse_line(trim($line));
472 627
 		    $data = array();
473
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
474
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
475
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
476
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
477
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
478
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
479
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
480
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
481
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
482
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
628
+		    if (isset($ais_data['ident'])) {
629
+		    	$data['ident'] = $ais_data['ident'];
630
+		    }
631
+		    if (isset($ais_data['mmsi'])) {
632
+		    	$data['mmsi'] = $ais_data['mmsi'];
633
+		    }
634
+		    if (isset($ais_data['speed'])) {
635
+		    	$data['speed'] = $ais_data['speed'];
636
+		    }
637
+		    if (isset($ais_data['heading'])) {
638
+		    	$data['heading'] = $ais_data['heading'];
639
+		    }
640
+		    if (isset($ais_data['latitude'])) {
641
+		    	$data['latitude'] = $ais_data['latitude'];
642
+		    }
643
+		    if (isset($ais_data['longitude'])) {
644
+		    	$data['longitude'] = $ais_data['longitude'];
645
+		    }
646
+		    if (isset($ais_data['status'])) {
647
+		    	$data['status'] = $ais_data['status'];
648
+		    }
649
+		    if (isset($ais_data['type'])) {
650
+		    	$data['type'] = $ais_data['type'];
651
+		    }
652
+		    if (isset($ais_data['imo'])) {
653
+		    	$data['imo'] = $ais_data['imo'];
654
+		    }
655
+		    if (isset($ais_data['callsign'])) {
656
+		    	$data['callsign'] = $ais_data['callsign'];
657
+		    }
483 658
 		    if (isset($ais_data['timestamp'])) {
484 659
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
485 660
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -493,8 +668,12 @@  discard block
 block discarded – undo
493 668
 		    $data['format_source'] = 'aisnmeatxt';
494 669
     		    $data['id_source'] = $id_source;
495 670
 		    //print_r($data);
496
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
497
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
671
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
672
+		    	$data['noarchive'] = true;
673
+		    }
674
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
675
+		    	$MI->add($data);
676
+		    }
498 677
 		    unset($data);
499 678
 		}
500 679
     	    }
@@ -517,20 +696,48 @@  discard block
 block discarded – undo
517 696
 			    if ($line != '') {
518 697
 				$ais_data = $AIS->parse_line(trim($line));
519 698
 				$data = array();
520
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
521
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
522
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
523
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
524
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
525
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
526
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
527
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
528
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
529
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
530
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
531
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
532
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
533
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
699
+				if (isset($ais_data['ident'])) {
700
+					$data['ident'] = $ais_data['ident'];
701
+				}
702
+				if (isset($ais_data['mmsi'])) {
703
+					$data['mmsi'] = $ais_data['mmsi'];
704
+				}
705
+				if (isset($ais_data['speed'])) {
706
+					$data['speed'] = $ais_data['speed'];
707
+				}
708
+				if (isset($ais_data['heading'])) {
709
+					$data['heading'] = $ais_data['heading'];
710
+				}
711
+				if (isset($ais_data['latitude'])) {
712
+					$data['latitude'] = $ais_data['latitude'];
713
+				}
714
+				if (isset($ais_data['longitude'])) {
715
+					$data['longitude'] = $ais_data['longitude'];
716
+				}
717
+				if (isset($ais_data['status'])) {
718
+					$data['status'] = $ais_data['status'];
719
+				}
720
+				if (isset($ais_data['statusid'])) {
721
+					$data['status_id'] = $ais_data['statusid'];
722
+				}
723
+				if (isset($ais_data['type'])) {
724
+					$data['type'] = $ais_data['type'];
725
+				}
726
+				if (isset($ais_data['typeid'])) {
727
+					$data['type_id'] = $ais_data['typeid'];
728
+				}
729
+				if (isset($ais_data['imo'])) {
730
+					$data['imo'] = $ais_data['imo'];
731
+				}
732
+				if (isset($ais_data['callsign'])) {
733
+					$data['callsign'] = $ais_data['callsign'];
734
+				}
735
+				if (isset($ais_data['destination'])) {
736
+					$data['arrival_code'] = $ais_data['destination'];
737
+				}
738
+				if (isset($ais_data['eta_ts'])) {
739
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
740
+				}
534 741
 				if (isset($ais_data['timestamp'])) {
535 742
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
536 743
 				} else {
@@ -538,18 +745,27 @@  discard block
 block discarded – undo
538 745
 				}
539 746
 				$data['format_source'] = 'aisnmeahttp';
540 747
 				$data['id_source'] = $id_source;
541
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
542
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
748
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
749
+					$data['noarchive'] = true;
750
+				}
751
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
752
+					$MI->add($data);
753
+				}
543 754
 				unset($data);
544 755
 			    }
545 756
 			}
546 757
 		    }
547 758
 		} else {
548 759
 		    $format = $value['format'];
549
-		    if (isset($tt[$format])) $tt[$format]++;
550
-		    else $tt[$format] = 0;
760
+		    if (isset($tt[$format])) {
761
+		    	$tt[$format]++;
762
+		    } else {
763
+		    	$tt[$format] = 0;
764
+		    }
551 765
 		    if ($tt[$format] > 30) {
552
-			if ($globalDebug) echo 'Reconnect...'."\n";
766
+			if ($globalDebug) {
767
+				echo 'Reconnect...'."\n";
768
+			}
553 769
 			sleep(2);
554 770
 			//$sourceeen[] = $value;
555 771
 			//connect_all($sourceeen);
@@ -588,7 +804,9 @@  discard block
 block discarded – undo
588 804
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
589 805
 			    $data['format_source'] = 'myshiptracking';
590 806
 			    $data['id_source'] = $id_source;
591
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
807
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
808
+			    	$data['noarchive'] = true;
809
+			    }
592 810
 			    $MI->add($data);
593 811
 			    unset($data);
594 812
 			}
@@ -613,7 +831,9 @@  discard block
 block discarded – undo
613 831
 			    $data['callsign'] = $line['callsign'];
614 832
 			    $data['mmsi'] = $line['mmsi'];
615 833
 			    $data['speed'] = $line['sog'];
616
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
834
+			    if ($line['heading'] != '511') {
835
+			    	$data['heading'] = $line['heading'];
836
+			    }
617 837
 			    $data['latitude'] = $line['latitude'];
618 838
 			    $data['longitude'] = $line['longitude'];
619 839
 			    $data['type_id'] = $line['shiptype'];
@@ -621,7 +841,9 @@  discard block
 block discarded – undo
621 841
 			    $data['datetime'] = $line['time'];
622 842
 			    $data['format_source'] = 'boatbeaconapp';
623 843
 			    $data['id_source'] = $id_source;
624
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
844
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
845
+			    	$data['noarchive'] = true;
846
+			    }
625 847
 			    $MI->add($data);
626 848
 			    unset($data);
627 849
 			}
@@ -642,22 +864,44 @@  discard block
 block discarded – undo
642 864
 		if (isset($all_data['features'][0]['id'])) {
643 865
 		    foreach ($all_data['features'] as $line) {
644 866
 			$data = array();
645
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
646
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
647
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
648
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
649
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
650
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
867
+			if (isset($line['properties']['name'])) {
868
+				$data['ident'] = $line['properties']['name'];
869
+			}
870
+			if (isset($line['properties']['callsign'])) {
871
+				$data['callsign'] = $line['properties']['callsign'];
872
+			}
873
+			if (isset($line['properties']['mmsi'])) {
874
+				$data['mmsi'] = $line['properties']['mmsi'];
875
+			}
876
+			if (isset($line['properties']['imo'])) {
877
+				$data['mmsi'] = $line['properties']['imo'];
878
+			}
879
+			if (isset($line['properties']['speed'])) {
880
+				$data['speed'] = $line['properties']['speed'];
881
+			}
882
+			if (isset($line['properties']['heading'])) {
883
+				$data['heading'] = $line['properties']['heading'];
884
+			}
651 885
 			$data['latitude'] = $line['geometry']['coordinates'][1];
652 886
 			$data['longitude'] = $line['geometry']['coordinates'][0];
653
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
654
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
655
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
887
+			if (isset($line['properties']['vesselType'])) {
888
+				$data['type'] = $line['properties']['vesselType'];
889
+			}
890
+			if (isset($line['properties']['destination'])) {
891
+				$data['arrival_code'] = $line['properties']['destination'];
892
+			}
893
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
894
+				$data['arrival_date'] = $line['properties']['eta'];
895
+			}
656 896
 			$data['format_source'] = 'boatnerd';
657 897
 			$data['id_source'] = $id_source;
658 898
 			$data['datetime'] = date('Y-m-d H:i:s');
659
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
660
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
899
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
900
+				$data['noarchive'] = true;
901
+			}
902
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
903
+				$MI->add($data);
904
+			}
661 905
 			unset($data);
662 906
 		    }
663 907
 		}
@@ -673,7 +917,9 @@  discard block
 block discarded – undo
673 917
 	    echo 'download...';
674 918
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
675 919
 	    echo 'done !'."\n";
676
-	    if ($buffer != '') $reset = 0;
920
+	    if ($buffer != '') {
921
+	    	$reset = 0;
922
+	    }
677 923
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
678 924
 	    $buffer = explode('\n',$buffer);
679 925
 	    foreach ($buffer as $line) {
@@ -698,7 +944,9 @@  discard block
 block discarded – undo
698 944
 		    //$data['etaTime'] = substr($line,135,5);
699 945
 		    $data['format_source'] = 'shipplotter';
700 946
     		    $data['id_source'] = $id_source;
701
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
947
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
948
+		    	$data['noarchive'] = true;
949
+		    }
702 950
 		    //print_r($data);
703 951
 		    echo 'Add...'."\n";
704 952
 		    $MI->add($data);
@@ -732,16 +980,28 @@  discard block
 block discarded – undo
732 980
     		    $line = explode(':', $line);
733 981
     		    if (count($line) > 30 && $line[0] != 'callsign') {
734 982
 			$data = array();
735
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
736
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
983
+			if (isset($line[37]) && $line[37] != '') {
984
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
985
+			} else {
986
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
987
+			}
737 988
 			$data['pilot_id'] = $line[1];
738 989
 			$data['pilot_name'] = $line[2];
739 990
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
740 991
 			$data['ident'] = $line[0]; // ident
741
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
992
+			if ($line[7] != '' && $line[7] != 0) {
993
+				$data['altitude'] = $line[7];
994
+			}
995
+			// altitude
742 996
 			$data['speed'] = $line[8]; // speed
743
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
744
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
997
+			if (isset($line[45])) {
998
+				$data['heading'] = $line[45];
999
+			}
1000
+			// heading
1001
+			elseif (isset($line[38])) {
1002
+				$data['heading'] = $line[38];
1003
+			}
1004
+			// heading
745 1005
 			$data['latitude'] = $line[5]; // lat
746 1006
 	        	$data['longitude'] = $line[6]; // long
747 1007
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -757,7 +1017,9 @@  discard block
 block discarded – undo
757 1017
 			$data['frequency'] = $line[4];
758 1018
 			$data['type'] = $line[18];
759 1019
 			$data['range'] = $line[19];
760
-			if (isset($line[35])) $data['info'] = $line[35];
1020
+			if (isset($line[35])) {
1021
+				$data['info'] = $line[35];
1022
+			}
761 1023
     			$data['id_source'] = $id_source;
762 1024
 	    		//$data['arrival_airport_time'] = ;
763 1025
 	    		if ($line[9] != '') {
@@ -771,27 +1033,47 @@  discard block
 block discarded – undo
771 1033
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
772 1034
 	    		*/
773 1035
 	    		$data['format_source'] = $value['format'];
774
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
775
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
776
-    			if ($line[3] == 'PILOT') $SI->add($data);
777
-			elseif ($line[3] == 'ATC') {
1036
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1037
+				$data['noarchive'] = true;
1038
+			}
1039
+			if (isset($value['name']) && $value['name'] != '') {
1040
+				$data['source_name'] = $value['name'];
1041
+			}
1042
+    			if ($line[3] == 'PILOT') {
1043
+    				$SI->add($data);
1044
+    			} elseif ($line[3] == 'ATC') {
778 1045
 				//print_r($data);
779 1046
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
780 1047
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
781 1048
 				$typec = substr($data['ident'],-3);
782
-				if ($typec == 'APP') $data['type'] = 'Approach';
783
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
784
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
785
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
786
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
787
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
788
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
789
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
790
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
791
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1049
+				if ($typec == 'APP') {
1050
+					$data['type'] = 'Approach';
1051
+				} elseif ($typec == 'TWR') {
1052
+					$data['type'] = 'Tower';
1053
+				} elseif ($typec == 'OBS') {
1054
+					$data['type'] = 'Observer';
1055
+				} elseif ($typec == 'GND') {
1056
+					$data['type'] = 'Ground';
1057
+				} elseif ($typec == 'DEL') {
1058
+					$data['type'] = 'Delivery';
1059
+				} elseif ($typec == 'DEP') {
1060
+					$data['type'] = 'Departure';
1061
+				} elseif ($typec == 'FSS') {
1062
+					$data['type'] = 'Flight Service Station';
1063
+				} elseif ($typec == 'CTR') {
1064
+					$data['type'] = 'Control Radar or Centre';
1065
+				} elseif ($data['type'] == '') {
1066
+					$data['type'] = 'Observer';
1067
+				}
1068
+				if (!isset($data['source_name'])) {
1069
+					$data['source_name'] = '';
1070
+				}
792 1071
 				if (isset($ATC)) {
793
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
794
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1072
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1073
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1074
+					} else {
1075
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1076
+					}
795 1077
 				}
796 1078
 			}
797 1079
     			unset($data);
@@ -818,14 +1100,20 @@  discard block
 block discarded – undo
818 1100
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
819 1101
 			$data['latitude'] = (float)$line['pktLatitude'];
820 1102
 			$data['longitude'] = (float)$line['pktLongitude'];
821
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
822
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1103
+			if ((float)$line['pktTrack'] != 0) {
1104
+				$data['heading'] = (float)$line['pktTrack'];
1105
+			}
1106
+			if ((int)$line['pktSpeed'] != 0) {
1107
+				$data['speed'] = (int)$line['pktSpeed'];
1108
+			}
823 1109
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
824 1110
 			$data['altitude_relative'] = 'AMSL';
825 1111
 			$data['pilot_id'] = (int)$line['pktPilotID'];
826 1112
 			$data['aircraft_icao'] = 'PARAGLIDER';
827 1113
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
828
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1114
+			if (isset($pilot_data[4])) {
1115
+				$data['pilot_name'] = $pilot_data[4];
1116
+			}
829 1117
 			$data['format_source'] = $value['format'];
830 1118
 			$SI->add($data);
831 1119
 			unset($data);
@@ -873,25 +1161,59 @@  discard block
 block discarded – undo
873 1161
 		    foreach ($all_data['acList'] as $line) {
874 1162
 			$data = array();
875 1163
 			$data['hex'] = $line['Icao']; // hex
876
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
877
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
878
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
879
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
880
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
881
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1164
+			if (isset($line['Call'])) {
1165
+				$data['ident'] = $line['Call'];
1166
+			}
1167
+			// ident
1168
+			if (isset($line['Alt'])) {
1169
+				$data['altitude'] = $line['Alt'];
1170
+			}
1171
+			// altitude
1172
+			if (isset($line['Spd'])) {
1173
+				$data['speed'] = $line['Spd'];
1174
+			}
1175
+			// speed
1176
+			if (isset($line['Trak'])) {
1177
+				$data['heading'] = $line['Trak'];
1178
+			}
1179
+			// heading
1180
+			if (isset($line['Lat'])) {
1181
+				$data['latitude'] = $line['Lat'];
1182
+			}
1183
+			// lat
1184
+			if (isset($line['Long'])) {
1185
+				$data['longitude'] = $line['Long'];
1186
+			}
1187
+			// long
882 1188
 			//$data['verticalrate'] = $line['']; // verticale rate
883
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1189
+			if (isset($line['Sqk'])) {
1190
+				$data['squawk'] = $line['Sqk'];
1191
+			}
1192
+			// squawk
884 1193
 			$data['emergency'] = ''; // emergency
885
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
886
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
887
-			else $data['datetime'] = date('Y-m-d H:i:s');
1194
+			if (isset($line['Reg'])) {
1195
+				$data['registration'] = $line['Reg'];
1196
+			}
1197
+			if (isset($line['PosTime'])) {
1198
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1199
+			} else {
1200
+				$data['datetime'] = date('Y-m-d H:i:s');
1201
+			}
888 1202
 			//$data['datetime'] = date('Y-m-d H:i:s');
889
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1203
+			if (isset($line['Type'])) {
1204
+				$data['aircraft_icao'] = $line['Type'];
1205
+			}
890 1206
 			$data['format_source'] = 'aircraftlistjson';
891 1207
 			$data['id_source'] = $id_source;
892
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
893
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
894
-			if (isset($data['latitude'])) $SI->add($data);
1208
+			if (isset($value['name']) && $value['name'] != '') {
1209
+				$data['source_name'] = $value['name'];
1210
+			}
1211
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1212
+				$data['noarchive'] = true;
1213
+			}
1214
+			if (isset($data['latitude'])) {
1215
+				$SI->add($data);
1216
+			}
895 1217
 			unset($data);
896 1218
 		    }
897 1219
 		} elseif (is_array($all_data)) {
@@ -908,17 +1230,26 @@  discard block
 block discarded – undo
908 1230
 			$data['verticalrate'] = $line['vrt']; // verticale rate
909 1231
 			$data['squawk'] = $line['squawk']; // squawk
910 1232
 			$data['emergency'] = ''; // emergency
911
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
912
-			else $data['datetime'] = date('Y-m-d H:i:s');
1233
+			if (isset($line['PosTime'])) {
1234
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1235
+			} else {
1236
+				$data['datetime'] = date('Y-m-d H:i:s');
1237
+			}
913 1238
 			$data['format_source'] = 'aircraftlistjson';
914 1239
 			$data['id_source'] = $id_source;
915
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
916
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1240
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1241
+				$data['noarchive'] = true;
1242
+			}
1243
+			if (isset($value['name']) && $value['name'] != '') {
1244
+				$data['source_name'] = $value['name'];
1245
+			}
917 1246
 			$SI->add($data);
918 1247
 			unset($data);
919 1248
 		    }
920 1249
 		}
921
-	    } elseif ($globalDebug) echo 'No data'."\n";
1250
+	    } elseif ($globalDebug) {
1251
+	    	echo 'No data'."\n";
1252
+	    }
922 1253
     	    //$last_exec['aircraftlistjson'] = time();
923 1254
     	    $last_exec[$id]['last'] = time();
924 1255
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -954,8 +1285,12 @@  discard block
 block discarded – undo
954 1285
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
955 1286
 	    	    $data['format_source'] = 'planeupdatefaa';
956 1287
     		    $data['id_source'] = $id_source;
957
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
958
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1289
+		    	$data['noarchive'] = true;
1290
+		    }
1291
+		    if (isset($value['name']) && $value['name'] != '') {
1292
+		    	$data['source_name'] = $value['name'];
1293
+		    }
959 1294
 		    $SI->add($data);
960 1295
 		    unset($data);
961 1296
 		}
@@ -989,7 +1324,9 @@  discard block
 block discarded – undo
989 1324
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
990 1325
 		    $data['format_source'] = 'opensky';
991 1326
 		    $data['id_source'] = $id_source;
992
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1327
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1328
+		    	$data['noarchive'] = true;
1329
+		    }
993 1330
 		    $SI->add($data);
994 1331
 		    unset($data);
995 1332
 		}
@@ -1006,7 +1343,9 @@  discard block
 block discarded – undo
1006 1343
 	    //$buffer = $Common->getData($hosts[$id]);
1007 1344
 	    $buffer = $Common->getData($value['host']);
1008 1345
 	    $all_data = json_decode($buffer,true);
1009
-	    if (!empty($all_data)) $reset = 0;
1346
+	    if (!empty($all_data)) {
1347
+	    	$reset = 0;
1348
+	    }
1010 1349
 	    foreach ($all_data as $key => $line) {
1011 1350
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1012 1351
 		    $data = array();
@@ -1027,8 +1366,12 @@  discard block
 block discarded – undo
1027 1366
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1028 1367
 	    	    $data['format_source'] = 'fr24json';
1029 1368
     		    $data['id_source'] = $id_source;
1030
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1031
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1369
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1370
+		    	$data['noarchive'] = true;
1371
+		    }
1372
+		    if (isset($value['name']) && $value['name'] != '') {
1373
+		    	$data['source_name'] = $value['name'];
1374
+		    }
1032 1375
 		    $SI->add($data);
1033 1376
 		    unset($data);
1034 1377
 		}
@@ -1057,24 +1400,42 @@  discard block
 block discarded – undo
1057 1400
 		    if (isset($line['inf'])) {
1058 1401
 			$data = array();
1059 1402
 			$data['hex'] = $line['inf']['ia'];
1060
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1403
+			if (isset($line['inf']['cs'])) {
1404
+				$data['ident'] = $line['inf']['cs'];
1405
+			}
1406
+			//$line[13]
1061 1407
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1062
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1063
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1408
+	    		if (isset($line['inf']['gs'])) {
1409
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1410
+	    		}
1411
+	    		// speed
1412
+	    		if (isset($line['inf']['tr'])) {
1413
+	    			$data['heading'] = $line['inf']['tr'];
1414
+	    		}
1415
+	    		// heading
1064 1416
 	    		$data['latitude'] = $line['pt'][0]; // lat
1065 1417
 	    		$data['longitude'] = $line['pt'][1]; // long
1066 1418
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1067
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1419
+	    		if (isset($line['inf']['sq'])) {
1420
+	    			$data['squawk'] = $line['inf']['sq'];
1421
+	    		}
1422
+	    		// squawk
1068 1423
 	    		//$data['aircraft_icao'] = $line[8];
1069
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1424
+	    		if (isset($line['inf']['rc'])) {
1425
+	    			$data['registration'] = $line['inf']['rc'];
1426
+	    		}
1070 1427
 			//$data['departure_airport_iata'] = $line[11];
1071 1428
 			//$data['arrival_airport_iata'] = $line[12];
1072 1429
 	    		//$data['emergency'] = ''; // emergency
1073 1430
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1074 1431
 	    		$data['format_source'] = 'radarvirtueljson';
1075 1432
     			$data['id_source'] = $id_source;
1076
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1077
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1433
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1434
+				$data['noarchive'] = true;
1435
+			}
1436
+			if (isset($value['name']) && $value['name'] != '') {
1437
+				$data['source_name'] = $value['name'];
1438
+			}
1078 1439
 			$SI->add($data);
1079 1440
 			unset($data);
1080 1441
 		    }
@@ -1100,30 +1461,65 @@  discard block
 block discarded – undo
1100 1461
 		    $data['id'] = $line['id'];
1101 1462
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1102 1463
 		    $data['ident'] = $line['callsign']; // ident
1103
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1104
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1105
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1106
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1107
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1108
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1464
+		    if (isset($line['pilotid'])) {
1465
+		    	$data['pilot_id'] = $line['pilotid'];
1466
+		    }
1467
+		    // pilot id
1468
+		    if (isset($line['name'])) {
1469
+		    	$data['pilot_name'] = $line['name'];
1470
+		    }
1471
+		    // pilot name
1472
+		    if (isset($line['alt'])) {
1473
+		    	$data['altitude'] = $line['alt'];
1474
+		    }
1475
+		    // altitude
1476
+		    if (isset($line['gs'])) {
1477
+		    	$data['speed'] = $line['gs'];
1478
+		    }
1479
+		    // speed
1480
+		    if (isset($line['heading'])) {
1481
+		    	$data['heading'] = $line['heading'];
1482
+		    }
1483
+		    // heading
1484
+		    if (isset($line['route'])) {
1485
+		    	$data['waypoints'] = $line['route'];
1486
+		    }
1487
+		    // route
1109 1488
 		    $data['latitude'] = $line['lat']; // lat
1110 1489
 		    $data['longitude'] = $line['lon']; // long
1111 1490
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1112 1491
 		    //$data['squawk'] = $line['squawk']; // squawk
1113 1492
 		    //$data['emergency'] = ''; // emergency
1114
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1115
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1116
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1493
+		    if (isset($line['depicao'])) {
1494
+		    	$data['departure_airport_icao'] = $line['depicao'];
1495
+		    }
1496
+		    if (isset($line['deptime'])) {
1497
+		    	$data['departure_airport_time'] = $line['deptime'];
1498
+		    }
1499
+		    if (isset($line['arricao'])) {
1500
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1501
+		    }
1117 1502
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1118
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1119
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1120
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1121
-		    else $data['info'] = '';
1503
+		    if (isset($line['aircraft'])) {
1504
+		    	$data['aircraft_icao'] = $line['aircraft'];
1505
+		    }
1506
+		    if (isset($line['transponder'])) {
1507
+		    	$data['squawk'] = $line['transponder'];
1508
+		    }
1509
+		    if (isset($line['atis'])) {
1510
+		    	$data['info'] = $line['atis'];
1511
+		    } else {
1512
+		    	$data['info'] = '';
1513
+		    }
1122 1514
 		    $data['format_source'] = 'pireps';
1123 1515
     		    $data['id_source'] = $id_source;
1124 1516
 		    $data['datetime'] = date('Y-m-d H:i:s');
1125
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1126
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1517
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1518
+		    	$data['noarchive'] = true;
1519
+		    }
1520
+		    if (isset($value['name']) && $value['name'] != '') {
1521
+		    	$data['source_name'] = $value['name'];
1522
+		    }
1127 1523
 		    if ($line['icon'] == 'plane') {
1128 1524
 			$SI->add($data);
1129 1525
 		    //    print_r($data);
@@ -1132,16 +1528,28 @@  discard block
 block discarded – undo
1132 1528
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1133 1529
 			$typec = substr($data['ident'],-3);
1134 1530
 			$data['type'] = '';
1135
-			if ($typec == 'APP') $data['type'] = 'Approach';
1136
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1137
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1138
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1139
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1140
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1141
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1142
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1143
-			else $data['type'] = 'Observer';
1144
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1531
+			if ($typec == 'APP') {
1532
+				$data['type'] = 'Approach';
1533
+			} elseif ($typec == 'TWR') {
1534
+				$data['type'] = 'Tower';
1535
+			} elseif ($typec == 'OBS') {
1536
+				$data['type'] = 'Observer';
1537
+			} elseif ($typec == 'GND') {
1538
+				$data['type'] = 'Ground';
1539
+			} elseif ($typec == 'DEL') {
1540
+				$data['type'] = 'Delivery';
1541
+			} elseif ($typec == 'DEP') {
1542
+				$data['type'] = 'Departure';
1543
+			} elseif ($typec == 'FSS') {
1544
+				$data['type'] = 'Flight Service Station';
1545
+			} elseif ($typec == 'CTR') {
1546
+				$data['type'] = 'Control Radar or Centre';
1547
+			} else {
1548
+				$data['type'] = 'Observer';
1549
+			}
1550
+			if (isset($ATC)) {
1551
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1552
+			}
1145 1553
 		    }
1146 1554
 		    unset($data);
1147 1555
 		}
@@ -1156,7 +1564,9 @@  discard block
 block discarded – undo
1156 1564
 	    )
1157 1565
 	) {
1158 1566
 	    //$buffer = $Common->getData($hosts[$id]);
1159
-	    if ($globalDebug) echo 'Get Data...'."\n";
1567
+	    if ($globalDebug) {
1568
+	    	echo 'Get Data...'."\n";
1569
+	    }
1160 1570
 	    $buffer = $Common->getData($value['host']);
1161 1571
 	    $all_data = json_decode($buffer,true);
1162 1572
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1164,10 +1574,16 @@  discard block
 block discarded – undo
1164 1574
 		foreach ($all_data as $line) {
1165 1575
 	    	    $data = array();
1166 1576
 	    	    //$data['id'] = $line['id']; // id not usable
1167
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1577
+	    	    if (isset($line['pilotid'])) {
1578
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1579
+	    	    }
1168 1580
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1169
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1170
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1581
+	    	    if (isset($line['pilotname'])) {
1582
+	    	    	$data['pilot_name'] = $line['pilotname'];
1583
+	    	    }
1584
+	    	    if (isset($line['pilotid'])) {
1585
+	    	    	$data['pilot_id'] = $line['pilotid'];
1586
+	    	    }
1171 1587
 	    	    $data['ident'] = $line['flightnum']; // ident
1172 1588
 	    	    $data['altitude'] = $line['alt']; // altitude
1173 1589
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1183,34 +1599,52 @@  discard block
 block discarded – undo
1183 1599
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1184 1600
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1185 1601
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1186
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1602
+	    	    } else {
1603
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1604
+	    	    }
1187 1605
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1188 1606
 	    	    $data['departure_airport_time'] = $line['deptime'];
1189 1607
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1190 1608
     		    $data['arrival_airport_time'] = $line['arrtime'];
1191 1609
     		    $data['registration'] = $line['aircraft'];
1192
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1193
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1610
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1611
+		    	$data['noarchive'] = true;
1612
+		    }
1613
+		    if (isset($line['route'])) {
1614
+		    	$data['waypoints'] = $line['route'];
1615
+		    }
1616
+		    // route
1194 1617
 		    if (isset($line['aircraftname'])) {
1195 1618
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1196 1619
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1197 1620
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1198
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1199
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1200
-	    		else {
1621
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1622
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1623
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1624
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1625
+	    		} else {
1201 1626
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1202
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1203
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1627
+	    		    if (isset($aircraft_data[1])) {
1628
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1629
+	    		    } else {
1630
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1631
+	    		    }
1204 1632
 	    		}
1205 1633
 	    	    }
1206
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1634
+    		    if (isset($line['route'])) {
1635
+    		    	$data['waypoints'] = $line['route'];
1636
+    		    }
1207 1637
     		    $data['id_source'] = $id_source;
1208 1638
 	    	    $data['format_source'] = 'phpvmacars';
1209
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1639
+		    if (isset($value['name']) && $value['name'] != '') {
1640
+		    	$data['source_name'] = $value['name'];
1641
+		    }
1210 1642
 		    $SI->add($data);
1211 1643
 		    unset($data);
1212 1644
 		}
1213
-		if ($globalDebug) echo 'No more data...'."\n";
1645
+		if ($globalDebug) {
1646
+			echo 'No more data...'."\n";
1647
+		}
1214 1648
 		unset($buffer);
1215 1649
 		unset($all_data);
1216 1650
 	    }
@@ -1223,7 +1657,9 @@  discard block
 block discarded – undo
1223 1657
 	    )
1224 1658
 	) {
1225 1659
 	    //$buffer = $Common->getData($hosts[$id]);
1226
-	    if ($globalDebug) echo 'Get Data...'."\n";
1660
+	    if ($globalDebug) {
1661
+	    	echo 'Get Data...'."\n";
1662
+	    }
1227 1663
 	    $buffer = $Common->getData($value['host']);
1228 1664
 	    $all_data = json_decode($buffer,true);
1229 1665
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1252,16 +1688,25 @@  discard block
 block discarded – undo
1252 1688
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1253 1689
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1254 1690
     		    //$data['registration'] = $line['aircraft'];
1255
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1691
+		    if (isset($line['route'])) {
1692
+		    	$data['waypoints'] = $line['route'];
1693
+		    }
1694
+		    // route
1256 1695
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1257 1696
     		    $data['id_source'] = $id_source;
1258 1697
 	    	    $data['format_source'] = 'vam';
1259
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1260
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1698
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1699
+		    	$data['noarchive'] = true;
1700
+		    }
1701
+		    if (isset($value['name']) && $value['name'] != '') {
1702
+		    	$data['source_name'] = $value['name'];
1703
+		    }
1261 1704
 		    $SI->add($data);
1262 1705
 		    unset($data);
1263 1706
 		}
1264
-		if ($globalDebug) echo 'No more data...'."\n";
1707
+		if ($globalDebug) {
1708
+			echo 'No more data...'."\n";
1709
+		}
1265 1710
 		unset($buffer);
1266 1711
 		unset($all_data);
1267 1712
 	    }
@@ -1274,7 +1719,9 @@  discard block
 block discarded – undo
1274 1719
 	    )
1275 1720
 	) {
1276 1721
 	    //$buffer = $Common->getData($hosts[$id]);
1277
-	    if ($globalDebug) echo 'Get Data...'."\n";
1722
+	    if ($globalDebug) {
1723
+	    	echo 'Get Data...'."\n";
1724
+	    }
1278 1725
 	    $buffer = $Common->getData($value['host']);
1279 1726
 	    $all_data = json_decode($buffer,true);
1280 1727
 	    if ($buffer != '') {
@@ -1292,18 +1739,24 @@  discard block
 block discarded – undo
1292 1739
 			$data['id_source'] = $id_source;
1293 1740
 			$data['format_source'] = 'blitzortung';
1294 1741
 			$SI->add($data);
1295
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1742
+			if ($globalDebug) {
1743
+				echo '☈ Lightning added'."\n";
1744
+			}
1296 1745
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1297 1746
 			unset($data);
1298 1747
 		    }
1299 1748
 		}
1300
-		if ($globalDebug) echo 'No more data...'."\n";
1749
+		if ($globalDebug) {
1750
+			echo 'No more data...'."\n";
1751
+		}
1301 1752
 		unset($buffer);
1302 1753
 	    }
1303 1754
 	    $last_exec[$id]['last'] = time();
1304 1755
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1305 1756
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1306
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1757
+	    if (function_exists('pcntl_fork')) {
1758
+	    	pcntl_signal_dispatch();
1759
+	    }
1307 1760
     	    //$last_exec[$id]['last'] = time();
1308 1761
 
1309 1762
 	    //$read = array( $sockets[$id] );
@@ -1311,7 +1764,9 @@  discard block
 block discarded – undo
1311 1764
 	    $write = NULL;
1312 1765
 	    $e = NULL;
1313 1766
 	    $n = socket_select($read, $write, $e, $timeout);
1314
-	    if ($e != NULL) var_dump($e);
1767
+	    if ($e != NULL) {
1768
+	    	var_dump($e);
1769
+	    }
1315 1770
 	    if ($n > 0) {
1316 1771
 		$reset = 0;
1317 1772
 		foreach ($read as $nb => $r) {
@@ -1333,13 +1788,17 @@  discard block
 block discarded – undo
1333 1788
 		    if ($buffer !== FALSE) {
1334 1789
 			if ($format == 'vrstcp') {
1335 1790
 			    $buffer = explode('},{',$buffer);
1336
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1791
+			} else {
1792
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1793
+			}
1337 1794
 		    }
1338 1795
 		    // SBS format is CSV format
1339 1796
 		    if ($buffer !== FALSE && $buffer !== '') {
1340 1797
 			$tt[$format] = 0;
1341 1798
 			if ($format == 'acarssbs3') {
1342
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1799
+			    if ($globalDebug) {
1800
+			    	echo 'ACARS : '.$buffer."\n";
1801
+			    }
1343 1802
 			    $ACARS->add(trim($buffer));
1344 1803
 			    $ACARS->deleteLiveAcarsData();
1345 1804
 			} elseif ($format == 'raw') {
@@ -1348,30 +1807,70 @@  discard block
 block discarded – undo
1348 1807
 			    if (is_array($data)) {
1349 1808
 				$data['datetime'] = date('Y-m-d H:i:s');
1350 1809
 				$data['format_source'] = 'raw';
1351
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1352
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1353
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1354
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1810
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1811
+					$data['source_name'] = $globalSources[$nb]['name'];
1812
+				}
1813
+				if (isset($globalSources[$nb]['sourcestats'])) {
1814
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1815
+				}
1816
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1817
+					$data['noarchive'] = true;
1818
+				}
1819
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1820
+					$SI->add($data);
1821
+				}
1355 1822
 			    }
1356 1823
 			} elseif ($format == 'ais') {
1357 1824
 			    $ais_data = $AIS->parse_line(trim($buffer));
1358 1825
 			    $data = array();
1359
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1360
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1361
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1362
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1363
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1364
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1365
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1366
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1367
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1368
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1369
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1370
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1371
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1372
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1373
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1374
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1826
+			    if (isset($ais_data['ident'])) {
1827
+			    	$data['ident'] = $ais_data['ident'];
1828
+			    }
1829
+			    if (isset($ais_data['mmsi'])) {
1830
+			    	$data['mmsi'] = $ais_data['mmsi'];
1831
+			    }
1832
+			    if (isset($ais_data['speed'])) {
1833
+			    	$data['speed'] = $ais_data['speed'];
1834
+			    }
1835
+			    if (isset($ais_data['heading'])) {
1836
+			    	$data['heading'] = $ais_data['heading'];
1837
+			    }
1838
+			    if (isset($ais_data['latitude'])) {
1839
+			    	$data['latitude'] = $ais_data['latitude'];
1840
+			    }
1841
+			    if (isset($ais_data['longitude'])) {
1842
+			    	$data['longitude'] = $ais_data['longitude'];
1843
+			    }
1844
+			    if (isset($ais_data['status'])) {
1845
+			    	$data['status'] = $ais_data['status'];
1846
+			    }
1847
+			    if (isset($ais_data['statusid'])) {
1848
+			    	$data['status_id'] = $ais_data['statusid'];
1849
+			    }
1850
+			    if (isset($ais_data['type'])) {
1851
+			    	$data['type'] = $ais_data['type'];
1852
+			    }
1853
+			    if (isset($ais_data['imo'])) {
1854
+			    	$data['imo'] = $ais_data['imo'];
1855
+			    }
1856
+			    if (isset($ais_data['callsign'])) {
1857
+			    	$data['callsign'] = $ais_data['callsign'];
1858
+			    }
1859
+			    if (isset($ais_data['destination'])) {
1860
+			    	$data['arrival_code'] = $ais_data['destination'];
1861
+			    }
1862
+			    if (isset($ais_data['eta_ts'])) {
1863
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1864
+			    }
1865
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1866
+			    	$data['noarchive'] = true;
1867
+			    }
1868
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1869
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1870
+			    }
1871
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1872
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1873
+			    }
1375 1874
 
1376 1875
 			    if (isset($ais_data['timestamp'])) {
1377 1876
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1380,7 +1879,9 @@  discard block
 block discarded – undo
1380 1879
 			    }
1381 1880
 			    $data['format_source'] = 'aisnmea';
1382 1881
     			    $data['id_source'] = $id_source;
1383
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1882
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1883
+			    	$MI->add($data);
1884
+			    }
1384 1885
 			    unset($data);
1385 1886
                         } elseif ($format == 'flightgearsp') {
1386 1887
                     	    //echo $buffer."\n";
@@ -1398,12 +1899,18 @@  discard block
 block discarded – undo
1398 1899
 				$data['speed'] = round($line[5]*1.94384);
1399 1900
 				$data['datetime'] = date('Y-m-d H:i:s');
1400 1901
 				$data['format_source'] = 'flightgearsp';
1401
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1402
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1902
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1903
+					$data['noarchive'] = true;
1904
+				}
1905
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1906
+					$SI->add($data);
1907
+				}
1403 1908
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1404 1909
 			    }
1405 1910
                         } elseif ($format == 'acars') {
1406
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1911
+                    	    if ($globalDebug) {
1912
+                    	    	echo 'ACARS : '.$buffer."\n";
1913
+                    	    }
1407 1914
 			    $ACARS->add(trim($buffer));
1408 1915
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1409 1916
 			    $ACARS->deleteLiveAcarsData();
@@ -1424,8 +1931,12 @@  discard block
 block discarded – undo
1424 1931
 				    $aircraft_type = $line[10];
1425 1932
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1426 1933
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1427
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1428
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1934
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1935
+				    	$data['noarchive'] = true;
1936
+				    }
1937
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1938
+				    	$SI->add($data);
1939
+				    }
1429 1940
 				}
1430 1941
 			    }
1431 1942
 			} elseif ($format == 'beast') {
@@ -1435,28 +1946,62 @@  discard block
 block discarded – undo
1435 1946
 			    foreach($buffer as $all_data) {
1436 1947
 				$line = json_decode('{'.$all_data.'}',true);
1437 1948
 				$data = array();
1438
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1439
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1440
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1441
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1442
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1443
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1444
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1949
+				if (isset($line['Icao'])) {
1950
+					$data['hex'] = $line['Icao'];
1951
+				}
1952
+				// hex
1953
+				if (isset($line['Call'])) {
1954
+					$data['ident'] = $line['Call'];
1955
+				}
1956
+				// ident
1957
+				if (isset($line['Alt'])) {
1958
+					$data['altitude'] = $line['Alt'];
1959
+				}
1960
+				// altitude
1961
+				if (isset($line['Spd'])) {
1962
+					$data['speed'] = $line['Spd'];
1963
+				}
1964
+				// speed
1965
+				if (isset($line['Trak'])) {
1966
+					$data['heading'] = $line['Trak'];
1967
+				}
1968
+				// heading
1969
+				if (isset($line['Lat'])) {
1970
+					$data['latitude'] = $line['Lat'];
1971
+				}
1972
+				// lat
1973
+				if (isset($line['Long'])) {
1974
+					$data['longitude'] = $line['Long'];
1975
+				}
1976
+				// long
1445 1977
 				//$data['verticalrate'] = $line['']; // verticale rate
1446
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1978
+				if (isset($line['Sqk'])) {
1979
+					$data['squawk'] = $line['Sqk'];
1980
+				}
1981
+				// squawk
1447 1982
 				$data['emergency'] = ''; // emergency
1448
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1983
+				if (isset($line['Reg'])) {
1984
+					$data['registration'] = $line['Reg'];
1985
+				}
1449 1986
 				/*
1450 1987
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1451 1988
 				else $data['datetime'] = date('Y-m-d H:i:s');
1452 1989
 				*/
1453 1990
 				$data['datetime'] = date('Y-m-d H:i:s');
1454
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1991
+				if (isset($line['Type'])) {
1992
+					$data['aircraft_icao'] = $line['Type'];
1993
+				}
1455 1994
 		    		$data['format_source'] = 'vrstcp';
1456 1995
 				$data['id_source'] = $id_source;
1457
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1458
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1459
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1996
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1997
+					$data['noarchive'] = true;
1998
+				}
1999
+				if (isset($value['name']) && $value['name'] != '') {
2000
+					$data['source_name'] = $value['name'];
2001
+				}
2002
+				if (isset($data['latitude']) && isset($data['hex'])) {
2003
+					$SI->add($data);
2004
+				}
1460 2005
 				unset($data);
1461 2006
 			    }
1462 2007
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1469,22 +2014,46 @@  discard block
 block discarded – undo
1469 2014
     				$data['hex'] = $lined['hexid'];
1470 2015
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1471 2016
     				$data['datetime'] = date('Y-m-d H:i:s');;
1472
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1473
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1474
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1475
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1476
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1477
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1478
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2017
+    				if (isset($lined['ident'])) {
2018
+    					$data['ident'] = $lined['ident'];
2019
+    				}
2020
+    				if (isset($lined['lat'])) {
2021
+    					$data['latitude'] = $lined['lat'];
2022
+    				}
2023
+    				if (isset($lined['lon'])) {
2024
+    					$data['longitude'] = $lined['lon'];
2025
+    				}
2026
+    				if (isset($lined['speed'])) {
2027
+    					$data['speed'] = $lined['speed'];
2028
+    				}
2029
+    				if (isset($lined['squawk'])) {
2030
+    					$data['squawk'] = $lined['squawk'];
2031
+    				}
2032
+    				if (isset($lined['alt'])) {
2033
+    					$data['altitude'] = $lined['alt'];
2034
+    				}
2035
+    				if (isset($lined['heading'])) {
2036
+    					$data['heading'] = $lined['heading'];
2037
+    				}
1479 2038
     				$data['id_source'] = $id_source;
1480 2039
     				$data['format_source'] = 'tsv';
1481
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1482
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1483
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1484
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2040
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2041
+    					$data['source_name'] = $globalSources[$nb]['name'];
2042
+    				}
2043
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2044
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2045
+    				}
2046
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2047
+					$data['noarchive'] = true;
2048
+				}
2049
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2050
+    					$SI->add($data);
2051
+    				}
1485 2052
     				unset($lined);
1486 2053
     				unset($data);
1487
-    			    } else $error = true;
2054
+    			    } else {
2055
+    			    	$error = true;
2056
+    			    }
1488 2057
 			} elseif ($format == 'aprs' && $use_aprs) {
1489 2058
 			    if ($aprs_connect == 0) {
1490 2059
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1510,63 +2079,121 @@  discard block
 block discarded – undo
1510 2079
 				    $aprs_last_tx = time();
1511 2080
 				    $data = array();
1512 2081
 				    //print_r($line);
1513
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1514
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1515
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1516
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1517
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1518
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1519
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1520
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1521
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1522
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2082
+				    if (isset($line['address'])) {
2083
+				    	$data['hex'] = $line['address'];
2084
+				    }
2085
+				    if (isset($line['mmsi'])) {
2086
+				    	$data['mmsi'] = $line['mmsi'];
2087
+				    }
2088
+				    if (isset($line['imo'])) {
2089
+				    	$data['imo'] = $line['imo'];
2090
+				    }
2091
+				    if (isset($line['squawk'])) {
2092
+				    	$data['squawk'] = $line['squawk'];
2093
+				    }
2094
+				    if (isset($line['arrival_code'])) {
2095
+				    	$data['arrical_code'] = $line['arrival_code'];
2096
+				    }
2097
+				    if (isset($line['arrival_date'])) {
2098
+				    	$data['arrical_date'] = $line['arrival_date'];
2099
+				    }
2100
+				    if (isset($line['type_id'])) {
2101
+				    	$data['type_id'] = $line['typeid'];
2102
+				    }
2103
+				    if (isset($line['status_id'])) {
2104
+				    	$data['status_id'] = $line['statusid'];
2105
+				    }
2106
+				    if (isset($line['timestamp'])) {
2107
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2108
+				    } else {
2109
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2110
+				    }
1523 2111
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1524
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2112
+				    if (isset($line['ident'])) {
2113
+				    	$data['ident'] = $line['ident'];
2114
+				    }
1525 2115
 				    $data['latitude'] = $line['latitude'];
1526 2116
 				    $data['longitude'] = $line['longitude'];
1527 2117
 				    //$data['verticalrate'] = $line[16];
1528
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2118
+				    if (isset($line['speed'])) {
2119
+				    	$data['speed'] = $line['speed'];
2120
+				    }
1529 2121
 				    //else $data['speed'] = 0;
1530
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1531
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1532
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2122
+				    if (isset($line['altitude'])) {
2123
+				    	$data['altitude'] = $line['altitude'];
2124
+				    }
2125
+				    if (isset($line['comment'])) {
2126
+				    	$data['comment'] = $line['comment'];
2127
+				    }
2128
+				    if (isset($line['symbol'])) {
2129
+				    	$data['type'] = $line['symbol'];
2130
+				    }
1533 2131
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1534 2132
 				    
1535
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2133
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2134
+				    	$data['heading'] = $line['heading'];
2135
+				    }
1536 2136
 				    //else echo 'No heading...'."\n";
1537 2137
 				    //else $data['heading'] = 0;
1538
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2138
+				    if (isset($line['stealth'])) {
2139
+				    	$data['aircraft_type'] = $line['stealth'];
2140
+				    }
1539 2141
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1540
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1541
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1542
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1543
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2142
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2143
+				    	$data['noarchive'] = true;
2144
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2145
+				    	$data['noarchive'] = false;
2146
+				    }
2147
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2148
+				    	$data['noarchive'] = true;
2149
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2150
+				    	$data['noarchive'] = false;
2151
+				    }
1544 2152
     				    $data['id_source'] = $id_source;
1545
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1546
-				    else $data['format_source'] = 'aprs';
2153
+    				    if (isset($line['format_source'])) {
2154
+    				    	$data['format_source'] = $line['format_source'];
2155
+    				    } else {
2156
+				    	$data['format_source'] = 'aprs';
2157
+				    }
1547 2158
 				    $data['source_name'] = $line['source'];
1548
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1549
-				    else $data['source_type'] = 'flarm';
1550
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2159
+				    if (isset($line['source_type'])) {
2160
+				    	$data['source_type'] = $line['source_type'];
2161
+				    } else {
2162
+				    	$data['source_type'] = 'flarm';
2163
+				    }
2164
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2165
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2166
+    				    }
1551 2167
 				    $currentdate = date('Y-m-d H:i:s');
1552 2168
 				    $aprsdate = strtotime($data['datetime']);
1553
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2169
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2170
+				    	$data['altitude_relative'] = 'AMSL';
2171
+				    }
1554 2172
 				    // Accept data if time <= system time + 20s
1555 2173
 				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1556 2174
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1557 2175
 					$send = $SI->add($data);
1558 2176
 				    } elseif ($data['source_type'] == 'ais') {
1559 2177
 					$data['type'] = '';
1560
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2178
+					if (isset($globalMarine) && $globalMarine) {
2179
+						$send = $MI->add($data);
2180
+					}
1561 2181
 				    } elseif (isset($line['stealth'])) {
1562
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1563
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2182
+					if ($line['stealth'] != 0) {
2183
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2184
+					} else {
2185
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2186
+					}
1564 2187
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1565 2188
 					    //$line['symbol'] == 'Balloon' ||
1566 2189
 					    $line['symbol'] == 'Glider' || 
1567 2190
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1568
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1569
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2191
+					    if ($line['symbol'] == 'Ballon') {
2192
+					    	$data['aircraft_icao'] = 'BALL';
2193
+					    }
2194
+					    if ($line['symbol'] == 'Glider') {
2195
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2196
+					    }
1570 2197
 					    $send = $SI->add($data);
1571 2198
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1572 2199
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1597,9 +2224,13 @@  discard block
 block discarded – undo
1597 2224
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1598 2225
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1599 2226
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1600
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2227
+					if (isset($globalTracker) && $globalTracker) {
2228
+						$send = $TI->add($data);
2229
+					}
1601 2230
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1602
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2231
+					if (!isset($data['altitude'])) {
2232
+						$data['altitude'] = 0;
2233
+					}
1603 2234
 					$Source->deleteOldLocationByType('gs');
1604 2235
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1605 2236
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1608,7 +2239,9 @@  discard block
 block discarded – undo
1608 2239
 					}
1609 2240
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1610 2241
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1611
-					if ($globalDebug) echo '# Weather Station added'."\n";
2242
+					if ($globalDebug) {
2243
+						echo '# Weather Station added'."\n";
2244
+					}
1612 2245
 					$Source->deleteOldLocationByType('wx');
1613 2246
 					$weather_data = json_encode($line);
1614 2247
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1618,7 +2251,9 @@  discard block
 block discarded – undo
1618 2251
 					}
1619 2252
 				    } elseif (isset($line['symbol']) && ($line['symbol'] == 'Lightning' || $line['symbol'] == 'Thunderstorm')) {
1620 2253
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1621
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2254
+					if ($globalDebug) {
2255
+						echo '☈ Lightning added'."\n";
2256
+					}
1622 2257
 					$Source->deleteOldLocationByType('lightning');
1623 2258
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1624 2259
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1630,8 +2265,7 @@  discard block
 block discarded – undo
1630 2265
 				    	print_r($line);
1631 2266
 				    }
1632 2267
 				    unset($data);
1633
-				}
1634
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2268
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1635 2269
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1636 2270
 				}
1637 2271
 				/*
@@ -1640,7 +2274,9 @@  discard block
 block discarded – undo
1640 2274
 				}
1641 2275
 				*/
1642 2276
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1643
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2277
+				elseif ($line == true && $globalDebug) {
2278
+					echo '!! Failed : '.$buffer."!!\n";
2279
+				}
1644 2280
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1645 2281
 					$Source->deleteOldLocationByType('lightning');
1646 2282
 					$Source->deleteOldLocationByType('wx');
@@ -1676,26 +2312,45 @@  discard block
 block discarded – undo
1676 2312
     				$data['ground'] = $line[21];
1677 2313
     				$data['emergency'] = $line[19];
1678 2314
     				$data['format_source'] = 'sbs';
1679
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1680
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1681
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2315
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2316
+					$data['source_name'] = $globalSources[$nb]['name'];
2317
+				}
2318
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2319
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2320
+    				}
2321
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2322
+					$data['noarchive'] = true;
2323
+				}
1682 2324
     				$data['id_source'] = $id_source;
1683
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1684
-    				else $error = true;
2325
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2326
+    					$send = $SI->add($data);
2327
+    				} else {
2328
+    					$error = true;
2329
+    				}
1685 2330
     				unset($data);
1686
-    			    } else $error = true;
2331
+    			    } else {
2332
+    			    	$error = true;
2333
+    			    }
1687 2334
 			    if ($error) {
1688 2335
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1689
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2336
+					if ($globalDebug) {
2337
+						echo "Not a message. Ignoring... \n";
2338
+					}
1690 2339
 				} else {
1691
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2340
+					if ($globalDebug) {
2341
+						echo "Wrong line format. Ignoring... \n";
2342
+					}
1692 2343
 					if ($globalDebug) {
1693 2344
 						echo $buffer;
1694 2345
 						//print_r($line);
1695 2346
 					}
1696 2347
 					//socket_close($r);
1697
-					if ($globalDebug) echo "Reconnect after an error...\n";
1698
-					if ($format == 'aprs') $aprs_connect = 0;
2348
+					if ($globalDebug) {
2349
+						echo "Reconnect after an error...\n";
2350
+					}
2351
+					if ($format == 'aprs') {
2352
+						$aprs_connect = 0;
2353
+					}
1699 2354
 					$sourceer[$nb] = $globalSources[$nb];
1700 2355
 					connect_all($sourceer);
1701 2356
 					$sourceer = array();
@@ -1703,10 +2358,14 @@  discard block
 block discarded – undo
1703 2358
 			    }
1704 2359
 			}
1705 2360
 			// Sleep for xxx microseconds
1706
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2361
+			if (isset($globalSBSSleep)) {
2362
+				usleep($globalSBSSleep);
2363
+			}
1707 2364
 		    } else {
1708 2365
 			if ($format == 'flightgearmp') {
1709
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2366
+			    	if ($globalDebug) {
2367
+			    		echo "Reconnect FlightGear MP...";
2368
+			    	}
1710 2369
 				//@socket_close($r);
1711 2370
 				sleep($globalMinFetch);
1712 2371
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1715,10 +2374,15 @@  discard block
 block discarded – undo
1715 2374
 				break;
1716 2375
 				
1717 2376
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1718
-			    if (isset($tt[$format])) $tt[$format]++;
1719
-			    else $tt[$format] = 0;
2377
+			    if (isset($tt[$format])) {
2378
+			    	$tt[$format]++;
2379
+			    } else {
2380
+			    	$tt[$format] = 0;
2381
+			    }
1720 2382
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1721
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2383
+				if ($globalDebug) {
2384
+					echo "ERROR : Reconnect ".$format."...";
2385
+				}
1722 2386
 				//@socket_close($r);
1723 2387
 				sleep(2);
1724 2388
 				$aprs_connect = 0;
@@ -1736,11 +2400,17 @@  discard block
 block discarded – undo
1736 2400
 	    } else {
1737 2401
 		$error = socket_strerror(socket_last_error());
1738 2402
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1739
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1740
-			if (isset($globalDebug)) echo "Restarting...\n";
2403
+			if ($globalDebug) {
2404
+				echo "ERROR : socket_select give this error ".$error . "\n";
2405
+			}
2406
+			if (isset($globalDebug)) {
2407
+				echo "Restarting...\n";
2408
+			}
1741 2409
 			// Restart the script if possible
1742 2410
 			if (is_array($sockets)) {
1743
-			    if ($globalDebug) echo "Shutdown all sockets...";
2411
+			    if ($globalDebug) {
2412
+			    	echo "Shutdown all sockets...";
2413
+			    }
1744 2414
 			    
1745 2415
 			    foreach ($sockets as $sock) {
1746 2416
 				@socket_shutdown($sock,2);
@@ -1748,25 +2418,45 @@  discard block
 block discarded – undo
1748 2418
 			    }
1749 2419
 			    
1750 2420
 			}
1751
-			if ($globalDebug) echo "Waiting...";
2421
+			if ($globalDebug) {
2422
+				echo "Waiting...";
2423
+			}
1752 2424
 			sleep(2);
1753 2425
 			$time = time();
1754 2426
 			//connect_all($hosts);
1755 2427
 			$aprs_connect = 0;
1756
-			if ($reset%5 == 0) sleep(20);
1757
-			if ($reset%10 == 0) sleep(100);
1758
-			if ($reset%20 == 0) sleep(200);
1759
-			if ($reset > 100) exit('Too many attempts...');
1760
-			if ($globalDebug) echo "Restart all connections...";
2428
+			if ($reset%5 == 0) {
2429
+				sleep(20);
2430
+			}
2431
+			if ($reset%10 == 0) {
2432
+				sleep(100);
2433
+			}
2434
+			if ($reset%20 == 0) {
2435
+				sleep(200);
2436
+			}
2437
+			if ($reset > 100) {
2438
+				exit('Too many attempts...');
2439
+			}
2440
+			if ($globalDebug) {
2441
+				echo "Restart all connections...";
2442
+			}
1761 2443
 			connect_all($globalSources);
1762 2444
 		}
1763 2445
 	    }
1764 2446
 	}
1765 2447
 	if ($globalDaemon === false) {
1766
-	    if ($globalDebug) echo 'Check all...'."\n";
1767
-	    if (isset($SI)) $SI->checkAll();
1768
-	    if (isset($TI)) $TI->checkAll();
1769
-	    if (isset($MI)) $MI->checkAll();
2448
+	    if ($globalDebug) {
2449
+	    	echo 'Check all...'."\n";
2450
+	    }
2451
+	    if (isset($SI)) {
2452
+	    	$SI->checkAll();
2453
+	    }
2454
+	    if (isset($TI)) {
2455
+	    	$TI->checkAll();
2456
+	    }
2457
+	    if (isset($MI)) {
2458
+	    	$MI->checkAll();
2459
+	    }
1770 2460
 	}
1771 2461
     }
1772 2462
 }
Please login to merge, or discard this patch.
manufacturer-statistics-airline-country.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer']))
Please login to merge, or discard this patch.
manufacturer-statistics-aircraft.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@
 block discarded – undo
22 22
 	print '<select name="aircraft_manufacturer" class="selectpicker" data-live-search="true">';
23 23
 	$Stats = new Stats();
24 24
 	$all_manufacturers = $Stats->getAllManufacturers();
25
-	if (empty($all_manufacturers)) $all_manufacturers = $Spotter->getAllManufacturers();
25
+	if (empty($all_manufacturers)) {
26
+		$all_manufacturers = $Spotter->getAllManufacturers();
27
+	}
26 28
 	foreach($all_manufacturers as $all_manufacturer)
27 29
 	{
28 30
 		if($manufacturer == ucwords($all_manufacturer['aircraft_manufacturer']))
Please login to merge, or discard this patch.