Completed
Push — master ( b49092...cf2135 )
by Yannick
30:03
created
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.Stats.php 1 patch
Braces   +661 added lines, -231 removed lines patch added patch discarded remove patch
@@ -15,10 +15,14 @@  discard block
 block discarded – undo
15 15
 	
16 16
 	public function __construct($dbc = null) {
17 17
 		global $globalFilterName;
18
-		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
18
+		if (isset($globalFilterName)) {
19
+			$this->filter_name = $globalFilterName;
20
+		}
19 21
 		$Connection = new Connection($dbc);
20 22
 		$this->db = $Connection->db();
21
-		if ($this->db === null) die('Error: No DB connection. (Stats)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Stats)');
25
+		}
22 26
 	}
23 27
 
24 28
 	public function addLastStatsUpdate($type,$stats_date) {
@@ -86,7 +90,9 @@  discard block
 block discarded – undo
86 90
 
87 91
 	public function getAllAirlineNames($filter_name = '') {
88 92
 		global $globalStatsFilters;
89
-		if ($filter_name == '') $filter_name = $this->filter_name;
93
+		if ($filter_name == '') {
94
+			$filter_name = $this->filter_name;
95
+		}
90 96
 		$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
91 97
 		 try {
92 98
 			$sth = $this->db->prepare($query);
@@ -106,7 +112,9 @@  discard block
 block discarded – undo
106 112
 		return $all;
107 113
 	}
108 114
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
109
-		if ($filter_name == '') $filter_name = $this->filter_name;
115
+		if ($filter_name == '') {
116
+			$filter_name = $this->filter_name;
117
+		}
110 118
 		$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
111 119
 		try {
112 120
 			$sth = $this->db->prepare($query);
@@ -118,7 +126,9 @@  discard block
 block discarded – undo
118 126
 		return $all;
119 127
 	}
120 128
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
121
-		if ($filter_name == '') $filter_name = $this->filter_name;
129
+		if ($filter_name == '') {
130
+			$filter_name = $this->filter_name;
131
+		}
122 132
 		$query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC";
123 133
 		try {
124 134
 			$sth = $this->db->prepare($query);
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		return $all;
131 141
 	}
132 142
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
133
-		if ($filter_name == '') $filter_name = $this->filter_name;
143
+		if ($filter_name == '') {
144
+			$filter_name = $this->filter_name;
145
+		}
134 146
 		$query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC";
135 147
 		try {
136 148
 			$sth = $this->db->prepare($query);
@@ -143,7 +155,9 @@  discard block
 block discarded – undo
143 155
 	}
144 156
 
145 157
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
146
-		if ($filter_name == '') $filter_name = $this->filter_name;
158
+		if ($filter_name == '') {
159
+			$filter_name = $this->filter_name;
160
+		}
147 161
 		$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
148 162
 		try {
149 163
 			$sth = $this->db->prepare($query);
@@ -156,7 +170,9 @@  discard block
 block discarded – undo
156 170
 	}
157 171
 
158 172
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
159
-		if ($filter_name == '') $filter_name = $this->filter_name;
173
+		if ($filter_name == '') {
174
+			$filter_name = $this->filter_name;
175
+		}
160 176
 		$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
161 177
 		try {
162 178
 			$sth = $this->db->prepare($query);
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 
172 188
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
173 189
 		global $globalStatsFilters;
174
-		if ($filter_name == '') $filter_name = $this->filter_name;
190
+		if ($filter_name == '') {
191
+			$filter_name = $this->filter_name;
192
+		}
175 193
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
176 194
 			$Spotter = new Spotter($this->db);
177 195
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -180,8 +198,11 @@  discard block
 block discarded – undo
180 198
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
181 199
 			}
182 200
 			if ($year == '' && $month == '') {
183
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
184
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
201
+				if ($limit) {
202
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
203
+				} else {
204
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
205
+				}
185 206
 				try {
186 207
 					$sth = $this->db->prepare($query);
187 208
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -189,11 +210,16 @@  discard block
 block discarded – undo
189 210
 					echo "error : ".$e->getMessage();
190 211
 				}
191 212
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192
-			} else $all = array();
213
+			} else {
214
+				$all = array();
215
+			}
193 216
 		} else {
194 217
 			if ($year == '' && $month == '') {
195
-				if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
196
-				else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
218
+				if ($limit) {
219
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0";
220
+				} else {
221
+					$query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC";
222
+				}
197 223
 				try {
198 224
 					$sth = $this->db->prepare($query);
199 225
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -201,7 +227,9 @@  discard block
 block discarded – undo
201 227
 					echo "error : ".$e->getMessage();
202 228
 				}
203 229
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
204
-			} else $all = array();
230
+			} else {
231
+				$all = array();
232
+			}
205 233
 		}
206 234
 		if (empty($all)) {
207 235
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -220,10 +248,15 @@  discard block
 block discarded – undo
220 248
 	}
221 249
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
222 250
 		global $globalStatsFilters;
223
-		if ($filter_name == '') $filter_name = $this->filter_name;
251
+		if ($filter_name == '') {
252
+			$filter_name = $this->filter_name;
253
+		}
224 254
 		if ($year == '' && $month == '') {
225
-			if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
226
-			else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
255
+			if ($limit) {
256
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0";
257
+			} else {
258
+				$query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count, countries.iso3 AS airline_country_iso3 FROM stats_airline,airlines,countries WHERE countries.name = airlines.country AND stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country, countries.iso3 ORDER BY airline_country_count DESC";
259
+			}
227 260
 			try {
228 261
 				$sth = $this->db->prepare($query);
229 262
 				$sth->execute(array(':filter_name' => $filter_name));
@@ -231,7 +264,9 @@  discard block
 block discarded – undo
231 264
 				echo "error : ".$e->getMessage();
232 265
 			}
233 266
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
234
-		} else $all = array();
267
+		} else {
268
+			$all = array();
269
+		}
235 270
 		if (empty($all)) {
236 271
 			$Spotter = new Spotter($this->db);
237 272
 			$filters = array();
@@ -246,7 +281,9 @@  discard block
 block discarded – undo
246 281
 	}
247 282
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
248 283
 		global $globalStatsFilters;
249
-		if ($filter_name == '') $filter_name = $this->filter_name;
284
+		if ($filter_name == '') {
285
+			$filter_name = $this->filter_name;
286
+		}
250 287
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
251 288
 			$Spotter = new Spotter($this->db);
252 289
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -255,8 +292,11 @@  discard block
 block discarded – undo
255 292
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
256 293
 			}
257 294
 			if ($year == '' && $month == '') {
258
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
259
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
295
+				if ($limit) {
296
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
297
+				} else {
298
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
299
+				}
260 300
 				try {
261 301
 					$sth = $this->db->prepare($query);
262 302
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -264,11 +304,16 @@  discard block
 block discarded – undo
264 304
 					echo "error : ".$e->getMessage();
265 305
 				}
266 306
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
267
-			} else $all = array();
307
+			} else {
308
+				$all = array();
309
+			}
268 310
 		} else {
269 311
 			if ($year == '' && $month == '') {
270
-				if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
271
-				else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
312
+				if ($limit) {
313
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0";
314
+				} else {
315
+					$query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC";
316
+				}
272 317
 				try {
273 318
 					$sth = $this->db->prepare($query);
274 319
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -276,7 +321,9 @@  discard block
 block discarded – undo
276 321
 					echo "error : ".$e->getMessage();
277 322
 				}
278 323
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
279
-			} else $all = array();
324
+			} else {
325
+				$all = array();
326
+			}
280 327
 		}
281 328
 		if (empty($all)) {
282 329
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -296,7 +343,9 @@  discard block
 block discarded – undo
296 343
 
297 344
 	public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
298 345
 		global $globalStatsFilters;
299
-		if ($filter_name == '') $filter_name = $this->filter_name;
346
+		if ($filter_name == '') {
347
+			$filter_name = $this->filter_name;
348
+		}
300 349
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
301 350
 			$Spotter = new Spotter($this->db);
302 351
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -305,8 +354,11 @@  discard block
 block discarded – undo
305 354
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
306 355
 			}
307 356
 			if ($year == '' && $month == '') {
308
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
309
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
357
+				if ($limit) {
358
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
359
+				} else {
360
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
361
+				}
310 362
 				try {
311 363
 					$sth = $this->db->prepare($query);
312 364
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -314,11 +366,16 @@  discard block
 block discarded – undo
314 366
 					echo "error : ".$e->getMessage();
315 367
 				}
316 368
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
317
-			} else $all = array();
369
+			} else {
370
+				$all = array();
371
+			}
318 372
 		} else {
319 373
 			if ($year == '' && $month == '') {
320
-				if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
321
-				else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
374
+				if ($limit) {
375
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0";
376
+				} else {
377
+					$query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_aiport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country, countries.iso3 ORDER BY airport_arrival_country_count DESC";
378
+				}
322 379
 				try {
323 380
 					$sth = $this->db->prepare($query);
324 381
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -326,7 +383,9 @@  discard block
 block discarded – undo
326 383
 					echo "error : ".$e->getMessage();
327 384
 				}
328 385
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
329
-			} else $all = array();
386
+			} else {
387
+				$all = array();
388
+			}
330 389
 		}
331 390
 		if (empty($all)) {
332 391
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -345,7 +404,9 @@  discard block
 block discarded – undo
345 404
 	}
346 405
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
347 406
 		global $globalStatsFilters;
348
-		if ($filter_name == '') $filter_name = $this->filter_name;
407
+		if ($filter_name == '') {
408
+			$filter_name = $this->filter_name;
409
+		}
349 410
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
350 411
 			$Spotter = new Spotter($this->db);
351 412
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -353,12 +414,18 @@  discard block
 block discarded – undo
353 414
 			foreach ($airlines as $airline) {
354 415
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
355 416
 			}
356
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
357
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
417
+			if ($limit) {
418
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
419
+			} else {
420
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
421
+			}
358 422
 			$query_values = array(':filter_name' => $filter_name);
359 423
 		} else {
360
-			if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
361
-			else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
424
+			if ($limit) {
425
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.name = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0";
426
+			} else {
427
+				$query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count, countries.iso3 as airport_departure_country_iso3 FROM stats_airport, countries WHERE countries.iso3 = stats_airport.airport_country AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country, countries.iso3 ORDER BY airport_departure_country_count DESC";
428
+			}
362 429
 			$query_values = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
363 430
 		}
364 431
 		try {
@@ -386,17 +453,29 @@  discard block
 block discarded – undo
386 453
 
387 454
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
388 455
 		global $globalStatsFilters, $globalVATSIM, $globalIVAO;
389
-		if ($filter_name == '') $filter_name = $this->filter_name;
456
+		if ($filter_name == '') {
457
+			$filter_name = $this->filter_name;
458
+		}
390 459
 		if ($year == '' && $month == '') {
391
-			if ($globalVATSIM) $forsource = 'vatsim';
392
-			if ($globalIVAO) $forsource = 'ivao';
460
+			if ($globalVATSIM) {
461
+				$forsource = 'vatsim';
462
+			}
463
+			if ($globalIVAO) {
464
+				$forsource = 'ivao';
465
+			}
393 466
 			if (isset($forsource)) {
394
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
395
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
467
+				if ($limit) {
468
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
469
+				} else {
470
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC";
471
+				}
396 472
 				$query_values = array(':filter_name' => $filter_name,':forsource' => $forsource);
397 473
 			} else {
398
-				if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
399
-				else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
474
+				if ($limit) {
475
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0";
476
+				} else {
477
+					$query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC";
478
+				}
400 479
 				$query_values = array(':filter_name' => $filter_name);
401 480
 			}
402 481
 			try {
@@ -406,7 +485,9 @@  discard block
 block discarded – undo
406 485
 				echo "error : ".$e->getMessage();
407 486
 			}
408 487
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
409
-		} else $all = array();
488
+		} else {
489
+			$all = array();
490
+		}
410 491
                 if (empty($all)) {
411 492
 	                $Spotter = new Spotter($this->db);
412 493
             		$filters = array();
@@ -421,7 +502,9 @@  discard block
 block discarded – undo
421 502
 	}
422 503
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
423 504
 		global $globalStatsFilters;
424
-		if ($filter_name == '') $filter_name = $this->filter_name;
505
+		if ($filter_name == '') {
506
+			$filter_name = $this->filter_name;
507
+		}
425 508
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
426 509
 			$Spotter = new Spotter($this->db);
427 510
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -430,8 +513,11 @@  discard block
 block discarded – undo
430 513
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
431 514
 			}
432 515
 			if ($year == '' && $month == '') {
433
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
434
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
516
+				if ($limit) {
517
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
518
+				} else {
519
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
520
+				}
435 521
 				try {
436 522
 					$sth = $this->db->prepare($query);
437 523
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -439,11 +525,16 @@  discard block
 block discarded – undo
439 525
 					echo "error : ".$e->getMessage();
440 526
 				}
441 527
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
442
-			} else $all = array();
528
+			} else {
529
+				$all = array();
530
+			}
443 531
 		} else {
444 532
 			if ($year == '' && $month == '') {
445
-				if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
446
-				else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
533
+				if ($limit) {
534
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0";
535
+				} else {
536
+					$query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC";
537
+				}
447 538
 				try {
448 539
 					$sth = $this->db->prepare($query);
449 540
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -451,7 +542,9 @@  discard block
 block discarded – undo
451 542
 					echo "error : ".$e->getMessage();
452 543
 				}
453 544
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-			} else $all = array();
545
+			} else {
546
+				$all = array();
547
+			}
455 548
 		}
456 549
 		if (empty($all)) {
457 550
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -470,7 +563,9 @@  discard block
 block discarded – undo
470 563
 	}
471 564
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
472 565
 		global $globalStatsFilters;
