Completed
Push — master ( 5e8324...900e93 )
by Yannick
06:22
created
install/class.update_schema.php 1 patch
Braces   +323 added lines, -120 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -804,12 +856,16 @@  discard block
 block discarded – undo
804 856
 		if ($globalDBdriver == 'mysql') {
805 857
 			if (!$Connection->tableExists('tle')) {
806 858
 				$error .= create_db::import_file('../db/tle.sql');
807
-				if ($error != '') return $error;
859
+				if ($error != '') {
860
+					return $error;
861
+				}
808 862
 			}
809 863
 		} else {
810 864
 			if (!$Connection->tableExists('tle')) {
811 865
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
812
-				if ($error != '') return $error;
866
+				if ($error != '') {
867
+					return $error;
868
+				}
813 869
 			}
814 870
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
815 871
 			try {
@@ -849,7 +905,9 @@  discard block
 block discarded – undo
849 905
 		} else {
850 906
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
851 907
 		}
852
-		if ($error != '') return 'Import airlines.sql : '.$error;
908
+		if ($error != '') {
909
+			return 'Import airlines.sql : '.$error;
910
+		}
853 911
 		if (!$Connection->checkColumnName('airlines','forsource')) {
854 912
 			// Add forsource to airlines
855 913
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1332,20 +1390,28 @@  discard block
 block discarded – undo
1332 1390
 		}
1333 1391
 		if ($globalDBdriver == 'mysql') {
1334 1392
 			$error .= create_db::import_file('../db/airlines.sql');
1335
-			if ($error != '') return $error;
1393
+			if ($error != '') {
1394
+				return $error;
1395
+			}
1336 1396
 		} else {
1337 1397
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1338
-			if ($error != '') return $error;
1398
+			if ($error != '') {
1399
+				return $error;
1400
+			}
1339 1401
 		}
1340 1402
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1341 1403
 			include_once(dirname(__FILE__).'/class.update_db.php');
1342 1404
 			if (isset($globalVATSIM) && $globalVATSIM) {
1343 1405
 				$error .= update_db::update_vatsim();
1344
-				if ($error != '') return $error;
1406
+				if ($error != '') {
1407
+					return $error;
1408
+				}
1345 1409
 			}
1346 1410
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1347 1411
 				$error .= update_db::update_IVAO();
1348
-				if ($error != '') return $error;
1412
+				if ($error != '') {
1413
+					return $error;
1414
+				}
1349 1415
 			}
1350 1416
 		}
1351 1417
 
@@ -1607,30 +1673,54 @@  discard block
 block discarded – undo
1607 1673
 		*/
1608 1674
 		if ($globalDBdriver == 'mysql') {
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
 			$error .= create_db::import_file('../db/tracker_live.sql');
1612
-			if ($error != '') return $error;
1680
+			if ($error != '') {
1681
+				return $error;
1682
+			}
1613 1683
 			$error .= create_db::import_file('../db/marine_output.sql');
1614
-			if ($error != '') return $error;
1684
+			if ($error != '') {
1685
+				return $error;
1686
+			}
1615 1687
 			$error .= create_db::import_file('../db/marine_live.sql');
1616
-			if ($error != '') return $error;
1688
+			if ($error != '') {
1689
+				return $error;
1690
+			}
1617 1691
 			$error .= create_db::import_file('../db/marine_identity.sql');
1618
-			if ($error != '') return $error;
1692
+			if ($error != '') {
1693
+				return $error;
1694
+			}
1619 1695
 			$error .= create_db::import_file('../db/marine_mid.sql');
1620
-			if ($error != '') return $error;
1696
+			if ($error != '') {
1697
+				return $error;
1698
+			}
1621 1699
 		} else {
1622 1700
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1623
-			if ($error != '') return $error;
1701
+			if ($error != '') {
1702
+				return $error;
1703
+			}
1624 1704
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1625
-			if ($error != '') return $error;
1705
+			if ($error != '') {
1706
+				return $error;
1707
+			}
1626 1708
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1627
-			if ($error != '') return $error;
1709
+			if ($error != '') {
1710
+				return $error;
1711
+			}
1628 1712
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1629
-			if ($error != '') return $error;
1713
+			if ($error != '') {
1714
+				return $error;
1715
+			}
1630 1716
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1631
-			if ($error != '') return $error;
1717
+			if ($error != '') {
1718
+				return $error;
1719
+			}
1632 1720
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1633
-			if ($error != '') return $error;
1721
+			if ($error != '') {
1722
+				return $error;
1723
+			}
1634 1724
 		}
