Completed
Push — master ( 460c94...2c5525 )
by Yannick
33:06
created
table-output.php 1 patch
Braces   +68 added lines, -25 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9 9
 
10
-if (!isset($type)) $type = 'aircraft';
10
+if (!isset($type)) {
11
+	$type = 'aircraft';
12
+}
11 13
 
12 14
 if (!isset($_GET['sort'])) 
13 15
 {
@@ -565,7 +567,9 @@  discard block
 block discarded – undo
565 567
 	if (isset($globalTimezone))
566 568
 	{
567 569
 		date_default_timezone_set($globalTimezone);
568
-	} else date_default_timezone_set('UTC');
570
+	} else {
571
+		date_default_timezone_set('UTC');
572
+	}
569 573
 	if ($showSpecial === true)
570 574
 	{
571 575
 		print '<tr class="special">'."\n";
@@ -580,7 +584,9 @@  discard block
 block discarded – undo
580 584
 			print '<tr class="active">';
581 585
 		} elseif (isset($spotter_item['spotted_registration'])) {
582 586
 			print '<tr class="info">';
583
-		} else print '<tr>';
587
+		} else {
588
+			print '<tr>';
589
+		}
584 590
 	}
585 591
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
586 592
 		if ($type == 'aircraft') {
@@ -588,8 +594,9 @@  discard block
 block discarded – undo
588 594
 			{
589 595
 				print '<td class="aircraft_thumbnail">'."\n";
590 596
 				if ($spotter_item['image_source'] == 'planespotters') {
591
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
592
-					else {
597
+					if ($spotter_item['image_source_website'] != '') {
598
+						$image_src = $spotter_item['image_source_website'];
599
+					} else {
593 600
 						$planespotter_url_array = explode("_", $spotter_item['image']);
594 601
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
595 602
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -602,7 +609,9 @@  discard block
 block discarded – undo
602 609
 				} else {
603 610
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
604 611
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
605
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
612
+					} else {
613
+						$image_thumbnail = $spotter_item['image_thumbnail'];
614
+					}
606 615
 					if (isset($spotter_item['airline_name'])) {
607 616
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
608 617
 					} else {
@@ -621,7 +630,9 @@  discard block
 block discarded – undo
621 630
 				print '<td class="aircraft_thumbnail">'."\n";
622 631
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
623 632
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
624
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
633
+				} else {
634
+					$image_thumbnail = $spotter_item['image_thumbnail'];
635
+				}
625 636
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
626 637
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
627 638
 				} else {
@@ -643,7 +654,9 @@  discard block
 block discarded – undo
643 654
 				print '<td class="aircraft_thumbnail">'."\n";
644 655
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
645 656
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
646
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
657
+				} else {
658
+					$image_thumbnail = $spotter_item['image_thumbnail'];
659
+				}
647 660
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
648 661
 				print '</td>'."\n";
649 662
 			} else {
@@ -696,8 +709,9 @@  discard block
 block discarded – undo
696 709
 				print '<td class="aircraft_thumbnail">'."\n";
697 710
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
698 711
 				if ($spotter_item['image_source'] == 'planespotters') {
699
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
700
-					else {
712
+					if ($spotter_item['image_source_website'] != '') {
713
+						$image_src = $spotter_item['image_source_website'];
714
+					} else {
701 715
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
702 716
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
703 717
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -714,7 +728,9 @@  discard block
 block discarded – undo
714 728
 				} else {
715 729
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
716 730
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
717
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
731
+					} else {
732
+						$image_thumbnail = $spotter_item['image_thumbnail'];
733
+					}
718 734
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
719 735
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
720 736
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -747,7 +763,9 @@  discard block
 block discarded – undo
747 763
 				print '<td class="aircraft_thumbnail">'."\n";
748 764
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
749 765
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
750
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
766
+				} else {
767
+					$image_thumbnail = $spotter_item['image_thumbnail'];
768
+				}
751 769
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
752 770
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
753 771
 				} else {
@@ -769,7 +787,9 @@  discard block
 block discarded – undo
769 787
 				print '<td class="aircraft_thumbnail">'."\n";
770 788
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
771 789
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
772
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
790
+				} else {
791
+					$image_thumbnail = $spotter_item['image_thumbnail'];
792
+				}
773 793
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
774 794
 				print '</td>'."\n";
775 795
 			} else {
@@ -887,8 +907,11 @@  discard block
 block discarded – undo
887 907
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
888 908
 			} else {
889 909
 				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
890
-				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
891
-				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
910
+				if (count($aircraft_names) == 1) {
911
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
912
+				} else {
913
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
914
+				}
892 915
 			}
893 916
 			print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
894 917
 		} elseif ($type == 'marine') {
@@ -931,15 +954,21 @@  discard block
 block discarded – undo
931 954
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
932 955
 				if ($spotter_item['departure_airport_time'] > 2460) {
933 956
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
934
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
957
+				} else {
958
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
959
+				}
935 960
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
936 961
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
937
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
962
+				} else {
963
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
964
+				}
938 965
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
939 966
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
940 967
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
941 968
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
942
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
969
+				} else {
970
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
971
+				}
943 972
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
944 973
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
945 974
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -961,7 +990,9 @@  discard block
 block discarded – undo
961 990
 						$longitude = $spotter_item['longitude'];
962 991
 					}
963 992
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
964
-				} else $distance = '';
993
+				} else {
994
+					$distance = '';
995
+				}
965 996
 				if ($distance != '') {
966 997
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
967 998
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -988,7 +1019,9 @@  discard block
 block discarded – undo
988 1019
 			} else {
989 1020
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
990 1021
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
991
-					if (!isset($Spotter)) $Spotter = new Spotter();
1022
+					if (!isset($Spotter)) {
1023
+						$Spotter = new Spotter();
1024
+					}
992 1025
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
993 1026
 					print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
994 1027
 					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
@@ -1004,20 +1037,28 @@  discard block
 block discarded – undo
1004 1037
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1005 1038
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1006 1039
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1007
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1040
+				} else {
1041
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1042
+				}
1008 1043
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1009 1044
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1010
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1045
+				} else {
1046
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1047
+				}
1011 1048
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1012 1049
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1013 1050
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1014 1051
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1015
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1052
+				} else {
1053
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1054
+				}
1016 1055
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1017 1056
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1018 1057
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1019 1058
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1020
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1059
+				} else {
1060
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1061
+				}
1021 1062
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1022 1063
 			}
1023 1064
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -1030,7 +1071,9 @@  discard block
 block discarded – undo
1030 1071
 						$longitude = $spotter_item['longitude'];
1031 1072
 					}
1032 1073
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1033
-				} else $distance = '';
1074
+				} else {
1075
+					$distance = '';
1076
+				}
1034 1077
 				if ($distance != '') {
1035 1078
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1036 1079
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
race-detailed.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@  discard block
 block discarded – undo
38 38
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
39 39
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
40 40
 	$filter = array();
41
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
42
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
41
+	if ($year != '') {
42
+		$filter = array_merge($filter,array('year' => $year));
43
+	}
44
+	if ($month != '') {
45
+		$filter = array_merge($filter,array('month' => $month));
46
+	}
43 47
 	if ($sort != '') 
44 48
 	{
45 49
 		$spotter_array = $Marine->getMarineDataByRace($race,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -57,8 +61,12 @@  discard block
 block discarded – undo
57 61
 	{
58 62
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['race_name']);
59 63
 		$ident = $spotter_array[0]['ident'];
60
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
61
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
64
+		if (isset($spotter_array[0]['latitude'])) {
65
+			$latitude = $spotter_array[0]['latitude'];
66
+		}
67
+		if (isset($spotter_array[0]['longitude'])) {
68
+			$longitude = $spotter_array[0]['longitude'];
69
+		}
62 70
 		require_once('header.php');
63 71
 		/*
64 72
 		if (isset($globalArchive) && $globalArchive) {
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 		*/
112 120
 		print '<div class="info column">';
113 121
 		print '<h1>'.$spotter_array[0]['race_name'].'</h1>';
114
-		if (isset($spotter_array[0]['race_id']) && $spotter_array[0]['race_id'] != '') print '<div><span class="label">'._("race ID").'</span>'.$spotter_array[0]['race_id'].'</div>';
122
+		if (isset($spotter_array[0]['race_id']) && $spotter_array[0]['race_id'] != '') {
123
+			print '<div><span class="label">'._("race ID").'</span>'.$spotter_array[0]['race_id'].'</div>';
124
+		}
115 125
 		/*
116 126
 		if ($year == '' && $month == '') {
117 127
 			$Stats = new Stats();
Please login to merge, or discard this patch.
race.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			}
34 34
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
35 35
 		}
36
-		if ($firstLetter != "'") $previous = $firstLetter;
36
+		if ($firstLetter != "'") {
37
+			$previous = $firstLetter;
38
+		}
37 39
 	}
38 40
 	print '</div>';
39 41
 	$previous = null;
@@ -48,10 +50,15 @@  discard block
 block discarded – undo
48 50
 				}
49 51
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
50 52
 			}
51
-			if ($firstLetter != "'") $previous = $firstLetter;
53
+			if ($firstLetter != "'") {
54
+				$previous = $firstLetter;
55
+			}
52 56
 			print '<div class="alphabet-item">';
53
-			if (isset($value['race_id']) && $value['race_id'] != '') print '<a href="'.$globalURL.'/marine/race/'.$value['race_id'].'">'.$value['race_name'].' ('.$value['race_id'].')';
54
-			else print '<a href="'.$globalURL.'/race/'.$value['race_name'].'">'.$value['race_name'];
57
+			if (isset($value['race_id']) && $value['race_id'] != '') {
58
+				print '<a href="'.$globalURL.'/marine/race/'.$value['race_id'].'">'.$value['race_name'].' ('.$value['race_id'].')';
59
+			} else {
60
+				print '<a href="'.$globalURL.'/race/'.$value['race_name'].'">'.$value['race_name'];
61
+			}
55 62
 			print '</a>';
56 63
 			print '</div>';
57 64
 		}
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +232 added lines, -82 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -78,8 +82,11 @@  discard block
 block discarded – undo
78 82
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
79 83
 			}
80 84
 		}
81
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
85
+		if ($filter_query_where == '' && $where) {
86
+			$filter_query_where = ' WHERE';
87
+		} elseif ($filter_query_where != '' && $and) {
88
+			$filter_query_where .= ' AND';
89
+		}
83 90
 		if ($filter_query_where != '') {
84 91
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
85 92
 		}
@@ -133,40 +140,78 @@  discard block
 block discarded – undo
133 140
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
134 141
 			} elseif (isset($row['spotter_archive_output_id'])) {
135 142
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
136
-			*/} 
137
-			elseif (isset($row['marineid'])) {
143
+			*/} elseif (isset($row['marineid'])) {
138 144
 				$temp_array['marine_id'] = $row['marineid'];
139 145
 			} else {
140 146
 				$temp_array['marine_id'] = '';
141 147
 			}
142
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
143
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
144
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
145
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
146
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
147
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
148
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
149
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
150
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
151
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
152
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
153
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
154
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
155
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
156
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
157
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
148
+			if (isset($row['fammarine_id'])) {
149
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
150
+			}
151
+			if (isset($row['mmsi'])) {
152
+				$temp_array['mmsi'] = $row['mmsi'];
153
+			}
154
+			if (isset($row['type'])) {
155
+				$temp_array['type'] = $row['type'];
156
+			}
157
+			if (isset($row['type_id'])) {
158
+				$temp_array['type_id'] = $row['type_id'];
159
+			}
160
+			if (isset($row['status'])) {
161
+				$temp_array['status'] = $row['status'];
162
+			}
163
+			if (isset($row['status_id'])) {
164
+				$temp_array['status_id'] = $row['status_id'];
165
+			}
166
+			if (isset($row['captain_id'])) {
167
+				$temp_array['captain_id'] = $row['captain_id'];
168
+			}
169
+			if (isset($row['captain_name'])) {
170
+				$temp_array['captain_name'] = $row['captain_name'];
171
+			}
172
+			if (isset($row['race_id'])) {
173
+				$temp_array['race_id'] = $row['race_id'];
174
+			}
175
+			if (isset($row['race_name'])) {
176
+				$temp_array['race_name'] = $row['race_name'];
177
+			}
178
+			if (isset($row['ident'])) {
179
+				$temp_array['ident'] = $row['ident'];
180
+			}
181
+			if (isset($row['arrival_port_name'])) {
182
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
183
+			}
184
+			if (isset($row['latitude'])) {
185
+				$temp_array['latitude'] = $row['latitude'];
186
+			}
187
+			if (isset($row['longitude'])) {
188
+				$temp_array['longitude'] = $row['longitude'];
189
+			}
190
+			if (isset($row['distance']) && $row['distance'] != '') {
191
+				$temp_array['distance'] = $row['distance'];
192
+			}
193
+			if (isset($row['format_source'])) {
194
+				$temp_array['format_source'] = $row['format_source'];
195
+			}
158 196
 			if (isset($row['heading'])) {
159 197
 				$temp_array['heading'] = $row['heading'];
160 198
 				$heading_direction = $this->parseDirection($row['heading']);
161
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
199
+				if (isset($heading_direction[0]['direction_fullname'])) {
200
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
201
+				}
202
+			}
203
+			if (isset($row['ground_speed'])) {
204
+				$temp_array['ground_speed'] = $row['ground_speed'];
162 205
 			}
163
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
164 206
 
165 207
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
166 208
 			{
167 209
 				$Image = new Image($this->db);
168
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
169
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
210
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
211
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
212
+				} else {
213
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
214
+				}
170 215
 				unset($Image);
171 216
 				if (count($image_array) > 0) {
172 217
 					$temp_array['image'] = $image_array[0]['image'];
@@ -218,13 +263,21 @@  discard block
 block discarded – undo
218 263
 			}
219 264
 			
220 265
 			$fromsource = NULL;
221
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
222
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
223
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
266
+			if (isset($row['source_name']) && $row['source_name'] != '') {
267
+				$temp_array['source_name'] = $row['source_name'];
268
+			}
269
+			if (isset($row['over_country']) && $row['over_country'] != '') {
270
+				$temp_array['over_country'] = $row['over_country'];
271
+			}
272
+			if (isset($row['distance']) && $row['distance'] != '') {
273
+				$temp_array['distance'] = $row['distance'];
274
+			}
224 275
 			$temp_array['query_number_rows'] = $num_rows;
225 276
 			$spotter_array[] = $temp_array;
226 277
 		}
227
-		if ($num_rows == 0) return array();
278
+		if ($num_rows == 0) {
279
+			return array();
280
+		}
228 281
 		$spotter_array[0]['query_number_rows'] = $num_rows;
229 282
 		return $spotter_array;
230 283
 	}	