473
-		if ($filter_name == '') $filter_name = $this->filter_name;
566
+		if ($filter_name == '') {
567
+			$filter_name = $this->filter_name;
568
+		}
474 569
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
475 570
 			$Spotter = new Spotter($this->db);
476 571
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -479,8 +574,11 @@  discard block
 block discarded – undo
479 574
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
480 575
 			}
481 576
 			if ($year == '' && $month == '') {
482
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
483
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
577
+				if ($limit) {
578
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
579
+				} else {
580
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
581
+				}
484 582
 				 try {
485 583
 					$sth = $this->db->prepare($query);
486 584
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -488,11 +586,16 @@  discard block
 block discarded – undo
488 586
 					echo "error : ".$e->getMessage();
489 587
 				}
490 588
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
491
-			} else $all = array();
589
+			} else {
590
+				$all = array();
591
+			}
492 592
 		} else {
493 593
 			if ($year == '' && $month == '') {
494
-				if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
495
-				else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
594
+				if ($limit) {
595
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0";
596
+				} else {
597
+					$query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC";
598
+				}
496 599
 				 try {
497 600
 					$sth = $this->db->prepare($query);
498 601
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -500,7 +603,9 @@  discard block
 block discarded – undo
500 603
 					echo "error : ".$e->getMessage();
501 604
 				}
502 605
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
503
-			} else $all = array();
606
+			} else {
607
+				$all = array();
608
+			}
504 609
 		}
505 610
 		if (empty($all)) {
506 611
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -519,7 +624,9 @@  discard block
 block discarded – undo
519 624
 	}
520 625
 	public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') {
521 626
 		$Connection = new Connection($this->db);
522
-		if ($filter_name == '') $filter_name = $this->filter_name;
627
+		if ($filter_name == '') {
628
+			$filter_name = $this->filter_name;
629
+		}
523 630
 		if ($Connection->tableExists('countries')) {
524 631
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
525 632
 				$Spotter = new Spotter($this->db);
@@ -529,8 +636,11 @@  discard block
 block discarded – undo
529 636
 					foreach ($airlines as $airline) {
530 637
 						$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
531 638
 					}
532
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
533
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
639
+					if ($limit) {
640
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
641
+					} else {
642
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY flight_count DESC";
643
+					}
534 644
 					 try {
535 645
 						$sth = $this->db->prepare($query);
536 646
 						$sth->execute(array(':filter_name' => $filter_name));
@@ -539,11 +649,16 @@  discard block
 block discarded – undo
539 649
 					}
540 650
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
541 651
 					return $all;
542
-				} else return array();
652
+				} else {
653
+					return array();
654
+				}
543 655
 			} else {
544 656
 				if ($year == '' && $month == '') {
545
-					if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
546
-					else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
657
+					if ($limit) {
658
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0";
659
+					} else {
660
+						$query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC";
661
+					}
547 662
 					 try {
548 663
 						$sth = $this->db->prepare($query);
549 664
 						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -552,7 +667,9 @@  discard block
 block discarded – undo
552 667
 					}
553 668
 					$all = $sth->fetchAll(PDO::FETCH_ASSOC);
554 669
 					return $all;
555
-				} else return array();
670
+				} else {
671
+					return array();
672
+				}
556 673
 			}