1635 1725
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1636 1726
 		try {
@@ -1650,8 +1740,11 @@  discard block
 block discarded – undo
1650 1740
     	    if ($Connection->tableExists('aircraft')) {
1651 1741
     		if (!$Connection->tableExists('config')) {
1652 1742
     		    $version = '1';
1653
-    		    if ($update) return self::update_from_1();
1654
-    		    else return $version;
1743
+    		    if ($update) {
1744
+    		    	return self::update_from_1();
1745
+    		    } else {
1746
+    		    	return $version;
1747
+    		    }
1655 1748
 		} else {
1656 1749
     		    $Connection = new Connection();
1657 1750
 		    $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
@@ -1665,150 +1758,260 @@  discard block
 block discarded – undo
1665 1758
     		    if ($update) {
1666 1759
     			if ($result['value'] == '2') {
1667 1760
     			    $error = self::update_from_2();
1668
-    			    if ($error != '') return $error;
1669
-    			    else return self::check_version(true);
1761
+    			    if ($error != '') {
1762
+    			    	return $error;
1763
+    			    } else {
1764
+    			    	return self::check_version(true);
1765
+    			    }
1670 1766
     			} elseif ($result['value'] == '3') {
1671 1767
     			    $error = self::update_from_3();
1672
-    			    if ($error != '') return $error;
1673
-    			    else return self::check_version(true);
1768
+    			    if ($error != '') {
1769
+    			    	return $error;
1770
+    			    } else {
1771
+    			    	return self::check_version(true);
1772
+    			    }
1674 1773
     			} elseif ($result['value'] == '4') {
1675 1774
     			    $error = self::update_from_4();
1676
-    			    if ($error != '') return $error;
1677
-    			    else return self::check_version(true);
1775
+    			    if ($error != '') {
1776
+    			    	return $error;
1777
+    			    } else {
1778
+    			    	return self::check_version(true);
1779
+    			    }
1678 1780
     			} elseif ($result['value'] == '5') {
1679 1781
     			    $error = self::update_from_5();
1680
-    			    if ($error != '') return $error;
1681
-    			    else return self::check_version(true);
1782
+    			    if ($error != '') {
1783
+    			    	return $error;
1784
+    			    } else {
1785
+    			    	return self::check_version(true);
1786
+    			    }
1682 1787
     			} elseif ($result['value'] == '6') {
1683 1788
     			    $error = self::update_from_6();
1684
-    			    if ($error != '') return $error;
1685
-    			    else return self::check_version(true);
1789
+    			    if ($error != '') {
1790
+    			    	return $error;
1791
+    			    } else {
1792
+    			    	return self::check_version(true);
1793
+    			    }
1686 1794
     			} elseif ($result['value'] == '7') {
1687 1795
     			    $error = self::update_from_7();
1688
-    			    if ($error != '') return $error;
1689
-    			    else return self::check_version(true);
1796
+    			    if ($error != '') {
1797
+    			    	return $error;
1798
+    			    } else {
1799
+    			    	return self::check_version(true);
1800
+    			    }
1690 1801
     			} elseif ($result['value'] == '8') {
1691 1802
     			    $error = self::update_from_8();
1692
-    			    if ($error != '') return $error;
1693
-    			    else return self::check_version(true);
1803
+    			    if ($error != '') {
1804
+    			    	return $error;
1805
+    			    } else {
1806
+    			    	return self::check_version(true);
1807
+    			    }
1694 1808
     			} elseif ($result['value'] == '9') {
1695 1809
     			    $error = self::update_from_9();
1696
-    			    if ($error != '') return $error;
1697
-    			    else return self::check_version(true);
1810
+    			    if ($error != '') {
1811
+    			    	return $error;
1812
+    			    } else {
1813
+    			    	return self::check_version(true);
1814
+    			    }
1698 1815
     			} elseif ($result['value'] == '10') {
1699 1816
     			    $error = self::update_from_10();
1700
-    			    if ($error != '') return $error;
1701
-    			    else return self::check_version(true);
1817
+    			    if ($error != '') {
1818
+    			    	return $error;
1819
+    			    } else {
1820
+    			    	return self::check_version(true);
1821
+    			    }
1702 1822
     			} elseif ($result['value'] == '11') {
1703 1823
     			    $error = self::update_from_11();
1704
-    			    if ($error != '') return $error;
1705
-    			    else return self::check_version(true);
1824
+    			    if ($error != '') {
1825
+    			    	return $error;
1826
+    			    } else {
1827
+    			    	return self::check_version(true);
1828
+    			    }
1706 1829
     			} elseif ($result['value'] == '12') {
1707 1830
     			    $error = self::update_from_12();
1708
-    			    if ($error != '') return $error;
1709
-    			    else return self::check_version(true);
1831
+    			    if ($error != '') {
1832
+    			    	return $error;
1833
+    			    } else {
1834
+    			    	return self::check_version(true);
1835
+    			    }
1710 1836
     			} elseif ($result['value'] == '13') {
1711 1837
     			    $error = self::update_from_13();
1712
-    			    if ($error != '') return $error;
1713
-    			    else return self::check_version(true);
1838
+    			    if ($error != '') {
1839
+    			    	return $error;
1840
+    			    } else {
1841
+    			    	return self::check_version(true);
1842
+    			    }
1714 1843
     			} elseif ($result['value'] == '14') {
1715 1844
     			    $error = self::update_from_14();
1716
-    			    if ($error != '') return $error;
1717
-    			    else return self::check_version(true);
1845
+    			    if ($error != '') {
1846
+    			    	return $error;
1847
+    			    } else {
1848
+    			    	return self::check_version(true);
1849
+    			    }
1718 1850
     			} elseif ($result['value'] == '15') {
1719 1851
     			    $error = self::update_from_15();
1720
-    			    if ($error != '') return $error;
1721
-    			    else return self::check_version(true);
1852
+    			    if ($error != '') {
1853
+    			    	return $error;
1854
+    			    } else {
1855
+    			    	return self::check_version(true);
1856
+    			    }
1722 1857
     			} elseif ($result['value'] == '16') {
1723 1858
     			    $error = self::update_from_16();
1724
-    			    if ($error != '') return $error;
1725
-    			    else return self::check_version(true);
1859
+    			    if ($error != '') {
1860
+    			    	return $error;
1861
+    			    } else {
1862
+    			    	return self::check_version(true);
1863
+    			    }
1726 1864
     			} elseif ($result['value'] == '17') {
1727 1865
     			    $error = self::update_from_17();
1728
-    			    if ($error != '') return $error;
1729
-    			    else return self::check_version(true);
1866
+    			    if ($error != '') {
1867
+    			    	return $error;
1868
+    			    } else {
1869
+    			    	return self::check_version(true);
1870
+    			    }
1730 1871
     			} elseif ($result['value'] == '18') {
1731 1872
     			    $error = self::update_from_18();
1732
-    			    if ($error != '') return $error;
1733
-    			    else return self::check_version(true);
1873
+    			    if ($error != '') {
1874
+    			    	return $error;
1875
+    			    } else {
1876
+    			    	return self::check_version(true);
1877
+    			    }
1734 1878
     			} elseif ($result['value'] == '19') {
1735 1879
     			    $error = self::update_from_19();
1736
-    			    if ($error != '') return $error;
1737
-    			    else return self::check_version(true);
1880
+    			    if ($error != '') {
1881
+    			    	return $error;
1882
+    			    } else {
1883
+    			    	return self::check_version(true);
1884
+    			    }
1738 1885
     			} elseif ($result['value'] == '20') {
1739 1886
     			    $error = self::update_from_20();
1740
-    			    if ($error != '') return $error;
1741
-    			    else return self::check_version(true);
1887
+    			    if ($error != '') {
1888
+    			    	return $error;
1889
+    			    } else {
1890
+    			    	return self::check_version(true);
1891
+    			    }
1742 1892
     			} elseif ($result['value'] == '21') {
1743 1893
     			    $error = self::update_from_21();
1744
-    			    if ($error != '') return $error;
1745
-    			    else return self::check_version(true);
1894
+    			    if ($error != '') {
1895
+    			    	return $error;
1896
+    			    } else {
1897
+    			    	return self::check_version(true);
1898
+    			    }
1746 1899
     			} elseif ($result['value'] == '22') {
1747 1900
     			    $error = self::update_from_22();
1748
-    			    if ($error != '') return $error;
1749
-    			    else return self::check_version(true);
1901
+    			    if ($error != '') {
1902
+    			    	return $error;
1903
+    			    } else {
1904
+    			    	return self::check_version(true);
1905
+    			    }
1750 1906
     			} elseif ($result['value'] == '23') {
1751 1907
     			    $error = self::update_from_23();
1752
-    			    if ($error != '') return $error;
1753
-    			    else return self::check_version(true);
1908
+    			    if ($error != '') {
1909
+    			    	return $error;
1910
+    			    } else {
1911
+    			    	return self::check_version(true);
1912
+    			    }
1754 1913
     			} elseif ($result['value'] == '24') {
1755 1914
     			    $error = self::update_from_24();
1756
-    			    if ($error != '') return $error;
1757
-    			    else return self::check_version(true);
1915
+    			    if ($error != '') {
1916
+    			    	return $error;
1917
+    			    } else {
1918
+    			    	return self::check_version(true);
1919
+    			    }
1758 1920
     			} elseif ($result['value'] == '25') {
1759 1921
     			    $error = self::update_from_25();
1760
-    			    if ($error != '') return $error;
1761
-    			    else return self::check_version(true);
1922
+    			    if ($error != '') {
1923
+    			    	return $error;
1924
+    			    } else {
1925
+    			    	return self::check_version(true);
1926
+    			    }
1762 1927
     			} elseif ($result['value'] == '26') {
1763 1928
     			    $error = self::update_from_26();
1764
-    			    if ($error != '') return $error;
1765
-    			    else return self::check_version(true);
1929
+    			    if ($error != '') {
1930
+    			    	return $error;
1931
+    			    } else {
1932
+    			    	return self::check_version(true);
1933
+    			    }
1766 1934
     			} elseif ($result['value'] == '27') {
1767 1935
     			    $error = self::update_from_27();
1768
-    			    if ($error != '') return $error;
1769
-    			    else return self::check_version(true);
1936
+    			    if ($error != '') {
1937
+    			    	return $error;
1938
+    			    } else {
1939
+    			    	return self::check_version(true);
1940
+    			    }
1770 1941
     			} elseif ($result['value'] == '28') {
1771 1942
     			    $error = self::update_from_28();
1772
-    			    if ($error != '') return $error;
1773
-    			    else return self::check_version(true);
1943
+    			    if ($error != '') {
1944
+    			    	return $error;
1945
+    			    } else {
1946
+    			    	return self::check_version(true);
1947
+    			    }
1774 1948
     			} elseif ($result['value'] == '29') {
1775 1949
     			    $error = self::update_from_29();
1776
-    			    if ($error != '') return $error;
1777
-    			    else return self::check_version(true);
1950
+    			    if ($error != '') {
1951
+    			    	return $error;
1952
+    			    } else {
1953
+    			    	return self::check_version(true);
1954
+    			    }
1778 1955
     			} elseif ($result['value'] == '30') {
1779 1956
     			    $error = self::update_from_30();
1780
-    			    if ($error != '') return $error;
1781
-    			    else return self::check_version(true);
1957
+    			    if ($error != '') {
1958
+    			    	return $error;
1959
+    			    } else {
1960
+    			    	return self::check_version(true);
1961
+    			    }
1782 1962
     			} elseif ($result['value'] == '31') {
1783 1963
     			    $error = self::update_from_31();
1784
-    			    if ($error != '') return $error;
1785
-    			    else return self::check_version(true);
1964
+    			    if ($error != '') {
1965
+    			    	return $error;
1966
+    			    } else {
1967
+    			    	return self::check_version(true);
1968
+    			    }
1786 1969
     			} elseif ($result['value'] == '32') {
1787 1970
     			    $error = self::update_from_32();
1788
-    			    if ($error != '') return $error;
1789
-    			    else return self::check_version(true);
1971
+    			    if ($error != '') {
1972
+    			    	return $error;
1973
+    			    } else {
1974
+    			    	return self::check_version(true);
1975
+    			    }
1790 1976
     			} elseif ($result['value'] == '33') {
1791 1977
     			    $error = self::update_from_33();
1792
-    			    if ($error != '') return $error;
1793
-    			    else return self::check_version(true);
1978
+    			    if ($error != '') {
1979
+    			    	return $error;
1980
+    			    } else {
1981
+    			    	return self::check_version(true);
1982
+    			    }
1794 1983
     			} elseif ($result['value'] == '34') {
1795 1984
     			    $error = self::update_from_34();
1796
-    			    if ($error != '') return $error;
1797
-    			    else return self::check_version(true);
1985
+    			    if ($error != '') {
1986
+    			    	return $error;
1987
+    			    } else {
1988
+    			    	return self::check_version(true);
1989
+    			    }
1798 1990
     			} elseif ($result['value'] == '35') {
1799 1991
     			    $error = self::update_from_35();
1800
-    			    if ($error != '') return $error;
1801
-    			    else return self::check_version(true);
1992
+    			    if ($error != '') {
1993
+    			    	return $error;
1994
+    			    } else {
1995
+    			    	return self::check_version(true);
1996
+    			    }
1802 1997
     			} elseif ($result['value'] == '36') {
1803 1998
     			    $error = self::update_from_36();
1804
-    			    if ($error != '') return $error;
1805
-    			    else return self::check_version(true);
1806
-    			} else return '';
1999
+    			    if ($error != '') {
2000
+    			    	return $error;
2001
+    			    } else {
2002
+    			    	return self::check_version(true);
2003
+    			    }
2004
+    			} else {
2005
+    				return '';
2006
+    			}
2007
+    		    } else {
2008
+    		    	return $result['value'];
1807 2009
     		    }
1808
-    		    else return $result['value'];
1809 2010
 		}
1810 2011
 		
1811
-	    } else return $version;
2012
+	    } else {
2013
+	    	return $version;
2014
+	    }
1812 2015
     	}
1813 2016
     	
1814 2017
 }
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +59 added lines, -20 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
125 132
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
150 159
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -178,7 +187,9 @@  discard block
 block discarded – undo
178 187
 
179 188
 		$filter_query = $this->getFilter($filter,true,true);
180 189
 