@@ -250,8 +303,12 @@  discard block
 block discarded – undo
250 303
 			{
251 304
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
252 305
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
253
-			} else $limit_query = "";
254
-		} else $limit_query = "";
306
+			} else {
307
+				$limit_query = "";
308
+			}
309
+		} else {
310
+			$limit_query = "";
311
+		}
255 312
 		if ($sort != "")
256 313
 		{
257 314
 			$search_orderby_array = $this->getOrderBy();
@@ -275,7 +332,9 @@  discard block
 block discarded – undo
275 332
 		global $global_marine_query;
276 333
 		
277 334
 		date_default_timezone_set('UTC');
278
-		if ($id == '') return array();
335
+		if ($id == '') {
336
+			return array();
337
+		}
279 338
 		$additional_query = "marine_output.fammarine_id = :id";
280 339
 		$query_values = array(':id' => $id);
281 340
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -719,8 +778,11 @@  discard block
 block discarded – undo
719 778
 		$sth = $this->db->prepare($query);
720 779
 		$sth->execute($query_values);
721 780
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
722
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
723
-		else return $result[0]['duration'];
781
+		if (is_int($result[0]['duration'])) {
782
+			return gmdate('H:i:s',$result[0]['duration']);
783
+		} else {
784
+			return $result[0]['duration'];
785
+		}
724 786
 	}
725 787
 
726 788
 	/**
@@ -779,8 +841,11 @@  discard block
 block discarded – undo
779 841
 		$query .= " ORDER BY marine_output.source_name ASC";
780 842
 
781 843
 		$sth = $this->db->prepare($query);
782
-		if (!empty($query_values)) $sth->execute($query_values);
783
-		else $sth->execute();
844
+		if (!empty($query_values)) {
845
+			$sth->execute($query_values);
846
+		} else {
847
+			$sth->execute();
848
+		}
784 849
 
785 850
 		$source_array = array();
786 851
 		$temp_array = array();
@@ -835,8 +900,11 @@  discard block
 block discarded – undo
835 900
 		$sth = $this->db->prepare($query);
836 901
 		$sth->execute(array(':mmsi' => $mmsi));
837 902
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
838
-		if (isset($result[0])) return $result[0];
839
-		else return array();
903
+		if (isset($result[0])) {
904
+			return $result[0];
905
+		} else {
906
+			return array();
907
+		}
840 908
 	}
841 909
 
842 910
 	/**
@@ -877,7 +945,9 @@  discard block
 block discarded – undo
877 945
 			date_default_timezone_set($globalTimezone);
878 946
 			$datetime = new DateTime();
879 947
 			$offset = $datetime->format('P');
880
-		} else $offset = '+00:00';
948
+		} else {
949
+			$offset = '+00:00';
950
+		}
881 951
 
882 952
 		if ($globalDBdriver == 'mysql') {
883 953
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -1129,14 +1199,28 @@  discard block
 block discarded – undo
1129 1199
 			$latitude = 0;
1130 1200
 			$longitude = 0;
1131 1201
 		}
1132
-		if ($type_id == '') $type_id = NULL;
1133
-		if ($status_id == '') $status_id = NULL;
1134
-		if ($distance == '') $distance = NULL;
1135
-		if ($race_rank == '') $race_rank = NULL;
1136
-		if ($race_time == '') $race_time = NULL;
1137
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1202
+		if ($type_id == '') {
1203
+			$type_id = NULL;
1204
+		}
1205
+		if ($status_id == '') {
1206
+			$status_id = NULL;
1207
+		}
1208
+		if ($distance == '') {
1209
+			$distance = NULL;
1210
+		}
1211
+		if ($race_rank == '') {
1212
+			$race_rank = NULL;
1213
+		}
1214
+		if ($race_time == '') {
1215
+			$race_time = NULL;
1216
+		}
1217
+		if ($heading == '' || $Common->isInteger($heading) === false) {
1218
+			$heading = 0;
1219
+		}
1138 1220
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1139
-		if ($arrival_date == '') $arrival_date = NULL;
1221
+		if ($arrival_date == '') {
1222
+			$arrival_date = NULL;
1223
+		}
1140 1224
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1141 1225
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1142 1226
 
@@ -1243,7 +1327,9 @@  discard block
 block discarded – undo
1243 1327
 		global $globalDBdriver, $globalArchive;
1244 1328
 		//$filter_query = $this->getFilter($filters,true,true);
1245 1329
 		$Connection= new Connection($this->db);
1246
-		if (!$Connection->tableExists('countries')) return array();
1330
+		if (!$Connection->tableExists('countries')) {
1331
+			return array();
1332
+		}
1247 1333
 		require_once('class.SpotterLive.php');
1248 1334
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1249 1335
 			$MarineLive = new MarineLive($this->db);
@@ -1287,7 +1373,9 @@  discard block
 block discarded – undo
1287 1373
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
1288 1374
 		}
1289 1375
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1290
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1376
+		if ($limit) {
1377
+			$query .= " LIMIT 10 OFFSET 0";
1378
+		}
1291 1379
 
1292 1380
 		$sth = $this->db->prepare($query);
1293 1381
 		$sth->execute();
@@ -1321,12 +1409,18 @@  discard block
 block discarded – undo
1321 1409
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1322 1410
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1323 1411
 		 if ($olderthanmonths > 0) {
1324
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1325
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1412
+			if ($globalDBdriver == 'mysql') {
1413
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1414
+			} else {
1415
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1416
+			}
1326 1417
 		}
1327 1418
 		if ($sincedate != '') {
1328
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1329
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1419
+			if ($globalDBdriver == 'mysql') {
1420
+				$query .= " AND marine_output.date > '".$sincedate."'";
1421
+			} else {
1422
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1423
+			}
1330 1424
 		}
1331 1425
 		$query_values = array();
1332 1426
 		if ($year != '') {
@@ -1357,7 +1451,9 @@  discard block
 block discarded – undo
1357 1451
 			}
1358 1452
 		}
1359 1453
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1360
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1454
+		if ($limit) {
1455
+			$query .= " LIMIT 10 OFFSET 0";
1456
+		}
1361 1457
       		
1362 1458
 		$sth = $this->db->prepare($query);
1363 1459
 		$sth->execute($query_values);
@@ -1392,7 +1488,9 @@  discard block
 block discarded – undo
1392 1488
 			date_default_timezone_set($globalTimezone);
1393 1489
 			$datetime = new DateTime();
1394 1490
 			$offset = $datetime->format('P');
1395
-		} else $offset = '+00:00';
1491
+		} else {
1492
+			$offset = '+00:00';
1493
+		}
1396 1494
 
1397 1495
 		if ($globalDBdriver == 'mysql') {
1398 1496
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1442,7 +1540,9 @@  discard block
 block discarded – undo
1442 1540
 			date_default_timezone_set($globalTimezone);
1443 1541
 			$datetime = new DateTime();
1444 1542
 			$offset = $datetime->format('P');
1445
-		} else $offset = '+00:00';
1543
+		} else {
1544
+			$offset = '+00:00';
1545
+		}
1446 1546
 		$filter_query = $this->getFilter($filters,true,true);
1447 1547
 		if ($globalDBdriver == 'mysql') {
1448 1548
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1488,7 +1588,9 @@  discard block
 block discarded – undo
1488 1588
 			date_default_timezone_set($globalTimezone);
1489 1589
 			$datetime = new DateTime();
1490 1590
 			$offset = $datetime->format('P');
1491
-		} else $offset = '+00:00';
1591
+		} else {
1592
+			$offset = '+00:00';
1593
+		}
1492 1594
 		$filter_query = $this->getFilter($filters,true,true);
1493 1595
 		if ($globalDBdriver == 'mysql') {
1494 1596
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1536,7 +1638,9 @@  discard block
 block discarded – undo
1536 1638
 			date_default_timezone_set($globalTimezone);
1537 1639
 			$datetime = new DateTime();
1538 1640
 			$offset = $datetime->format('P');
1539
-		} else $offset = '+00:00';
1641
+		} else {
1642
+			$offset = '+00:00';
1643
+		}
1540 1644
 
1541 1645
 		if ($globalDBdriver == 'mysql') {
1542 1646
 			$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
@@ -1585,7 +1689,9 @@  discard block
 block discarded – undo
1585 1689
 			date_default_timezone_set($globalTimezone);
1586 1690
 			$datetime = new DateTime();
1587 1691
 			$offset = $datetime->format('P');
1588
-		} else $offset = '+00:00';
1692
+		} else {
1693
+			$offset = '+00:00';
1694
+		}
1589 1695
 		$filter_query = $this->getFilter($filters,true,true);
1590 1696
 		if ($globalDBdriver == 'mysql') {
1591 1697
 			$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
@@ -1634,7 +1740,9 @@  discard block
 block discarded – undo
1634 1740
 			date_default_timezone_set($globalTimezone);
1635 1741
 			$datetime = new DateTime();
1636 1742
 			$offset = $datetime->format('P');
1637
-		} else $offset = '+00:00';
1743
+		} else {
1744
+			$offset = '+00:00';
1745
+		}
1638 1746
 
1639 1747
 		$orderby_sql = '';
1640 1748
 		if ($orderby == "hour")
@@ -1703,7 +1811,9 @@  discard block
 block discarded – undo
1703 1811
 			date_default_timezone_set($globalTimezone);
1704 1812
 			$datetime = new DateTime($date);
1705 1813
 			$offset = $datetime->format('P');
1706
-		} else $offset = '+00:00';
1814
+		} else {
1815
+			$offset = '+00:00';
1816
+		}
1707 1817
 
1708 1818
 		if ($globalDBdriver == 'mysql') {
1709 1819
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1751,7 +1861,9 @@  discard block
 block discarded – undo
1751 1861
 			date_default_timezone_set($globalTimezone);
1752 1862
 			$datetime = new DateTime();
1753 1863
 			$offset = $datetime->format('P');
1754
-		} else $offset = '+00:00';
1864
+		} else {
1865
+			$offset = '+00:00';
1866
+		}
1755 1867
 
1756 1868
 		if ($globalDBdriver == 'mysql') {
1757 1869
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1816,8 +1928,11 @@  discard block
 block discarded – undo
1816 1928
 				$query_values = array_merge($query_values,array(':month' => $month));
1817 1929
 			}
1818 1930
 		}
1819
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1820
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1931
+		if (empty($query_values)) {
1932
+			$queryi .= $this->getFilter($filters);
1933
+		} else {
1934
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1935
+		}
1821 1936
 		
1822 1937
 		$sth = $this->db->prepare($queryi);
1823 1938
 		$sth->execute($query_values);
@@ -1854,8 +1969,11 @@  discard block
 block discarded – undo
1854 1969
 				$query_values = array_merge($query_values,array(':month' => $month));
1855 1970
 			}
1856 1971
 		}
1857
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1858
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1972
+		if (empty($query_values)) {
1973
+			$queryi .= $this->getFilter($filters);
1974
+		} else {
1975
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1976
+		}
1859 1977
 		
1860 1978
 		$sth = $this->db->prepare($queryi);
1861 1979
 		$sth->execute($query_values);
@@ -1877,7 +1995,9 @@  discard block
 block discarded – undo
1877 1995
 			date_default_timezone_set($globalTimezone);
1878 1996
 			$datetime = new DateTime();
1879 1997
 			$offset = $datetime->format('P');
1880
-		} else $offset = '+00:00';
1998
+		} else {
1999
+			$offset = '+00:00';
2000
+		}
1881 2001
 
1882 2002
 		if ($globalDBdriver == 'mysql') {
1883 2003
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1981,7 +2101,9 @@  discard block
 block discarded – undo
1981 2101
 	*/