557 674
 		} else {
558 675
 			/*
@@ -566,10 +683,15 @@  discard block
 block discarded – undo
566 683
 	}
567 684
 	public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') {
568 685
 		global $globalStatsFilters;
569
-		if ($filter_name == '') $filter_name = $this->filter_name;
686
+		if ($filter_name == '') {
687
+			$filter_name = $this->filter_name;
688
+		}
570 689
 		if ($year == '' && $month == '') {
571
-			if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
572
-			else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
690
+			if ($limit) {
691
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0";
692
+			} else {
693
+				$query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC";
694
+			}
573 695
 			try {
574 696
 				$sth = $this->db->prepare($query);
575 697
 				$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -577,7 +699,9 @@  discard block
 block discarded – undo
577 699
 				echo "error : ".$e->getMessage();
578 700
 			}
579 701
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
580
-		} else $all = array();
702
+		} else {
703
+			$all = array();
704
+		}
581 705
 		if (empty($all)) {
582 706
 			$filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month);
583 707
 			if ($filter_name != '') {
@@ -592,7 +716,9 @@  discard block
 block discarded – undo
592 716
 
593 717
 	public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') {
594 718
 		global $globalStatsFilters;
595
-		if ($filter_name == '') $filter_name = $this->filter_name;
719
+		if ($filter_name == '') {
720
+			$filter_name = $this->filter_name;
721
+		}
596 722
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
597 723
 			$Spotter = new Spotter($this->db);
598 724
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -601,8 +727,11 @@  discard block
 block discarded – undo
601 727
 				foreach ($airlines as $airline) {
602 728
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
603 729
 				}
604
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
605
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
730
+				if ($limit) {
731
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
732
+				} else {
733
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY owner_count DESC";
734
+				}
606 735
 				try {
607 736
 					$sth = $this->db->prepare($query);
608 737
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -610,11 +739,16 @@  discard block
 block discarded – undo
610 739
 					echo "error : ".$e->getMessage();
611 740
 				}
612 741
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
613
-			} else $all = array();
742
+			} else {
743
+				$all = array();
744
+			}
614 745
 		} else {
615 746
 			if ($year == '' && $month == '') {
616
-				if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
617
-				else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
747
+				if ($limit) {
748
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0";
749
+				} else {
750
+					$query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC";
751
+				}
618 752
 				try {
619 753
 					$sth = $this->db->prepare($query);
620 754
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -622,7 +756,9 @@  discard block
 block discarded – undo
622 756
 					echo "error : ".$e->getMessage();
623 757
 				}
624 758
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
625
-			} else $all = array();
759
+			} else {
760
+				$all = array();
761
+			}
626 762
 		}
627 763
 		if (empty($all)) {
628 764
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -641,7 +777,9 @@  discard block
 block discarded – undo
641 777
 	}
642 778
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
643 779
 		global $globalStatsFilters;
644
-		if ($filter_name == '') $filter_name = $this->filter_name;
780
+		if ($filter_name == '') {
781
+			$filter_name = $this->filter_name;
782
+		}
645 783
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
646 784
 			$Spotter = new Spotter($this->db);
647 785
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -650,8 +788,11 @@  discard block
 block discarded – undo
650 788
 				foreach ($airlines as $airline) {
651 789
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
652 790
 				}
653
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
654
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
791
+				if ($limit) {
792
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
793
+				} else {
794
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
795
+				}
655 796
 				try {
656 797
 					$sth = $this->db->prepare($query);
657 798
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -659,11 +800,16 @@  discard block
 block discarded – undo
659 800
 					echo "error : ".$e->getMessage();
660 801
 				}
661 802
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
662
-			} else $all = array();
803
+			} else {
804
+				$all = array();
805
+			}
663 806
 		} else {
664 807
 			if ($year == '' && $month == '') {
665
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
666
-				else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
808
+				if ($limit) {
809
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0";
810
+				} else {
811
+					$query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count, airport.latitude AS airport_departure_latitude, airport.longitude AS airport_departure_longitude FROM stats_airport,airport WHERE airport.icao = stats_airport.airport_icao AND departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC";
812
+				}
667 813
 				try {
668 814
 					$sth = $this->db->prepare($query);
669 815
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -671,7 +817,9 @@  discard block
 block discarded – undo
671 817
 					echo "error : ".$e->getMessage();
672 818
 				}
673 819
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
674
-			} else $all = array();
820
+			} else {
821
+				$all = array();
822
+			}
675 823
 		}
676 824
 		if (empty($all)) {
677 825
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -696,7 +844,9 @@  discard block
 block discarded – undo
696 844
 				$icao = $value['airport_departure_icao'];
697 845
 				if (isset($all[$icao])) {
698 846
 					$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
699
-				} else $all[$icao] = $value;
847
+				} else {
848
+					$all[$icao] = $value;
849
+				}
700 850
 			}
701 851
 			$count = array();
702 852
 			foreach ($all as $key => $row) {
@@ -708,7 +858,9 @@  discard block
 block discarded – undo
708 858
 	}
709 859
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
710 860
 		global $globalStatsFilters;
711
-		if ($filter_name == '') $filter_name = $this->filter_name;
861
+		if ($filter_name == '') {
862
+			$filter_name = $this->filter_name;
863
+		}
712 864
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
713 865
 			$Spotter = new Spotter($this->db);
714 866
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -717,8 +869,11 @@  discard block
 block discarded – undo
717 869
 				foreach ($airlines as $airline) {
718 870
 					$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
719 871
 				}
720
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
721
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
872
+				if ($limit) {
873
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
874
+				} else {
875
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
876
+				}
722 877
 				try {
723 878
 					$sth = $this->db->prepare($query);
724 879
 					$sth->execute(array(':filter_name' => $filter_name));
@@ -726,11 +881,16 @@  discard block
 block discarded – undo
726 881
 					echo "error : ".$e->getMessage();
727 882
 				}
728 883
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
729
-			} else $all = array();
884
+			} else {
885
+				$all = array();
886
+			}
730 887
 		} else {
731 888
 			if ($year == '' && $month == '') {
732
-				if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
733
-				else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
889
+				if ($limit) {
890
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0";
891
+				} else {
892
+					$query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count, airport.latitude AS airport_arrival_latitude, airport.longitude AS airport_arrival_longitude FROM stats_airport, airport WHERE airport.icao = stats_airport.airport_icao AND arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC";
893
+				}
734 894
 				try {
735 895
 					$sth = $this->db->prepare($query);
736 896
 					$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
@@ -738,7 +898,9 @@  discard block
 block discarded – undo
738 898
 					echo "error : ".$e->getMessage();
739 899
 				}
740 900
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
741
-			} else $all = array();
901
+			} else {
902
+				$all = array();
903
+			}
742 904
 		}
743 905
 		if (empty($all)) {
744 906
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -763,7 +925,9 @@  discard block
 block discarded – undo
763 925
 				$icao = $value['airport_arrival_icao'];
764 926
 				if (isset($all[$icao])) {
765 927
 					$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
766
-				} else $all[$icao] = $value;
928
+				} else {
929
+					$all[$icao] = $value;
930
+				}
767 931
 			}
768 932
 			$count = array();
769 933
 			foreach ($all as $key => $row) {
@@ -775,7 +939,9 @@  discard block
 block discarded – undo
775 939
 	}
776 940
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
777 941
 		global $globalDBdriver, $globalStatsFilters;
778
-		if ($filter_name == '') $filter_name = $this->filter_name;
942
+		if ($filter_name == '') {
943
+			$filter_name = $this->filter_name;
944
+		}
779 945
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
780 946
 			$Spotter = new Spotter($this->db);
781 947
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -784,20 +950,32 @@  discard block
 block discarded – undo
784 950
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
785 951
 			}
786 952
 			if ($globalDBdriver == 'mysql') {
787
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
788
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
953
+				if ($limit) {
954
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
955
+				} else {
956
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
957
+				}
789 958
 			} else {
790
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
791
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
959
+				if ($limit) {
960
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
961
+				} else {
962
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, SUM(cnt) as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY stats_date";
963
+				}
792 964
 			}
793 965
 			$query_data = array(':filter_name' => $filter_name);
794 966
 		} else {
795 967
 			if ($globalDBdriver == 'mysql') {
796
-				if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
797
-				else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
968
+				if ($limit) {
969
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name";
970
+				} else {
971
+					$query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
972
+				}
798 973
 			} else {
799
-				if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
800
-				else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
974
+				if ($limit) {
975
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
976
+				} else {
977
+					$query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name";
978
+				}
801 979
 			}
802 980
 			$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
803 981
 		}
@@ -825,7 +1003,9 @@  discard block
 block discarded – undo
825 1003
 	
826 1004
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
827 1005
 		global $globalStatsFilters;
828
-		if ($filter_name == '') $filter_name = $this->filter_name;
1006
+		if ($filter_name == '') {
1007
+			$filter_name = $this->filter_name;
1008
+		}
829 1009
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
830 1010
 			$Spotter = new Spotter($this->db);
831 1011
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -862,7 +1042,9 @@  discard block
 block discarded – undo
862 1042
 	}
863 1043
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
864 1044
 		global $globalDBdriver, $globalStatsFilters;
865
-		if ($filter_name == '') $filter_name = $this->filter_name;
1045
+		if ($filter_name == '') {
1046
+			$filter_name = $this->filter_name;
1047
+		}
866 1048
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
867 1049
 			$Spotter = new Spotter($this->db);
868 1050
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -907,7 +1089,9 @@  discard block
 block discarded – undo
907 1089
 	}
908 1090
 	public function countAllDates($stats_airline = '',$filter_name = '') {
909 1091
 		global $globalStatsFilters;
910
-		if ($filter_name == '') $filter_name = $this->filter_name;
1092
+		if ($filter_name == '') {
1093
+			$filter_name = $this->filter_name;
1094
+		}
911 1095
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
912 1096
 			$Spotter = new Spotter($this->db);
913 1097
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -944,7 +1128,9 @@  discard block
 block discarded – undo
944 1128
 	}
945 1129
 	public function countAllDatesMarine($filter_name = '') {
946 1130
 		global $globalStatsFilters;
947
-		if ($filter_name == '') $filter_name = $this->filter_name;
1131
+		if ($filter_name == '') {
1132
+			$filter_name = $this->filter_name;
1133
+		}
948 1134
 		$query = "SELECT marine_date as date_name, cnt as date_count FROM stats_marine WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
949 1135
 		$query_data = array(':filter_name' => $filter_name);
950 1136
 		try {
@@ -966,7 +1152,9 @@  discard block
 block discarded – undo
966 1152
 	}
967 1153
 	public function countAllDatesTracker($filter_name = '') {
968 1154
 		global $globalStatsFilters;
969
-		if ($filter_name == '') $filter_name = $this->filter_name;
1155
+		if ($filter_name == '') {
1156
+			$filter_name = $this->filter_name;
1157
+		}
970 1158
 		$query = "SELECT tracker_date as date_name, cnt as date_count FROM stats_tracker WHERE stats_type = 'date' AND filter_name = :filter_name ORDER BY date_count DESC";
971 1159
 		$query_data = array(':filter_name' => $filter_name);
972 1160
 		try {
@@ -988,7 +1176,9 @@  discard block
 block discarded – undo
988 1176
 	}
989 1177
 	public function countAllDatesByAirlines($filter_name = '') {
990 1178
 		global $globalStatsFilters;
991
-		if ($filter_name == '') $filter_name = $this->filter_name;
1179
+		if ($filter_name == '') {
1180
+			$filter_name = $this->filter_name;
1181
+		}
992 1182
 		$query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name";
993 1183
 		$query_data = array('filter_name' => $filter_name);
994 1184
 		try {
@@ -1010,7 +1200,9 @@  discard block
 block discarded – undo
1010 1200
 	}
1011 1201
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
1012 1202
 		global $globalStatsFilters, $globalDBdriver;
1013
-		if ($filter_name == '') $filter_name = $this->filter_name;
1203
+		if ($filter_name == '') {
1204
+			$filter_name = $this->filter_name;
1205
+		}
1014 1206
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1015 1207
 			$Spotter = new Spotter($this->db);
1016 1208
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1095,7 +1287,9 @@  discard block
 block discarded – undo
1095 1287
 	}
1096 1288
 	public function countAllMilitaryMonths($filter_name = '') {
1097 1289
 		global $globalStatsFilters;
1098
-		if ($filter_name == '') $filter_name = $this->filter_name;
1290
+		if ($filter_name == '') {
1291
+			$filter_name = $this->filter_name;
1292
+		}
1099 1293
 		$query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name";
1100 1294
 		try {
1101 1295
 			$sth = $this->db->prepare($query);
@@ -1116,7 +1310,9 @@  discard block
 block discarded – undo
1116 1310
 	}
1117 1311
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
1118 1312
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
1119
-		if ($filter_name == '') $filter_name = $this->filter_name;
1313
+		if ($filter_name == '') {
1314
+			$filter_name = $this->filter_name;
1315
+		}
1120 1316
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1121 1317
 			$Spotter = new Spotter($this->db);
1122 1318
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1124,12 +1320,18 @@  discard block
 block discarded – undo
1124 1320
 			foreach ($airlines as $airline) {
1125 1321
 				$alliance_airlines = array_merge($alliance_airlines,array($airline['airline_icao']));
1126 1322
 			}
1127
-			if ($limit) $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1128
-			else $query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1323
+			if ($limit) {
1324
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1325
+			} else {
1326
+				$query = "SELECT flight_date as hour_name, SUM(cnt) as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline IN ('".implode("','",$alliance_airlines)."') AND filter_name = :filter_name GROUP BY flight_date";
1327
+			}
1129 1328
 			$query_data = array(':filter_name' => $filter_name);
1130 1329
 		} else {
1131
-			if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1132
-			else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1330
+			if ($limit) {
1331
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1332
+			} else {
1333
+				$query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name";
1334
+			}
1133 1335
 			$query_data = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
1134 1336
 		}
1135 1337
 		if ($orderby == 'hour') {
@@ -1139,7 +1341,9 @@  discard block
 block discarded – undo
1139 1341
 				$query .= " ORDER BY CAST(flight_date AS integer) ASC";
1140 1342
 			}
1141 1343
 		}
1142
-		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
1344
+		if ($orderby == 'count') {
1345
+			$query .= " ORDER BY hour_count DESC";
1346
+		}
1143 1347
 		try {
1144 1348
 			$sth = $this->db->prepare($query);
1145 1349
 			$sth->execute($query_data);
@@ -1163,8 +1367,12 @@  discard block
 block discarded – undo
1163 1367
 	}
1164 1368
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
1165 1369
 		global $globalStatsFilters;
1166
-		if ($filter_name == '') $filter_name = $this->filter_name;
1167
-		if ($year == '') $year = date('Y');
1370
+		if ($filter_name == '') {
1371
+			$filter_name = $this->filter_name;
1372
+		}
1373
+		if ($year == '') {
1374
+			$year = date('Y');
1375
+		}
1168 1376
 		$all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month);
1169 1377
 		if (empty($all)) {
1170 1378
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1183,8 +1391,12 @@  discard block
 block discarded – undo
1183 1391
 	}
1184 1392
 	public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') {
1185 1393
 		global $globalStatsFilters;
1186
-		if ($filter_name == '') $filter_name = $this->filter_name;
1187
-		if ($year == '') $year = date('Y');
1394
+		if ($filter_name == '') {
1395
+			$filter_name = $this->filter_name;
1396
+		}
1397
+		if ($year == '') {
1398
+			$year = date('Y');
1399
+		}
1188 1400
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
1189 1401
 		if (empty($all)) {
1190 1402
 			$filters = array();
@@ -1200,8 +1412,12 @@  discard block
 block discarded – undo
1200 1412
 	}
1201 1413
 	public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') {
1202 1414
 		global $globalStatsFilters;
1203
-		if ($filter_name == '') $filter_name = $this->filter_name;
1204
-		if ($year == '') $year = date('Y');
1415
+		if ($filter_name == '') {
1416
+			$filter_name = $this->filter_name;
1417
+		}
1418
+		if ($year == '') {
1419
+			$year = date('Y');
1420
+		}
1205 1421
 		$all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month);
1206 1422
 		if (empty($all)) {
1207 1423
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1220,7 +1436,9 @@  discard block
 block discarded – undo
1220 1436
 	}
1221 1437
 	public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1222 1438
 		global $globalStatsFilters;
1223
-		if ($filter_name == '') $filter_name = $this->filter_name;
1439
+		if ($filter_name == '') {
1440
+			$filter_name = $this->filter_name;
1441
+		}
1224 1442
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1225 1443
 			$Spotter = new Spotter($this->db);
1226 1444
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1238,7 +1456,9 @@  discard block
 block discarded – undo
1238 1456
 				}
1239 1457
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1240 1458
 				$all = $result[0]['nb'];
1241
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1459
+			} else {
1460
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1461
+			}
1242 1462
 		} else {
1243 1463
 			if ($year == '' && $month == '') {
1244 1464
 				$query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1250,7 +1470,9 @@  discard block
 block discarded – undo
1250 1470
 				}
1251 1471
 				$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1252 1472
 				$all = $result[0]['nb'];
1253
-			} else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1473
+			} else {
1474
+				$all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month);
1475
+			}
1254 1476
 		}
1255 1477
 		if (empty($all)) {
1256 1478
 			if (strpos($stats_airline,'alliance_') !== FALSE) {
@@ -1269,7 +1491,9 @@  discard block
 block discarded – undo
1269 1491
 	}
1270 1492
 	public function countOverallAirlines($filter_name = '',$year = '',$month = '') {
1271 1493
 		global $globalStatsFilters;
1272
-		if ($filter_name == '') $filter_name = $this->filter_name;
1494
+		if ($filter_name == '') {
1495
+			$filter_name = $this->filter_name;
1496
+		}
1273 1497
 		if ($year == '' && $month == '') {
1274 1498
 			$query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name";
1275 1499
 			try {
@@ -1280,7 +1504,9 @@  discard block
 block discarded – undo
1280 1504
 			}
1281 1505
 			$result = $sth->fetchAll(PDO::FETCH_ASSOC);
1282 1506
 			$all = $result[0]['nb_airline'];
1283
-		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1507
+		} else {
1508
+			$all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
1509
+		}
1284 1510
 		if (empty($all)) {
1285 1511
 			$filters = array();
1286 1512
 			$filters = array('year' => $year,'month' => $month);
@@ -1295,7 +1521,9 @@  discard block
 block discarded – undo
1295 1521
 	}
1296 1522
 	public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') {
1297 1523
 		global $globalStatsFilters;
1298
-		if ($filter_name == '') $filter_name = $this->filter_name;
1524
+		if ($filter_name == '') {
1525
+			$filter_name = $this->filter_name;
1526
+		}
1299 1527
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1300 1528
 			$Spotter = new Spotter($this->db);
1301 1529
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1350,7 +1578,9 @@  discard block
 block discarded – undo
1350 1578
 	}
1351 1579
 	public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') {
1352 1580
 		global $globalStatsFilters;
1353
-		if ($filter_name == '') $filter_name = $this->filter_name;
1581
+		if ($filter_name == '') {
1582
+			$filter_name = $this->filter_name;
1583
+		}
1354 1584
 		//if ($year == '') $year = date('Y');
1355 1585
 		if ($year == '' && $month == '') {
1356 1586
 			$query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
@@ -1379,7 +1609,9 @@  discard block
 block discarded – undo
1379 1609
 	}
1380 1610
 
1381 1611
 	public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') {
1382
-		if ($filter_name == '') $filter_name = $this->filter_name;
1612
+		if ($filter_name == '') {
1613
+			$filter_name = $this->filter_name;
1614
+		}
1383 1615
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1384 1616
 			$Spotter = new Spotter($this->db);
1385 1617
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1403,7 +1635,9 @@  discard block
 block discarded – undo
1403 1635
 		return $all;
1404 1636
 	}
1405 1637
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
1406
-		if ($filter_name == '') $filter_name = $this->filter_name;
1638
+		if ($filter_name == '') {
1639
+			$filter_name = $this->filter_name;
1640
+		}
1407 1641
 		$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
1408 1642
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1409 1643
 		try {
@@ -1416,7 +1650,9 @@  discard block
 block discarded – undo
1416 1650
 		return $all;
1417 1651
 	}
1418 1652
 	public function deleteStatsByType($type,$stats_airline = '', $filter_name = '') {
1419
-		if ($filter_name == '') $filter_name = $this->filter_name;
1653
+		if ($filter_name == '') {
1654
+			$filter_name = $this->filter_name;
1655
+		}
1420 1656
 		$query = "DELETE FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name";
1421 1657
 		$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1422 1658
 		try {
@@ -1427,7 +1663,9 @@  discard block
 block discarded – undo
1427 1663
 		}
1428 1664
 	}
1429 1665
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
1430
-		if ($filter_name == '') $filter_name = $this->filter_name;
1666
+		if ($filter_name == '') {
1667
+			$filter_name = $this->filter_name;
1668
+		}
1431 1669
 		global $globalArchiveMonths, $globalDBdriver;
1432 1670
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1433 1671
 			$Spotter = new Spotter($this->db);
@@ -1483,7 +1721,9 @@  discard block
 block discarded – undo
1483 1721
 	}
1484 1722
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
1485 1723
 		global $globalArchiveMonths, $globalDBdriver;
1486
-		if ($filter_name == '') $filter_name = $this->filter_name;
1724
+		if ($filter_name == '') {
1725
+			$filter_name = $this->filter_name;
1726
+		}
1487 1727
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1488 1728
 			$Spotter = new Spotter($this->db);
1489 1729
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1516,7 +1756,9 @@  discard block
 block discarded – undo
1516 1756
 	}
1517 1757
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
1518 1758
 		global $globalArchiveMonths, $globalDBdriver;
1519
-		if ($filter_name == '') $filter_name = $this->filter_name;
1759
+		if ($filter_name == '') {
1760
+			$filter_name = $this->filter_name;
1761
+		}
1520 1762
 		if (strpos($stats_airline,'alliance_') !== FALSE) {
1521 1763
 			$Spotter = new Spotter($this->db);
1522 1764
 			$airlines = $Spotter->getAllAirlineNamesByAlliance(str_replace('_',' ',str_replace('alliance_','',$stats_airline)));
@@ -1547,7 +1789,9 @@  discard block
 block discarded – undo
1547 1789
 	}
1548 1790
 	public function getStatsAirlineTotal($filter_name = '') {
1549 1791
 		global $globalArchiveMonths, $globalDBdriver;
1550
-		if ($filter_name == '') $filter_name = $this->filter_name;
1792
+		if ($filter_name == '') {
1793
+			$filter_name = $this->filter_name;
1794
+		}
1551 1795
 		if ($globalDBdriver == 'mysql') {
1552 1796
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
1553 1797
 		} else {
@@ -1564,7 +1808,9 @@  discard block
 block discarded – undo
1564 1808
 	}
1565 1809
 	public function getStatsOwnerTotal($filter_name = '') {
1566 1810
 		global $globalArchiveMonths, $globalDBdriver;
1567
-		if ($filter_name == '') $filter_name = $this->filter_name;
1811
+		if ($filter_name == '') {
1812
+			$filter_name = $this->filter_name;
1813
+		}
1568 1814
 		if ($globalDBdriver == 'mysql') {
1569 1815
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
1570 1816
 		} else {
@@ -1581,7 +1827,9 @@  discard block
 block discarded – undo
1581 1827
 	}
1582 1828
 	public function getStatsOwner($owner_name,$filter_name = '') {
1583 1829
 		global $globalArchiveMonths, $globalDBdriver;
1584
-		if ($filter_name == '') $filter_name = $this->filter_name;
1830
+		if ($filter_name == '') {
1831
+			$filter_name = $this->filter_name;
1832
+		}
1585 1833
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
1586 1834
 		try {
1587 1835
 			$sth = $this->db->prepare($query);
@@ -1590,12 +1838,17 @@  discard block
 block discarded – undo
1590 1838
 			echo "error : ".$e->getMessage();
1591 1839
 		}
1592 1840
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1593
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1594
-		else return 0;
1841
+		if (isset($all[0]['cnt'])) {
1842
+			return $all[0]['cnt'];
1843
+		} else {
1844
+			return 0;
1845
+		}
1595 1846
 	}
1596 1847
 	public function getStatsPilotTotal($filter_name = '') {
1597 1848
 		global $globalArchiveMonths, $globalDBdriver;
1598
-		if ($filter_name == '') $filter_name = $this->filter_name;
1849
+		if ($filter_name == '') {
1850
+			$filter_name = $this->filter_name;
1851
+		}
1599 1852
 		if ($globalDBdriver == 'mysql') {
1600 1853
 			$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1601 1854
 		} else {
@@ -1612,7 +1865,9 @@  discard block
 block discarded – undo
1612 1865
 	}
1613 1866
 	public function getStatsPilot($pilot,$filter_name = '') {
1614 1867
 		global $globalArchiveMonths, $globalDBdriver;
1615
-		if ($filter_name == '') $filter_name = $this->filter_name;
1868
+		if ($filter_name == '') {
1869
+			$filter_name = $this->filter_name;
1870
+		}
1616 1871
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1617 1872
 		try {
1618 1873
 			$sth = $this->db->prepare($query);
@@ -1621,13 +1876,18 @@  discard block
 block discarded – undo
1621 1876
 			echo "error : ".$e->getMessage();
1622 1877
 		}
1623 1878
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1624
-		if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1625
-		else return 0;
1879
+		if (isset($all[0]['cnt'])) {
1880
+			return $all[0]['cnt'];
1881
+		} else {
1882
+			return 0;
1883
+		}
1626 1884
 	}
1627 1885
 
1628 1886
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1629 1887
 		global $globalDBdriver;
1630
-		if ($filter_name == '') $filter_name = $this->filter_name;
1888
+		if ($filter_name == '') {
1889
+			$filter_name = $this->filter_name;
1890
+		}
1631 1891
 		if ($globalDBdriver == 'mysql') {
1632 1892
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt";
1633 1893
 		} else {
@@ -1643,7 +1903,9 @@  discard block
 block discarded – undo
1643 1903
 	}
1644 1904
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1645 1905
 		global $globalDBdriver;
1646
-		if ($filter_name == '') $filter_name = $this->filter_name;
1906
+		if ($filter_name == '') {
1907
+			$filter_name = $this->filter_name;
1908
+		}
1647 1909
 		if ($globalDBdriver == 'mysql') {
1648 1910
 			$query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1649 1911
 		} else {
@@ -2116,27 +2378,37 @@  discard block
 block discarded – undo
2116 2378
 		date_default_timezone_set('UTC');
2117 2379
 		if (isset($globalMarine) && $globalMarine) {
2118 2380
 			$last_update = $this->getLastStatsUpdate('last_update_stats_marine');
2119
-			if ($globalDebug) echo '!!! Update Marine stats !!!'."\n";
2381
+			if ($globalDebug) {
2382
+				echo '!!! Update Marine stats !!!'."\n";
2383
+			}
2120 2384
 			if (isset($last_update[0]['value'])) {
2121 2385
 				$last_update_day = $last_update[0]['value'];
2122
-			} else $last_update_day = '2012-12-12 12:12:12';
2386
+			} else {
2387
+				$last_update_day = '2012-12-12 12:12:12';
2388
+			}
2123 2389
 			$reset = false;
2124 2390
 			$Marine = new Marine($this->db);
2125 2391
 			$filtername = 'marine';
2126 2392
 			if ($Connection->tableExists('countries')) {
2127
-				if ($globalDebug) echo 'Count all vessels by countries...'."\n";
2393
+				if ($globalDebug) {
2394
+					echo 'Count all vessels by countries...'."\n";
2395
+				}
2128 2396
 				$alldata = $Marine->countAllMarineOverCountries(false,0,$last_update_day);
2129 2397
 				foreach ($alldata as $number) {
2130 2398
 					$this->addStatCountryMarine($number['marine_country_iso2'],$number['marine_country_iso3'],$number['marine_country'],$number['marine_count'],'','',$reset);
2131 2399
 				}
2132 2400
 			}
2133
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2401
+			if ($globalDebug) {
2402
+				echo 'Count all vessels by months...'."\n";
2403
+			}
2134 2404
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2135 2405
 			$filter_last_month = array('since_date' => $last_month);
2136 2406
 			$alldata = $Marine->countAllMonths($filter_last_month);
2137 2407
 			$lastyear = false;
2138 2408
 			foreach ($alldata as $number) {
2139
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2409
+				if ($number['year_name'] != date('Y')) {
2410
+					$lastyear = true;
2411
+				}
2140 2412
 				$this->addStat('marine_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2141 2413
 			}
2142 2414
 			echo 'Marine data...'."\n";
@@ -2172,26 +2444,36 @@  discard block
 block discarded – undo
2172 2444
 		}
2173 2445
 		if (isset($globalTracker) && $globalTracker) {
2174 2446
 			$last_update = $this->getLastStatsUpdate('last_update_stats_tracker');
2175
-			if ($globalDebug) echo '!!! Update tracker stats !!!'."\n";
2447
+			if ($globalDebug) {
2448
+				echo '!!! Update tracker stats !!!'."\n";
2449
+			}
2176 2450
 			if (isset($last_update[0]['value'])) {
2177 2451
 				$last_update_day = $last_update[0]['value'];
2178
-			} else $last_update_day = '2012-12-12 12:12:12';
2452
+			} else {
2453
+				$last_update_day = '2012-12-12 12:12:12';
2454
+			}
2179 2455
 			$reset = false;
2180 2456
 			$Tracker = new Tracker($this->db);
2181 2457
 			if ($Connection->tableExists('countries')) {
2182
-				if ($globalDebug) echo 'Count all trackers by countries...'."\n";
2458
+				if ($globalDebug) {
2459
+					echo 'Count all trackers by countries...'."\n";
2460
+				}
2183 2461
 				$alldata = $Tracker->countAllTrackerOverCountries(false,0,$last_update_day);
2184 2462
 				foreach ($alldata as $number) {
2185 2463
 					$this->addStatCountryTracker($number['tracker_country_iso2'],$number['tracker_country_iso3'],$number['tracker_country'],$number['tracker_count'],'','',$reset);
2186 2464
 				}
2187 2465
 			}
2188
-			if ($globalDebug) echo 'Count all vessels by months...'."\n";
2466
+			if ($globalDebug) {
2467
+				echo 'Count all vessels by months...'."\n";
2468
+			}
2189 2469
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2190 2470
 			$filter_last_month = array('since_date' => $last_month);
2191 2471
 			$alldata = $Tracker->countAllMonths($filter_last_month);
2192 2472
 			$lastyear = false;
2193 2473
 			foreach ($alldata as $number) {
2194
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2474
+				if ($number['year_name'] != date('Y')) {
2475
+					$lastyear = true;
2476
+				}
2195 2477
 				$this->addStat('tracker_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2196 2478
 			}
2197 2479
 			echo 'Tracker data...'."\n";
@@ -2228,10 +2510,14 @@  discard block
 block discarded – undo
2228 2510
 
2229 2511
 		if (isset($globalAircraft) && $globalAircraft) {
2230 2512
 			$last_update = $this->getLastStatsUpdate('last_update_stats');
2231
-			if ($globalDebug) echo '!!! Update aicraft stats !!!'."\n";
2513
+			if ($globalDebug) {
2514
+				echo '!!! Update aicraft stats !!!'."\n";
2515
+			}
2232 2516
 			if (isset($last_update[0]['value'])) {
2233 2517
 				$last_update_day = $last_update[0]['value'];
2234
-			} else $last_update_day = '2012-12-12 12:12:12';
2518
+			} else {
2519
+				$last_update_day = '2012-12-12 12:12:12';
2520
+			}
2235 2521
 			$reset = false;
2236 2522
 			//if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) {
2237 2523
 			if ($globalStatsResetYear) {
@@ -2240,43 +2526,63 @@  discard block
 block discarded – undo
2240 2526
 			}
2241 2527
 			$Spotter = new Spotter($this->db);
2242 2528
 
2243
-			if ($globalDebug) echo 'Count all aircraft types...'."\n";
2529
+			if ($globalDebug) {
2530
+				echo 'Count all aircraft types...'."\n";
2531
+			}
2244 2532
 			$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day);
2245 2533
 			foreach ($alldata as $number) {
2246 2534
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset);
2247 2535
 			}
2248
-			if ($globalDebug) echo 'Count all airlines...'."\n";
2536
+			if ($globalDebug) {
2537
+				echo 'Count all airlines...'."\n";
2538
+			}
2249 2539
 			$alldata = $Spotter->countAllAirlines(false,0,$last_update_day);
2250 2540
 			foreach ($alldata as $number) {
2251 2541
 				$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset);
2252 2542
 			}
2253
-			if ($globalDebug) echo 'Count all registrations...'."\n";
2543
+			if ($globalDebug) {
2544
+				echo 'Count all registrations...'."\n";
2545
+			}
2254 2546
 			$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day);
2255 2547
 			foreach ($alldata as $number) {
2256 2548
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset);
2257 2549
 			}
2258
-			if ($globalDebug) echo 'Count all callsigns...'."\n";
2550
+			if ($globalDebug) {
2551
+				echo 'Count all callsigns...'."\n";
2552
+			}
2259 2553
 			$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day);
2260 2554
 			foreach ($alldata as $number) {
2261 2555
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2262 2556
 			}
2263
-			if ($globalDebug) echo 'Count all owners...'."\n";
2557
+			if ($globalDebug) {
2558
+				echo 'Count all owners...'."\n";
2559
+			}
2264 2560
 			$alldata = $Spotter->countAllOwners(false,0,$last_update_day);
2265 2561
 			foreach ($alldata as $number) {
2266 2562
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset);
2267 2563
 			}
2268
-			if ($globalDebug) echo 'Count all pilots...'."\n";
2564
+			if ($globalDebug) {
2565
+				echo 'Count all pilots...'."\n";
2566
+			}
2269 2567
 			$alldata = $Spotter->countAllPilots(false,0,$last_update_day);
2270 2568
 			foreach ($alldata as $number) {
2271
-				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') $number['pilot_id'] = $number['pilot_name'];
2569
+				if ($number['pilot_id'] == 0 || $number['pilot_id'] == '') {
2570
+					$number['pilot_id'] = $number['pilot_name'];
2571
+				}
2272 2572
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset);
2273 2573
 			}
2274 2574
 			
2275
-			if ($globalDebug) echo 'Count all departure airports...'."\n";
2575
+			if ($globalDebug) {
2576
+				echo 'Count all departure airports...'."\n";
2577
+			}
2276 2578
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
2277
-			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
2579
+			if ($globalDebug) {
2580
+				echo 'Count all detected departure airports...'."\n";
2581
+			}
2278 2582
 			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
2279
-			if ($globalDebug) echo 'Order departure airports...'."\n";
2583
+			if ($globalDebug) {
2584
+				echo 'Order departure airports...'."\n";
2585
+			}
2280 2586
 			$alldata = array();
2281 2587
 			foreach ($pall as $value) {
2282 2588
 				$icao = $value['airport_departure_icao'];
@@ -2286,7 +2592,9 @@  discard block
 block discarded – undo
2286 2592
 				$icao = $value['airport_departure_icao'];
2287 2593
 				if (isset($alldata[$icao])) {
2288 2594
 					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2289
-				} else $alldata[$icao] = $value;
2595
+				} else {
2596
+					$alldata[$icao] = $value;
2597
+				}
2290 2598
 			}
2291 2599
 			$count = array();
2292 2600
 			foreach ($alldata as $key => $row) {
@@ -2296,11 +2604,17 @@  discard block
 block discarded – undo
2296 2604
 			foreach ($alldata as $number) {
2297 2605
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset);
2298 2606
 			}
2299
-			if ($globalDebug) echo 'Count all arrival airports...'."\n";
2607
+			if ($globalDebug) {
2608
+				echo 'Count all arrival airports...'."\n";
2609
+			}
2300 2610
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
2301
-			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
2611
+			if ($globalDebug) {
2612
+				echo 'Count all detected arrival airports...'."\n";
2613
+			}
2302 2614
 			$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
2303
-			if ($globalDebug) echo 'Order arrival airports...'."\n";
2615
+			if ($globalDebug) {
2616
+				echo 'Order arrival airports...'."\n";
2617
+			}
2304 2618
 			$alldata = array();
2305 2619
 			foreach ($pall as $value) {
2306 2620
 				$icao = $value['airport_arrival_icao'];
@@ -2310,7 +2624,9 @@  discard block
 block discarded – undo
2310 2624
 				$icao = $value['airport_arrival_icao'];
2311 2625
 				if (isset($alldata[$icao])) {
2312 2626
 					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2313
-				} else $alldata[$icao] = $value;
2627
+				} else {
2628
+					$alldata[$icao] = $value;
2629
+				}
2314 2630
 			}
2315 2631
 			$count = array();
2316 2632
 			foreach ($alldata as $key => $row) {
@@ -2321,7 +2637,9 @@  discard block
 block discarded – undo
2321 2637
 				echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset);
2322 2638
 			}
2323 2639
 			if ($Connection->tableExists('countries')) {
2324
-				if ($globalDebug) echo 'Count all flights by countries...'."\n";
2640
+				if ($globalDebug) {
2641
+					echo 'Count all flights by countries...'."\n";
2642
+				}
2325 2643
 				//$SpotterArchive = new SpotterArchive();
2326 2644
 				//$alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day);
2327 2645
 				$Spotter = new Spotter($this->db);
@@ -2332,7 +2650,9 @@  discard block
 block discarded – undo
2332 2650
 			}
2333 2651
 			
2334 2652
 			if (isset($globalAccidents) && $globalAccidents) {
2335
-				if ($globalDebug) echo 'Count fatalities stats...'."\n";
2653
+				if ($globalDebug) {
2654
+					echo 'Count fatalities stats...'."\n";
2655
+				}
2336 2656
 				$Accident = new Accident($this->db);
2337 2657
 				$this->deleteStatsByType('fatalities_byyear');
2338 2658
 				$alldata = $Accident->countFatalitiesByYear();
@@ -2348,48 +2668,68 @@  discard block
 block discarded – undo
2348 2668
 
2349 2669
 			// Add by month using getstat if month finish...
2350 2670
 			//if (date('m',strtotime($last_update_day)) != date('m')) {
2351
-			if ($globalDebug) echo 'Count all flights by months...'."\n";
2671
+			if ($globalDebug) {
2672
+				echo 'Count all flights by months...'."\n";
2673
+			}
2352 2674
 			$last_month = date('Y-m-01 00:00:00', strtotime('-1 month', strtotime($last_update_day)));
2353 2675
 			$filter_last_month = array('since_date' => $last_month);
2354 2676
 			$Spotter = new Spotter($this->db);
2355 2677
 			$alldata = $Spotter->countAllMonths($filter_last_month);
2356 2678
 			$lastyear = false;
2357 2679
 			foreach ($alldata as $number) {
2358
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2680
+				if ($number['year_name'] != date('Y')) {
2681
+					$lastyear = true;
2682
+				}
2359 2683
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2360 2684
 			}
2361
-			if ($globalDebug) echo 'Count all military flights by months...'."\n";
2685
+			if ($globalDebug) {
2686
+				echo 'Count all military flights by months...'."\n";
2687
+			}
2362 2688
 			$alldata = $Spotter->countAllMilitaryMonths($filter_last_month);
2363 2689
 			foreach ($alldata as $number) {
2364 2690
 				$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2365 2691
 			}
2366
-			if ($globalDebug) echo 'Count all owners by months...'."\n";
2692
+			if ($globalDebug) {
2693
+				echo 'Count all owners by months...'."\n";
2694
+			}
2367 2695
 			$alldata = $Spotter->countAllMonthsOwners($filter_last_month);
2368 2696
 			foreach ($alldata as $number) {
2369 2697
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2370 2698
 			}
2371
-			if ($globalDebug) echo 'Count all pilots by months...'."\n";
2699
+			if ($globalDebug) {
2700
+				echo 'Count all pilots by months...'."\n";
2701
+			}
2372 2702
 			$alldata = $Spotter->countAllMonthsPilots($filter_last_month);
2373 2703
 			foreach ($alldata as $number) {
2374 2704
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2375 2705
 			}
2376
-			if ($globalDebug) echo 'Count all airlines by months...'."\n";
2706
+			if ($globalDebug) {
2707
+				echo 'Count all airlines by months...'."\n";
2708
+			}
2377 2709
 			$alldata = $Spotter->countAllMonthsAirlines($filter_last_month);
2378 2710
 			foreach ($alldata as $number) {
2379 2711
 				$this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2380 2712
 			}
2381
-			if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
2713
+			if ($globalDebug) {
2714
+				echo 'Count all aircrafts by months...'."\n";
2715
+			}
2382 2716
 			$alldata = $Spotter->countAllMonthsAircrafts($filter_last_month);
2383 2717
 			foreach ($alldata as $number) {
2384 2718
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2385 2719
 			}
2386
-			if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
2720
+			if ($globalDebug) {
2721
+				echo 'Count all real arrivals by months...'."\n";
2722
+			}
2387 2723
 			$alldata = $Spotter->countAllMonthsRealArrivals($filter_last_month);
2388 2724
 			foreach ($alldata as $number) {
2389 2725
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])));
2390 2726
 			}
2391
-			if ($globalDebug) echo 'Airports data...'."\n";
2392
-			if ($globalDebug) echo '...Departure'."\n";
2727
+			if ($globalDebug) {
2728
+				echo 'Airports data...'."\n";
2729
+			}
2730
+			if ($globalDebug) {
2731
+				echo '...Departure'."\n";
2732
+			}
2393 2733
 			$this->deleteStatAirport('daily');
2394 2734
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
2395 2735
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
@@ -2507,7 +2847,9 @@  discard block
 block discarded – undo
2507 2847
 			// Count by airlines
2508 2848
 			echo '--- Stats by airlines ---'."\n";
2509 2849
 			if ($Connection->tableExists('countries')) {
2510
-				if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n";
2850
+				if ($globalDebug) {
2851
+					echo 'Count all flights by countries by airlines...'."\n";
2852
+				}
2511 2853
 				$SpotterArchive = new SpotterArchive($this->db);
2512 2854
 				//$Spotter = new Spotter($this->db);
2513 2855
 				$alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day);
@@ -2516,37 +2858,53 @@  discard block
 block discarded – undo
2516 2858
 					$this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset);
2517 2859
 				}
2518 2860
 			}
2519
-			if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n";
2861
+			if ($globalDebug) {
2862
+				echo 'Count all aircraft types by airlines...'."\n";
2863
+			}
2520 2864
 			$Spotter = new Spotter($this->db);
2521 2865
 			$alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day);
2522 2866
 			foreach ($alldata as $number) {
2523 2867
 				$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset);
2524 2868
 			}
2525
-			if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n";
2869
+			if ($globalDebug) {
2870
+				echo 'Count all aircraft registrations by airlines...'."\n";
2871
+			}
2526 2872
 			$alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day);
2527 2873
 			foreach ($alldata as $number) {
2528 2874
 				$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset);
2529 2875
 			}
2530
-			if ($globalDebug) echo 'Count all callsigns by airlines...'."\n";
2876
+			if ($globalDebug) {
2877
+				echo 'Count all callsigns by airlines...'."\n";
2878
+			}
2531 2879
 			$alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day);
2532 2880
 			foreach ($alldata as $number) {
2533 2881
 				$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset);
2534 2882
 			}
2535
-			if ($globalDebug) echo 'Count all owners by airlines...'."\n";
2883
+			if ($globalDebug) {
2884
+				echo 'Count all owners by airlines...'."\n";
2885
+			}
2536 2886
 			$alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day);
2537 2887
 			foreach ($alldata as $number) {
2538 2888
 				$this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset);
2539 2889
 			}
2540
-			if ($globalDebug) echo 'Count all pilots by airlines...'."\n";
2890
+			if ($globalDebug) {
2891
+				echo 'Count all pilots by airlines...'."\n";
2892
+			}
2541 2893
 			$alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day);
2542 2894
 			foreach ($alldata as $number) {
2543 2895
 				$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset);
2544 2896
 			}
2545
-			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
2897
+			if ($globalDebug) {
2898
+				echo 'Count all departure airports by airlines...'."\n";
2899
+			}
2546 2900
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
2547
-			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
2901
+			if ($globalDebug) {
2902
+				echo 'Count all detected departure airports by airlines...'."\n";
2903
+			}
2548 2904
 			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
2549
-			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
2905
+			if ($globalDebug) {
2906
+				echo 'Order detected departure airports by airlines...'."\n";
2907
+			}
2550 2908
 			//$alldata = array();
2551 2909
 			foreach ($dall as $value) {
2552 2910
 				$icao = $value['airport_departure_icao'];
@@ -2567,11 +2925,17 @@  discard block
 block discarded – undo
2567 2925
 			foreach ($alldata as $number) {
2568 2926
 				echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset);
2569 2927
 			}
2570
-			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
2928
+			if ($globalDebug) {
2929
+				echo 'Count all arrival airports by airlines...'."\n";
2930
+			}
2571 2931
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
2572
-			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
2932
+			if ($globalDebug) {
2933
+				echo 'Count all detected arrival airports by airlines...'."\n";
2934
+			}
2573 2935
 			$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
2574
-			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
2936
+			if ($globalDebug) {
2937
+				echo 'Order arrival airports by airlines...'."\n";
2938
+			}
2575 2939
 			//$alldata = array();
2576 2940
 			foreach ($dall as $value) {
2577 2941
 				$icao = $value['airport_arrival_icao'];
@@ -2590,37 +2954,53 @@  discard block
 block discarded – undo
2590 2954
 			}
2591 2955
 			$alldata = $pall;
2592 2956
 			foreach ($alldata as $number) {
2593
-				if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2957
+				if ($number['airline_icao'] != '') {
2958
+					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset);
2959
+				}
2960
+			}
2961
+			if ($globalDebug) {
2962
+				echo 'Count all flights by months by airlines...'."\n";
2594 2963
 			}
2595
-			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
2596 2964
 			$Spotter = new Spotter($this->db);
2597 2965
 			$alldata = $Spotter->countAllMonthsByAirlines($filter_last_month);
2598 2966
 			$lastyear = false;
2599 2967
 			foreach ($alldata as $number) {
2600
-				if ($number['year_name'] != date('Y')) $lastyear = true;
2968
+				if ($number['year_name'] != date('Y')) {
2969
+					$lastyear = true;
2970
+				}
2601 2971
 				$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2602 2972
 			}
2603
-			if ($globalDebug) echo 'Count all owners by months by airlines...'."\n";
2973
+			if ($globalDebug) {
2974
+				echo 'Count all owners by months by airlines...'."\n";
2975
+			}
2604 2976
 			$alldata = $Spotter->countAllMonthsOwnersByAirlines($filter_last_month);
2605 2977
 			foreach ($alldata as $number) {
2606 2978
 				$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2607 2979
 			}
2608
-			if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n";
2980
+			if ($globalDebug) {
2981
+				echo 'Count all pilots by months by airlines...'."\n";
2982
+			}
2609 2983
 			$alldata = $Spotter->countAllMonthsPilotsByAirlines($filter_last_month);
2610 2984
 			foreach ($alldata as $number) {
2611 2985
 				$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2612 2986
 			}
2613
-			if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n";
2987
+			if ($globalDebug) {
2988
+				echo 'Count all aircrafts by months by airlines...'."\n";
2989
+			}
2614 2990
 			$alldata = $Spotter->countAllMonthsAircraftsByAirlines($filter_last_month);
2615 2991
 			foreach ($alldata as $number) {
2616 2992
 				$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2617 2993
 			}
2618
-			if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n";
2994
+			if ($globalDebug) {
2995
+				echo 'Count all real arrivals by months by airlines...'."\n";
2996
+			}
2619 2997
 			$alldata = $Spotter->countAllMonthsRealArrivalsByAirlines($filter_last_month);
2620 2998
 			foreach ($alldata as $number) {
2621 2999
 				$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']);
2622 3000
 			}
2623
-			if ($globalDebug) echo '...Departure'."\n";
3001
+			if ($globalDebug) {
3002
+				echo '...Departure'."\n";
3003
+			}
2624 3004
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
2625 3005
 			$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
2626 3006
 			foreach ($dall as $value) {
@@ -2643,7 +3023,9 @@  discard block
 block discarded – undo
2643 3023
 			foreach ($alldata as $number) {
2644 3024
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']);
2645 3025
 			}
2646
-			if ($globalDebug) echo '...Arrival'."\n";
3026
+			if ($globalDebug) {
3027
+				echo '...Arrival'."\n";
3028
+			}
2647 3029
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
2648 3030
 			$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
2649 3031
 			foreach ($dall as $value) {
@@ -2667,13 +3049,19 @@  discard block
 block discarded – undo
2667 3049
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']);
2668 3050
 			}
2669 3051
 
2670
-			if ($globalDebug) echo 'Flights data...'."\n";
2671
-			if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n";
3052
+			if ($globalDebug) {
3053
+				echo 'Flights data...'."\n";
3054
+			}
3055
+			if ($globalDebug) {
3056
+				echo '-> countAllDatesLastMonth...'."\n";
3057
+			}
2672 3058
 			$alldata = $Spotter->countAllDatesLastMonthByAirlines($filter_last_month);
2673 3059
 			foreach ($alldata as $number) {
2674 3060
 				$this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']);
2675 3061
 			}
2676
-			if ($globalDebug) echo '-> countAllDates...'."\n";
3062
+			if ($globalDebug) {
3063
+				echo '-> countAllDates...'."\n";
3064
+			}
2677 3065
 			//$previousdata = $this->countAllDatesByAirlines();
2678 3066
 			$alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines($filter_last_month));
2679 3067
 			$values = array();
@@ -2686,14 +3074,18 @@  discard block
 block discarded – undo
2686 3074
 				$this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']);
2687 3075
 			}
2688 3076
 			
2689
-			if ($globalDebug) echo '-> countAllHours...'."\n";
3077
+			if ($globalDebug) {
3078
+				echo '-> countAllHours...'."\n";
3079
+			}
2690 3080
 			$alldata = $Spotter->countAllHoursByAirlines('hour',$filter_last_month);
2691 3081
 			foreach ($alldata as $number) {
2692 3082
 				$this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']);
2693 3083
 			}
2694 3084
 
2695 3085
 			// Stats by filters
2696
-			if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array();
3086
+			if (!isset($globalStatsFilters) || $globalStatsFilters == '') {
3087
+				$globalStatsFilters = array();
3088
+			}
2697 3089
 			foreach ($globalStatsFilters as $name => $filter) {
2698 3090
 				if (!empty($filter)) {
2699 3091
 					//$filter_name = $filter['name'];
@@ -2701,7 +3093,9 @@  discard block
 block discarded – undo
2701 3093
 					$reset = false;
2702 3094
 					$last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name);
2703 3095
 					if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) {
2704
-						if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3096
+						if ($globalDebug) {
3097
+							echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n";
3098
+						}
2705 3099
 						$this->deleteOldStats($filter_name);
2706 3100
 						unset($last_update);
2707 3101
 					}
@@ -2718,39 +3112,55 @@  discard block
 block discarded – undo
2718 3112
 						$reset = true;
2719 3113
 					}
2720 3114
 					// Count by filter
2721
-					if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n";
3115
+					if ($globalDebug) {
3116
+						echo '--- Stats for filter '.$filter_name.' ---'."\n";
3117
+					}
2722 3118
 					$Spotter = new Spotter($this->db);
2723
-					if ($globalDebug) echo 'Count all aircraft types...'."\n";
3119
+					if ($globalDebug) {
3120
+						echo 'Count all aircraft types...'."\n";
3121
+					}
2724 3122
 					$alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter);
2725 3123
 					foreach ($alldata as $number) {
2726 3124
 						$this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'',$filter_name,$reset);
2727 3125
 					}
2728
-					if ($globalDebug) echo 'Count all airlines...'."\n";
3126
+					if ($globalDebug) {
3127
+						echo 'Count all airlines...'."\n";
3128
+					}
2729 3129
 					$alldata = $Spotter->countAllAirlines(false,0,$last_update_day,$filter);
2730 3130
 					foreach ($alldata as $number) {
2731 3131
 						$this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],$filter_name,$reset);
2732 3132
 					}
2733
-					if ($globalDebug) echo 'Count all aircraft registrations...'."\n";
3133
+					if ($globalDebug) {
3134
+						echo 'Count all aircraft registrations...'."\n";
3135
+					}
2734 3136
 					$alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day,$filter);
2735 3137
 					foreach ($alldata as $number) {
2736 3138
 						$this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'',$filter_name,$reset);
2737 3139
 					}
2738
-					if ($globalDebug) echo 'Count all callsigns...'."\n";
3140
+					if ($globalDebug) {
3141
+						echo 'Count all callsigns...'."\n";
3142
+					}
2739 3143
 					$alldata = $Spotter->countAllCallsigns(false,0,$last_update_day,$filter);
2740 3144
 					foreach ($alldata as $number) {
2741 3145
 						$this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],'',$filter_name,$reset);
2742 3146
 					}
2743
-					if ($globalDebug) echo 'Count all owners...'."\n";
3147
+					if ($globalDebug) {
3148
+						echo 'Count all owners...'."\n";
3149
+					}
2744 3150
 					$alldata = $Spotter->countAllOwners(false,0,$last_update_day,$filter);
2745 3151
 					foreach ($alldata as $number) {
2746 3152
 						$this->addStatOwner($number['owner_name'],$number['owner_count'],'',$filter_name,$reset);
2747 3153
 					}
2748
-					if ($globalDebug) echo 'Count all pilots...'."\n";
3154
+					if ($globalDebug) {
3155
+						echo 'Count all pilots...'."\n";
3156
+					}
2749 3157
 					$alldata = $Spotter->countAllPilots(false,0,$last_update_day,$filter);
2750 3158
 					foreach ($alldata as $number) {
2751 3159
 						$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
2752 3160
 					}
2753
-					if ($globalDebug) echo 'Count departure airports...'."\n";
3161
+					if ($globalDebug) {
3162
+						echo 'Count departure airports...'."\n";
3163
+					}
2754 3164
 					$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
2755 3165
 					$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
2756 3166
 					$alldata = array();
@@ -2762,7 +3172,9 @@  discard block
 block discarded – undo
2762 3172
 						$icao = $value['airport_departure_icao'];
2763 3173
 						if (isset($alldata[$icao])) {
2764 3174
 							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
2765
-						} else $alldata[$icao] = $value;
3175
+						} else {
3176
+							$alldata[$icao] = $value;
3177
+						}
2766 3178
 					}
2767 3179
 					$count = array();
2768 3180
 					foreach ($alldata as $key => $row) {
@@ -2772,7 +3184,9 @@  discard block
 block discarded – undo
2772 3184
 					foreach ($alldata as $number) {
2773 3185
 						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
2774 3186
 					}
2775
-					if ($globalDebug) echo 'Count all arrival airports...'."\n";
3187
+					if ($globalDebug) {
3188
+						echo 'Count all arrival airports...'."\n";
3189
+					}
2776 3190
 					$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
2777 3191
 					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
2778 3192
 					$alldata = array();
@@ -2784,7 +3198,9 @@  discard block
 block discarded – undo
2784 3198
 						$icao = $value['airport_arrival_icao'];
2785 3199
 						if (isset($alldata[$icao])) {
2786 3200
 							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
2787
-						} else $alldata[$icao] = $value;
3201
+						} else {
3202
+							$alldata[$icao] = $value;
3203
+						}
2788 3204
 					}
2789 3205
 					$count = array();
2790 3206
 					foreach ($alldata as $key => $row) {
@@ -2794,35 +3210,49 @@  discard block
 block discarded – undo
2794 3210
 					foreach ($alldata as $number) {
2795 3211
 						echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
2796 3212
 					}
2797
-					if ($globalDebug) echo 'Count all months...'."\n";
3213
+					if ($globalDebug) {
3214
+						echo 'Count all months...'."\n";
3215
+					}
2798 3216
 					$Spotter = new Spotter($this->db);
2799 3217
 					$alldata = $Spotter->countAllMonths($filter);
2800 3218
 					$lastyear = false;
2801 3219
 					foreach ($alldata as $number) {
2802
-						if ($number['year_name'] != date('Y')) $lastyear = true;
3220
+						if ($number['year_name'] != date('Y')) {
3221
+							$lastyear = true;
3222
+						}
2803 3223
 						$this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2804 3224
 					}
2805
-					if ($globalDebug) echo 'Count all owners by months...'."\n";
3225
+					if ($globalDebug) {
3226
+						echo 'Count all owners by months...'."\n";
3227
+					}
2806 3228
 					$alldata = $Spotter->countAllMonthsOwners($filter);
2807 3229
 					foreach ($alldata as $number) {
2808 3230
 						$this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2809 3231
 					}
2810
-					if ($globalDebug) echo 'Count all pilots by months...'."\n";
3232
+					if ($globalDebug) {
3233
+						echo 'Count all pilots by months...'."\n";
3234
+					}
2811 3235
 					$alldata = $Spotter->countAllMonthsPilots($filter);
2812 3236
 					foreach ($alldata as $number) {
2813 3237
 						$this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2814 3238
 					}
2815
-					if ($globalDebug) echo 'Count all military by months...'."\n";
3239
+					if ($globalDebug) {
3240
+						echo 'Count all military by months...'."\n";
3241
+					}
2816 3242
 					$alldata = $Spotter->countAllMilitaryMonths($filter);
2817 3243
 					foreach ($alldata as $number) {
2818 3244
 						$this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2819 3245
 					}
2820
-					if ($globalDebug) echo 'Count all aircrafts by months...'."\n";
3246
+					if ($globalDebug) {
3247
+						echo 'Count all aircrafts by months...'."\n";
3248
+					}
2821 3249
 					$alldata = $Spotter->countAllMonthsAircrafts($filter);
2822 3250
 				    	foreach ($alldata as $number) {
2823 3251
 			    			$this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
2824 3252
 					}
2825
-					if ($globalDebug) echo 'Count all real arrivals by months...'."\n";
3253
+					if ($globalDebug) {
3254
+						echo 'Count all real arrivals by months...'."\n";
3255
+					}
2826 3256
 					$alldata = $Spotter->countAllMonthsRealArrivals($filter);
2827 3257
 					foreach ($alldata as $number) {
2828 3258
 						$this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name);
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +191 added lines, -68 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -69,8 +73,11 @@  discard block
 block discarded – undo
69 73
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
70 74
 			}
71 75
 		}
72
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
73
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
76
+		if ($filter_query_where == '' && $where) {
77
+			$filter_query_where = ' WHERE';
78
+		} elseif ($filter_query_where != '' && $and) {
79
+			$filter_query_where .= ' AND';
80
+		}
74 81
 		if ($filter_query_where != '') {
75 82
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
76 83
 		}
@@ -124,32 +131,54 @@  discard block
 block discarded – undo
124 131
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
125 132
 			} elseif (isset($row['spotter_archive_output_id'])) {
126 133
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
127
-			*/} 
128
-			elseif (isset($row['marineid'])) {
134
+			*/} elseif (isset($row['marineid'])) {
129 135
 				$temp_array['marine_id'] = $row['marineid'];
130 136
 			} else {
131 137
 				$temp_array['marine_id'] = '';
132 138
 			}