181
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190
+		if (!isset($globalLiveInterval)) {
191
+			$globalLiveInterval = '200';
192
+		}
182 193
 		if ($globalDBdriver == 'mysql') {
183 194
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 195
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
@@ -211,7 +222,9 @@  discard block
 block discarded – undo
211 222
 		global $globalDBdriver, $globalLiveInterval;
212 223
 		$filter_query = $this->getFilter($filter,true,true);
213 224
 
214
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
225
+		if (!isset($globalLiveInterval)) {
226
+			$globalLiveInterval = '200';
227
+		}
215 228
 		if ($globalDBdriver == 'mysql') {
216 229
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
217 230
 		} else {
@@ -239,7 +252,9 @@  discard block
 block discarded – undo
239 252
 	{
240 253
 		global $globalDBdriver, $globalLiveInterval;
241 254
 		$Spotter = new Spotter($this->db);
242
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
243 258
 		$filter_query = $this->getFilter($filter);
244 259
 
245 260
 		if (is_array($coord)) {
@@ -247,7 +262,9 @@  discard block
 block discarded – undo
247 262
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248 263
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 264
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-		} else return array();
265
+		} else {
266
+			return array();
267
+		}
251 268
 		if ($globalDBdriver == 'mysql') {
252 269
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
253 270
 		} else {
@@ -411,11 +428,15 @@  discard block
 block discarded – undo
411 428
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
412 429
 		if ($globalDBdriver == 'mysql') {
413 430
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
414
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
431
+			if ($liveinterval) {
432
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
433
+			}
415 434
 			$query .= ' ORDER BY date';
416 435
 		} else {
417 436
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
418
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
437
+			if ($liveinterval) {
438
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
439
+			}
419 440
 			$query .= ' ORDER BY date';
420 441
 		}
421 442
 
@@ -510,7 +531,9 @@  discard block
 block discarded – undo
510 531
 				$i++;
511 532
 				$j++;
512 533
 				if ($j == 30) {
513
-					if ($globalDebug) echo ".";
534
+					if ($globalDebug) {
535
+						echo ".";
536
+					}
514 537
 				    	try {
515 538
 						
516 539
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -790,7 +813,9 @@  discard block
 block discarded – undo
790 813
 			{
791 814
 				return false;
792 815
 			}
793
-		} else return '';
816
+		} else {
817
+			return '';
818
+		}
794 819
 
795 820
 		if ($longitude != '')
796 821
 		{
@@ -798,7 +823,9 @@  discard block
 block discarded – undo
798 823
 			{
799 824
 				return false;
800 825
 			}
801
-		} else return '';
826
+		} else {
827
+			return '';
828
+		}
802 829
 
803 830
 
804 831
 		if ($heading != '')
@@ -807,7 +834,9 @@  discard block
 block discarded – undo
807 834
 			{
808 835
 				return false;
809 836
 			}
810
-		} else $heading = 0;
837
+		} else {
838
+			$heading = 0;
839
+		}
811 840
 
812 841
 		if ($groundspeed != '')
813 842
 		{
@@ -815,9 +844,13 @@  discard block
 block discarded – undo
815 844
 			{
816 845
 				return false;
817 846
 			}
818
-		} else $groundspeed = 0;
847
+		} else {
848
+			$groundspeed = 0;
849
+		}
819 850
 		date_default_timezone_set('UTC');
820
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
851
+		if ($date == '') {
852
+			$date = date("Y-m-d H:i:s", time());
853
+		}
821 854
 
822 855
         
823 856
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -838,9 +871,15 @@  discard block
 block discarded – undo
838 871
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
839 872
 		
840 873
 
841
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
842
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
843
-            	if ($arrival_date == '') $arrival_date = NULL;
874
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
875
+            		$groundspeed = 0;
876
+            	}
877
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
878
+            		$heading = 0;
879
+            	}
880
+            	if ($arrival_date == '') {
881
+            		$arrival_date = NULL;
882
+            	}
844 883
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
845 884
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
846 885
 
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +145 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,25 +130,40 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['marineid'])) {
133
+			*/} elseif (isset($row['marineid'])) {
130 134
 				$temp_array['marineid'] = $row['marineid'];
131 135
 			} else {
132 136
 				$temp_array['marineid'] = '';
133 137
 			}
134
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
135
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
138
+			if (isset($row['fammarine_id'])) {
139
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
140
+			}
141
+			if (isset($row['mmsi'])) {
142
+				$temp_array['mmsi'] = $row['mmsi'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
137 147
 			$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'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
141 157
 			if (isset($row['heading'])) {
142 158
 				$temp_array['heading'] = $row['heading'];
143 159
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 166
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 167
 			
148 168
 			if (isset($row['date'])) {
149 169
 				$dateArray = $this->parseDateString($row['date']);
@@ -186,13 +206,21 @@  discard block
 block discarded – undo
186 206
 			}
187 207
 			
188 208
 			$fromsource = NULL;
189
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
190
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
191
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
209
+			if (isset($row['source_name']) && $row['source_name'] != '') {
210
+				$temp_array['source_name'] = $row['source_name'];
211
+			}
212
+			if (isset($row['over_country']) && $row['over_country'] != '') {
213
+				$temp_array['over_country'] = $row['over_country'];
214
+			}
215
+			if (isset($row['distance']) && $row['distance'] != '') {
216
+				$temp_array['distance'] = $row['distance'];
217
+			}
192 218
 			$temp_array['query_number_rows'] = $num_rows;
193 219
 			$spotter_array[] = $temp_array;
194 220
 		}
195
-		if ($num_rows == 0) return array();
221
+		if ($num_rows == 0) {
222
+			return array();
223
+		}
196 224
 		$spotter_array[0]['query_number_rows'] = $num_rows;
197 225
 		return $spotter_array;
198 226
 	}	
@@ -223,8 +251,12 @@  discard block
 block discarded – undo
223 251
 			{
224 252
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
225 253
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
226
-			} else $limit_query = "";
227
-		} else $limit_query = "";
254
+			} else {
255
+				$limit_query = "";
256
+			}
257
+		} else {
258
+			$limit_query = "";
259
+		}
228 260
 		
229 261
 		if ($sort != "")
230 262
 		{
@@ -252,7 +284,9 @@  discard block
 block discarded – undo
252 284
 		global $global_query;
253 285
 		
254 286
 		date_default_timezone_set('UTC');
255
-		if ($id == '') return array();
287
+		if ($id == '') {
288
+			return array();
289
+		}
256 290
 		$additional_query = "marine_output.fammarine_id = :id";
257 291
 		$query_values = array(':id' => $id);
258 292
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -395,8 +429,11 @@  discard block
 block discarded – undo
395 429
 		$query .= " ORDER BY marine_output.source_name ASC";
396 430
 
397 431
 		$sth = $this->db->prepare($query);
398
-		if (!empty($query_values)) $sth->execute($query_values);
399
-		else $sth->execute();
432
+		if (!empty($query_values)) {
433
+			$sth->execute($query_values);
434
+		} else {
435
+			$sth->execute();
436
+		}
400 437
 
401 438
 		$source_array = array();
402 439
 		$temp_array = array();
@@ -451,8 +488,11 @@  discard block
 block discarded – undo
451 488
 		$sth = $this->db->prepare($query);
452 489
 		$sth->execute(array(':mmsi' => $mmsi));
453 490
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-		if (isset($result[0])) return $result[0];
455
-		else return array();
491
+		if (isset($result[0])) {
492
+			return $result[0];
493
+		} else {
494
+			return array();
495
+		}
456 496
 	}
457 497
 