1982 2102
 	public function parseDirection($direction = 0)
1983 2103
 	{
1984
-		if ($direction == '') $direction = 0;
2104
+		if ($direction == '') {
2105
+			$direction = 0;
2106
+		}
1985 2107
 		$direction_array = array();
1986 2108
 		$temp_array = array();
1987 2109
 
@@ -2070,7 +2192,9 @@  discard block
 block discarded – undo
2070 2192
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2071 2193
 	
2072 2194
 		$Connection = new Connection($this->db);
2073
-		if (!$Connection->tableExists('countries')) return '';
2195
+		if (!$Connection->tableExists('countries')) {
2196
+			return '';
2197
+		}
2074 2198
 	
2075 2199
 		try {
2076 2200
 			/*
@@ -2090,9 +2214,13 @@  discard block
 block discarded – undo
2090 2214
 			$sth->closeCursor();
2091 2215
 			if (count($row) > 0) {
2092 2216
 				return $row;
2093
-			} else return '';
2217
+			} else {
2218
+				return '';
2219
+			}
2094 2220
 		} catch (PDOException $e) {
2095
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2221
+			if (isset($globalDebug) && $globalDebug) {
2222
+				echo 'Error : '.$e->getMessage()."\n";
2223
+			}
2096 2224
 			return '';
2097 2225
 		}
2098 2226
 	
@@ -2110,7 +2238,9 @@  discard block
 block discarded – undo
2110 2238
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2111 2239
 	
2112 2240
 		$Connection = new Connection($this->db);
2113
-		if (!$Connection->tableExists('countries')) return '';
2241
+		if (!$Connection->tableExists('countries')) {
2242
+			return '';
2243
+		}
2114 2244
 	
2115 2245
 		try {
2116 2246
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -2122,9 +2252,13 @@  discard block
 block discarded – undo
2122 2252
 			$sth->closeCursor();
2123 2253
 			if (count($row) > 0) {
2124 2254
 				return $row;
2125
-			} else return '';
2255
+			} else {
2256
+				return '';
2257
+			}
2126 2258
 		} catch (PDOException $e) {
2127
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2259
+			if (isset($globalDebug) && $globalDebug) {
2260
+				echo 'Error : '.$e->getMessage()."\n";
2261
+			}
2128 2262
 			return '';
2129 2263
 		}
2130 2264
 	
@@ -2142,7 +2276,9 @@  discard block
 block discarded – undo
2142 2276
 	{
2143 2277
 		global $globalBitlyAccessToken;
2144 2278
 		
2145
-		if ($globalBitlyAccessToken == '') return $url;
2279
+		if ($globalBitlyAccessToken == '') {
2280
+			return $url;
2281
+		}
2146 2282
         
2147 2283
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
2148 2284
 		
@@ -2218,7 +2354,9 @@  discard block
 block discarded – undo
2218 2354
 			}
2219 2355
 		}
2220 2356
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
2221
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2357
+		if ($limit) {
2358
+			$query .= " LIMIT 10 OFFSET 0";
2359
+		}
2222 2360
 		$sth = $this->db->prepare($query);
2223 2361
 		$sth->execute($query_values);
2224 2362
 		$marine_array = array();
@@ -2256,9 +2394,15 @@  discard block
 block discarded – undo
2256 2394
 				foreach ($q_array as $q_item){
2257 2395
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2258 2396
 					$additional_query .= " AND (";
2259
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2260
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2261
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2397
+					if (is_int($q_item)) {
2398
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2399
+					}
2400
+					if (is_int($q_item)) {
2401
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2402
+					}
2403
+					if (is_int($q_item)) {
2404
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2405
+					}
2262 2406
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
2263 2407
 					$additional_query .= ")";
2264 2408
 				}
@@ -2306,7 +2450,9 @@  discard block
 block discarded – undo
2306 2450
 				date_default_timezone_set($globalTimezone);
2307 2451
 				$datetime = new DateTime();
2308 2452
 				$offset = $datetime->format('P');
2309
-			} else $offset = '+00:00';
2453
+			} else {
2454
+				$offset = '+00:00';
2455
+			}
2310 2456
 			if ($date_array[1] != "")
2311 2457
 			{
2312 2458
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2333,8 +2479,12 @@  discard block
 block discarded – undo
2333 2479
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2334 2480
 			{
2335 2481
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2336
-			} else $limit_query = "";
2337
-		} else $limit_query = "";
2482
+			} else {
2483
+				$limit_query = "";
2484
+			}
2485
+		} else {
2486
+			$limit_query = "";
2487
+		}
2338 2488
 		if ($sort != "")
2339 2489
 		{
2340 2490
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +140 added lines, -47 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (MarineLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -86,8 +90,11 @@  discard block
 block discarded – undo
86 90
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
87 91
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88 92
 		}
89
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
93
+		if ($filter_query_where == '' && $where) {
94
+			$filter_query_where = ' WHERE';
95
+		} elseif ($filter_query_where != '' && $and) {
96
+			$filter_query_where .= ' AND';
97
+		}
91 98
 		if ($filter_query_where != '') {
92 99
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
93 100
 		}
@@ -128,9 +135,13 @@  discard block
 block discarded – undo
128 135
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
129 136
 			}
130 137
 		}
131
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
138
+		if ($orderby_query == '') {
139
+			$orderby_query= ' ORDER BY date DESC';
140
+		}
132 141
 
133
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
142
+		if (!isset($globalLiveInterval)) {
143
+			$globalLiveInterval = '200';
144
+		}
134 145
 		if ($globalDBdriver == 'mysql') {
135 146
 			//$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";
136 147
 			$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;
@@ -155,7 +166,9 @@  discard block
 block discarded – undo
155 166
 
156 167
 		$filter_query = $this->getFilter($filter,true,true);
157 168
 
158
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
159 172
 		if ($globalDBdriver == 'mysql') {
160 173
 			$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, marine_live.captain_name 
161 174
 			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";
@@ -197,58 +210,96 @@  discard block
 block discarded – undo
197 210
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
198 211
 		$filter_query = $this->getFilter($filter,true,true);
199 212
 
200
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
201
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
213
+		if (!isset($globalLiveInterval)) {
214
+			$globalLiveInterval = '200';
215
+		}
216
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
217
+			$globalMap3DMarinesLimit = '300';
218
+		}
202 219
 		if ($globalDBdriver == 'mysql') {
203 220
 			if (isset($globalArchive) && $globalArchive === TRUE) {
204 221
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
205 222
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
206
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
207
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
223
+				if ($usecoord) {
224
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
225
+				}
226
+				if ($id != '') {
227
+					$query .= "OR marine_archive.fammarine_id = :id ";
228
+				}
208 229
 				$query .= "UNION
209 230
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
210 231
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
211
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
212
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
232
+				if ($usecoord) {
233
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
234
+				}
235
+				if ($id != '') {
236
+					$query .= "OR marine_live.fammarine_id = :id ";
237
+				}
213 238
 				$query .= ") AS marine 
214 239
 				    WHERE latitude <> '0' AND longitude <> '0' 
215 240
 				    ORDER BY fammarine_id, date";
216
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
241
+				if ($limit) {
242
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
243
+				}
217 244
 			} else {
218 245
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
219 246
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
220
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
221
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
247
+				if ($usecoord) {
248
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
250
+				if ($id != '') {
251
+					$query .= "OR marine_live.fammarine_id = :id ";
252
+				}
222 253
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
223 254
 				ORDER BY marine_live.fammarine_id, marine_live.date";
224
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
255
+				if ($limit) {
256
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
257
+				}
225 258
 			}
226 259
 		} else {
227 260
 			if (isset($globalArchive) && $globalArchive === TRUE) {
228 261
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source, marine_archive.captain_name 
229 262
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
230
-				if ($usecoord) $query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
231
-				if ($id != '') $query .= "OR marine_archive.fammarine_id = :id ";
263
+				if ($usecoord) {
264
+					$query .= "AND (marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
265
+				}
266
+				if ($id != '') {
267
+					$query .= "OR marine_archive.fammarine_id = :id ";
268
+				}
232 269
 				$query .= "UNION
233 270
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
234 271
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
235
-				if ($usecoord) $query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
236
-				if ($id != '') $query .= " OR marine_live.fammarine_id = :id";
272
+				if ($usecoord) {
273
+					$query .= " AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
274
+				}
275
+				if ($id != '') {
276
+					$query .= " OR marine_live.fammarine_id = :id";
277
+				}
237 278
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
238 279
 				$query .= "ORDER BY fammarine_id, date";
239
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
280
+				if ($limit) {
281
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
282
+				}
240 283
 			} else {
241 284
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
242 285
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
243
-				if ($usecoord) $query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
244
-				if ($id != '') $query .= "OR marine_live.fammarine_id = :id ";
286
+				if ($usecoord) {
287
+					$query .= "AND (marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
288
+				}
289
+				if ($id != '') {
290
+					$query .= "OR marine_live.fammarine_id = :id ";
291
+				}
245 292
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
246 293
 				ORDER BY marine_live.fammarine_id, marine_live.date";
247
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
294
+				if ($limit) {
295
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
296
+				}
248 297
 			}
249 298
 		}
250 299
 		$query_values = array();
251
-		if ($id != '') $query_values = array(':id' => $id);
300
+		if ($id != '') {
301
+			$query_values = array(':id' => $id);
302
+		}
252 303
 		try {
253 304
 			$sth = $this->db->prepare($query);
254 305
 			$sth->execute($query_values);
@@ -271,7 +322,9 @@  discard block
 block discarded – undo
271 322
 		global $globalDBdriver, $globalLiveInterval;
272 323
 		$filter_query = $this->getFilter($filter,true,true);
273 324
 
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
325
+		if (!isset($globalLiveInterval)) {
326
+			$globalLiveInterval = '200';
327
+		}
275 328
 		if ($globalDBdriver == 'mysql') {
276 329
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
277 330
 		} else {
@@ -299,7 +352,9 @@  discard block
 block discarded – undo
299 352
 	{
300 353
 		global $globalDBdriver, $globalLiveInterval;
301 354
 		$Marine = new Marine($this->db);
302
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
355
+		if (!isset($globalLiveInterval)) {
356
+			$globalLiveInterval = '200';
357
+		}
303 358
 		$filter_query = $this->getFilter($filter);
304 359
 
305 360
 		if (is_array($coord)) {
@@ -307,7 +362,9 @@  discard block
 block discarded – undo
307 362
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
308 363
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
309 364
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
310
-		} else return array();
365
+		} else {
366
+			return array();
367
+		}
311 368
 		if ($globalDBdriver == 'mysql') {
312 369
 			$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 ORDER BY date DESC'.$filter_query;
313 370
 		} else {
@@ -327,7 +384,9 @@  discard block
 block discarded – undo
327 384
 	{
328 385
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
329 386
 		$Marine = new Marine($this->db);
330
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
387
+		if (!isset($globalLiveInterval)) {
388
+			$globalLiveInterval = '200';
389
+		}
331 390
 		$filter_query = $this->getFilter($filter,true,true);
332 391
 
333 392
 		if (is_array($coord)) {
@@ -335,7 +394,9 @@  discard block
 block discarded – undo
335 394
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336 395
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
337 396
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
338
-		} else return array();
397
+		} else {
398
+			return array();
399
+		}
339 400
 		/*
340 401
 		if ($globalDBdriver == 'mysql') {
341 402
 			$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 
@@ -558,11 +619,15 @@  discard block
 block discarded – undo
558 619
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
559 620
 		if ($globalDBdriver == 'mysql') {
560 621
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
561
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
622
+			if ($liveinterval) {
623
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
624
+			}
562 625
 			$query .= ' ORDER BY date';
563 626
 		} else {
564 627
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
565
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
628
+			if ($liveinterval) {
629
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
630
+			}
566 631
 			$query .= ' ORDER BY date';
567 632
 		}
568 633
 
@@ -657,7 +722,9 @@  discard block
 block discarded – undo
657 722
 				$i++;
658 723
 				$j++;
659 724
 				if ($j == 30) {
660
-					if ($globalDebug) echo ".";
725
+					if ($globalDebug) {
726
+						echo ".";
727
+					}
661 728
 				    	try {
662 729
 						
663 730
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -951,7 +1018,9 @@  discard block
 block discarded – undo
951 1018
 			{
952 1019
 				return false;
953 1020
 			}
954
-		} else return '';
1021
+		} else {
1022
+			return '';
1023
+		}
955 1024
 
956 1025
 		if ($longitude != '')
957 1026
 		{
@@ -959,7 +1028,9 @@  discard block
 block discarded – undo
959 1028
 			{
960 1029
 				return false;
961 1030
 			}
962
-		} else return '';
1031
+		} else {
1032
+			return '';
1033
+		}
963 1034
 
964 1035
 
965 1036
 		if ($heading != '')
@@ -968,7 +1039,9 @@  discard block
 block discarded – undo
968 1039
 			{
969 1040
 				return false;
970 1041
 			}
971
-		} else $heading = 0;
1042
+		} else {
1043
+			$heading = 0;
1044
+		}
972 1045
 
973 1046
 		if ($groundspeed != '')
974 1047
 		{
@@ -976,9 +1049,13 @@  discard block
 block discarded – undo
976 1049
 			{
977 1050
 				return false;
978 1051
 			}
979
-		} else $groundspeed = 0;
1052
+		} else {
1053
+			$groundspeed = 0;
1054
+		}
980 1055
 		date_default_timezone_set('UTC');
981
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1056
+		if ($date == '') {
1057
+			$date = date("Y-m-d H:i:s", time());
1058
+		}
982 1059
 
983 1060
         
984 1061
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1006,16 +1083,28 @@  discard block
 block discarded – undo
1006 1083
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
1007 1084
 		$race_rank = filter_var($race_rank,FILTER_SANITIZE_NUMBER_INT);
1008 1085
 		$race_time = filter_var($race_time,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1009
-		if ($typeid == '') $typeid = NULL;
1010
-		if ($statusid == '') $statusid = NULL;
1011
-		if ($distance == '') $distance = NULL;
1086
+		if ($typeid == '') {
1087
+			$typeid = NULL;
1088
+		}
1089
+		if ($statusid == '') {
1090
+			$statusid = NULL;
1091
+		}
1092
+		if ($distance == '') {
1093
+			$distance = NULL;
1094
+		}
1012 1095
 
1013 1096
             	//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1014
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1015
-            	if ($arrival_date == '') $arrival_date = NULL;
1097
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1098
+            		$heading = 0;
1099
+            	}
1100
+            	if ($arrival_date == '') {
1101
+            		$arrival_date = NULL;
1102
+            	}
1016 1103
             	$query = '';
1017 1104
 		if ($globalArchive) {
1018
-			if ($globalDebug) echo '-- Delete previous data -- ';
1105
+			if ($globalDebug) {
1106
+				echo '-- Delete previous data -- ';
1107
+			}
1019 1108
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
1020 1109
 		}
1021 1110
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name,distance,race_rank,race_time) 
@@ -1030,10 +1119,14 @@  discard block
 block discarded – undo
1030 1119
 		}
1031 1120
 		
1032 1121
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1033
-			if ($globalDebug) echo '(Add to Marine archive : ';
1122
+			if ($globalDebug) {
1123
+				echo '(Add to Marine archive : ';
1124
+			}
1034 1125
 			$MarineArchive = new MarineArchive($this->db);
1035 1126
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name,$distance,$race_rank,$race_time);
1036
-			if ($globalDebug) echo $result.')';
1127
+			if ($globalDebug) {
1128
+				echo $result.')';
1129
+			}
1037 1130
 		}
1038 1131
 		return "success";
1039 1132
 	}
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +207 added lines, -71 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
     public function checkAll() {
55 55
 	global $globalDebug, $globalNoDB;
56 56
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
57
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
57
+	    if ($globalDebug) {
58
+	    	echo "Update last seen tracked data...\n";
59
+	    }
58 60
 	    foreach ($this->all_tracked as $key => $flight) {
59 61
 		if (isset($this->all_tracked[$key]['id'])) {
60 62
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -68,13 +70,17 @@  discard block
 block discarded – undo
68 70
     public function del() {
69 71
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 72
 	// Delete old infos
71
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
73
+	if ($globalDebug) {
74
+		echo 'Delete old values and update latest data...'."\n";
75
+	}
72 76
 	foreach ($this->all_tracked as $key => $flight) {
73 77
     	    if (isset($flight['lastupdate'])) {
74 78
         	if ($flight['lastupdate'] < (time()-3000)) {
75 79
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76 80
             		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    if ($globalDebug) {
82
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
83
+            		    }
78 84
 			    /*
79 85
 			    $MarineLive = new MarineLive();
80 86
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -84,7 +90,9 @@  discard block
 block discarded – undo
84 90
             		    $Marine = new Marine($this->db);
85 91
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 92
 				$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'],$this->all_tracked[$key]['datetime'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
87
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
93
+				if ($globalDebug && $result != 'success') {
94
+					echo '!!! ERROR : '.$result."\n";
95
+				}
88 96
 			    }
89 97
 			    // Put in archive
90 98
 //				$Marine->db = null;
@@ -98,7 +106,9 @@  discard block
 block discarded – undo
98 106
 
99 107
     public function add($line) {
100 108
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine, $globalLiveInterval;
101
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
109
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
110
+		$globalCoordMinChange = '0.02';
111
+	}
102 112
 	date_default_timezone_set('UTC');
103 113
 	$dataFound = false;
104 114
 	$send = false;
@@ -112,20 +122,30 @@  discard block
 block discarded – undo
112 122
 		// Increment message number
113 123
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114 124
 		    $current_date = date('Y-m-d');
115
-		    if (isset($line['source_name'])) $source = $line['source_name'];
116
-		    else $source = '';
117
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
125
+		    if (isset($line['source_name'])) {
126
+		    	$source = $line['source_name'];
127
+		    } else {
128
+		    	$source = '';
129
+		    }
130
+		    if ($source == '' || $line['format_source'] == 'aprs') {
131
+		    	$source = $line['format_source'];
132
+		    }
118 133
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119 134
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120 135
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
136
+		    } else {
137
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
138
+		    }
122 139
 		}
123 140
 		
124 141
 		
125 142
 		$Common = new Common();
126 143
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
144
+	        if (!isset($line['id'])) {
145
+	        	$id = trim($line['mmsi']);
146
+	        } else {
147
+	        	$id = trim($line['id']);
148
+	        }
129 149
 		
130 150
 		if (!isset($this->all_tracked[$id])) {
131 151
 		    $this->all_tracked[$id] = array();
@@ -133,10 +153,16 @@  discard block
 block discarded – undo
133 153
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => '','distance' => NULL));
134 154
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135 155
 		    if (!isset($line['id'])) {
136
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
156
+			if (!isset($globalDaemon)) {
157
+				$globalDaemon = TRUE;
158
+			}
137 159
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
138
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
160
+		     } else {
161
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
162
+		     }
163
+		    if ($globalAllTracked !== FALSE) {
164
+		    	$dataFound = true;
165
+		    }
140 166
 		}
141 167
 		
142 168
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -193,7 +219,9 @@  discard block
 block discarded – undo
193 219
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
194 220
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
195 221
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
196
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
222
+			if ($globalDebug) {
223
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
224
+			}
197 225
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
198 226
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
199 227
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -206,7 +234,9 @@  discard block
 block discarded – undo
206 234
 			}
207 235
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
208 236
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
209
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
237
+			if ($globalDebug) {
238
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
239
+			}
210 240
 			if (!isset($line['id'])) {
211 241
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
212 242
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -215,7 +245,9 @@  discard block
 block discarded – undo
215 245
 		    }
216 246
 		}
217 247
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
218
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
248
+		    if (strtotime($line['arrival_date']) > time()) {
249
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
250
+		    }
219 251
 		}
220 252
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
221 253
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -257,34 +289,49 @@  discard block
 block discarded – undo
257 289
 				$Marine = new Marine($this->db);
258 290
 				$fromsource = NULL;
259 291
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
260
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
292
+				if ($globalDebug && $result != 'success') {
293
+					echo '!!! ERROR : '.$result."\n";
294
+				}
261 295
 				$Marine->db = null;
262
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
296
+				if ($globalDebugTimeElapsed) {
297
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
298
+				}
263 299
 			    }
264 300
 			}
265 301
 		    }
266
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
302
+		    if (!isset($this->all_tracked[$id]['id'])) {
303
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
304
+		    }
267 305
 		}
268 306
 
269 307
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
270 308
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
271 309
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
272 310
 		    } else {
273
-				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";
274
-				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";
311
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
312
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
313
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
314
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
315
+				}
275 316
 				return '';
276 317
 		    }
277 318
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
278
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
319
+			if ($globalDebug) {
320
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
321
+			}
279 322
 			return '';
280 323
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
281
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
324
+			if ($globalDebug) {
325
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
326
+			}
282 327
 			return '';
283 328
 		} elseif (!isset($line['datetime'])) {
284 329
 			date_default_timezone_set('UTC');
285 330
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
286 331
 		} else {
287
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
332
+			if ($globalDebug) {
333
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
334
+			}
288 335
 			return '';
289 336
 		}
290 337
 
@@ -297,14 +344,21 @@  discard block
 block discarded – undo
297 344
 		    if ($distance > 1000 && $distance < 10000) {
298 345
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
299 346
 			$speed = $speed*3.6;
300
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
301
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
347
+			if ($speed < 1000) {
348
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed,2)));
349
+			}
350
+  			if ($globalDebug) {
351
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
352
+  			}
302 353
 		    }
303 354
 		}
304 355
 
305 356
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
306
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
307
-	    	    else unset($timediff);
357
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
358
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
359
+	    	    } else {
360
+	    	    	unset($timediff);
361
+	    	    }
308 362
 	    	    if ($this->tmd > 5 ||
309 363
 	    		!isset($timediff) ||
310 364
 	    		$timediff > $globalLiveInterval ||
@@ -321,22 +375,32 @@  discard block
 block discarded – undo
321 375
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
322 376
 				$this->all_tracked[$id]['putinarchive'] = true;
323 377
 				
324
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
378
+				if ($globalDebug) {
379
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
380
+				}
325 381
 				$timeelapsed = microtime(true);
326 382
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
327 383
 				    $Marine = new Marine($this->db);
328 384
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
329
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
385
+				    if (!empty($all_country)) {
386
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
387
+				    }
330 388
 				    $Marine->db = null;
331
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
389
+				    if ($globalDebugTimeElapsed) {
390
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
391
+				    }
332 392
 				}
333 393
 				$this->tmd = 0;
334
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
394
+				if ($globalDebug) {
395
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
396
+				}
335 397
 			    }
336 398
 			}
337 399
 
338 400
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
339
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
401
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
402
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
403
+				}
340 404
 				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') {
341 405
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
342 406
 				    $dataFound = true;
@@ -345,8 +409,12 @@  discard block
 block discarded – undo
345 409
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
346 410
 			}
347 411
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
348
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
349
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
412
+			    if ($line['longitude'] > 180) {
413
+			    	$line['longitude'] = $line['longitude'] - 360;
414
+			    }
415
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
416
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
417
+				}
350 418
 				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') {
351 419
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
352 420
 				    $dataFound = true;
@@ -364,7 +432,9 @@  discard block
 block discarded – undo
364 432
 		    }
365 433
 		}
366 434
 		if (isset($line['last_update']) && $line['last_update'] != '') {
367
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
435
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
436
+		    	$dataFound = true;
437
+		    }
368 438
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
369 439
 		}
370 440
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -378,15 +448,21 @@  discard block
 block discarded – undo
378 448
 		}
379 449
 		
380 450
 		if (isset($line['heading']) && $line['heading'] != '') {
381
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
451
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
452
+		    	$this->all_tracked[$id]['putinarchive'] = true;
453
+		    }
382 454
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
383 455
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
384 456
 		    //$dataFound = true;
385 457
   		} 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']) {
386 458
   		    $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']);
387 459
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
388
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
389
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
460
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
461
+		    	$this->all_tracked[$id]['putinarchive'] = true;
462
+		    }
463
+  		    if ($globalDebug) {
464
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
465
+  		    }
390 466
   		}
391 467
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
392 468
 
@@ -398,28 +474,45 @@  discard block
 block discarded – undo
398 474
 		        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'])) {
399 475
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
400 476
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
401
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
477
+				    if ($globalDebug) {
478
+				    	echo "Check if vessel is already in DB...";
479
+				    }
402 480
 				    $timeelapsed = microtime(true);
403 481
 				    $MarineLive = new MarineLive($this->db);
404 482
 				    if (isset($line['id']) && isset($globalVM) && $globalVM) {
405 483
 					$Marine = new Marine($this->db);
406 484
 					$recent_ident = $Marine->checkId($line['id']);
407
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
485
+					if ($globalDebugTimeElapsed) {
486
+						echo 'Time elapsed for update checkId : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
487
+					}
408 488
 					$Marine->db=null;
409 489
 				    } elseif (isset($line['id'])) {
410 490
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
411
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
491
+					if ($globalDebugTimeElapsed) {
492
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
493
+					}
412 494
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
413 495
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
414
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+					if ($globalDebugTimeElapsed) {
497
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+					}
415 499
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
416 500
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
417
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
418
-				    } else $recent_ident = '';
501
+					if ($globalDebugTimeElapsed) {
502
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
503
+					}
504
+				    } else {
505
+				    	$recent_ident = '';
506
+				    }
419 507
 				    $MarineLive->db=null;
420
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
421
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
422
-				} else $recent_ident = '';
508
+				    if ($globalDebug && $recent_ident == '') {
509
+				    	echo " Not in DB.\n";
510
+				    } elseif ($globalDebug && $recent_ident != '') {
511
+				    	echo " Already in DB.\n";
512
+				    }
513
+				} else {
514
+					$recent_ident = '';
515
+				}
423 516
 			    } else {
424 517
 				$recent_ident = '';
425 518
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -428,32 +521,47 @@  discard block
 block discarded – undo
428 521
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
429 522
 			    {
430 523
 				if ($globalDebug) {
431
-					if ($this->all_tracked[$id]['mmsi'] == '') echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
432
-					else echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
524
+					if ($this->all_tracked[$id]['mmsi'] == '') {
525
+						echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
526
+					} else {
527
+						echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
528
+					}
433 529
 				}
434 530
 				//adds the spotter data for the archive
435 531
 				    $highlight = '';
436
-				    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')));
532
+				    if (!isset($this->all_tracked[$id]['id'])) {
533
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
534
+				    }
437 535
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
438 536
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
439 537
 					    $timeelapsed = microtime(true);
440 538
 					    $Marine = new Marine($this->db);
441 539
 					    $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]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
442 540
 					    $Marine->db = null;
443
-					    if ($globalDebug && isset($result)) echo $result."\n";
444
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					    if ($globalDebug && isset($result)) {
542
+					    	echo $result."\n";
543
+					    }
544
+					    if ($globalDebugTimeElapsed) {
545
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
546
+					    }
445 547
 					}
446 548
 				    }
447 549
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
448 550
 					// Add source stat in DB
449 551
 					$Stats = new Stats($this->db);
450 552
 					if (!empty($this->stats)) {
451
-					    if ($globalDebug) echo 'Add source stats : ';
553
+					    if ($globalDebug) {
554
+					    	echo 'Add source stats : ';
555
+					    }
452 556
 				    	    foreach($this->stats as $date => $data) {
453 557
 						foreach($data as $source => $sourced) {
454 558
 					    	    //print_r($sourced);
455
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
456
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
559
+				    	    	    if (isset($sourced['polar'])) {
560
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
561
+				    	    	    }
562
+				    	    	    if (isset($sourced['hist'])) {
563
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
564
+				    	    	    }
457 565
 				    		    if (isset($sourced['msg'])) {
458 566
 				    			if (time() - $sourced['msg']['date'] > 10) {
459 567
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -466,7 +574,9 @@  discard block
 block discarded – undo
466 574
 			    			    unset($this->stats[$date]);
467 575
 			    			}
468 576
 				    	    }
469
-				    	    if ($globalDebug) echo 'Done'."\n";
577
+				    	    if ($globalDebug) {
578
+				    	    	echo 'Done'."\n";
579
+				    	    }
470 580
 					}
471 581
 					$Stats->db = null;
472 582
 				    }
@@ -476,13 +586,17 @@  discard block
 block discarded – undo
476 586
 				$this->all_tracked[$id]['addedMarine'] = 1;
477 587
 				//print_r($this->all_tracked[$id]);
478 588
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
479
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
589
+				    if ($globalDebug) {
590
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
591
+				    }
480 592
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
481 593
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
482 594
 					$MarineLive = new MarineLive($this->db);
483 595
 					$MarineLive->deleteLiveMarineData();
484 596
 					$MarineLive->db=null;
485
-					if ($globalDebug) echo " Done\n";
597
+					if ($globalDebug) {
598
+						echo " Done\n";
599
+					}
486 600
 				    }
487 601
 				    $this->last_delete = time();
488 602
 				}
@@ -508,15 +622,21 @@  discard block
 block discarded – undo
508 622
 
509 623
 		    if (!$ignoreImport) {
510 624
 			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'])) {
511
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
625
+				if ($globalDebug) {
626
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
627
+				}
512 628
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
513 629
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
514 630
 					$timeelapsed = microtime(true);
515 631
 					$MarineLive = new MarineLive($this->db);
516 632
 					$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]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name'],$this->all_tracked[$id]['distance'],$this->all_tracked[$id]['race_rank'],$this->all_tracked[$id]['race_time']);
517 633
 					$MarineLive->db = null;
518
-					if ($globalDebug) echo $result."\n";
519
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
634
+					if ($globalDebug) {
635
+						echo $result."\n";
636
+					}
637
+					if ($globalDebugTimeElapsed) {
638
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
639
+					}
520 640
 				    }
521 641
 				}
522 642
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -528,7 +648,9 @@  discard block
 block discarded – undo
528 648
 				
529 649
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
530 650
 					$source = $this->all_tracked[$id]['source_name'];
531
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
651
+					if ($source == '') {
652
+						$source = $this->all_tracked[$id]['format_source'];
653
+					}
532 654
 					if (!isset($this->source_location[$source])) {
533 655
 						$Location = new Source($this->db);
534 656
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -549,7 +671,9 @@  discard block
 block discarded – undo
549 671
 					$stats_heading = round($stats_heading/22.5);
550 672
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
551 673
 					$current_date = date('Y-m-d');
552
-					if ($stats_heading == 16) $stats_heading = 0;
674
+					if ($stats_heading == 16) {
675
+						$stats_heading = 0;
676
+					}
553 677
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
554 678
 						for ($i=0;$i<=15;$i++) {
555 679
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -567,7 +691,9 @@  discard block
 block discarded – undo
567 691
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
568 692
 						    end($this->stats[$current_date][$source]['hist']);
569 693
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
570
-						} else $mini = 0;
694
+						} else {
695
+							$mini = 0;
696
+						}
571 697
 						for ($i=$mini;$i<=$distance;$i+=10) {
572 698
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
573 699
 						}
@@ -579,19 +705,27 @@  discard block
 block discarded – undo
579 705
 				
580 706
 
581 707
 				$this->all_tracked[$id]['lastupdate'] = time();
582
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
583
-			} 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";
708
+				if ($this->all_tracked[$id]['putinarchive']) {
709
+					$send = true;
710
+				}
711
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
712
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
713
+			}
584 714
 			//$this->del();
585 715
 			
586 716
 			
587 717
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
588 718
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
589
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
719
+				if ($globalDebug) {
720
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
721
+				}
590 722
 				$MarineLive = new MarineLive($this->db);
591 723
 				$MarineLive->deleteLiveMarineDataNotUpdated();
592 724
 				$MarineLive->db = null;
593 725
 				//MarineLive->deleteLiveMarineData();
594
-				if ($globalDebug) echo " Done\n";
726
+				if ($globalDebug) {
727
+					echo " Done\n";
728
+				}
595 729
 			    }
596 730
 			    $this->last_delete_hourly = time();
597 731
 			}
@@ -600,7 +734,9 @@  discard block
 block discarded – undo
600 734
 		    //$ignoreImport = false;
601 735
 		}
602 736
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
603
-		if ($send) return $this->all_tracked[$id];
737
+		if ($send) {
738
+			return $this->all_tracked[$id];
739
+		}
604 740
 	    }
605 741
 	}
606 742
     }
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +522 added lines, -192 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2272,14 +2428,22 @@  discard block
 block discarded – undo
2272 2428
 		$error = '';
2273 2429
 		if ($globalDBdriver == 'mysql') {
2274 2430
 			$error .= create_db::import_file('../db/aircraft.sql');
2275
-			if ($error != '') return $error;
2431
+			if ($error != '') {
2432
+				return $error;
2433
+			}
2276 2434
 			$error .= create_db::import_file('../db/aircraft_block.sql');
2277
-			if ($error != '') return $error;
2435
+			if ($error != '') {
2436
+				return $error;
2437
+			}
2278 2438
 		} else {
2279 2439
 			$error .= create_db::import_file('../db/pgsql/aircraft.sql');
2280
-			if ($error != '') return $error;
2440
+			if ($error != '') {
2441
+				return $error;
2442
+			}
2281 2443
 			$error .= create_db::import_file('../db/pgsql/aircraft_block.sql');
2282
-			if ($error != '') return $error;
2444
+			if ($error != '') {
2445
+				return $error;
2446
+			}
2283 2447
 		}
2284 2448
 		$query = "UPDATE config SET value = '51' WHERE name = 'schema_version'";
2285 2449
 		try {
@@ -2536,8 +2700,11 @@  discard block
 block discarded – undo
2536 2700
 			if ($Connection->tableExists('aircraft')) {
2537 2701
 				if (!$Connection->tableExists('config')) {
2538 2702
 					$version = '1';
2539
-					if ($update) return self::update_from_1();
2540
-					else return $version;
2703
+					if ($update) {
2704
+						return self::update_from_1();
2705
+					} else {
2706
+						return $version;
2707
+					}
2541 2708
 				} else {
2542 2709
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2543 2710
 					try {
@@ -2550,219 +2717,382 @@  discard block
 block discarded – undo
2550 2717
 					if ($update) {
2551 2718
 						if ($result['value'] == '2') {
2552 2719
 							$error = self::update_from_2();
2553
-							if ($error != '') return $error;
2554
-							else return self::check_version(true);
2720
+							if ($error != '') {
2721
+								return $error;
2722
+							} else {
2723
+								return self::check_version(true);
2724
+							}
2555 2725
 						} elseif ($result['value'] == '3') {
2556 2726
 							$error = self::update_from_3();
2557
-							if ($error != '') return $error;
2558
-							else return self::check_version(true);
2727
+							if ($error != '') {
2728
+								return $error;
2729
+							} else {
2730
+								return self::check_version(true);
2731
+							}
2559 2732
 						} elseif ($result['value'] == '4') {
2560 2733
 							$error = self::update_from_4();
2561
-							if ($error != '') return $error;
2562
-							else return self::check_version(true);
2734
+							if ($error != '') {
2735
+								return $error;
2736
+							} else {
2737
+								return self::check_version(true);
2738
+							}
2563 2739
 						} elseif ($result['value'] == '5') {
2564 2740
 							$error = self::update_from_5();
2565
-							if ($error != '') return $error;
2566
-							else return self::check_version(true);
2741
+							if ($error != '') {
2742
+								return $error;
2743
+							} else {
2744
+								return self::check_version(true);
2745
+							}
2567 2746
 						} elseif ($result['value'] == '6') {
2568 2747
 							$error = self::update_from_6();
2569
-							if ($error != '') return $error;
2570
-							else return self::check_version(true);
2748
+							if ($error != '') {
2749
+								return $error;
2750
+							} else {
2751
+								return self::check_version(true);
2752
+							}
2571 2753
 						} elseif ($result['value'] == '7') {
2572 2754
 							$error = self::update_from_7();
2573
-							if ($error != '') return $error;
2574
-							else return self::check_version(true);
2755
+							if ($error != '') {
2756
+								return $error;
2757
+							} else {
2758
+								return self::check_version(true);
2759
+							}
2575 2760
 						} elseif ($result['value'] == '8') {
2576 2761
 							$error = self::update_from_8();
2577
-							if ($error != '') return $error;
2578
-							else return self::check_version(true);
2762
+							if ($error != '') {
2763
+								return $error;
2764
+							} else {
2765
+								return self::check_version(true);
2766
+							}
2579 2767
 						} elseif ($result['value'] == '9') {
2580 2768
 							$error = self::update_from_9();
2581
-							if ($error != '') return $error;
2582
-							else return self::check_version(true);
2769
+							if ($error != '') {
2770
+								return $error;
2771
+							} else {
2772
+								return self::check_version(true);
2773
+							}
2583 2774
 						} elseif ($result['value'] == '10') {
2584 2775
 							$error = self::update_from_10();
2585
-							if ($error != '') return $error;
2586
-							else return self::check_version(true);
2776
+							if ($error != '') {
2777
+								return $error;
2778
+							} else {
2779
+								return self::check_version(true);
2780
+							}
2587 2781
 						} elseif ($result['value'] == '11') {
2588 2782
 							$error = self::update_from_11();
2589
-							if ($error != '') return $error;
2590
-							else return self::check_version(true);
2783
+							if ($error != '') {
2784
+								return $error;
2785
+							} else {
2786
+								return self::check_version(true);
2787
+							}
2591 2788
 						} elseif ($result['value'] == '12') {
2592 2789
 							$error = self::update_from_12();
2593
-							if ($error != '') return $error;
2594
-							else return self::check_version(true);
2790
+							if ($error != '') {
2791
+								return $error;
2792
+							} else {
2793
+								return self::check_version(true);
2794
+							}
2595 2795
 						} elseif ($result['value'] == '13') {
2596 2796
 							$error = self::update_from_13();
2597
-							if ($error != '') return $error;
2598
-							else return self::check_version(true);
2797
+							if ($error != '') {
2798
+								return $error;
2799
+							} else {
2800
+								return self::check_version(true);
2801
+							}
2599 2802
 						} elseif ($result['value'] == '14') {
2600 2803
 							$error = self::update_from_14();
2601
-							if ($error != '') return $error;
2602
-							else return self::check_version(true);
2804
+							if ($error != '') {
2805
+								return $error;
2806
+							} else {
2807
+								return self::check_version(true);
2808
+							}
2603 2809
 						} elseif ($result['value'] == '15') {
2604 2810
 							$error = self::update_from_15();
2605
-							if ($error != '') return $error;
2606
-							else return self::check_version(true);
2811
+							if ($error != '') {
2812
+								return $error;
2813
+							} else {
2814
+								return self::check_version(true);
2815
+							}
2607 2816
 						} elseif ($result['value'] == '16') {
2608 2817
 							$error = self::update_from_16();
2609
-							if ($error != '') return $error;
2610
-							else return self::check_version(true);
2818
+							if ($error != '') {
2819
+								return $error;
2820
+							} else {
2821
+								return self::check_version(true);
2822
+							}
2611 2823
 						} elseif ($result['value'] == '17') {
2612 2824
 							$error = self::update_from_17();
2613
-							if ($error != '') return $error;
2614
-							else return self::check_version(true);
2825
+							if ($error != '') {
2826
+								return $error;
2827
+							} else {
2828
+								return self::check_version(true);
2829
+							}
2615 2830
 						} elseif ($result['value'] == '18') {
2616 2831
 							$error = self::update_from_18();
2617
-							if ($error != '') return $error;
2618
-							else return self::check_version(true);
2832
+							if ($error != '') {
2833
+								return $error;
2834
+							} else {
2835
+								return self::check_version(true);
2836
+							}
2619 2837
 						} elseif ($result['value'] == '19') {
2620 2838
 							$error = self::update_from_19();
2621
-							if ($error != '') return $error;
2622
-							else return self::check_version(true);
2839
+							if ($error != '') {
2840
+								return $error;
2841
+							} else {
2842
+								return self::check_version(true);
2843
+							}
2623 2844
 						} elseif ($result['value'] == '20') {
2624 2845
 							$error = self::update_from_20();
2625
-							if ($error != '') return $error;
2626
-							else return self::check_version(true);
2846
+							if ($error != '') {
2847
+								return $error;
2848
+							} else {
2849
+								return self::check_version(true);
2850
+							}
2627 2851
 						} elseif ($result['value'] == '21') {
2628 2852
 							$error = self::update_from_21();
2629
-							if ($error != '') return $error;
2630
-							else return self::check_version(true);
2853
+							if ($error != '') {
2854
+								return $error;
2855
+							} else {
2856
+								return self::check_version(true);
2857
+							}
2631 2858
 						} elseif ($result['value'] == '22') {
2632 2859
 							$error = self::update_from_22();
2633
-							if ($error != '') return $error;
2634
-							else return self::check_version(true);
2860
+							if ($error != '') {
2861
+								return $error;
2862
+							} else {
2863
+								return self::check_version(true);
2864
+							}
2635 2865
 						} elseif ($result['value'] == '23') {
2636 2866
 							$error = self::update_from_23();
2637
-							if ($error != '') return $error;
2638
-							else return self::check_version(true);
2867
+							if ($error != '') {
2868
+								return $error;
2869
+							} else {
2870
+								return self::check_version(true);
2871
+							}
2639 2872
 						} elseif ($result['value'] == '24') {
2640 2873
 							$error = self::update_from_24();
2641
-							if ($error != '') return $error;
2642
-							else return self::check_version(true);
2874
+							if ($error != '') {
2875
+								return $error;
2876
+							} else {
2877
+								return self::check_version(true);
2878
+							}
2643 2879
 						} elseif ($result['value'] == '25') {
2644 2880
 							$error = self::update_from_25();
2645
-							if ($error != '') return $error;
2646
-							else return self::check_version(true);
2881
+							if ($error != '') {
2882
+								return $error;
2883
+							} else {
2884
+								return self::check_version(true);
2885
+							}
2647 2886
 						} elseif ($result['value'] == '26') {
2648 2887
 							$error = self::update_from_26();
2649
-							if ($error != '') return $error;
2650
-							else return self::check_version(true);
2888
+							if ($error != '') {
2889
+								return $error;
2890
+							} else {
2891
+								return self::check_version(true);
2892
+							}
2651 2893
 						} elseif ($result['value'] == '27') {
2652 2894
 							$error = self::update_from_27();
2653
-							if ($error != '') return $error;
2654
-							else return self::check_version(true);
2895
+							if ($error != '') {
2896
+								return $error;
2897
+							} else {
2898
+								return self::check_version(true);
2899
+							}
2655 2900
 						} elseif ($result['value'] == '28') {
2656 2901
 							$error = self::update_from_28();
2657
-							if ($error != '') return $error;
2658
-							else return self::check_version(true);
2902
+							if ($error != '') {
2903
+								return $error;
2904
+							} else {
2905
+								return self::check_version(true);
2906
+							}
2659 2907
 						} elseif ($result['value'] == '29') {
2660 2908
 							$error = self::update_from_29();
2661
-							if ($error != '') return $error;
2662
-							else return self::check_version(true);
2909
+							if ($error != '') {
2910
+								return $error;
2911
+							} else {
2912
+								return self::check_version(true);
2913
+							}
2663 2914
 						} elseif ($result['value'] == '30') {
2664 2915
 							$error = self::update_from_30();
2665
-							if ($error != '') return $error;
2666
-							else return self::check_version(true);
2916
+							if ($error != '') {
2917
+								return $error;
2918
+							} else {
2919
+								return self::check_version(true);
2920
+							}
2667 2921
 						} elseif ($result['value'] == '31') {
2668 2922
 							$error = self::update_from_31();
2669
-							if ($error != '') return $error;
2670
-							else return self::check_version(true);
2923
+							if ($error != '') {
2924
+								return $error;
2925
+							} else {
2926
+								return self::check_version(true);
2927
+							}
2671 2928
 						} elseif ($result['value'] == '32') {
2672 2929
 							$error = self::update_from_32();
2673
-							if ($error != '') return $error;
2674
-							else return self::check_version(true);
2930
+							if ($error != '') {
2931
+								return $error;
2932
+							} else {
2933
+								return self::check_version(true);
2934
+							}
2675 2935
 						} elseif ($result['value'] == '33') {
2676 2936
 							$error = self::update_from_33();
2677
-							if ($error != '') return $error;
2678
-							else return self::check_version(true);
2937
+							if ($error != '') {
2938
+								return $error;
2939
+							} else {
2940
+								return self::check_version(true);
2941
+							}
2679 2942
 						} elseif ($result['value'] == '34') {
2680 2943
 							$error = self::update_from_34();
2681
-							if ($error != '') return $error;
2682
-							else return self::check_version(true);
2944
+							if ($error != '') {
2945
+								return $error;
2946
+							} else {
2947
+								return self::check_version(true);
2948
+							}
2683 2949
 						} elseif ($result['value'] == '35') {
2684 2950
 							$error = self::update_from_35();
2685
-							if ($error != '') return $error;
2686
-							else return self::check_version(true);
2951
+							if ($error != '') {
2952
+								return $error;
2953
+							} else {
2954
+								return self::check_version(true);
2955
+							}
2687 2956
 						} elseif ($result['value'] == '36') {
2688 2957
 							$error = self::update_from_36();
2689
-							if ($error != '') return $error;
2690
-							else return self::check_version(true);
2958
+							if ($error != '') {
2959
+								return $error;
2960
+							} else {
2961
+								return self::check_version(true);
2962
+							}
2691 2963
 						} elseif ($result['value'] == '37') {
2692 2964
 							$error = self::update_from_37();
2693
-							if ($error != '') return $error;
2694
-							else return self::check_version(true);
2965
+							if ($error != '') {
2966
+								return $error;
2967
+							} else {
2968
+								return self::check_version(true);
2969
+							}
2695 2970
 						} elseif ($result['value'] == '38') {
2696 2971
 							$error = self::update_from_38();
2697
-							if ($error != '') return $error;
2698
-							else return self::check_version(true);
2972
+							if ($error != '') {
2973
+								return $error;
2974
+							} else {
2975
+								return self::check_version(true);
2976
+							}
2699 2977
 						} elseif ($result['value'] == '39') {
2700 2978
 							$error = self::update_from_39();
2701
-							if ($error != '') return $error;
2702
-							else return self::check_version(true);
2979
+							if ($error != '') {
2980
+								return $error;
2981
+							} else {
2982
+								return self::check_version(true);
2983
+							}
2703 2984
 						} elseif ($result['value'] == '40') {
2704 2985
 							$error = self::update_from_40();
2705
-							if ($error != '') return $error;
2706
-							else return self::check_version(true);
2986
+							if ($error != '') {
2987
+								return $error;
2988
+							} else {
2989
+								return self::check_version(true);
2990
+							}
2707 2991
 						} elseif ($result['value'] == '41') {
2708 2992
 							$error = self::update_from_41();
2709
-							if ($error != '') return $error;
2710
-							else return self::check_version(true);
2993
+							if ($error != '') {
2994
+								return $error;
2995
+							} else {
2996
+								return self::check_version(true);
2997
+							}
2711 2998
 						} elseif ($result['value'] == '42') {
2712 2999
 							$error = self::update_from_42();
2713
-							if ($error != '') return $error;
2714
-							else return self::check_version(true);
3000
+							if ($error != '') {
3001
+								return $error;
3002
+							} else {
3003
+								return self::check_version(true);
3004
+							}
2715 3005
 						} elseif ($result['value'] == '43') {
2716 3006
 							$error = self::update_from_43();
2717
-							if ($error != '') return $error;
2718
-							else return self::check_version(true);
3007
+							if ($error != '') {
3008
+								return $error;
3009
+							} else {
3010
+								return self::check_version(true);
3011
+							}
2719 3012
 						} elseif ($result['value'] == '44') {
2720 3013
 							$error = self::update_from_44();
2721
-							if ($error != '') return $error;
2722
-							else return self::check_version(true);
3014
+							if ($error != '') {
3015
+								return $error;
3016
+							} else {
3017
+								return self::check_version(true);
3018
+							}
2723 3019
 						} elseif ($result['value'] == '45') {
2724 3020
 							$error = self::update_from_45();
2725
-							if ($error != '') return $error;
2726
-							else return self::check_version(true);
3021
+							if ($error != '') {
3022
+								return $error;
3023
+							} else {
3024
+								return self::check_version(true);
3025
+							}
2727 3026
 						} elseif ($result['value'] == '46') {
2728 3027
 							$error = self::update_from_46();
2729
-							if ($error != '') return $error;
2730
-							else return self::check_version(true);
3028
+							if ($error != '') {
3029
+								return $error;
3030
+							} else {
3031
+								return self::check_version(true);
3032
+							}
2731 3033
 						} elseif ($result['value'] == '47') {
2732 3034
 							$error = self::update_from_47();
2733
-							if ($error != '') return $error;
2734
-							else return self::check_version(true);
3035
+							if ($error != '') {
3036
+								return $error;
3037
+							} else {
3038
+								return self::check_version(true);
3039
+							}
2735 3040
 						} elseif ($result['value'] == '48') {
2736 3041
 							$error = self::update_from_48();
2737
-							if ($error != '') return $error;
2738
-							else return self::check_version(true);
3042
+							if ($error != '') {
3043
+								return $error;
3044
+							} else {
3045
+								return self::check_version(true);
3046
+							}
2739 3047
 						} elseif ($result['value'] == '49') {
2740 3048
 							$error = self::update_from_49();
2741
-							if ($error != '') return $error;
2742
-							else return self::check_version(true);
3049
+							if ($error != '') {
3050
+								return $error;
3051
+							} else {
3052
+								return self::check_version(true);
3053
+							}
2743 3054
 						} elseif ($result['value'] == '50') {
2744 3055
 							$error = self::update_from_50();
2745
-							if ($error != '') return $error;
2746
-							else return self::check_version(true);
3056
+							if ($error != '') {
3057
+								return $error;
3058
+							} else {
3059
+								return self::check_version(true);
3060
+							}
2747 3061
 						} elseif ($result['value'] == '51') {
2748 3062
 							$error = self::update_from_51();
2749
-							if ($error != '') return $error;
2750
-							else return self::check_version(true);
3063
+							if ($error != '') {
3064
+								return $error;
3065
+							} else {
3066
+								return self::check_version(true);
3067
+							}
2751 3068
 						} elseif ($result['value'] == '52') {
2752 3069
 							$error = self::update_from_52();
2753
-							if ($error != '') return $error;
2754
-							else return self::check_version(true);
3070
+							if ($error != '') {
3071
+								return $error;
3072
+							} else {
3073
+								return self::check_version(true);
3074
+							}
2755 3075
 						} elseif ($result['value'] == '53') {
2756 3076
 							$error = self::update_from_53();
2757
-							if ($error != '') return $error;
2758
-							else return self::check_version(true);
2759
-						} else return '';
3077
+							if ($error != '') {
3078
+								return $error;
3079
+							} else {
3080
+								return self::check_version(true);
3081
+							}
3082
+						} else {
3083
+							return '';
3084
+						}
2760 3085
 					} else {
2761
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2762
-						else return 0;
3086
+						if (isset($result['value']) && $result['value'] != '') {
3087
+							return $result['value'];
3088
+						} else {
3089
+							return 0;
3090
+						}
2763 3091
 					}
2764 3092
 				}
2765
-			} else return $version;
3093
+			} else {
3094
+				return $version;
3095
+			}
2766 3096
 		}
2767 3097
 	}
2768 3098
 }
Please login to merge, or discard this patch.
captain-detailed.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -38,8 +38,12 @@  discard block
 block discarded – undo
38 38
 	$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
39 39
 	$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
40 40
 	$filter = array();
41
-	if ($year != '') $filter = array_merge($filter,array('year' => $year));
42
-	if ($month != '') $filter = array_merge($filter,array('month' => $month));
41
+	if ($year != '') {
42
+		$filter = array_merge($filter,array('year' => $year));
43
+	}
44
+	if ($month != '') {
45
+		$filter = array_merge($filter,array('month' => $month));
46
+	}
43 47
 	if ($sort != '') 
44 48
 	{
45 49
 		$spotter_array = $Marine->getMarineDataByCaptain($captain,$limit_start.",".$absolute_difference, $sort,$filter);
@@ -57,8 +61,12 @@  discard block
 block discarded – undo
57 61
 	{
58 62
 		$title = sprintf(_("Detailed View for %s"),$spotter_array[0]['captain_name']);
59 63
 		$ident = $spotter_array[0]['ident'];
60
-		if (isset($spotter_array[0]['latitude'])) $latitude = $spotter_array[0]['latitude'];
61
-		if (isset($spotter_array[0]['longitude'])) $longitude = $spotter_array[0]['longitude'];
64
+		if (isset($spotter_array[0]['latitude'])) {
65
+			$latitude = $spotter_array[0]['latitude'];
66
+		}
67
+		if (isset($spotter_array[0]['longitude'])) {
68
+			$longitude = $spotter_array[0]['longitude'];
69
+		}
62 70
 		require_once('header.php');
63 71
 		/*
64 72
 		if (isset($globalArchive) && $globalArchive) {
@@ -111,7 +119,9 @@  discard block
 block discarded – undo
111 119
 		*/
112 120
 		print '<div class="info column">';
113 121
 		print '<h1>'.$spotter_array[0]['captain_name'].'</h1>';
114
-		if (isset($spotter_array[0]['captain_id']) && $spotter_array[0]['captain_id'] != '') print '<div><span class="label">'._("Captain ID").'</span>'.$spotter_array[0]['captain_id'].'</div>';
122
+		if (isset($spotter_array[0]['captain_id']) && $spotter_array[0]['captain_id'] != '') {
123
+			print '<div><span class="label">'._("Captain ID").'</span>'.$spotter_array[0]['captain_id'].'</div>';
124
+		}
115 125
 		/*
116 126
 		if ($year == '' && $month == '') {
117 127
 			$Stats = new Stats();
@@ -130,7 +140,9 @@  discard block
 block discarded – undo
130 140
 		//$airlines = count($Marine->countAllAirlinesByCaptain($captain,$filter));
131 141
 		//print '<div><span class="label">'._("Airlines").'</span>'.$airlines.'</div>';
132 142
 		$duration = $Marine->getRaceDurationByCaptain($captain,$filter);
133
-		if ($duration != '0') print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
143
+		if ($duration != '0') {
144
+			print '<div><span class="label">'._("Total races spotted duration").'</span>'.$duration.'</div>';
145
+		}
134 146
 		print '</div>';
135 147
 	
136 148
 		//include('captain-sub-menu.php');
Please login to merge, or discard this patch.
header.php 1 patch
Braces   +95 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,12 +6,19 @@  discard block
 block discarded – undo
6 6
 //gets the page file and stores it in a variable
7 7
 $file_path = pathinfo($_SERVER['SCRIPT_NAME']);
8 8
 $current_page = $file_path['filename'];
9
-if ($globalTimezone == '') $globalTimezone = 'UTC';
9
+if ($globalTimezone == '') {
10
+	$globalTimezone = 'UTC';
11
+}
10 12
 date_default_timezone_set($globalTimezone);
11
-if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') $MapType = $_COOKIE['MapType'];
12
-else $MapType = $globalMapProvider;
13
+if (isset($_COOKIE['MapType']) && $_COOKIE['MapType'] != '') {
14
+	$MapType = $_COOKIE['MapType'];
15
+} else {
16
+	$MapType = $globalMapProvider;
17
+}
13 18
 
14
-if (isset($globalMapOffline) && $globalMapOffline) $MapType = 'offline';
19
+if (isset($globalMapOffline) && $globalMapOffline) {
20
+	$MapType = 'offline';
21
+}
15 22
 
16 23
 if (isset($_GET['3d'])) {
17 24
 	setcookie('MapFormat','3d');
@@ -209,7 +216,10 @@  discard block
 block discarded – undo
209 216
 <?php
210 217
 		} else {
211 218
 ?>
212
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) print '&tsk='.$tsk; ?>"></script>
219
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?<?php print time(); ?><?php if (isset($tsk)) {
220
+	print '&tsk='.$tsk;
221
+}
222
+?>"></script>
213 223
 <?php
214 224
 		}
215 225
 		if (!isset($globalAircraft) || $globalAircraft) {
@@ -249,7 +259,13 @@  discard block
 block discarded – undo
249 259
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
250 260
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
251 261
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
252
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
262
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?ident=<?php print $ident; ?><?php if(isset($latitude)) {
263
+	print '&latitude='.$latitude;
264
+}
265
+?><?php if(isset($longitude)) {
266
+	print '&longitude='.$longitude;
267
+}
268
+?>&<?php print time(); ?>"></script>
253 269
 <?php
254 270
 		if (!isset($type) || $type == 'aircraft') {
255 271
 ?>
@@ -322,7 +338,13 @@  discard block
 block discarded – undo
322 338
 <script src="<?php print $globalURL; ?>/js/MovingMarker.js"></script>
323 339
 <script src="<?php print $globalURL; ?>/js/jquery.idle.min.js"></script>
324 340
 <script src="<?php print $globalURL; ?>/js/map.common.js"></script>
325
-<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) print '&latitude='.$latitude; ?><?php if(isset($longitude)) print '&longitude='.$longitude; ?>&<?php print time(); ?>"></script>
341
+<script src="<?php print $globalURL; ?>/js/map.2d.js.php?flightaware_id=<?php print $flightaware_id; ?><?php if(isset($latitude)) {
342
+	print '&latitude='.$latitude;
343
+}
344
+?><?php if(isset($longitude)) {
345
+	print '&longitude='.$longitude;
346
+}
347
+?>&<?php print time(); ?>"></script>
326 348
 <script src="<?php print $globalURL; ?>/js/map-aircraft.2d.js.php?flightaware_id=<?php print $flightaware_id; ?>&<?php print time(); ?>"></script>
327 349
 <?php
328 350
 		if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '' && ($MapType == 'Google-Roadmap' || $MapType == 'Google-Satellite' || $MapType == 'Google-Hybrid' || $MapType == 'Google-Terrain')) {
@@ -403,7 +425,12 @@  discard block
 block discarded – undo
403 425
         <span class="icon-bar"></span>
404 426
       </button>
405 427
       <a href="<?php print $globalURL; ?>/search" class="navbar-toggle search"><i class="fa fa-search"></i></a>
406
-      <a class="navbar-brand" href="<?php if ($globalURL == '') print '/'; else print $globalURL; ?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
428
+      <a class="navbar-brand" href="<?php if ($globalURL == '') {
429
+	print '/';
430
+} else {
431
+	print $globalURL;
432
+}
433
+?>"><img src="<?php print $globalURL.$logoURL; ?>" height="30px" /></a>
407 434
     </div>
408 435
     <div class="collapse navbar-collapse">
409 436
 
@@ -458,7 +485,10 @@  discard block
 block discarded – undo
458 485
 	}
459 486
 ?>
460 487
 
461
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
488
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
489
+	echo 'right-';
490
+}
491
+?>caret"></b></a>
462 492
           <ul class="dropdown-menu">
463 493
           	<li><a href="<?php print $globalURL; ?>/aircraft"><?php echo _("Aircraft Types"); ?></a></li>
464 494
 <?php
@@ -529,8 +559,14 @@  discard block
 block discarded – undo
529 559
         </li>
530 560
       	<li><a href="<?php print $globalURL; ?>/search"><?php echo _("Search"); ?></a></li>
531 561
       	<li><a href="<?php print $globalURL; ?>/statistics"><?php echo _("Statistics"); ?></a></li>
532
-        <li class="dropdown<?php if ($sub) echo '-submenu'; ?>">
533
-          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
562
+        <li class="dropdown<?php if ($sub) {
563
+	echo '-submenu';
564
+}
565
+?>">
566
+          <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Tools"); ?> <b class="<?php if ($sub) {
567
+	echo 'right-';
568
+}
569
+?>caret"></b></a>
534 570
           <ul class="dropdown-menu">
535 571
           	<li><a href="<?php print $globalURL; ?>/tools/acars"><?php echo _("ACARS translator"); ?></a></li>
536 572
           	<li><a href="<?php print $globalURL; ?>/tools/metar"><?php echo _("METAR translator"); ?></a></li>
@@ -574,7 +610,10 @@  discard block
 block discarded – undo
574 610
 <?php
575 611
 	}
576 612
 ?>
577
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
613
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
614
+	echo 'right-';
615
+}
616
+?>caret"></b></a>
578 617
 		<ul class="dropdown-menu">
579 618
 <?php
580 619
 	if (isset($globalVM) && $globalVM) {
@@ -624,7 +663,10 @@  discard block
 block discarded – undo
624 663
 <?php
625 664
 	}
626 665
 ?>
627
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
666
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
667
+	echo 'right-';
668
+}
669
+?>caret"></b></a>
628 670
 		<ul class="dropdown-menu">
629 671
 		    <li><a href="<?php print $globalURL; ?>/tracker/currently"><?php echo _("Current Activity"); ?></a></li>
630 672
 		    <li><a href="<?php print $globalURL; ?>/tracker/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -667,7 +709,10 @@  discard block
 block discarded – undo
667 709
 ?>
668 710
 
669 711
 <!--
670
-		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) echo 'right-'; ?>caret"></b></a>
712
+		<a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo _("Explore"); ?> <b class="<?php if ($sub) {
713
+	echo 'right-';
714
+}
715
+?>caret"></b></a>
671 716
 		<ul class="dropdown-menu">
672 717
 		    <li><a href="<?php print $globalURL; ?>/satellite/currently"><?php echo _("Current Activity"); ?></a></li>
673 718
 		    <li><a href="<?php print $globalURL; ?>/satellite/latest"><?php echo _("Latest Activity"); ?></a></li>
@@ -725,9 +770,14 @@  discard block
 block discarded – undo
725 770
   		    <?php
726 771
   		        foreach ($alllang as $key => $lang) {
727 772
   		            print '<option value="'.$key.'"';
728
-  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) print ' selected ';
729
-  		            if ($lang[0] == 'Deutsch') print '>'.$lang[0].' (&beta;eta)</option>';
730
-  		            else print '>'.$lang[0].'</option>';
773
+  		            if (isset($_COOKIE['language']) && $_COOKIE['language'] == $key) {
774
+  		            	print ' selected ';
775
+  		            }
776
+  		            if ($lang[0] == 'Deutsch') {
777
+  		            	print '>'.$lang[0].' (&beta;eta)</option>';
778
+  		            } else {
779
+  		            	print '>'.$lang[0].'</option>';
780
+  		            }
731 781
   		        }
732 782
   		    ?>
733 783
   		</select>
@@ -875,9 +925,24 @@  discard block
 block discarded – undo
875 925
 	$customid = $globalMapProvider;
876 926
 ?>
877 927
     L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
878
-        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
879
-        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
880
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
928
+        maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
929
+	print $globalMapCustomLayer[$customid]['maxZoom'];
930
+} else {
931
+	print '18';
932
+}
933
+?>,
934
+        minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
935
+	print $globalMapCustomLayer[$customid]['minZoom'];
936
+} else {
937
+	print '0';
938
+}
939
+?>,
940
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
941
+	print 'false';
942
+} else {
943
+	print 'true';
944
+}
945
+?>,
881 946
         attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
882 947
     }).addTo(map);
883 948
 <?php
@@ -892,7 +957,12 @@  discard block
 block discarded – undo
892 957
         maxZoom: 5,
893 958
         tms : true,
894 959
         zindex : 3,
895
-        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
960
+        noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
961
+	print 'false';
962
+} else {
963
+	print 'true';
964
+}
965
+?>,
896 966
         attribution: 'Natural Earth'
897 967
     }).addTo(map);
898 968
 <?php
@@ -915,4 +985,7 @@  discard block
 block discarded – undo
915 985
 
916 986
 ?>
917 987
 
918
-<section class="container main-content <?php if (strtolower($current_page) == 'index') print 'index '; ?>clear">
988
+<section class="container main-content <?php if (strtolower($current_page) == 'index') {
989
+	print 'index ';
990
+}
991
+?>clear">
Please login to merge, or discard this patch.