133
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
134
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
137
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
139
+			if (isset($row['fammarine_id'])) {
140
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
141
+			}
142
+			if (isset($row['mmsi'])) {
143
+				$temp_array['mmsi'] = $row['mmsi'];
144
+			}
145
+			if (isset($row['type'])) {
146
+				$temp_array['type'] = $row['type'];
147
+			}
148
+			if (isset($row['type_id'])) {
149
+				$temp_array['type_id'] = $row['type_id'];
150
+			}
151
+			if (isset($row['ident'])) {
152
+				$temp_array['ident'] = $row['ident'];
153
+			}
154
+			if (isset($row['latitude'])) {
155
+				$temp_array['latitude'] = $row['latitude'];
156
+			}
157
+			if (isset($row['longitude'])) {
158
+				$temp_array['longitude'] = $row['longitude'];
159
+			}
160
+			if (isset($row['format_source'])) {
161
+				$temp_array['format_source'] = $row['format_source'];
162
+			}
141 163
 			if (isset($row['heading'])) {
142 164
 				$temp_array['heading'] = $row['heading'];
143 165
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 172
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 173
 
148 174
 			if($temp_array['mmsi'] != "")
149 175
 			{
150 176
 				$Image = new Image($this->db);
151
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
152
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
177
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
178
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
179
+				} else {
180
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
181
+				}
153 182
 				unset($Image);
154 183
 				if (count($image_array) > 0) {
155 184
 					$temp_array['image'] = $image_array[0]['image'];
@@ -201,13 +230,21 @@  discard block
 block discarded – undo
201 230
 			}
202 231
 			
203 232
 			$fromsource = NULL;
204
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
205
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
206
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
233
+			if (isset($row['source_name']) && $row['source_name'] != '') {
234
+				$temp_array['source_name'] = $row['source_name'];
235
+			}
236
+			if (isset($row['over_country']) && $row['over_country'] != '') {
237
+				$temp_array['over_country'] = $row['over_country'];
238
+			}
239
+			if (isset($row['distance']) && $row['distance'] != '') {
240
+				$temp_array['distance'] = $row['distance'];
241
+			}
207 242
 			$temp_array['query_number_rows'] = $num_rows;
208 243
 			$spotter_array[] = $temp_array;
209 244
 		}