458 498
 	/*
@@ -468,7 +508,9 @@  discard block
 block discarded – undo
468 508
 			date_default_timezone_set($globalTimezone);
469 509
 			$datetime = new DateTime();
470 510
 			$offset = $datetime->format('P');
471
-		} else $offset = '+00:00';
511
+		} else {
512
+			$offset = '+00:00';
513
+		}
472 514
 
473 515
 		if ($globalDBdriver == 'mysql') {
474 516
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -663,9 +705,15 @@  discard block
 block discarded – undo
663 705
             		$latitude = 0;
664 706
             		$longitude = 0;
665 707
             	}
666
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
-                if ($arrival_date == '') $arrival_date = NULL;
708
+                if ($heading == '' || $Common->isInteger($heading) === false) {
709
+                	$heading = 0;
710
+                }
711
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
712
+                	$groundspeed = 0;
713
+                }
714
+                if ($arrival_date == '') {
715
+                	$arrival_date = NULL;
716
+                }
669 717
 		$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) 
670 718
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 719
 
@@ -829,12 +877,18 @@  discard block
 block discarded – undo
829 877
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
830 878
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
831 879
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
880
+			if ($globalDBdriver == 'mysql') {
881
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
882
+			} else {
883
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
884
+			}
834 885
 		}
835 886
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
837
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
887
+			if ($globalDBdriver == 'mysql') {
888
+				$query .= " AND marine_output.date > '".$sincedate."'";
889
+			} else {
890
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
891
+			}
838 892
 		}
839 893
 		$query_values = array();
840 894
 		if ($year != '') {
@@ -865,7 +919,9 @@  discard block
 block discarded – undo
865 919
 			}
866 920
 		}
867 921
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
922
+		if ($limit) {
923
+			$query .= " LIMIT 10 OFFSET 0";
924
+		}
869 925
       		
870 926
 		$sth = $this->db->prepare($query);
871 927
 		$sth->execute($query_values);
@@ -900,7 +956,9 @@  discard block
 block discarded – undo
900 956
 			date_default_timezone_set($globalTimezone);
901 957
 			$datetime = new DateTime();
902 958
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
959
+		} else {
960
+			$offset = '+00:00';
961
+		}
904 962
 
905 963
 		if ($globalDBdriver == 'mysql') {
906 964
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1008,9 @@  discard block
 block discarded – undo
950 1008
 			date_default_timezone_set($globalTimezone);
951 1009
 			$datetime = new DateTime();
952 1010
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1011
+		} else {
1012
+			$offset = '+00:00';
1013
+		}
954 1014
 		$filter_query = $this->getFilter($filters,true,true);
955 1015
 		if ($globalDBdriver == 'mysql') {
956 1016
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1056,9 @@  discard block
 block discarded – undo
996 1056
 			date_default_timezone_set($globalTimezone);
997 1057
 			$datetime = new DateTime();
998 1058
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1059
+		} else {
1060
+			$offset = '+00:00';
1061
+		}
1000 1062
 		$filter_query = $this->getFilter($filters,true,true);
1001 1063
 		if ($globalDBdriver == 'mysql') {
1002 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1106,9 @@  discard block
 block discarded – undo
1044 1106
 			date_default_timezone_set($globalTimezone);
1045 1107
 			$datetime = new DateTime();
1046 1108
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1109
+		} else {
1110
+			$offset = '+00:00';
1111
+		}
1048 1112
 
1049 1113
 		if ($globalDBdriver == 'mysql') {
1050 1114
 			$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
@@ -1093,7 +1157,9 @@  discard block
 block discarded – undo
1093 1157
 			date_default_timezone_set($globalTimezone);
1094 1158
 			$datetime = new DateTime();
1095 1159
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1160
+		} else {
1161
+			$offset = '+00:00';
1162
+		}
1097 1163
 		$filter_query = $this->getFilter($filters,true,true);
1098 1164
 		if ($globalDBdriver == 'mysql') {
1099 1165
 			$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
@@ -1142,7 +1208,9 @@  discard block
 block discarded – undo
1142 1208
 			date_default_timezone_set($globalTimezone);
1143 1209
 			$datetime = new DateTime();
1144 1210
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1211
+		} else {
1212
+			$offset = '+00:00';
1213
+		}
1146 1214
 
1147 1215
 		$orderby_sql = '';
1148 1216
 		if ($orderby == "hour")
@@ -1211,7 +1279,9 @@  discard block
 block discarded – undo
1211 1279
 			date_default_timezone_set($globalTimezone);
1212 1280
 			$datetime = new DateTime($date);
1213 1281
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1282
+		} else {
1283
+			$offset = '+00:00';
1284
+		}
1215 1285
 
1216 1286
 		if ($globalDBdriver == 'mysql') {
1217 1287
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1329,9 @@  discard block
 block discarded – undo
1259 1329
 			date_default_timezone_set($globalTimezone);
1260 1330
 			$datetime = new DateTime();
1261 1331
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1332
+		} else {
1333
+			$offset = '+00:00';
1334
+		}
1263 1335
 
1264 1336
 		if ($globalDBdriver == 'mysql') {
1265 1337
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1323,8 +1395,11 @@  discard block
 block discarded – undo
1323 1395
 				$query_values = array_merge($query_values,array(':month' => $month));
1324 1396
 			}
1325 1397
 		}
1326
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1327
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1398
+		if (empty($query_values)) {
1399
+			$queryi .= $this->getFilter($filters);
1400
+		} else {
1401
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1402
+		}
1328 1403
 		
1329 1404
 		$sth = $this->db->prepare($queryi);
1330 1405
 		$sth->execute($query_values);
@@ -1346,7 +1421,9 @@  discard block
 block discarded – undo
1346 1421
 			date_default_timezone_set($globalTimezone);
1347 1422
 			$datetime = new DateTime();
1348 1423
 			$offset = $datetime->format('P');
1349
-		} else $offset = '+00:00';
1424
+		} else {
1425
+			$offset = '+00:00';
1426
+		}
1350 1427
 
1351 1428
 		if ($globalDBdriver == 'mysql') {
1352 1429
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1450,7 +1527,9 @@  discard block
 block discarded – undo
1450 1527
 	*/
1451 1528
 	public function parseDirection($direction = 0)