210
-		if ($num_rows == 0) return array();
245
+		if ($num_rows == 0) {
246
+			return array();
247
+		}
211 248
 		$spotter_array[0]['query_number_rows'] = $num_rows;
212 249
 		return $spotter_array;
213 250
 	}	
@@ -233,8 +270,12 @@  discard block
 block discarded – undo
233 270
 			{
234 271
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
235 272
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
236
-			} else $limit_query = "";
237
-		} else $limit_query = "";
273
+			} else {
274
+				$limit_query = "";
275
+			}
276
+		} else {
277
+			$limit_query = "";
278
+		}
238 279
 		if ($sort != "")
239 280
 		{
240 281
 			$search_orderby_array = $this->getOrderBy();
@@ -258,7 +299,9 @@  discard block
 block discarded – undo
258 299
 		global $global_query;
259 300
 		
260 301
 		date_default_timezone_set('UTC');
261
-		if ($id == '') return array();
302
+		if ($id == '') {
303
+			return array();
304
+		}
262 305
 		$additional_query = "marine_output.fammarine_id = :id";
263 306
 		$query_values = array(':id' => $id);
264 307
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -401,8 +444,11 @@  discard block
 block discarded – undo
401 444
 		$query .= " ORDER BY marine_output.source_name ASC";
402 445
 
403 446
 		$sth = $this->db->prepare($query);
404
-		if (!empty($query_values)) $sth->execute($query_values);
405
-		else $sth->execute();
447
+		if (!empty($query_values)) {
448
+			$sth->execute($query_values);
449
+		} else {
450
+			$sth->execute();
451
+		}
406 452
 
407 453
 		$source_array = array();
408 454
 		$temp_array = array();
@@ -457,8 +503,11 @@  discard block
 block discarded – undo
457 503
 		$sth = $this->db->prepare($query);
458 504
 		$sth->execute(array(':mmsi' => $mmsi));
459 505
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
460
-		if (isset($result[0])) return $result[0];
461
-		else return array();
506
+		if (isset($result[0])) {
507
+			return $result[0];
508
+		} else {
509
+			return array();
510
+		}
462 511
 	}
463 512
 
464 513
 	/*
@@ -474,7 +523,9 @@  discard block
 block discarded – undo
474 523
 			date_default_timezone_set($globalTimezone);
475 524
 			$datetime = new DateTime();
476 525
 			$offset = $datetime->format('P');
477
-		} else $offset = '+00:00';
526
+		} else {
527
+			$offset = '+00:00';
528
+		}
478 529
 
479 530
 		if ($globalDBdriver == 'mysql') {
480 531
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -704,9 +755,15 @@  discard block
 block discarded – undo
704 755
             		$latitude = 0;
705 756
             		$longitude = 0;
706 757
             	}
707
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
708
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
709
-                if ($arrival_date == '') $arrival_date = NULL;
758
+                if ($heading == '' || $Common->isInteger($heading) === false) {
759
+                	$heading = 0;
760
+                }
761
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
762
+                	$groundspeed = 0;
763
+                }
764
+                if ($arrival_date == '') {
765
+                	$arrival_date = NULL;
766
+                }
710 767
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
711 768
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
712 769
 
@@ -814,7 +871,9 @@  discard block
 block discarded – undo
814 871
 		global $globalDBdriver, $globalArchive;
815 872
 		//$filter_query = $this->getFilter($filters,true,true);
816 873
 		$Connection= new Connection($this->db);
817
-		if (!$Connection->tableExists('countries')) return array();
874
+		if (!$Connection->tableExists('countries')) {
875
+			return array();
876
+		}
818 877
 		require_once('class.SpotterLive.php');
819 878
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
820 879
 			$MarineLive = new MarineLive($this->db);
@@ -858,7 +917,9 @@  discard block
 block discarded – undo
858 917
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
859 918
 		}
860 919
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
861
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
920
+		if ($limit) {
921
+			$query .= " LIMIT 10 OFFSET 0";
922
+		}
862 923
 
863 924
 		$sth = $this->db->prepare($query);
864 925
 		$sth->execute();
@@ -892,12 +953,18 @@  discard block
 block discarded – undo
892 953
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
893 954
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
894 955
 		 if ($olderthanmonths > 0) {
895
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
896
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
956
+			if ($globalDBdriver == 'mysql') {
957
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
958
+			} else {
959
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
960
+			}
897 961
 		}
898 962
 		if ($sincedate != '') {
899
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
900
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
963
+			if ($globalDBdriver == 'mysql') {
964
+				$query .= " AND marine_output.date > '".$sincedate."'";
965
+			} else {
966
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
967
+			}
901 968
 		}
902 969
 		$query_values = array();
903 970
 		if ($year != '') {
@@ -928,7 +995,9 @@  discard block
 block discarded – undo
928 995
 			}
929 996
 		}
930 997
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
931
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
998
+		if ($limit) {
999
+			$query .= " LIMIT 10 OFFSET 0";
1000
+		}
932 1001
       		
933 1002
 		$sth = $this->db->prepare($query);
934 1003
 		$sth->execute($query_values);
@@ -963,7 +1032,9 @@  discard block
 block discarded – undo
963 1032
 			date_default_timezone_set($globalTimezone);
964 1033
 			$datetime = new DateTime();
965 1034
 			$offset = $datetime->format('P');
966
-		} else $offset = '+00:00';
1035
+		} else {
1036
+			$offset = '+00:00';
1037
+		}
967 1038
 
968 1039
 		if ($globalDBdriver == 'mysql') {
969 1040
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1084,9 @@  discard block
 block discarded – undo
1013 1084
 			date_default_timezone_set($globalTimezone);
1014 1085
 			$datetime = new DateTime();
1015 1086
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1087
+		} else {
1088
+			$offset = '+00:00';
1089
+		}
1017 1090
 		$filter_query = $this->getFilter($filters,true,true);
1018 1091
 		if ($globalDBdriver == 'mysql') {
1019 1092
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1059,7 +1132,9 @@  discard block
 block discarded – undo
1059 1132
 			date_default_timezone_set($globalTimezone);
1060 1133
 			$datetime = new DateTime();
1061 1134
 			$offset = $datetime->format('P');
1062
-		} else $offset = '+00:00';
1135
+		} else {
1136
+			$offset = '+00:00';
1137
+		}
1063 1138
 		$filter_query = $this->getFilter($filters,true,true);
1064 1139
 		if ($globalDBdriver == 'mysql') {
1065 1140
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1107,7 +1182,9 @@  discard block
 block discarded – undo
1107 1182
 			date_default_timezone_set($globalTimezone);
1108 1183
 			$datetime = new DateTime();
1109 1184
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1185
+		} else {
1186
+			$offset = '+00:00';
1187
+		}
1111 1188
 
1112 1189
 		if ($globalDBdriver == 'mysql') {
1113 1190
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1156,7 +1233,9 @@  discard block
 block discarded – undo
1156 1233
 			date_default_timezone_set($globalTimezone);
1157 1234
 			$datetime = new DateTime();
1158 1235
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1236
+		} else {
1237
+			$offset = '+00:00';
1238
+		}
1160 1239
 		$filter_query = $this->getFilter($filters,true,true);
1161 1240
 		if ($globalDBdriver == 'mysql') {
1162 1241
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1205,7 +1284,9 @@  discard block
 block discarded – undo
1205 1284
 			date_default_timezone_set($globalTimezone);
1206 1285
 			$datetime = new DateTime();
1207 1286
 			$offset = $datetime->format('P');
1208
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1209 1290
 
1210 1291
 		$orderby_sql = '';
1211 1292
 		if ($orderby == "hour")
@@ -1274,7 +1355,9 @@  discard block
 block discarded – undo
1274 1355
 			date_default_timezone_set($globalTimezone);
1275 1356
 			$datetime = new DateTime($date);
1276 1357
 			$offset = $datetime->format('P');
1277
-		} else $offset = '+00:00';
1358
+		} else {
1359
+			$offset = '+00:00';
1360
+		}
1278 1361
 
1279 1362
 		if ($globalDBdriver == 'mysql') {
1280 1363
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1322,7 +1405,9 @@  discard block
 block discarded – undo
1322 1405
 			date_default_timezone_set($globalTimezone);
1323 1406
 			$datetime = new DateTime();
1324 1407
 			$offset = $datetime->format('P');
1325
-		} else $offset = '+00:00';
1408
+		} else {
1409
+			$offset = '+00:00';
1410
+		}
1326 1411
 
1327 1412
 		if ($globalDBdriver == 'mysql') {
1328 1413
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1387,8 +1472,11 @@  discard block
 block discarded – undo
1387 1472
 				$query_values = array_merge($query_values,array(':month' => $month));
1388 1473
 			}
1389 1474
 		}
1390
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1391
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1475
+		if (empty($query_values)) {
1476
+			$queryi .= $this->getFilter($filters);
1477
+		} else {
1478
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1479
+		}
1392 1480
 		
1393 1481
 		$sth = $this->db->prepare($queryi);
1394 1482
 		$sth->execute($query_values);
@@ -1425,8 +1513,11 @@  discard block
 block discarded – undo
1425 1513
 				$query_values = array_merge($query_values,array(':month' => $month));
1426 1514
 			}
1427 1515
 		}
1428
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1429
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1516
+		if (empty($query_values)) {
1517
+			$queryi .= $this->getFilter($filters);
1518
+		} else {
1519
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1520
+		}
1430 1521
 		
1431 1522
 		$sth = $this->db->prepare($queryi);
1432 1523
 		$sth->execute($query_values);
@@ -1448,7 +1539,9 @@  discard block
 block discarded – undo
1448 1539
 			date_default_timezone_set($globalTimezone);
1449 1540
 			$datetime = new DateTime();
1450 1541
 			$offset = $datetime->format('P');
1451
-		} else $offset = '+00:00';
1542
+		} else {
1543
+			$offset = '+00:00';
1544
+		}
1452 1545
 
1453 1546
 		if ($globalDBdriver == 'mysql') {
1454 1547
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1552,7 +1645,9 @@  discard block
 block discarded – undo
1552 1645
 	*/