1452 1529
 	{
1453
-		if ($direction == '') $direction = 0;
1530
+		if ($direction == '') {
1531
+			$direction = 0;
1532
+		}
1454 1533
 		$direction_array = array();
1455 1534
 		$temp_array = array();
1456 1535
 
@@ -1539,7 +1618,9 @@  discard block
 block discarded – undo
1539 1618
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1540 1619
 	
1541 1620
 		$Connection = new Connection($this->db);
1542
-		if (!$Connection->tableExists('countries')) return '';
1621
+		if (!$Connection->tableExists('countries')) {
1622
+			return '';
1623
+		}
1543 1624
 	
1544 1625
 		try {
1545 1626
 			/*
@@ -1559,9 +1640,13 @@  discard block
 block discarded – undo
1559 1640
 			$sth->closeCursor();
1560 1641
 			if (count($row) > 0) {
1561 1642
 				return $row;
1562
-			} else return '';
1643
+			} else {
1644
+				return '';
1645
+			}
1563 1646
 		} catch (PDOException $e) {
1564
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1647
+			if (isset($globalDebug) && $globalDebug) {
1648
+				echo 'Error : '.$e->getMessage()."\n";
1649
+			}
1565 1650
 			return '';
1566 1651
 		}
1567 1652
 	
@@ -1579,7 +1664,9 @@  discard block
 block discarded – undo
1579 1664
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1580 1665
 	
1581 1666
 		$Connection = new Connection($this->db);
1582
-		if (!$Connection->tableExists('countries')) return '';
1667
+		if (!$Connection->tableExists('countries')) {
1668
+			return '';
1669
+		}
1583 1670
 	
1584 1671
 		try {
1585 1672
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1591,9 +1678,13 @@  discard block
 block discarded – undo
1591 1678
 			$sth->closeCursor();
1592 1679
 			if (count($row) > 0) {
1593 1680
 				return $row;
1594
-			} else return '';
1681
+			} else {
1682
+				return '';
1683
+			}
1595 1684
 		} catch (PDOException $e) {
1596
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1685
+			if (isset($globalDebug) && $globalDebug) {
1686
+				echo 'Error : '.$e->getMessage()."\n";
1687
+			}
1597 1688
 			return '';
1598 1689
 		}
1599 1690
 	
@@ -1611,7 +1702,9 @@  discard block
 block discarded – undo
1611 1702
 	{
1612 1703
 		global $globalBitlyAccessToken;
1613 1704
 		
1614
-		if ($globalBitlyAccessToken == '') return $url;
1705
+		if ($globalBitlyAccessToken == '') {
1706
+			return $url;
1707
+		}
1615 1708
         
1616 1709
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1617 1710
 		
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +149 added lines, -51 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function checkAll() {
47 47
 	global $globalDebug;
48
-	if ($globalDebug) echo "Update last seen tracked data...\n";
48
+	if ($globalDebug) {
49
+		echo "Update last seen tracked data...\n";
50
+	}
49 51
 	foreach ($this->all_tracked as $key => $flight) {
50 52
 	    if (isset($this->all_tracked[$key]['id'])) {
51 53
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -58,12 +60,16 @@  discard block
 block discarded – undo
58 60
     public function del() {
59 61
 	global $globalDebug;
60 62
 	// Delete old infos
61
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
63
+	if ($globalDebug) {
64
+		echo 'Delete old values and update latest data...'."\n";
65
+	}
62 66
 	foreach ($this->all_tracked as $key => $flight) {
63 67
     	    if (isset($flight['lastupdate'])) {
64 68
         	if ($flight['lastupdate'] < (time()-3000)) {
65 69
             	    if (isset($this->all_tracked[$key]['id'])) {
66
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
70
+            		if ($globalDebug) {
71
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
72
+            		}
67 73
 			/*
68 74
 			$MarineLive = new MarineLive();
69 75
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -73,7 +79,9 @@  discard block
 block discarded – undo
73 79
             		$Marine = new Marine($this->db);
74 80
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
75 81
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
76
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
82
+				if ($globalDebug && $result != 'success') {
83
+					echo '!!! ERROR : '.$result."\n";
84
+				}
77 85
 			}
78 86
 			// Put in archive
79 87
 //			$Marine->db = null;
@@ -86,7 +94,9 @@  discard block
 block discarded – undo
86 94
 
87 95
     public function add($line) {
88 96
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
89
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
97
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
98
+		$globalCoordMinChange = '0.02';
99
+	}
90 100
 	date_default_timezone_set('UTC');
91 101
 	$dataFound = false;
92 102
 	$send = false;
@@ -111,8 +121,11 @@  discard block
 block discarded – undo
111 121
 		
112 122
 		$Common = new Common();
113 123
 		$AIS = new AIS();
114
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
115
-	        else $id = trim($line['id']);
124
+	        if (!isset($line['id'])) {
125
+	        	$id = trim($line['mmsi']);
126
+	        } else {
127
+	        	$id = trim($line['id']);
128
+	        }
116 129
 		
117 130
 		if (!isset($this->all_tracked[$id])) {
118 131
 		    $this->all_tracked[$id] = array();
@@ -120,10 +133,16 @@  discard block
 block discarded – undo
120 133
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121 134
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
122 135
 		    if (!isset($line['id'])) {
123
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
136
+			if (!isset($globalDaemon)) {
137
+				$globalDaemon = TRUE;
138
+			}
124 139
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
125
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
126
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
140
+		     } else {
141
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
142
+		     }
143
+		    if ($globalAllTracked !== FALSE) {
144
+		    	$dataFound = true;
145
+		    }
127 146
 		}
128 147
 		
129 148
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -166,11 +185,17 @@  discard block
 block discarded – undo
166 185
             		$Marine = new Marine($this->db);
167 186
             		$fromsource = NULL;
168 187
             		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
169
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188
+			if ($globalDebug && $result != 'success') {
189
+				echo '!!! ERROR : '.$result."\n";
190
+			}
170 191
 			$Marine->db = null;
171
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+			if ($globalDebugTimeElapsed) {
193
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
194
+			}
195
+		    }
196
+		    if (!isset($this->all_tracked[$id]['id'])) {
197
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
172 198
 		    }
173
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
174 199
 		}
175 200
 
176 201
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -181,14 +206,21 @@  discard block
 block discarded – undo
181 206
 		    if ($distance > 1000 && $distance < 10000) {
182 207
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
183 208
 			$speed = $speed*3.6;
184
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
185
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
209
+			if ($speed < 1000) {
210
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
211
+			}
212
+  			if ($globalDebug) {
213
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
214
+  			}
186 215
 		    }
187 216
 		}
188 217
 
189 218
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
191
-	    	    else unset($timediff);
219
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
220
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
221
+	    	    } else {
222
+	    	    	unset($timediff);
223
+	    	    }
192 224
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
193 225
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
194 226
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -196,20 +228,30 @@  discard block
 block discarded – undo
196 228
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
197 229
 				$this->all_tracked[$id]['putinarchive'] = true;
198 230
 				
199
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
231
+				if ($globalDebug) {
232
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
233
+				}
200 234
 				$timeelapsed = microtime(true);
201 235
 				$Marine = new Marine($this->db);
202 236
 				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
203
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
237
+				if (!empty($all_country)) {
238
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
239
+				}
204 240
 				$Marine->db = null;
205
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
241
+				if ($globalDebugTimeElapsed) {
242
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
243
+				}
206 244
 				$this->tmd = 0;
207
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
245
+				if ($globalDebug) {
246
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
247
+				}
208 248
 			    }
209 249
 			}
210 250
 
211 251
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
212
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
252
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
253
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
254
+				}
213 255
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
214 256
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215 257
 				    $dataFound = true;
@@ -218,8 +260,12 @@  discard block
 block discarded – undo
218 260
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
219 261
 			}
220 262
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
221
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
222
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
263
+			    if ($line['longitude'] > 180) {
264
+			    	$line['longitude'] = $line['longitude'] - 360;
265
+			    }
266
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
267
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
268
+				}
223 269
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
224 270
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225 271
 				    $dataFound = true;
@@ -237,7 +283,9 @@  discard block
 block discarded – undo
237 283
 		    }
238 284
 		}
239 285
 		if (isset($line['last_update']) && $line['last_update'] != '') {
240
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
286
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
287
+		    	$dataFound = true;
288
+		    }
241 289
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
242 290
 		}
243 291
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -255,15 +303,21 @@  discard block
 block discarded – undo
255 303
 		}
256 304
 		
257 305
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
306
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
307
+		    	$this->all_tracked[$id]['putinarchive'] = true;
308
+		    }
259 309
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260 310
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261 311
 		    //$dataFound = true;
262 312
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263 313
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264 314
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
315
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
316
+		    	$this->all_tracked[$id]['putinarchive'] = true;
317
+		    }
318
+  		    if ($globalDebug) {
319
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
320
+  		    }
267 321
   		}
268 322
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 323
 
@@ -271,8 +325,11 @@  discard block
 block discarded – undo
271 325
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
272 326
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
273 327
 		    } else {
274
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
275
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
328
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
329
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
330
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
331
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
332
+				}
276 333
 				return '';
277 334
 		    }
278 335
 		} else {
@@ -286,22 +343,35 @@  discard block
 block discarded – undo
286 343
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
287 344
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288 345
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
289
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
346
+				if ($globalDebug) {
347
+					echo "Check if aircraft is already in DB...";
348
+				}
290 349
 				$timeelapsed = microtime(true);
291 350
 				$MarineLive = new MarineLive($this->db);
292 351
 				if (isset($line['id'])) {
293 352
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
294
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
353
+				    if ($globalDebugTimeElapsed) {
354
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
355
+				    }
295 356
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
296 357
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358
+				    if ($globalDebugTimeElapsed) {
359
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+				    }
298 361
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
299 362
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
-				} else $recent_ident = '';
363
+				    if ($globalDebugTimeElapsed) {
364
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
365
+				    }
366
+				} else {
367
+					$recent_ident = '';
368
+				}
302 369
 				$MarineLive->db=null;
303
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
304
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
305 375
 			    } else {
306 376
 				$recent_ident = '';
307 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -309,16 +379,24 @@  discard block
 block discarded – undo
309 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
310 380
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311 381
 			    {
312
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
384
+				}
313 385
 				//adds the spotter data for the archive
314 386
 				    $highlight = '';
315
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
389
+				    }
316 390
 				    $timeelapsed = microtime(true);
317 391
 				    $Marine = new Marine($this->db);
318 392
 				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
319 393
 				    $Marine->db = null;
320
-				    if ($globalDebug && isset($result)) echo $result."\n";
321
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
322 400
 				    
323 401
 				    /*
324 402
 				    // Add source stat in DB
@@ -352,12 +430,16 @@  discard block
 block discarded – undo
352 430
 				$this->all_tracked[$id]['addedMarine'] = 1;
353 431
 				//print_r($this->all_tracked[$id]);
354 432
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
355
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
433
+				    if ($globalDebug) {
434
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
435
+				    }
356 436
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
357 437
 				    $MarineLive = new MarineLive($this->db);
358 438
 				    $MarineLive->deleteLiveMarineData();
359 439
 				    $MarineLive->db=null;
360
-				    if ($globalDebug) echo " Done\n";
440
+				    if ($globalDebug) {
441
+				    	echo " Done\n";
442
+				    }
361 443
 				    $this->last_delete = time();
362 444
 				}
363 445
 			    } elseif ($recent_ident != '') {
@@ -380,13 +462,17 @@  discard block
 block discarded – undo
380 462
 
381 463
 		    if (!$ignoreImport) {
382 464
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
383
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
465
+				if ($globalDebug) {
466
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
467
+				}
384 468
 				$timeelapsed = microtime(true);
385 469
 				$MarineLive = new MarineLive($this->db);
386 470
 				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
387 471
 				$MarineLive->db = null;
388 472
 				$this->all_tracked[$id]['putinarchive'] = false;
389
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+				if ($globalDebugTimeElapsed) {
474
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
475
+				}
390 476
 
391 477
 				// Put statistics in $this->stats variable
392 478
 				/*
@@ -443,19 +529,29 @@  discard block
 block discarded – undo
443 529
 				*/
444 530
 
445 531
 				$this->all_tracked[$id]['lastupdate'] = time();
446
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
447
-				if ($globalDebug) echo $result."\n";
448
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
532
+				if ($this->all_tracked[$id]['putinarchive']) {
533
+					$send = true;
534
+				}
535
+				if ($globalDebug) {
536
+					echo $result."\n";
537
+				}
538
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
539
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
540
+			}
449 541
 			//$this->del();
450 542
 			
451 543
 			
452 544
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
453
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
545
+			    if ($globalDebug) {
546
+			    	echo "---- Deleting Live Marine data Not updated since 2 hour...";
547
+			    }
454 548
 			    $MarineLive = new MarineLive($this->db);
455 549
 			    $MarineLive->deleteLiveMarineDataNotUpdated();
456 550
 			    $MarineLive->db = null;
457 551
 			    //MarineLive->deleteLiveMarineData();
458
-			    if ($globalDebug) echo " Done\n";
552
+			    if ($globalDebug) {
553
+			    	echo " Done\n";
554
+			    }
459 555
 			    $this->last_delete_hourly = time();
460 556
 			}
461 557
 			
@@ -463,7 +559,9 @@  discard block
 block discarded – undo
463 559
 		    //$ignoreImport = false;
464 560
 		}
465 561
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
466
-		if ($send) return $this->all_tracked[$id];
562
+		if ($send) {
563
+			return $this->all_tracked[$id];
564
+		}
467 565
 	    }
468 566
 	}
469 567
     }
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Braces   +322 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,19 +479,34 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
397 499
 			$num_seq = (int)$pcs[1]; // number of sequences
398 500
 			$seq = (int)$pcs[2]; // get sequence
399 501
 			// get msg sequence id
400
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
502
+			if ($pcs[3] == '') {
503
+				$msg_sid = -1;
504
+			}
505
+			// non-multipart message, set to -1
506
+			else {
507
+				$msg_sid = (int)$pcs[3];
508
+			}
509
+			// multipart message
402 510
 			$ais_ch = $pcs[4]; // get AIS channel
403 511
 			// message sequence checking
404 512
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -459,10 +567,18 @@  discard block
 block discarded – undo
459 567
 				//DEBUG echo "[$start $end $tst]\n";
460 568
 				$result = $this->process_ais_raw( $tst, "" );
461 569
 				$last_pos = $end + 1;
462
-			} else break;
570
+			} else {
571
+				break;
572
+			}
573
+		}
574
+		if ($last_pos > 0) {
575
+			$cbuf = substr($cbuf, $last_pos);
463 576
 		}
464
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
465
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
577
+		// move...
578
+		if (strlen($cbuf) > 1024) {
579
+			$cbuf = "";
580
+		}
581
+		// prevent overflow simple mode...
466 582
 		return $result;
467 583
 	}
468 584
 
@@ -482,7 +598,9 @@  discard block
 block discarded – undo
482 598
 		if ($lat<0.0) {
483 599
 			$lat = -$lat;
484 600
 			$neg=true;
485
-		} else $neg=false;
601
+		} else {
602
+			$neg=false;
603
+		}
486 604
 		$latd = 0x00000000;
487 605
 		$latd = intval ($lat * 600000.0);
488 606
 		if ($neg==true) {
@@ -498,7 +616,9 @@  discard block
 block discarded – undo
498 616
 		if ($lon<0.0) {
499 617
 			$lon = -$lon;
500 618
 			$neg=true;
501
-		} else $neg=false;
619
+		} else {
620
+			$neg=false;
621
+		}
502 622
 		$lond = 0x00000000;
503 623
 		$lond = intval ($lon * 600000.0);