1553 1646
 	public function parseDirection($direction = 0)
1554 1647
 	{
1555
-		if ($direction == '') $direction = 0;
1648
+		if ($direction == '') {
1649
+			$direction = 0;
1650
+		}
1556 1651
 		$direction_array = array();
1557 1652
 		$temp_array = array();
1558 1653
 
@@ -1641,7 +1736,9 @@  discard block
 block discarded – undo
1641 1736
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1642 1737
 	
1643 1738
 		$Connection = new Connection($this->db);
1644
-		if (!$Connection->tableExists('countries')) return '';
1739
+		if (!$Connection->tableExists('countries')) {
1740
+			return '';
1741
+		}
1645 1742
 	
1646 1743
 		try {
1647 1744
 			/*
@@ -1661,9 +1758,13 @@  discard block
 block discarded – undo
1661 1758
 			$sth->closeCursor();
1662 1759
 			if (count($row) > 0) {
1663 1760
 				return $row;
1664
-			} else return '';
1761
+			} else {
1762
+				return '';
1763
+			}
1665 1764
 		} catch (PDOException $e) {
1666
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1765
+			if (isset($globalDebug) && $globalDebug) {
1766
+				echo 'Error : '.$e->getMessage()."\n";
1767
+			}
1667 1768
 			return '';
1668 1769
 		}
1669 1770
 	
@@ -1681,7 +1782,9 @@  discard block
 block discarded – undo
1681 1782
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1682 1783
 	
1683 1784
 		$Connection = new Connection($this->db);
1684
-		if (!$Connection->tableExists('countries')) return '';
1785
+		if (!$Connection->tableExists('countries')) {
1786
+			return '';
1787
+		}
1685 1788
 	
1686 1789
 		try {
1687 1790
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1693,9 +1796,13 @@  discard block
 block discarded – undo
1693 1796
 			$sth->closeCursor();
1694 1797
 			if (count($row) > 0) {
1695 1798
 				return $row;
1696
-			} else return '';
1799
+			} else {
1800
+				return '';
1801
+			}
1697 1802
 		} catch (PDOException $e) {
1698
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1803
+			if (isset($globalDebug) && $globalDebug) {
1804
+				echo 'Error : '.$e->getMessage()."\n";
1805
+			}
1699 1806
 			return '';
1700 1807
 		}
1701 1808
 	
@@ -1713,7 +1820,9 @@  discard block
 block discarded – undo
1713 1820
 	{
1714 1821
 		global $globalBitlyAccessToken;
1715 1822
 		
1716
-		if ($globalBitlyAccessToken == '') return $url;
1823
+		if ($globalBitlyAccessToken == '') {
1824
+			return $url;
1825
+		}
1717 1826
         
1718 1827
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1719 1828
 		
@@ -1789,7 +1898,9 @@  discard block
 block discarded – undo
1789 1898
 			}
1790 1899
 		}
1791 1900
 		$query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC";
1792
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1901
+		if ($limit) {
1902
+			$query .= " LIMIT 10 OFFSET 0";
1903
+		}
1793 1904
 		$sth = $this->db->prepare($query);
1794 1905
 		$sth->execute($query_values);
1795 1906
 		$marine_array = array();
@@ -1826,9 +1937,15 @@  discard block
 block discarded – undo
1826 1937
 				foreach ($q_array as $q_item){
1827 1938
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1828 1939
 					$additional_query .= " AND (";
1829
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1830
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1831
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
1940
+					if (is_int($q_item)) {
1941
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1942
+					}
1943
+					if (is_int($q_item)) {
1944
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1945
+					}
1946
+					if (is_int($q_item)) {
1947
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
1948
+					}
1832 1949
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
1833 1950
 					$additional_query .= ")";
1834 1951
 				}
@@ -1876,7 +1993,9 @@  discard block
 block discarded – undo
1876 1993
 				date_default_timezone_set($globalTimezone);
1877 1994
 				$datetime = new DateTime();
1878 1995
 				$offset = $datetime->format('P');
1879
-			} else $offset = '+00:00';
1996
+			} else {
1997
+				$offset = '+00:00';
1998
+			}
1880 1999
 			if ($date_array[1] != "")
1881 2000
 			{
1882 2001
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1903,8 +2022,12 @@  discard block
 block discarded – undo
1903 2022
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1904 2023
 			{
1905 2024
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1906
-			} else $limit_query = "";
1907
-		} else $limit_query = "";
2025
+			} else {
2026
+				$limit_query = "";
2027
+			}
2028
+		} else {
2029
+			$limit_query = "";
2030
+		}
1908 2031
 		if ($sort != "")
1909 2032
 		{
1910 2033
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 	public function __construct($dbc = null) {
11 11
 		$Connection = new Connection($dbc);
12 12
 		$this->db = $Connection->db();
13
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
13
+		if ($this->db === null) {
14
+			die('Error: No DB connection. (Tracker)');
15
+		}
14 16
 	}
15 17
 
16 18
 	/**
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 		if (isset($filter[0]['source'])) {
33 35
 			$filters = array_merge($filters,$filter);
34 36
 		}
35
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
37
+		if (is_array($globalFilter)) {
38
+			$filter = array_merge($filter,$globalFilter);
39
+		}
36 40
 		$filter_query_join = '';
37 41
 		$filter_query_where = '';
38 42
 		foreach($filters as $flt) {
@@ -71,8 +75,11 @@  discard block
 block discarded – undo
71 75
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 76
 			}
73 77
 		}
74
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
75
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
78
+		if ($filter_query_where == '' && $where) {
79
+			$filter_query_where = ' WHERE';
80
+		} elseif ($filter_query_where != '' && $and) {
81
+			$filter_query_where .= ' AND';
82
+		}
76 83
 		if ($filter_query_where != '') {
77 84
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78 85
 		}
@@ -126,26 +133,43 @@  discard block
 block discarded – undo
126 133
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
127 134
 			} elseif (isset($row['tracker_archive_output_id'])) {
128 135
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
129
-			*/} 
130
-			elseif (isset($row['trackerid'])) {
136
+			*/} elseif (isset($row['trackerid'])) {
131 137
 				$temp_array['trackerid'] = $row['trackerid'];
132 138
 			} else {
133 139
 				$temp_array['trackerid'] = '';
134 140
 			}
135
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
137
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
141
+			if (isset($row['famtrackid'])) {
142
+				$temp_array['famtrackid'] = $row['famtrackid'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
147
+			if (isset($row['comment'])) {
148
+				$temp_array['comment'] = $row['comment'];
149
+			}
138 150
 			$temp_array['ident'] = $row['ident'];
139
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
140
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
141
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
160
+			if (isset($row['altitude'])) {
161
+				$temp_array['altitude'] = $row['altitude'];
162
+			}
143 163
 			if (isset($row['heading'])) {
144 164
 				$temp_array['heading'] = $row['heading'];
145 165
 				$heading_direction = $this->parseDirection($row['heading']);
146
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
166
+				if (isset($heading_direction[0]['direction_fullname'])) {
167
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
168
+				}
169
+			}
170
+			if (isset($row['ground_speed'])) {
171
+				$temp_array['ground_speed'] = $row['ground_speed'];
147 172
 			}
148
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
149 173
 			
150 174
 			if (isset($row['date'])) {
151 175
 				$dateArray = $this->parseDateString($row['date']);
@@ -188,13 +212,21 @@  discard block
 block discarded – undo
188 212
 			}
189 213
 			
190 214
 			$fromsource = NULL;
191
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
192
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
193
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
215
+			if (isset($row['source_name']) && $row['source_name'] != '') {
216
+				$temp_array['source_name'] = $row['source_name'];
217
+			}
218
+			if (isset($row['over_country']) && $row['over_country'] != '') {
219
+				$temp_array['over_country'] = $row['over_country'];
220
+			}
221
+			if (isset($row['distance']) && $row['distance'] != '') {
222
+				$temp_array['distance'] = $row['distance'];
223
+			}
194 224
 			$temp_array['query_number_rows'] = $num_rows;
195 225
 			$tracker_array[] = $temp_array;
196 226
 		}
197
-		if ($num_rows == 0) return array();
227
+		if ($num_rows == 0) {
228
+			return array();
229
+		}
198 230
 		$tracker_array[0]['query_number_rows'] = $num_rows;
199 231
 		return $tracker_array;
200 232
 	}	
@@ -225,8 +257,12 @@  discard block
 block discarded – undo
225 257
 			{
226 258
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
227 259
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
228
-			} else $limit_query = "";
229
-		} else $limit_query = "";
260
+			} else {
261
+				$limit_query = "";
262
+			}
263
+		} else {
264
+			$limit_query = "";
265
+		}
230 266
 		