504 624
 		if ($neg==true) {
@@ -511,9 +631,14 @@  discard block
 block discarded – undo
511 631
 
512 632
 	private function char2bin($name, $max_len) {
513 633
 		$len = strlen($name);
514
-		if ($len > $max_len) $name = substr($name,0,$max_len);
515
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
516
-		else $pad = '';
634
+		if ($len > $max_len) {
635
+			$name = substr($name,0,$max_len);
636
+		}
637
+		if ($len < $max_len) {
638
+			$pad = str_repeat('0', ($max_len - $len) * 6);
639
+		} else {
640
+			$pad = '';
641
+		}
517 642
 		$rv = '';
518 643
 		$ais_chars = array(
519 644
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -526,9 +651,12 @@  discard block
 block discarded – undo
526 651
 		);
527 652
 		// "
528 653
 		$_a = str_split($name);
529
-		if ($_a) foreach ($_a as $_1) {
654
+		if ($_a) {
655
+			foreach ($_a as $_1) {
530 656
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531
-			else $dec = 0;
657
+		} else {
658
+				$dec = 0;
659
+			}
532 660
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
533 661
 			$rv .= $bin;
534 662
 			//echo "$_1 $dec ($bin)<br/>";
@@ -540,7 +668,9 @@  discard block
 block discarded – undo
540 668
 		$len_bit = strlen($_enc);
541 669
 		$rem6 = $len_bit % 6;
542 670
 		$pad6_len = 0;
543
-		if ($rem6) $pad6_len = 6 - $rem6;
671
+		if ($rem6) {
672
+			$pad6_len = 6 - $rem6;
673
+		}
544 674
 		//echo  $pad6_len.'<br>';
545 675
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546 676
 		$len_enc = strlen($_enc) / 6;
@@ -549,8 +679,11 @@  discard block
 block discarded – undo
549 679
 		for ($i=0; $i<$len_enc; $i++) {
550 680
 			$offset = $i * 6;
551 681
 			$dec = bindec(substr($_enc,$offset,6));
552
-			if ($dec < 40) $dec += 48;
553
-			else $dec += 56;
682
+			if ($dec < 40) {
683
+				$dec += 48;
684
+			} else {
685
+				$dec += 56;
686
+			}
554 687
 			//echo chr($dec)." $dec<br/>";
555 688
 			$itu .= chr($dec);
556 689
 		}
@@ -563,25 +696,41 @@  discard block
 block discarded – undo
563 696
 		}
564 697
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565 698
 		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
567
-		else $lsbc = '0';
699
+		if ($lsb >=0 && $lsb <= 15 ) {
700
+			$lsbc = $hex_arr[$lsb];
701
+		} else {
702
+			$lsbc = '0';
703
+		}
568 704
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
570
-		else $msbc = '0';
705
+		if ($msb >=0 && $msb <= 15 ) {
706
+			$msbc = $hex_arr[$msb];
707
+		} else {
708
+			$msbc = '0';
709
+		}
571 710
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 711
 		return $itu;
573 712
 	}
574 713
 
575 714
 	public function parse($buffer) {
576 715
 		$data = $this->process_ais_buf($buffer);
577
-		if (!is_object($data)) return array();
578
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
579
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
716
+		if (!is_object($data)) {
717
+			return array();
718
+		}
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
580 725
 		$result['ident'] = trim($data->name);
581 726
 		$result['timestamp'] = $data->ts;
582 727
 		$result['mmsi'] = $data->mmsi;
583
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
584
-		if ($data->cog != 0) $result['heading'] = $data->cog;
728
+		if ($data->sog != -1.0) {
729
+			$result['speed'] = $data->sog;
730
+		}
731
+		if ($data->cog != 0) {
732
+			$result['heading'] = $data->cog;
733
+		}
585 734
 		/*
586 735
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
587 736
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -591,15 +740,25 @@  discard block
 block discarded – undo
591 740
 
592 741
 	public function mmsitype($mmsi) {
593 742
 		if (strlen($mmsi) == 9) {
594
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
596
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
598
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
599
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
600
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
601
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
602
-			else return 'Ship';
743
+			if (substr($mmsi,0,3) == '974') {
744
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
745
+			} elseif (substr($mmsi,0,3) == '972') {
746
+				return 'MOB (Man Overboard) device';
747
+			} elseif (substr($mmsi,0,3) == '970') {
748
+				return 'AIS SART (Search and Rescue Transmitter)';
749
+			} elseif (substr($mmsi,0,3) == '111') {
750
+				return 'SAR (Search and Rescue) aircraft';
751
+			} elseif (substr($mmsi,0,2) == '98') {
752
+				return 'Auxiliary craft associated with a parent ship';
753
+			} elseif (substr($mmsi,0,2) == '99') {
754
+				return 'Aids to Navigation';
755
+			} elseif (substr($mmsi,0,2) == '00') {
756
+				return 'Coastal stations';
757
+			} elseif (substr($mmsi,0,1) == '0') {
758
+				return 'Group of ships';
759
+			} else {
760
+				return 'Ship';
761
+			}
603 762
 		}
604 763
 
605 764
 	
@@ -616,25 +775,48 @@  discard block
 block discarded – undo
616 775
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 776
 			return array();
618 777
 		}
619
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
620
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
778
+		if ($data->lon != 0) {
779
+			$result['longitude'] = $data->lon;
780
+		}
781
+		if ($data->lat != 0) {
782
+			$result['latitude'] = $data->lat;
783
+		}
621 784
 		$result['ident'] = trim(str_replace('@','',$data->name));
622 785
 		$result['timestamp'] = $data->ts;
623 786
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
787
+		if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') {
788
+			$result['mmsi'] = '3'.$result['mmsi'];
789
+		}
625 790
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627
-		if ($data->heading != '') $result['heading'] = $data->heading;
628
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
629
-		if ($data->status != '') $result['status'] = $data->status;
630
-		if ($data->type != '') $result['type'] = $data->type;
631
-		if ($data->typeid != '') $result['typeid'] = $data->typeid;
632
-		if ($data->imo != '') $result['imo'] = $data->imo;
633
-		if ($data->callsign != '') $result['callsign'] = $data->callsign;
791
+		if ($data->sog != -1.0) {
792
+			$result['speed'] = $data->sog;
793
+		}
794
+		if ($data->heading != '') {
795
+			$result['heading'] = $data->heading;
796
+		} elseif ($data->cog != 0) {
797
+			$result['heading'] = $data->cog;
798
+		}
799
+		if ($data->status != '') {
800
+			$result['status'] = $data->status;
801
+		}
802
+		if ($data->type != '') {
803
+			$result['type'] = $data->type;
804
+		}
805
+		if ($data->typeid != '') {
806
+			$result['typeid'] = $data->typeid;
807
+		}
808
+		if ($data->imo != '') {
809
+			$result['imo'] = $data->imo;
810
+		}
811
+		if ($data->callsign != '') {
812
+			$result['callsign'] = $data->callsign;
813
+		}
634 814
 		if ($data->eta_month != '' && $data->eta_day != '' && $data->eta_hour != '' && $data->eta_minute != '') {
635 815
 			$result['eta_ts'] = strtotime(date('Y').'-'.$data->eta_month.'-'.$data->eta_day.' '.$data->eta_hour.':'.$data->eta_minute.':00');
636 816
 		}
637
-		if ($data->destination != '') $result['destination'] = $data->destination;
817
+		if ($data->destination != '') {
818
+			$result['destination'] = $data->destination;
819
+		}
638 820
 		$result['all'] = (array) $data;
639 821
 		/*
640 822
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +73 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -112,10 +120,16 @@  discard block
 block discarded – undo
112 120
 	* @return Array array of the tables in HTML page
113 121
 	*/
114 122
 	public function table2array($data) {
115
-		if (!is_string($data)) return array();
116
-		if ($data == '') return array();
123
+		if (!is_string($data)) {
124
+			return array();
125
+		}
126
+		if ($data == '') {
127
+			return array();
128
+		}
117 129
 		$html = str_get_html($data);
118
-		if ($html === false) return array();
130
+		if ($html === false) {
131
+			return array();
132
+		}
119 133
 		$tabledata=array();
120 134
 		foreach($html->find('tr') as $element)
121 135
 		{
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	*/
151 165
 	public function text2array($data) {
152 166
 		$html = str_get_html($data);
153
-		if ($html === false) return array();
167
+		if ($html === false) {
168
+			return array();
169
+		}
154 170
 		$tabledata=array();
155 171
 		foreach($html->find('p') as $element)
156 172
 		{
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 	* @return Float Distance in $unit
172 188
 	*/
173 189
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174
-		if ($lat == $latc && $lon == $lonc) return 0;
190
+		if ($lat == $latc && $lon == $lonc) {
191
+			return 0;
192
+		}
175 193
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
176 194
 		if ($unit == "km") {
177 195
 			return round($dist * 1.609344);
@@ -195,10 +213,16 @@  discard block
 block discarded – undo
195 213
 	public function withinThreshold ($timeDifference, $distance) {
196 214
 		$x = abs($timeDifference);
197 215
 		$d = abs($distance);
198
-		if ($x == 0 || $d == 0) return true;
216
+		if ($x == 0 || $d == 0) {
217
+			return true;
218
+		}
199 219
 		// may be due to Internet jitter; distance is realistic
200
-		if ($x < 0.7 && $d < 2000) return true;
201
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
220
+		if ($x < 0.7 && $d < 2000) {
221
+			return true;
222
+		} else {
223
+			return $d/$x < 1500*0.27778;
224
+		}
225
+		// 1500 km/h max
202 226
 	}
203 227
 
204 228
 
@@ -226,11 +250,17 @@  discard block
 block discarded – undo
226 250
 	
227 251
 	public function convertDM($coord,$latlong) {
228 252
 		if ($latlong == 'latitude') {
229
-			if ($coord < 0) $NSEW = 'S';
230
-			else $NSEW = 'N';
253
+			if ($coord < 0) {
254
+				$NSEW = 'S';
255
+			} else {
256
+				$NSEW = 'N';
257
+			}
231 258
 		} elseif ($latlong == 'longitude') {
232
-			if ($coord < 0) $NSEW = 'W';
233
-			else $NSEW = 'E';
259
+			if ($coord < 0) {
260
+				$NSEW = 'W';
261
+			} else {
262
+				$NSEW = 'E';
263
+			}
234 264
 		}
235 265
 		$coord = abs($coord);
236 266
 		$deg = floor($coord);
@@ -273,7 +303,9 @@  discard block
 block discarded – undo
273 303
 	public function hex2str($hex) {
274 304
 		$str = '';
275 305
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
306
+		for($i=0;$i<$hexln;$i+=2) {
307
+			$str .= chr(hexdec(substr($hex,$i,2)));
308
+		}
277 309
 		return $str;
278 310
 	}
279 311
 	
@@ -301,8 +333,11 @@  discard block
 block discarded – undo
301 333
 		$b = $lat2 - $lat1;
302 334
 		$c = -($a*$lat1+$b*$lon1);
303 335
 		$d = $a*$lat3+$b*$lon3+$c;
304
-		if ($d > -$approx && $d < $approx) return true;
305
-		else return false;
336
+		if ($d > -$approx && $d < $approx) {
337
+			return true;
338
+		} else {
339
+			return false;
340
+		}
306 341
 	}
307 342
 	
308 343
 	public function array_merge_noappend() {
@@ -361,7 +396,9 @@  discard block
 block discarded – undo
361 396
 			return $result;
362 397
 		}
363 398
 		$handle = @opendir('./locale');
364
-		if ($handle === false) return $result;
399
+		if ($handle === false) {
400
+			return $result;
401
+		}
365 402
 		while (false !== ($file = readdir($handle))) {
366 403
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
367 404
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
 		$error = false; 
429 466
 		if ($fp_out = gzopen($dest, $mode)) { 
430 467
 			if ($fp_in = fopen($source,'rb')) { 
431
-				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
468
+				while (!feof($fp_in)) {
469
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
470
+				}
433 471
 				fclose($fp_in); 
434 472
 			} else {
435 473
 				$error = true; 
@@ -438,14 +476,17 @@  discard block
 block discarded – undo
438 476
 		} else {
439 477
 			$error = true; 
440 478
 		}
441
-		if ($error)
442
-			return false; 
443
-		else
444
-			return $dest; 
479
+		if ($error) {
480
+					return false;
481
+		} else {
482
+					return $dest;
483
+		}
445 484
 	} 
446 485
 	
447 486
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
487
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
488
+			return $string;
489
+		}
449 490
 		$chars = array(
450 491
 		    // Decompositions for Latin-1 Supplement
451 492
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -569,7 +610,9 @@  discard block
 block discarded – undo
569 610
 		$ip = gethostbyname($host);
570 611
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
571 612
 		$r = @socket_connect($s, $ip, $port);
572
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
613
+		if (!socket_set_nonblock($s)) {
614
+			echo "Unable to set nonblock on socket\n";
615
+		}
573 616
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
574 617
 			return $s;
575 618
 		}
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +432 added lines, -114 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -397,11 +498,17 @@  discard block
 block discarded – undo
397 498
 			<div id="flightaware_data">
398 499
 				<p>
399 500
 					<label for="flightawareusername">FlightAware username</label>
400
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
501
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
502
+	print $globalFlightAwareUsername;
503
+}
504
+?>" />
401 505
 				</p>
402 506
 				<p>
403 507
 					<label for="flightawarepassword">FlightAware password/API key</label>
404
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
508
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
509
+	print $globalFlightAwarePassword;
510
+}
511
+?>" />
405 512
 				</p>
406 513
 			</div>
407 514
 -->
@@ -460,27 +567,84 @@  discard block
 block discarded – undo
460 567
 								?>
461 568
 								<td>
462 569
 									<select name="format[]" id="format">
463
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
464
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
465
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
466
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
467
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
468
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
469
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
470
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
471
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
472
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
473
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
474
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
475
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
476
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
477
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
478
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
479
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
570
+										<option value="auto" <?php if (!isset($source['format'])) {
571
+	print 'selected';
572
+}
573
+?>>Auto</option>
574
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
575
+	print 'selected';
576
+}
577
+?>>SBS</option>
578
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
579
+	print 'selected';
580
+}
581
+?>>TSV</option>
582
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
583
+	print 'selected';
584
+}
585
+?>>Raw</option>
586
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
587
+	print 'selected';
588
+}
589
+?>>APRS</option>
590
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
591
+	print 'selected';
592
+}
593
+?>>Radarcape deltadb.txt</option>
594
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
595
+	print 'selected';
596
+}
597
+?>>Vatsim</option>
598
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
599
+	print 'selected';
600
+}
601
+?>>Virtual Radar Server AircraftList.json</option>
602
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
603
+	print 'selected';
604
+}
605
+?>>Virtual Radar Server TCP</option>
606
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
607
+	print 'selected';
608
+}
609
+?>>phpVMS</option>
610
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
611
+	print 'selected';
612
+}
613
+?>>Virtual Airlines Manager</option>
614
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
615
+	print 'selected';
616
+}
617
+?>>IVAO</option>
618
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
619
+	print 'selected';
620
+}
621
+?>>FlightGear Multiplayer</option>
622
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
623
+	print 'selected';
624
+}
625
+?>>FlightGear Singleplayer</option>
626
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
627
+	print 'selected';
628
+}
629
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
630
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
631
+	print 'selected';
632
+}
633
+?>>ACARS SBS-3 over TCP</option>
634
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
635
+	print 'selected';
636
+}
637
+?>>NMEA AIS over TCP</option>
480 638
 									</select>