231 267
 		if ($sort != "")
232 268
 		{
@@ -254,7 +290,9 @@  discard block
 block discarded – undo
254 290
 		global $global_query;
255 291
 		
256 292
 		date_default_timezone_set('UTC');
257
-		if ($id == '') return array();
293
+		if ($id == '') {
294
+			return array();
295
+		}
258 296
 		$additional_query = "tracker_output.famtrackid = :id";
259 297
 		$query_values = array(':id' => $id);
260 298
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -397,8 +435,11 @@  discard block
 block discarded – undo
397 435
 		$query .= " ORDER BY tracker_output.source_name ASC";
398 436
 
399 437
 		$sth = $this->db->prepare($query);
400
-		if (!empty($query_values)) $sth->execute($query_values);
401
-		else $sth->execute();
438
+		if (!empty($query_values)) {
439
+			$sth->execute($query_values);
440
+		} else {
441
+			$sth->execute();
442
+		}
402 443
 
403 444
 		$source_array = array();
404 445
 		$temp_array = array();
@@ -453,7 +494,9 @@  discard block
 block discarded – undo
453 494
 			date_default_timezone_set($globalTimezone);
454 495
 			$datetime = new DateTime();
455 496
 			$offset = $datetime->format('P');
456
-		} else $offset = '+00:00';
497
+		} else {
498
+			$offset = '+00:00';
499
+		}
457 500
 
458 501
 		if ($globalDBdriver == 'mysql') {
459 502
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -609,7 +652,9 @@  discard block
 block discarded – undo
609 652
 			{
610 653
 				return false;
611 654
 			}
612
-		} else $altitude = 0;
655
+		} else {
656
+			$altitude = 0;
657
+		}
613 658
 		
614 659
 		if ($heading != "")
615 660
 		{
@@ -648,8 +693,12 @@  discard block
 block discarded – undo
648 693
             		$latitude = 0;
649 694
             		$longitude = 0;
650 695
             	}
651
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
652
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
696
+                if ($heading == '' || $Common->isInteger($heading) === false) {
697
+                	$heading = 0;
698
+                }
699
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
700
+                	$groundspeed = 0;
701
+                }
653 702
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
654 703
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
655 704
 
@@ -753,7 +802,9 @@  discard block
 block discarded – undo
753 802
 		global $globalDBdriver, $globalArchive;
754 803
 		//$filter_query = $this->getFilter($filters,true,true);
755 804
 		$Connection= new Connection($this->db);
756
-		if (!$Connection->tableExists('countries')) return array();
805
+		if (!$Connection->tableExists('countries')) {
806
+			return array();
807
+		}
757 808
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
758 809
 			require_once('class.TrackerLive.php');
759 810
 			$TrackerLive = new TrackerLive($this->db);
@@ -796,7 +847,9 @@  discard block
 block discarded – undo
796 847
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
797 848
 		}
798 849
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
799
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
850
+		if ($limit) {
851
+			$query .= " LIMIT 10 OFFSET 0";
852
+		}
800 853
       
801 854
 		
802 855
 		$sth = $this->db->prepare($query);
@@ -829,12 +882,18 @@  discard block
 block discarded – undo
829 882
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
830 883
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
831 884
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
885
+			if ($globalDBdriver == 'mysql') {
886
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
887
+			} else {
888
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
889
+			}
834 890
 		}
835 891
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
837
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
892
+			if ($globalDBdriver == 'mysql') {
893
+				$query .= " AND tracker_output.date > '".$sincedate."'";
894
+			} else {
895
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
896
+			}
838 897
 		}
839 898
 		$query_values = array();
840 899
 		if ($year != '') {
@@ -865,7 +924,9 @@  discard block
 block discarded – undo
865 924
 			}
866 925
 		}
867 926
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
927
+		if ($limit) {
928
+			$query .= " LIMIT 10 OFFSET 0";
929
+		}
869 930
       		
870 931
 		$sth = $this->db->prepare($query);
871 932
 		$sth->execute($query_values);
@@ -900,7 +961,9 @@  discard block
 block discarded – undo
900 961
 			date_default_timezone_set($globalTimezone);
901 962
 			$datetime = new DateTime();
902 963
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
964
+		} else {
965
+			$offset = '+00:00';
966
+		}
904 967
 
905 968
 		if ($globalDBdriver == 'mysql') {
906 969
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1013,9 @@  discard block
 block discarded – undo
950 1013
 			date_default_timezone_set($globalTimezone);
951 1014
 			$datetime = new DateTime();
952 1015
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1016
+		} else {
1017
+			$offset = '+00:00';
1018
+		}
954 1019
 		$filter_query = $this->getFilter($filters,true,true);
955 1020
 		if ($globalDBdriver == 'mysql') {
956 1021
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1061,9 @@  discard block
 block discarded – undo
996 1061
 			date_default_timezone_set($globalTimezone);
997 1062
 			$datetime = new DateTime();
998 1063
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1064
+		} else {
1065
+			$offset = '+00:00';
1066
+		}
1000 1067
 		$filter_query = $this->getFilter($filters,true,true);
1001 1068
 		if ($globalDBdriver == 'mysql') {
1002 1069
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1111,9 @@  discard block
 block discarded – undo
1044 1111
 			date_default_timezone_set($globalTimezone);
1045 1112
 			$datetime = new DateTime();
1046 1113
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1114
+		} else {
1115
+			$offset = '+00:00';
1116
+		}
1048 1117
 
1049 1118
 		if ($globalDBdriver == 'mysql') {
1050 1119
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1093,7 +1162,9 @@  discard block
 block discarded – undo
1093 1162
 			date_default_timezone_set($globalTimezone);
1094 1163
 			$datetime = new DateTime();
1095 1164
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1165
+		} else {
1166
+			$offset = '+00:00';
1167
+		}
1097 1168
 		$filter_query = $this->getFilter($filters,true,true);
1098 1169
 		if ($globalDBdriver == 'mysql') {
1099 1170
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1142,7 +1213,9 @@  discard block
 block discarded – undo
1142 1213
 			date_default_timezone_set($globalTimezone);
1143 1214
 			$datetime = new DateTime();
1144 1215
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1216
+		} else {
1217
+			$offset = '+00:00';
1218
+		}
1146 1219
 
1147 1220
 		$orderby_sql = '';
1148 1221
 		if ($orderby == "hour")
@@ -1211,7 +1284,9 @@  discard block
 block discarded – undo
1211 1284
 			date_default_timezone_set($globalTimezone);
1212 1285
 			$datetime = new DateTime($date);
1213 1286
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1287
+		} else {
1288
+			$offset = '+00:00';
1289
+		}
1215 1290
 
1216 1291
 		if ($globalDBdriver == 'mysql') {
1217 1292
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1334,9 @@  discard block
 block discarded – undo
1259 1334
 			date_default_timezone_set($globalTimezone);
1260 1335
 			$datetime = new DateTime();
1261 1336
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1337
+		} else {
1338
+			$offset = '+00:00';
1339
+		}
1263 1340
 
1264 1341
 		if ($globalDBdriver == 'mysql') {
1265 1342
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1324,8 +1401,11 @@  discard block
 block discarded – undo
1324 1401
 				$query_values = array_merge($query_values,array(':month' => $month));
1325 1402
 			}
1326 1403
 		}
1327
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1328
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1404
+		if (empty($query_values)) {
1405
+			$queryi .= $this->getFilter($filters);
1406
+		} else {
1407
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1408
+		}
1329 1409
 		
1330 1410
 		$sth = $this->db->prepare($queryi);
1331 1411
 		$sth->execute($query_values);
@@ -1362,8 +1442,11 @@  discard block
 block discarded – undo
1362 1442
 				$query_values = array_merge($query_values,array(':month' => $month));
1363 1443
 			}
1364 1444
 		}
1365
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1366
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1445
+		if (empty($query_values)) {
1446
+			$queryi .= $this->getFilter($filters);
1447
+		} else {
1448
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1449
+		}
1367 1450
 		
1368 1451
 		$sth = $this->db->prepare($queryi);
1369 1452
 		$sth->execute($query_values);
@@ -1385,7 +1468,9 @@  discard block
 block discarded – undo
1385 1468
 			date_default_timezone_set($globalTimezone);
1386 1469
 			$datetime = new DateTime();
1387 1470
 			$offset = $datetime->format('P');
1388
-		} else $offset = '+00:00';
1471
+		} else {
1472
+			$offset = '+00:00';
1473
+		}
1389 1474
 
1390 1475
 		if ($globalDBdriver == 'mysql') {
1391 1476
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1489,7 +1574,9 @@  discard block
 block discarded – undo
1489 1574
 	*/
1490 1575
 	public function parseDirection($direction = 0)
1491 1576
 	{
1492
-		if ($direction == '') $direction = 0;
1577
+		if ($direction == '') {
1578
+			$direction = 0;
1579
+		}
1493 1580
 		$direction_array = array();
1494 1581
 		$temp_array = array();
1495 1582
 
@@ -1578,7 +1665,9 @@  discard block
 block discarded – undo
1578 1665
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1579 1666
 	
1580 1667
 		$Connection = new Connection($this->db);
1581
-		if (!$Connection->tableExists('countries')) return '';
1668
+		if (!$Connection->tableExists('countries')) {
1669
+			return '';
1670
+		}
1582 1671
 	
1583 1672
 		try {
1584 1673
 			/*
@@ -1598,9 +1687,13 @@  discard block
 block discarded – undo
1598 1687
 			$sth->closeCursor();
1599 1688
 			if (count($row) > 0) {
1600 1689
 				return $row;
1601
-			} else return '';
1690
+			} else {
1691
+				return '';
1692
+			}
1602 1693
 		} catch (PDOException $e) {
1603
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1694
+			if (isset($globalDebug) && $globalDebug) {
1695
+				echo 'Error : '.$e->getMessage()."\n";
1696
+			}
1604 1697
 			return '';
1605 1698
 		}
1606 1699
 	
@@ -1618,7 +1711,9 @@  discard block
 block discarded – undo
1618 1711
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1619 1712
 	
1620 1713
 		$Connection = new Connection($this->db);
1621
-		if (!$Connection->tableExists('countries')) return '';
1714
+		if (!$Connection->tableExists('countries')) {
1715
+			return '';
1716
+		}
1622 1717
 	
1623 1718
 		try {
1624 1719
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1630,9 +1725,13 @@  discard block
 block discarded – undo
1630 1725
 			$sth->closeCursor();
1631 1726
 			if (count($row) > 0) {
1632 1727
 				return $row;
1633
-			} else return '';
1728
+			} else {
1729
+				return '';
1730
+			}
1634 1731
 		} catch (PDOException $e) {
1635
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1732
+			if (isset($globalDebug) && $globalDebug) {
1733
+				echo 'Error : '.$e->getMessage()."\n";
1734
+			}
1636 1735
 			return '';
1637 1736
 		}
1638 1737
 	
@@ -1693,7 +1792,9 @@  discard block
 block discarded – undo
1693 1792
 			}
1694 1793
 		}
1695 1794
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1696
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1795
+		if ($limit) {
1796
+			$query .= " LIMIT 10 OFFSET 0";
1797
+		}
1697 1798
 		$sth = $this->db->prepare($query);
1698 1799
 		$sth->execute($query_values);
1699 1800
 		$tracker_array = array();
@@ -1730,7 +1831,9 @@  discard block
 block discarded – undo
1730 1831
 				foreach ($q_array as $q_item){
1731 1832
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1732 1833
 					$additional_query .= " AND (";
1733
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1834
+					if (is_int($q_item)) {
1835
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1836
+					}
1734 1837
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1735 1838
 					$additional_query .= ")";
1736 1839
 				}
@@ -1756,7 +1859,9 @@  discard block
 block discarded – undo
1756 1859
 				date_default_timezone_set($globalTimezone);
1757 1860
 				$datetime = new DateTime();
1758 1861
 				$offset = $datetime->format('P');
1759
-			} else $offset = '+00:00';
1862
+			} else {
1863
+				$offset = '+00:00';
1864
+			}
1760 1865
 			if ($date_array[1] != "")
1761 1866
 			{
1762 1867
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1783,8 +1888,12 @@  discard block
 block discarded – undo
1783 1888
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1784 1889
 			{
1785 1890
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1786
-			} else $limit_query = "";
1787
-		} else $limit_query = "";
1891
+			} else {
1892
+				$limit_query = "";
1893
+			}
1894
+		} else {
1895
+			$limit_query = "";
1896
+		}
1788 1897
 		if ($sort != "")
1789 1898
 		{
1790 1899
 			$search_orderby_array = $this->getOrderBy();
@@ -1827,7 +1936,9 @@  discard block
 block discarded – undo
1827 1936
 	{
1828 1937
 		global $globalBitlyAccessToken;
1829 1938
 		
1830
-		if ($globalBitlyAccessToken == '') return $url;
1939
+		if ($globalBitlyAccessToken == '') {
1940
+			return $url;
1941
+		}
1831 1942
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1832 1943
 		$ch = curl_init();
1833 1944
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.