481 639
 								</td>
482
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
483
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
640
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
641
+	print $source['name'];
642
+}
643
+?>" /></td>
644
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
645
+	print 'checked';
646
+}
647
+?> /></td>
484 648
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
485 649
 							</tr>
486 650
 <?php
@@ -528,11 +692,17 @@  discard block
 block discarded – undo
528 692
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
529 693
 					<p>
530 694
 						<label for="acarshost">ACARS UDP host</label>
531
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
695
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
696
+	print $globalACARSHost;
697
+}
698
+?>" />
532 699
 					</p>
533 700
 					<p>
534 701
 						<label for="acarsport">ACARS UDP port</label>
535
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
702
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
703
+	print $globalACARSPort;
704
+}
705
+?>" />
536 706
 					</p>
537 707
 				</fieldset>
538 708
 			</div>
@@ -612,13 +782,19 @@  discard block
 block discarded – undo
612 782
 			<div id="schedules_options">
613 783
 				<p>
614 784
 					<label for="britishairways">British Airways API Key</label>
615
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
785
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
786
+	print $globalBritishAirwaysKey;
787
+}
788
+?>" />
616 789
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
617 790
 				</p>
618 791
 				<!--
619 792
 				<p>
620 793
 					<label for="transavia">Transavia Test API Consumer Key</label>
621
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
794
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
795
+	print $globalTransaviaKey;
796
+}
797
+?>" />
622 798
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
623 799
 				</p>
624 800
 				-->
@@ -627,10 +803,16 @@  discard block
 block discarded – undo
627 803
 						<b>Lufthansa API Key</b>
628 804
 						<p>
629 805
 							<label for="lufthansakey">Key</label>
630
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
806
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
807
+	print $globalLufthansaKey['key'];
808
+}
809
+?>" />
631 810
 						</p><p>
632 811
 							<label for="lufthansasecret">Secret</label>
633
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
812
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
813
+	print $globalLufthansaKey['secret'];
814
+}
815
+?>" />
634 816
 						</p>
635 817
 					</div>
636 818
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -650,7 +832,10 @@  discard block
 block discarded – undo
650 832
 			</p>
651 833
 			<p>
652 834
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
653
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
835
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
836
+	print $globalNOTAMSource;
837
+}
838
+?>" />
654 839
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
655 840
 			</p>
656 841
 			<br />
@@ -666,14 +851,20 @@  discard block
 block discarded – undo
666 851
 			<div id="metarsrc">
667 852
 				<p>
668 853
 					<label for="metarsource">URL of your METAR source</label>
669
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
854
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
855
+	print $globalMETARurl;
856
+}
857
+?>" />
670 858
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
671 859
 				</p>
672 860
 			</div>
673 861
 			<br />
674 862
 			<p>
675 863
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
676
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
864
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
865
+	print $globalBitlyAccessToken;
866
+}
867
+?>" />
677 868
 			</p>
678 869
 			<br />
679 870
 			<p>
@@ -693,7 +884,12 @@  discard block
 block discarded – undo
693 884
 			</p>
694 885
 			<p>
695 886
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
696
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
887
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
888
+	print $globalArchiveMonths;
889
+} else {
890
+	echo '0';
891
+}
892
+?>" />
697 893
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
698 894
 			</p>
699 895
 			<p>
@@ -703,12 +899,22 @@  discard block
 block discarded – undo
703 899
 			</p>
704 900
 			<p>
705 901
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
706
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
902
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
903
+	print $globalArchiveKeepMonths;
904
+} else {
905
+	echo '0';
906
+}
907
+?>" />
707 908
 				<p class="help-block">0 to disable</p>
708 909
 			</p>
709 910
 			<p>
710 911
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
711
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
912
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
913
+	print $globalArchiveKeepTrackMonths;
914
+} else {
915
+	echo '0';
916
+}
917
+?>" />
712 918
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
713 919
 			</p>
714 920
 			<br />
@@ -718,7 +924,12 @@  discard block
 block discarded – undo
718 924
 				<p class="help-block">Uncheck if the script is running as cron job</p>
719 925
 				<div id="cronends"> 
720 926
 					<label for="cronend">Run script for xx seconds</label>
721
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
927
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
928
+	print $globalCronEnd;
929
+} else {
930
+	print '0';
931
+}
932
+?>" />
722 933
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
723 934
 				</div>
724 935
 			</p>
@@ -763,26 +974,49 @@  discard block
 block discarded – undo
763 974
 			<br />
764 975
 			<p>
765 976
 				<label for="refresh">Show flights detected since xxx seconds</label>
766
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
977
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
978
+	echo $globalLiveInterval;
979
+} else {
980
+	echo '200';
981
+}
982
+?>" />
767 983
 			</p>
768 984
 			<p>
769 985
 				<label for="maprefresh">Live map refresh (in seconds)</label>
770
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
986
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
987
+	echo $globalMapRefresh;
988
+} else {
989
+	echo '30';
990
+}
991
+?>" />
771 992
 			</p>
772 993
 			<p>
773 994
 				<label for="mapidle">Map idle timeout (in minutes)</label>
774
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
995
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
996
+	echo $globalMapIdleTimeout;
997
+} else {
998
+	echo '30';
999
+}
1000
+?>" />
775 1001
 				<p class="help-block">0 to disable</p>
776 1002
 			</p>
777 1003
 			<br />
778 1004
 			<p>
779 1005
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
780
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1006
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1007
+	echo $globalClosestMinDist;
1008
+} else {
1009
+	echo '50';
1010
+}
1011
+?>" />
781 1012
 			</p>
782 1013
 			<br />
783 1014
 			<p>
784 1015
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
785
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1016
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1017
+	echo $globalAircraftSize;
1018
+}
1019
+?>" />
786 1020
 			</p>
787 1021
 			<br />
788 1022
 			<p>
@@ -790,7 +1024,12 @@  discard block
 block discarded – undo
790 1024
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
791 1025
 			?>
792 1026
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
793
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1027
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1028
+	echo $globalAircraftIconColor;
1029
+} else {
1030
+	echo '1a3151';
1031
+}
1032
+?>" />
794 1033
 			<?php
795 1034
 				if (!is_writable('../cache')) {
796 1035
 			?>
@@ -808,8 +1047,18 @@  discard block
 block discarded – undo
808 1047
 			<p>
809 1048
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
810 1049
 				<div class="range">
811
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
812
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1050
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1051
+	echo $globalAirportZoom;
1052
+} else {
1053
+	echo '7';
1054
+}
1055
+?>" />
1056
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1057
+	echo $globalAirportZoom;
1058
+} else {
1059
+	echo '7';
1060
+}
1061
+?></output>
813 1062
 				</div>
814 1063
 			</p>
815 1064
 		</fieldset>
@@ -837,8 +1086,12 @@  discard block
 block discarded – undo
837 1086
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
838 1087
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
839 1088
 
840
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
841
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1089
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1090
+		$error .= 'Mysql driver for PDO must be loaded';
1091
+	}
1092
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1093
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1094
+	}
842 1095
 	
843 1096
 	$_SESSION['database_root'] = $dbroot;
844 1097
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -905,15 +1158,23 @@  discard block
 block discarded – undo
905 1158
 	$source_city = $_POST['source_city'];
906 1159
 	$source_country = $_POST['source_country'];
907 1160
 	$source_ref = $_POST['source_ref'];
908
-	if (isset($source_id)) $source_id = $_POST['source_id'];
909
-	else $source_id = array();
1161
+	if (isset($source_id)) {
1162
+		$source_id = $_POST['source_id'];
1163
+	} else {
1164
+		$source_id = array();
1165
+	}
910 1166
 	
911 1167
 	$sources = array();
912 1168
 	foreach ($source_name as $keys => $name) {
913
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
914
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1169
+	    if (isset($source_id[$keys])) {
1170
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1171
+	    } else {
1172
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1173
+	    }
1174
+	}
1175
+	if (count($sources) > 0) {
1176
+		$_SESSION['sources'] = $sources;
915 1177
 	}
916
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
917 1178
 
918 1179
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
919 1180
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -933,14 +1194,23 @@  discard block
 block discarded – undo
933 1194
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
934 1195
 
935 1196
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
936
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
937
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1197
+	if ($globalaircraft == 'aircraft') {
1198
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1199
+	} else {
1200
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1201
+	}
938 1202
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
939
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
940
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1203
+	if ($globaltracker == 'tracker') {
1204
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1205
+	} else {
1206
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1207
+	}
941 1208
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
942
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
943
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1209
+	if ($globalmarine == 'marine') {
1210
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1211
+	} else {
1212
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1213
+	}
944 1214
 
945 1215
 /*	
946 1216
 	$globalSBS1Hosts = array();
@@ -961,13 +1231,21 @@  discard block
 block discarded – undo
961 1231
 	$port = $_POST['port'];
962 1232
 	$name = $_POST['name'];
963 1233
 	$format = $_POST['format'];
964
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
965
-	else $sourcestats = array();
1234
+	if (isset($_POST['sourcestats'])) {
1235
+		$sourcestats = $_POST['sourcestats'];
1236
+	} else {
1237
+		$sourcestats = array();
1238
+	}
966 1239
 	$gSources = array();
967 1240
 	foreach ($host as $key => $h) {
968
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
969
-		else $cov = 'FALSE';
970
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1241
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1242
+			$cov = 'TRUE';
1243
+		} else {
1244
+			$cov = 'FALSE';
1245
+		}
1246
+		if ($h != '') {
1247
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1248
+		}
971 1249
 	}
972 1250
 	$settings = array_merge($settings,array('globalSources' => $gSources));
973 1251
 
@@ -992,7 +1270,9 @@  discard block
 block discarded – undo
992 1270
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
993 1271
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
994 1272
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
995
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1273
+	} else {
1274
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1275
+	}
996 1276
 
997 1277
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
998 1278
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1031,7 +1311,9 @@  discard block
 block discarded – undo
1031 1311
 
1032 1312
 	// Create in settings.php keys not yet configurable if not already here
1033 1313
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1034
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1314
+	if (!isset($globalDebug)) {
1315
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1316
+	}
1035 1317
 
1036 1318
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1037 1319
 	if ($resetyearstats == 'resetyearstats') {
@@ -1068,27 +1350,43 @@  discard block
 block discarded – undo
1068 1350
 	}
1069 1351
 */
1070 1352
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1071
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1073
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1074
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1353
+	if ($globalsbs == 'sbs') {
1354
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1355
+	} else {
1356
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1357
+	}
1358
+	if ($globalaprs == 'aprs') {
1359
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1360
+	} else {
1361
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1362
+	}
1075 1363
 	if ($globalivao == 'ivao') {
1076 1364
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1077 1365
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1078
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1366
+	} else {
1367
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1368
+	}
1079 1369
 	if ($globalvatsim == 'vatsim') {
1080 1370
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1081 1371
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1082
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1372
+	} else {
1373
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1374
+	}
1083 1375
 	if ($globalphpvms == 'phpvms') {
1084 1376
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1085
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1377
+	} else {
1378
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1379
+	}
1086 1380
 	if ($globalvam == 'vam') {
1087 1381
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1088
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1382
+	} else {
1383
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1384
+	}
1089 1385
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1090 1386
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1091
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1387
+	} else {
1388
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1389
+	}
1092 1390
 	
1093 1391
 
1094 1392
 
@@ -1224,7 +1522,9 @@  discard block
 block discarded – undo
1224 1522
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1225 1523
 	}
1226 1524
 
1227
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1525
+	if (!isset($globalTransaction)) {
1526
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1527
+	}
1228 1528
 
1229 1529
 	// Set some defaults values...
1230 1530
 	if (!isset($globalAircraftImageSources)) {
@@ -1239,15 +1539,23 @@  discard block
 block discarded – undo
1239 1539
 
1240 1540
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1241 1541
 
1242
-	if ($error == '') settings::modify_settings($settings);
1243
-	if ($error == '') settings::comment_settings($settings_comment);
1542
+	if ($error == '') {
1543
+		settings::modify_settings($settings);
1544
+	}
1545
+	if ($error == '') {
1546
+		settings::comment_settings($settings_comment);
1547
+	}
1244 1548
 	if ($error != '') {
1245 1549
 		print '<div class="info column">'.$error.'</div>';
1246 1550
 		require('../footer.php');
1247 1551
 		exit;
1248 1552
 	} else {
1249
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1250
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1553
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1554
+			$_SESSION['waypoints'] = 1;
1555
+		}
1556
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1557
+			$_SESSION['owner'] = 1;
1558
+		}
1251 1559
 		if (isset($_POST['createdb'])) {
1252 1560
 			$_SESSION['install'] = 'database_create';
1253 1561
 		} else {
@@ -1288,10 +1596,18 @@  discard block
 block discarded – undo
1288 1596
 	$popw = false;
1289 1597
 	foreach ($_SESSION['done'] as $done) {
1290 1598
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1291
-	    if ($done == 'Create database') $pop = true;
1292
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1293
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1294
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1599
+	    if ($done == 'Create database') {
1600
+	    	$pop = true;
1601
+	    }
1602
+	    if ($_SESSION['install'] == 'database_create') {
1603
+	    	$pop = true;
1604
+	    }
1605
+	    if ($_SESSION['install'] == 'database_import') {
1606
+	    	$popi = true;
1607
+	    }
1608
+	    if ($_SESSION['install'] == 'waypoints') {
1609
+	    	$popw = true;
1610
+	    }
1295 1611
 	}
1296 1612
 	if ($pop) {
1297 1613
 	    sleep(5);
@@ -1302,7 +1618,9 @@  discard block
 block discarded – undo
1302 1618
 	} else if ($popw) {
1303 1619
 	    sleep(5);
1304 1620
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1305
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1621
+	} else {
1622
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1623
+	}
1306 1624
 	print '</div></ul>';
1307 1625
 	print '<div id="error"></div>';
1308 1626
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/date/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.
accident.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/accident/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.