Completed
Push — master ( 118bb3...d652ce )
by Yannick
29:38
created
footer.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,10 @@
 block discarded – undo
9 9
 	<?php
10 10
 	    }
11 11
 	?>
12
-	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) print $globalURL; ?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
12
+	<span>Developed in Barrie by <a href="http://mtru.nz/" target="_blank">Mario Trunz</a> & at <a href="http://www.zugaina.com" target="_blank">Zugaina</a> by Ycarus</span> - <span><a href="<?php if (isset($globalURL)) {
13
+	print $globalURL;
14
+}
15
+?>/about#source">Source &amp; Credits</a></span> - <span><a href="https://www.flightairmap.fr/" target="_blank">Get source code</a></span>
13 16
 </footer>
14 17
 
15 18
 <div class="notifications bottom-left"></div>
Please login to merge, or discard this patch.
require/class.Tracker.php 1 patch
Braces   +149 added lines, -53 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,26 +130,43 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['trackerid'])) {
133
+			*/} elseif (isset($row['trackerid'])) {
130 134
 				$temp_array['trackerid'] = $row['trackerid'];
131 135
 			} else {
132 136
 				$temp_array['trackerid'] = '';
133 137
 			}
134
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
135
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
136
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
138
+			if (isset($row['famtrackid'])) {
139
+				$temp_array['famtrackid'] = $row['famtrackid'];
140
+			}
141
+			if (isset($row['type'])) {
142
+				$temp_array['type'] = $row['type'];
143
+			}
144
+			if (isset($row['comment'])) {
145
+				$temp_array['comment'] = $row['comment'];
146
+			}
137 147
 			$temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
141
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
157
+			if (isset($row['altitude'])) {
158
+				$temp_array['altitude'] = $row['altitude'];
159
+			}
142 160
 			if (isset($row['heading'])) {
143 161
 				$temp_array['heading'] = $row['heading'];
144 162
 				$heading_direction = $this->parseDirection($row['heading']);
145
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
146 169
 			}
147
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
148 170
 			
149 171
 			if (isset($row['date'])) {
150 172
 				$dateArray = $this->parseDateString($row['date']);
@@ -187,13 +209,21 @@  discard block
 block discarded – undo
187 209
 			}
188 210
 			
189 211
 			$fromsource = NULL;
190
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
191
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
192
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
212
+			if (isset($row['source_name']) && $row['source_name'] != '') {
213
+				$temp_array['source_name'] = $row['source_name'];
214
+			}
215
+			if (isset($row['over_country']) && $row['over_country'] != '') {
216
+				$temp_array['over_country'] = $row['over_country'];
217
+			}
218
+			if (isset($row['distance']) && $row['distance'] != '') {
219
+				$temp_array['distance'] = $row['distance'];
220
+			}
193 221
 			$temp_array['query_number_rows'] = $num_rows;
194 222
 			$spotter_array[] = $temp_array;
195 223
 		}
196
-		if ($num_rows == 0) return array();
224
+		if ($num_rows == 0) {
225
+			return array();
226
+		}
197 227
 		$spotter_array[0]['query_number_rows'] = $num_rows;
198 228
 		return $spotter_array;
199 229
 	}	
@@ -224,8 +254,12 @@  discard block
 block discarded – undo
224 254
 			{
225 255
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
226 256
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
227
-			} else $limit_query = "";
228
-		} else $limit_query = "";
257
+			} else {
258
+				$limit_query = "";
259
+			}
260
+		} else {
261
+			$limit_query = "";
262
+		}
229 263
 		
230 264
 		if ($sort != "")
231 265
 		{
@@ -253,7 +287,9 @@  discard block
 block discarded – undo
253 287
 		global $global_query;
254 288
 		
255 289
 		date_default_timezone_set('UTC');
256
-		if ($id == '') return array();
290
+		if ($id == '') {
291
+			return array();
292
+		}
257 293
 		$additional_query = "tracker_output.famtrackid = :id";
258 294
 		$query_values = array(':id' => $id);
259 295
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -396,8 +432,11 @@  discard block
 block discarded – undo
396 432
 		$query .= " ORDER BY tracker_output.source_name ASC";
397 433
 
398 434
 		$sth = $this->db->prepare($query);
399
-		if (!empty($query_values)) $sth->execute($query_values);
400
-		else $sth->execute();
435
+		if (!empty($query_values)) {
436
+			$sth->execute($query_values);
437
+		} else {
438
+			$sth->execute();
439
+		}
401 440
 
402 441
 		$source_array = array();
403 442
 		$temp_array = array();
@@ -452,7 +491,9 @@  discard block
 block discarded – undo
452 491
 			date_default_timezone_set($globalTimezone);
453 492
 			$datetime = new DateTime();
454 493
 			$offset = $datetime->format('P');
455
-		} else $offset = '+00:00';
494
+		} else {
495
+			$offset = '+00:00';
496
+		}
456 497
 
457 498
 		if ($globalDBdriver == 'mysql') {
458 499
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -608,7 +649,9 @@  discard block
 block discarded – undo
608 649
 			{
609 650
 				return false;
610 651
 			}
611
-		} else $altitude = 0;
652
+		} else {
653
+			$altitude = 0;
654
+		}
612 655
 		
613 656
 		if ($heading != "")
614 657
 		{
@@ -647,8 +690,12 @@  discard block
 block discarded – undo
647 690
             		$latitude = 0;
648 691
             		$longitude = 0;
649 692
             	}
650
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
651
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
693
+                if ($heading == '' || $Common->isInteger($heading) === false) {
694
+                	$heading = 0;
695
+                }
696
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
697
+                	$groundspeed = 0;
698
+                }
652 699
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
653 700
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
654 701
 
@@ -757,7 +804,9 @@  discard block
 block discarded – undo
757 804
 		global $globalDBdriver, $globalArchive;
758 805
 		//$filter_query = $this->getFilter($filters,true,true);
759 806
 		$Connection= new Connection($this->db);
760
-		if (!$Connection->tableExists('countries')) return array();
807
+		if (!$Connection->tableExists('countries')) {
808
+			return array();
809
+		}
761 810
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
762 811
 			require_once('class.TrackerLive.php');
763 812
 			$TrackerLive = new TrackerLive();
@@ -800,7 +849,9 @@  discard block
 block discarded – undo
800 849
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
801 850
 		}
802 851
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
803
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
852
+		if ($limit) {
853
+			$query .= " LIMIT 10 OFFSET 0";
854
+		}
804 855
       
805 856
 		
806 857
 		$sth = $this->db->prepare($query);
@@ -833,12 +884,18 @@  discard block
 block discarded – undo
833 884
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
834 885
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
835 886
 		 if ($olderthanmonths > 0) {
836
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
837
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
887
+			if ($globalDBdriver == 'mysql') {
888
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
889
+			} else {
890
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
891
+			}
838 892
 		}
839 893
 		if ($sincedate != '') {
840
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
841
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
894
+			if ($globalDBdriver == 'mysql') {
895
+				$query .= " AND tracker_output.date > '".$sincedate."'";
896
+			} else {
897
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
898
+			}
842 899
 		}
843 900
 		$query_values = array();
844 901
 		if ($year != '') {
@@ -869,7 +926,9 @@  discard block
 block discarded – undo
869 926
 			}
870 927
 		}
871 928
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
872
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
929
+		if ($limit) {
930
+			$query .= " LIMIT 10 OFFSET 0";
931
+		}
873 932
       		
874 933
 		$sth = $this->db->prepare($query);
875 934
 		$sth->execute($query_values);
@@ -904,7 +963,9 @@  discard block
 block discarded – undo
904 963
 			date_default_timezone_set($globalTimezone);
905 964
 			$datetime = new DateTime();
906 965
 			$offset = $datetime->format('P');
907
-		} else $offset = '+00:00';
966
+		} else {
967
+			$offset = '+00:00';
968
+		}
908 969
 
909 970
 		if ($globalDBdriver == 'mysql') {
910 971
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -954,7 +1015,9 @@  discard block
 block discarded – undo
954 1015
 			date_default_timezone_set($globalTimezone);
955 1016
 			$datetime = new DateTime();
956 1017
 			$offset = $datetime->format('P');
957
-		} else $offset = '+00:00';
1018
+		} else {
1019
+			$offset = '+00:00';
1020
+		}
958 1021
 		$filter_query = $this->getFilter($filters,true,true);
959 1022
 		if ($globalDBdriver == 'mysql') {
960 1023
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1000,7 +1063,9 @@  discard block
 block discarded – undo
1000 1063
 			date_default_timezone_set($globalTimezone);
1001 1064
 			$datetime = new DateTime();
1002 1065
 			$offset = $datetime->format('P');
1003
-		} else $offset = '+00:00';
1066
+		} else {
1067
+			$offset = '+00:00';
1068
+		}
1004 1069
 		$filter_query = $this->getFilter($filters,true,true);
1005 1070
 		if ($globalDBdriver == 'mysql') {
1006 1071
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1048,7 +1113,9 @@  discard block
 block discarded – undo
1048 1113
 			date_default_timezone_set($globalTimezone);
1049 1114
 			$datetime = new DateTime();
1050 1115
 			$offset = $datetime->format('P');
1051
-		} else $offset = '+00:00';
1116
+		} else {
1117
+			$offset = '+00:00';
1118
+		}
1052 1119
 
1053 1120
 		if ($globalDBdriver == 'mysql') {
1054 1121
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1097,7 +1164,9 @@  discard block
 block discarded – undo
1097 1164
 			date_default_timezone_set($globalTimezone);
1098 1165
 			$datetime = new DateTime();
1099 1166
 			$offset = $datetime->format('P');
1100
-		} else $offset = '+00:00';
1167
+		} else {
1168
+			$offset = '+00:00';
1169
+		}
1101 1170
 		$filter_query = $this->getFilter($filters,true,true);
1102 1171
 		if ($globalDBdriver == 'mysql') {
1103 1172
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1146,7 +1215,9 @@  discard block
 block discarded – undo
1146 1215
 			date_default_timezone_set($globalTimezone);
1147 1216
 			$datetime = new DateTime();
1148 1217
 			$offset = $datetime->format('P');
1149
-		} else $offset = '+00:00';
1218
+		} else {
1219
+			$offset = '+00:00';
1220
+		}
1150 1221
 
1151 1222
 		$orderby_sql = '';
1152 1223
 		if ($orderby == "hour")
@@ -1215,7 +1286,9 @@  discard block
 block discarded – undo
1215 1286
 			date_default_timezone_set($globalTimezone);
1216 1287
 			$datetime = new DateTime($date);
1217 1288
 			$offset = $datetime->format('P');
1218
-		} else $offset = '+00:00';
1289
+		} else {
1290
+			$offset = '+00:00';
1291
+		}
1219 1292
 
1220 1293
 		if ($globalDBdriver == 'mysql') {
1221 1294
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1263,7 +1336,9 @@  discard block
 block discarded – undo
1263 1336
 			date_default_timezone_set($globalTimezone);
1264 1337
 			$datetime = new DateTime();
1265 1338
 			$offset = $datetime->format('P');
1266
-		} else $offset = '+00:00';
1339
+		} else {
1340
+			$offset = '+00:00';
1341
+		}
1267 1342
 
1268 1343
 		if ($globalDBdriver == 'mysql') {
1269 1344
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1328,8 +1403,11 @@  discard block
 block discarded – undo
1328 1403
 				$query_values = array_merge($query_values,array(':month' => $month));
1329 1404
 			}
1330 1405
 		}
1331
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1332
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1406
+		if (empty($query_values)) {
1407
+			$queryi .= $this->getFilter($filters);
1408
+		} else {
1409
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1410
+		}
1333 1411
 		
1334 1412
 		$sth = $this->db->prepare($queryi);
1335 1413
 		$sth->execute($query_values);
@@ -1351,7 +1429,9 @@  discard block
 block discarded – undo
1351 1429
 			date_default_timezone_set($globalTimezone);
1352 1430
 			$datetime = new DateTime();
1353 1431
 			$offset = $datetime->format('P');
1354
-		} else $offset = '+00:00';
1432
+		} else {
1433
+			$offset = '+00:00';
1434
+		}
1355 1435
 
1356 1436
 		if ($globalDBdriver == 'mysql') {
1357 1437
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1455,7 +1535,9 @@  discard block
 block discarded – undo
1455 1535
 	*/
1456 1536
 	public function parseDirection($direction = 0)
1457 1537
 	{
1458
-		if ($direction == '') $direction = 0;
1538
+		if ($direction == '') {
1539
+			$direction = 0;
1540
+		}
1459 1541
 		$direction_array = array();
1460 1542
 		$temp_array = array();
1461 1543
 
@@ -1544,7 +1626,9 @@  discard block
 block discarded – undo
1544 1626
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1545 1627
 	
1546 1628
 		$Connection = new Connection($this->db);
1547
-		if (!$Connection->tableExists('countries')) return '';
1629
+		if (!$Connection->tableExists('countries')) {
1630
+			return '';
1631
+		}
1548 1632
 	
1549 1633
 		try {
1550 1634
 			/*
@@ -1564,9 +1648,13 @@  discard block
 block discarded – undo
1564 1648
 			$sth->closeCursor();
1565 1649
 			if (count($row) > 0) {
1566 1650
 				return $row;
1567
-			} else return '';
1651
+			} else {
1652
+				return '';
1653
+			}
1568 1654
 		} catch (PDOException $e) {
1569
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1655
+			if (isset($globalDebug) && $globalDebug) {
1656
+				echo 'Error : '.$e->getMessage()."\n";
1657
+			}
1570 1658
 			return '';
1571 1659
 		}
1572 1660
 	
@@ -1584,7 +1672,9 @@  discard block
 block discarded – undo
1584 1672
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1585 1673
 	
1586 1674
 		$Connection = new Connection($this->db);
1587
-		if (!$Connection->tableExists('countries')) return '';
1675
+		if (!$Connection->tableExists('countries')) {
1676
+			return '';
1677
+		}
1588 1678
 	
1589 1679
 		try {
1590 1680
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1596,9 +1686,13 @@  discard block
 block discarded – undo
1596 1686
 			$sth->closeCursor();
1597 1687
 			if (count($row) > 0) {
1598 1688
 				return $row;
1599
-			} else return '';
1689
+			} else {
1690
+				return '';
1691
+			}
1600 1692
 		} catch (PDOException $e) {
1601
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1693
+			if (isset($globalDebug) && $globalDebug) {
1694
+				echo 'Error : '.$e->getMessage()."\n";
1695
+			}
1602 1696
 			return '';
1603 1697
 		}
1604 1698
 	
@@ -1616,7 +1710,9 @@  discard block
 block discarded – undo
1616 1710
 	{
1617 1711
 		global $globalBitlyAccessToken;
1618 1712
 		
1619
-		if ($globalBitlyAccessToken == '') return $url;
1713
+		if ($globalBitlyAccessToken == '') {
1714
+			return $url;
1715
+		}
1620 1716
         
1621 1717
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1622 1718
 		
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Braces   +158 added lines, -54 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
94
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
95
+		$globalCoordMinChange = '0.02';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -107,8 +117,11 @@  discard block
 block discarded – undo
107 117
 		*/
108 118
 		
109 119
 		$Common = new Common();
110
-	        if (!isset($line['id'])) $id = trim($line['ident']);
111
-	        else $id = trim($line['id']);
120
+	        if (!isset($line['id'])) {
121
+	        	$id = trim($line['ident']);
122
+	        } else {
123
+	        	$id = trim($line['id']);
124
+	        }
112 125
 		
113 126
 		if (!isset($this->all_tracked[$id])) {
114 127
 		    $this->all_tracked[$id] = array();
@@ -116,31 +129,46 @@  discard block
 block discarded – undo
116 129
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
117 130
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
118 131
 		    if (!isset($line['id'])) {
119
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
132
+			if (!isset($globalDaemon)) {
133
+				$globalDaemon = TRUE;
134
+			}
120 135
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
121
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
122
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
136
+		     } else {
137
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
138
+		     }
139
+		    if ($globalAllTracked !== FALSE) {
140
+		    	$dataFound = true;
141
+		    }
123 142
 		}
124 143
 		
125 144
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126 145
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127 146
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128 147
 		    } else {
129
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
130
-				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]['ident']." - format : ".$line['format_source']."\n";
148
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
149
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
150
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
151
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
152
+				}
131 153
 				return '';
132 154
 		    }
133 155
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
156
+			if ($globalDebug) {
157
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
158
+			}
135 159
 			return '';
136 160
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
161
+			if ($globalDebug) {
162
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
163
+			}
138 164
 			return '';
139 165
 		} elseif (!isset($line['datetime'])) {
140 166
 			date_default_timezone_set('UTC');
141 167
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142 168
 		} else {
143
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
169
+			if ($globalDebug) {
170
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!";
171
+			}
144 172
 			return '';
145 173
 		}
146 174
 		
@@ -152,11 +180,17 @@  discard block
 block discarded – undo
152 180
             		$Tracker = new Tracker($this->db);
153 181
             		$fromsource = NULL;
154 182
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183
+			if ($globalDebug && $result != 'success') {
184
+				echo '!!! ERROR : '.$result."\n";
185
+			}
156 186
 			$Tracker->db = null;
157
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
187
+			if ($globalDebugTimeElapsed) {
188
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
189
+			}
190
+		    }
191
+		    if (!isset($this->all_tracked[$id]['id'])) {
192
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
158 193
 		    }
159
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160 194
 		}
161 195
 
162 196
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -167,14 +201,21 @@  discard block
 block discarded – undo
167 201
 		    if ($distance > 100 && $distance < 10000) {
168 202
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
169 203
 			$speed = $speed*3.6;
170
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
204
+			if ($speed < 1000) {
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
206
+			}
207
+  			if ($globalDebug) {
208
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
209
+  			}
172 210
 		    }
173 211
 		}
174 212
 
175 213
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
176
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
-	    	    else unset($timediff);
214
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
215
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
216
+	    	    } else {
217
+	    	    	unset($timediff);
218
+	    	    }
178 219
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179 220
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
180 221
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -182,20 +223,30 @@  discard block
 block discarded – undo
182 223
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
183 224
 				$this->all_tracked[$id]['putinarchive'] = true;
184 225
 				
185
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
226
+				if ($globalDebug) {
227
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
228
+				}
186 229
 				$timeelapsed = microtime(true);
187 230
 				$Tracker = new Tracker($this->db);
188 231
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
232
+				if (!empty($all_country)) {
233
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
234
+				}
190 235
 				$Tracker->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
236
+				if ($globalDebugTimeElapsed) {
237
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
238
+				}
192 239
 				$this->tmd = 0;
193
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
240
+				if ($globalDebug) {
241
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
242
+				}
194 243
 			    }
195 244
 			}
196 245
 
197 246
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
198
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
247
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
248
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
249
+				}
199 250
 				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') {
200 251
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
201 252
 				    $dataFound = true;
@@ -204,8 +255,12 @@  discard block
 block discarded – undo
204 255
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205 256
 			}
206 257
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
207
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
258
+			    if ($line['longitude'] > 180) {
259
+			    	$line['longitude'] = $line['longitude'] - 360;
260
+			    }
261
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
262
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
263
+				}
209 264
 				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') {
210 265
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
211 266
 				    $dataFound = true;
@@ -223,7 +278,9 @@  discard block
 block discarded – undo
223 278
 		    }
224 279
 		}
225 280
 		if (isset($line['last_update']) && $line['last_update'] != '') {
226
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
281
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
282
+		    	$dataFound = true;
283
+		    }
227 284
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
228 285
 		}
229 286
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -243,7 +300,9 @@  discard block
 block discarded – undo
243 300
 
244 301
 		if (isset($line['altitude']) && $line['altitude'] != '') {
245 302
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
246
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
303
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
304
+				$this->all_tracked[$id]['putinarchive'] = true;
305
+			}
247 306
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => round($line['altitude']/100)));
248 307
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249 308
 			//$dataFound = true;
@@ -255,15 +314,21 @@  discard block
 block discarded – undo
255 314
 		}
256 315
 		
257 316
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
317
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
318
+		    	$this->all_tracked[$id]['putinarchive'] = true;
319
+		    }
259 320
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260 321
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261 322
 		    //$dataFound = true;
262 323
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263 324
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264 325
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
326
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
327
+		    	$this->all_tracked[$id]['putinarchive'] = true;
328
+		    }
329
+  		    if ($globalDebug) {
330
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
331
+  		    }
267 332
   		}
268 333
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 334
 
@@ -272,20 +337,31 @@  discard block
 block discarded – undo
272 337
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
273 338
 		        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'])) {
274 339
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
275
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
340
+				if ($globalDebug) {
341
+					echo "Check if aircraft is already in DB...";
342
+				}
276 343
 				$timeelapsed = microtime(true);
277 344
 				$TrackerLive = new TrackerLive($this->db);
278 345
 				if (isset($line['id'])) {
279 346
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
280
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
347
+				    if ($globalDebugTimeElapsed) {
348
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
+				    }
281 350
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
282 351
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284
-				} else $recent_ident = '';
352
+				    if ($globalDebugTimeElapsed) {
353
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
354
+				    }
355
+				} else {
356
+					$recent_ident = '';
357
+				}
285 358
 				$TrackerLive->db=null;
286 359
 
287
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
288
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
360
+				if ($globalDebug && $recent_ident == '') {
361
+					echo " Not in DB.\n";
362
+				} elseif ($globalDebug && $recent_ident != '') {
363
+					echo " Already in DB.\n";
364
+				}
289 365
 			    } else {
290 366
 				$recent_ident = '';
291 367
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -293,16 +369,24 @@  discard block
 block discarded – undo
293 369
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
294 370
 			    if($recent_ident == "")
295 371
 			    {
296
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
372
+				if ($globalDebug) {
373
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
374
+				}
297 375
 				//adds the spotter data for the archive
298 376
 				    $highlight = '';
299
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
377
+				    if (!isset($this->all_tracked[$id]['id'])) {
378
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
379
+				    }
300 380
 				    $timeelapsed = microtime(true);
301 381
 				    $Tracker = new Tracker($this->db);
302 382
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
303 383
 				    $Tracker->db = null;
304
-				    if ($globalDebug && isset($result)) echo $result."\n";
305
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
384
+				    if ($globalDebug && isset($result)) {
385
+				    	echo $result."\n";
386
+				    }
387
+				    if ($globalDebugTimeElapsed) {
388
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
389
+				    }
306 390
 				    
307 391
 				    /*
308 392
 				    // Add source stat in DB
@@ -336,12 +420,16 @@  discard block
 block discarded – undo
336 420
 				$this->all_tracked[$id]['addedTracker'] = 1;
337 421
 				//print_r($this->all_tracked[$id]);
338 422
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
339
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
423
+				    if ($globalDebug) {
424
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
425
+				    }
340 426
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
341 427
 				    $TrackerLive = new TrackerLive($this->db);
342 428
 				    $TrackerLive->deleteLiveTrackerData();
343 429
 				    $TrackerLive->db=null;
344
-				    if ($globalDebug) echo " Done\n";
430
+				    if ($globalDebug) {
431
+				    	echo " Done\n";
432
+				    }
345 433
 				    $this->last_delete = time();
346 434
 				}
347 435
 			    } else {
@@ -364,13 +452,17 @@  discard block
 block discarded – undo
364 452
 
365 453
 		    if (!$ignoreImport) {
366 454
 			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'])) {
367
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
455
+				if ($globalDebug) {
456
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
457
+				}
368 458
 				$timeelapsed = microtime(true);
369 459
 				$TrackerLive = new TrackerLive($this->db);
370 460
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
371 461
 				$TrackerLive->db = null;
372 462
 				$this->all_tracked[$id]['putinarchive'] = false;
373
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
463
+				if ($globalDebugTimeElapsed) {
464
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
465
+				}
374 466
 
375 467
 				// Put statistics in $this->stats variable
376 468
 				/*
@@ -427,19 +519,29 @@  discard block
 block discarded – undo
427 519
 				*/
428 520
 
429 521
 				$this->all_tracked[$id]['lastupdate'] = time();
430
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
431
-				if ($globalDebug) echo $result."\n";
432
-			} 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";
522
+				if ($this->all_tracked[$id]['putinarchive']) {
523
+					$send = true;
524
+				}
525
+				if ($globalDebug) {
526
+					echo $result."\n";
527
+				}
528
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
529
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
530
+			}
433 531
 			//$this->del();
434 532
 			
435 533
 			
436 534
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
437
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
535
+			    if ($globalDebug) {
536
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
537
+			    }
438 538
 			    $TrackerLive = new TrackerLive($this->db);
439 539
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
440 540
 			    $TrackerLive->db = null;
441 541
 			    //TrackerLive->deleteLiveTrackerData();
442
-			    if ($globalDebug) echo " Done\n";
542
+			    if ($globalDebug) {
543
+			    	echo " Done\n";
544
+			    }
443 545
 			    $this->last_delete_hourly = time();
444 546
 			}
445 547
 			
@@ -447,7 +549,9 @@  discard block
 block discarded – undo
447 549
 		    //$ignoreImport = false;
448 550
 		}
449 551
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
450
-		if ($send) return $this->all_tracked[$id];
552
+		if ($send) {
553
+			return $this->all_tracked[$id];
554
+		}
451 555
 	    }
452 556
 	}
453 557
     }
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Braces   +155 added lines, -59 removed lines patch added patch discarded remove patch
@@ -107,17 +107,23 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
110
+	    if ($globalDebug) {
111
+	    	echo '!!! APRS invalid : '.$input."\n";
112
+	    }
111 113
 	    return false;
112 114
 	}
113 115
 	
114
-	if ($debug) echo 'input : '.$input."\n";
116
+	if ($debug) {
117
+		echo 'input : '.$input."\n";
118
+	}
115 119
 	/* Save header and body. */
116 120
 	$body = substr($input,$splitpos+1,$input_len);
117 121
 	$body_len = strlen($body);
118 122
 	$header = substr($input,0,$splitpos);
119 123
 	//$header_len = strlen($header);
120
-	if ($debug) echo 'header : '.$header."\n";
124
+	if ($debug) {
125
+		echo 'header : '.$header."\n";
126
+	}
121 127
 	
122 128
 	/* Parse source, target and path. */
123 129
 	//FLRDF0A52>APRS,qAS,LSTB
@@ -131,10 +137,14 @@  discard block
 block discarded – undo
131 137
 		$result['format_source'] = 'famaprs';
132 138
 		$result['source_type'] = 'ais';
133 139
 	    } else {
134
-		if ($debug) echo 'ident : '.$ident."\n";
140
+		if ($debug) {
141
+			echo 'ident : '.$ident."\n";
142
+		}
135 143
 		$result['ident'] = $ident;
136 144
 	    }
137
-	} else return false;
145
+	} else {
146
+		return false;
147
+	}
138 148
 	$elements = explode(',',$all_elements);
139 149
 	$source = end($elements);
140 150
 	$result['source'] = $source;
@@ -143,7 +153,9 @@  discard block
 block discarded – undo
143 153
 	        //echo "ok";
144 154
 	        //if ($element == 'TCPIP*') return false;
145 155
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146
-		if ($debug) echo 'element : '.$element."\n";
156
+		if ($debug) {
157
+			echo 'element : '.$element."\n";
158
+		}
147 159
 		return false;
148 160
 	    }
149 161
 	    /*
@@ -156,13 +168,17 @@  discard block
 block discarded – undo
156 168
 	}
157 169
 	
158 170
 	$type = substr($body,0,1);
159
-	if ($debug) echo 'type : '.$type."\n";
171
+	if ($debug) {
172
+		echo 'type : '.$type."\n";
173
+	}
160 174
 	if ($type == ';') {
161 175
 		if (isset($result['source_type']) && $result['source_type'] == 'modes') {
162 176
 			$result['address'] = trim(substr($body,1,9));
163 177
 		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') {
164 178
 			$result['mmsi'] = trim(substr($body,1,9));
165
-		} else $result['ident'] = trim(substr($body,1,9));
179
+		} else {
180
+			$result['ident'] = trim(substr($body,1,9));
181
+		}
166 182
 	} elseif ($type == ',') {
167 183
 		// Invalid data or test data
168 184
 		return false;
@@ -230,7 +246,9 @@  discard block
 block discarded – undo
230 246
 		//$symbol_table = $matches[4];
231 247
 		$lat = intval($lat_deg);
232 248
 		$lon = intval($lon_deg);
233
-		if ($lat > 89 || $lon > 179) return false;
249
+		if ($lat > 89 || $lon > 179) {
250
+			return false;
251
+		}
234 252
 	    
235 253
 	    /*
236 254
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -240,8 +258,12 @@  discard block
 block discarded – undo
240 258
 	    */
241 259
 		$latitude = $lat + floatval($lat_min)/60;
242 260
 		$longitude = $lon + floatval($lon_min)/60;
243
-		if ($sind == 'S') $latitude = 0-$latitude;
244
-		if ($wind == 'W') $longitude = 0-$longitude;
261
+		if ($sind == 'S') {
262
+			$latitude = 0-$latitude;
263
+		}
264
+		if ($wind == 'W') {
265
+			$longitude = 0-$longitude;
266
+		}
245 267
 		$result['latitude'] = $latitude;
246 268
 		$result['longitude'] = $longitude;
247 269
 		$body_parse = substr($body_parse,18);
@@ -275,7 +297,9 @@  discard block
 block discarded – undo
275 297
 			$body_parse = substr($body_parse,1);
276 298
 			$body_parse_len = strlen($body_parse);
277 299
 			$result['symbol_code'] = $symbol_code;
278
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
300
+			if (isset($this->symbols[$symbol_code])) {
301
+				$result['symbol'] = $this->symbols[$symbol_code];
302
+			}
279 303
 			if ($symbol_code != '_') {
280 304
 			}
281 305
 		    //$body_parse = substr($body_parse,1);
@@ -286,7 +310,9 @@  discard block
 block discarded – undo
286 310
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
287 311
 		    	    $course = substr($body_parse,0,3);
288 312
 		    	    $tmp_s = intval($course);
289
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
313
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
314
+		    	    	$result['heading'] = intval($course);
315
+		    	    }
290 316
 		    	    $speed = substr($body_parse,4,3);
291 317
 		    	    if ($speed != '...') {
292 318
 		    		//$result['speed'] = round($speed*1.852);
@@ -327,10 +353,16 @@  discard block
 block discarded – undo
327 353
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
328 354
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
329 355
 			    
330
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
331
-				else $result['latitude'] += $lat_off;
332
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
333
-				else $result['longitude'] += $lon_off;
356
+				if ($result['latitude'] < 0) {
357
+					$result['latitude'] -= $lat_off;
358
+				} else {
359
+					$result['latitude'] += $lat_off;
360
+				}
361
+				if ($result['longitude'] < 0) {
362
+					$result['longitude'] -= $lon_off;
363
+				} else {
364
+					$result['longitude'] += $lon_off;
365
+				}
334 366
 			    }
335 367
 			    
336 368
 		            $body_parse = substr($body_parse,6);
@@ -372,27 +404,48 @@  discard block
 block discarded – undo
372 404
 			$address = substr($id,2);
373 405
 			//print_r($matches);
374 406
 			$addressType = (intval(substr($id,0,2),16))&3;
375
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
376
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
377
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
378
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
407
+			if ($addressType == 0) {
408
+				$result['addresstype'] = "RANDOM";
409
+			} elseif ($addressType == 1) {
410
+				$result['addresstype'] = "ICAO";
411
+			} elseif ($addressType == 2) {
412
+				$result['addresstype'] = "FLARM";
413
+			} elseif ($addressType == 3) {
414
+				$result['addresstype'] = "OGN";
415
+			}
379 416
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
380 417
 			$result['aircrafttype_code'] = $aircraftType;
381
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
382
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
383
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
384
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
385
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
386
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
387
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
388
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
389
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
390
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
391
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
392
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
393
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
394
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
395
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
418
+			if ($aircraftType == 0) {
419
+				$result['aircrafttype'] = "UNKNOWN";
420
+			} elseif ($aircraftType == 1) {
421
+				$result['aircrafttype'] = "GLIDER";
422
+			} elseif ($aircraftType == 2) {
423
+				$result['aircrafttype'] = "TOW_PLANE";
424
+			} elseif ($aircraftType == 3) {
425
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
426
+			} elseif ($aircraftType == 4) {
427
+				$result['aircrafttype'] = "PARACHUTE";
428
+			} elseif ($aircraftType == 5) {
429
+				$result['aircrafttype'] = "DROP_PLANE";
430
+			} elseif ($aircraftType == 6) {
431
+				$result['aircrafttype'] = "HANG_GLIDER";
432
+			} elseif ($aircraftType == 7) {
433
+				$result['aircrafttype'] = "PARA_GLIDER";
434
+			} elseif ($aircraftType == 8) {
435
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
436
+			} elseif ($aircraftType == 9) {
437
+				$result['aircrafttype'] = "JET_AIRCRAFT";
438
+			} elseif ($aircraftType == 10) {
439
+				$result['aircrafttype'] = "UFO";
440
+			} elseif ($aircraftType == 11) {
441
+				$result['aircrafttype'] = "BALLOON";
442
+			} elseif ($aircraftType == 12) {
443
+				$result['aircrafttype'] = "AIRSHIP";
444
+			} elseif ($aircraftType == 13) {
445
+				$result['aircrafttype'] = "UAV";
446
+			} elseif ($aircraftType == 15) {
447
+				$result['aircrafttype'] = "STATIC_OBJECT";
448
+			}
396 449
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
397 450
 			$result['stealth'] = $stealth;
398 451
 			$result['address'] = $address;
@@ -432,13 +485,21 @@  discard block
 block discarded – undo
432 485
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
433 486
 		    }
434 487
 		}
435
-		} else $result['comment'] = trim($body_parse);
488
+		} else {
489
+			$result['comment'] = trim($body_parse);
490
+		}
436 491
 
437 492
 	    }
438 493
 	//}
439
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
440
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
441
-	if ($debug) print_r($result);
494
+	if (isset($result['latitude'])) {
495
+		$result['latitude'] = round($result['latitude'],4);
496
+	}
497
+	if (isset($result['longitude'])) {
498
+		$result['longitude'] = round($result['longitude'],4);
499
+	}
500
+	if ($debug) {
501
+		print_r($result);
502
+	}
442 503
 	return $result;
443 504
     }
444 505
     
@@ -447,12 +508,21 @@  discard block
 block discarded – undo
447 508
 	$aprs_connect = 0;
448 509
 	$aprs_keep = 120;
449 510
 	$aprs_last_tx = time();
450
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
451
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
452
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
453
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
454
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
455
-	else $aprs_pass = '-1';
511
+	if (isset($globalAPRSversion)) {
512
+		$aprs_version = $globalAPRSversion;
513
+	} else {
514
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
515
+	}
516
+	if (isset($globalServerAPRSssid)) {
517
+		$aprs_ssid = $globalServerAPRSssid;
518
+	} else {
519
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
520
+	}
521
+	if (isset($globalServerAPRSpass)) {
522
+		$aprs_pass = $globalServerAPRSpass;
523
+	} else {
524
+		$aprs_pass = '-1';
525
+	}
456 526
 	
457 527
 	$aprs_filter  = '';
458 528
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -484,7 +554,9 @@  discard block
 block discarded – undo
484 554
     }
485 555
     
486 556
     public function send($data) {
487
-	if ($this->connected === false) $this->connect();
557
+	if ($this->connected === false) {
558
+		$this->connect();
559
+	}
488 560
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
489 561
 	if ($send === FALSE) {
490 562
 		socket_close($this->socket);
@@ -506,22 +578,32 @@  discard block
 block discarded – undo
506 578
 			//$w = '00';
507 579
 			$custom = '';
508 580
 			if ($ident != '') {
509
-				if ($custom != '') $custom .= '/';
581
+				if ($custom != '') {
582
+					$custom .= '/';
583
+				}
510 584
 				$custom .= 'CS='.$ident;
511 585
 			}
512 586
 			if ($squawk != '') {
513
-				if ($custom != '') $custom .= '/';
587
+				if ($custom != '') {
588
+					$custom .= '/';
589
+				}
514 590
 				$custom .= 'SQ='.$squawk;
515 591
 			}
516 592
 			if ($verticalrate != '') {
517
-				if ($custom != '') $custom .= '/';
593
+				if ($custom != '') {
594
+					$custom .= '/';
595
+				}
518 596
 				$custom .= 'VR='.$verticalrate;
519 597
 			}
520 598
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
521
-				if ($custom != '') $custom .= '/';
599
+				if ($custom != '') {
600
+					$custom .= '/';
601
+				}
522 602
 				$custom .= 'AI='.$aircraft_icao;
523 603
 			}
524
-			if ($custom != '') $custom = ' '.$custom;
604
+			if ($custom != '') {
605
+				$custom = ' '.$custom;
606
+			}
525 607
 			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
526 608
 		}
527 609
 	}
@@ -539,30 +621,44 @@  discard block
 block discarded – undo
539 621
 			//$w = '00';
540 622
 			$custom = '';
541 623
 			if ($ident != '') {
542
-				if ($custom != '') $custom .= '/';
624
+				if ($custom != '') {
625
+					$custom .= '/';
626
+				}
543 627
 				$custom .= 'CS='.str_replace(' ','_',$ident);
544 628
 			}
545 629
 			if ($typeid != '') {
546
-				if ($custom != '') $custom .= '/';
630
+				if ($custom != '') {
631
+					$custom .= '/';
632
+				}
547 633
 				$custom .= 'TI='.$typeid;
548 634
 			}
549 635
 			if ($statusid != '') {
550
-				if ($custom != '') $custom .= '/';
636
+				if ($custom != '') {
637
+					$custom .= '/';
638
+				}
551 639
 				$custom .= 'SI='.$statusid;
552 640
 			}
553 641
 			if ($imo != '') {
554
-				if ($custom != '') $custom .= '/';
642
+				if ($custom != '') {
643
+					$custom .= '/';
644
+				}
555 645
 				$custom .= 'IMO='.$imo;
556 646
 			}
557 647
 			if ($arrival_date != '') {
558
-				if ($custom != '') $custom .= '/';
648
+				if ($custom != '') {
649
+					$custom .= '/';
650
+				}
559 651
 				$custom .= 'AD='.strtotime($arrival_date);
560 652
 			}
561 653
 			if ($arrival_code != '') {
562
-				if ($custom != '') $custom .= '/';
654
+				if ($custom != '') {
655
+					$custom .= '/';
656
+				}
563 657
 				$custom .= 'AC='.str_replace(' ','_',$arrival_code);
564 658
 			}
565
-			if ($custom != '') $custom = ' '.$custom;
659
+			if ($custom != '') {
660
+				$custom = ' '.$custom;
661
+			}
566 662
 			$altitude = 0;
567 663
 			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n");
568 664
 		}
Please login to merge, or discard this patch.
require/class.SBS.php 1 patch
Braces   +248 added lines, -87 removed lines patch added patch discarded remove patch
@@ -7,9 +7,13 @@  discard block
 block discarded – undo
7 7
 	//echo $buffer."\n";
8 8
 	$data = array();
9 9
 	$typehex = substr($buffer,0,1);
10
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
11
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
12
-	else $hex = substr($buffer,1,-1);
10
+	if ($typehex == '*' || $typehex == ':') {
11
+		$hex = substr($buffer,1,-1);
12
+	} elseif ($typehex == '@' || $typehex == '%') {
13
+		$hex = substr($buffer,13,-13);
14
+	} else {
15
+		$hex = substr($buffer,1,-1);
16
+	}
13 17
 	$bin = gmp_strval( gmp_init($hex,16), 2);
14 18
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
15 19
 	if (strlen($hex) == 28) {
@@ -52,8 +56,9 @@  discard block
 block discarded – undo
52 56
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
53 57
 		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
54 58
 		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
55
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
56
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
59
+		    if ($oe == 0) {
60
+		    	$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
61
+		    } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
57 62
 			$cprlat_odd = $cprlat;
58 63
 			$cprlon_odd = $cprlon;
59 64
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -62,8 +67,12 @@  discard block
 block discarded – undo
62 67
 			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
63 68
 			$lat_even = (360.0/60)*($j%60+$cprlat_even);
64 69
 			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
65
-			if ($lat_even >= 270) $lat_even = $lat_even - 360;
66
-			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
70
+			if ($lat_even >= 270) {
71
+				$lat_even = $lat_even - 360;
72
+			}
73
+			if ($lat_odd >= 270) {
74
+				$lat_odd = $lat_odd - 360;
75
+			}
67 76
 			// check latitude zone
68 77
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
69 78
 			    if ($this::$latlon[$icao]['created'] > time()) {
@@ -71,7 +80,9 @@  discard block
 block discarded – undo
71 80
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
72 81
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
73 82
 				$lat = $lat_even;
74
-				if ($lon > 180) $lon = $lon -360;
83
+				if ($lon > 180) {
84
+					$lon = $lon -360;
85
+				}
75 86
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
76 87
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
77 88
 				    $data['latitude'] = $lat;
@@ -82,14 +93,18 @@  discard block
 block discarded – undo
82 93
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
83 94
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
84 95
 				$lat = $lat_odd;
85
-				if ($lon > 180) $lon = $lon -360;
96
+				if ($lon > 180) {
97
+					$lon = $lon -360;
98
+				}
86 99
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
87 100
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
88 101
 				    $data['latitude'] = $lat;
89 102
 				    $data['longitude'] = $lon;
90 103
 				}
91 104
 			    }
92
-			} else echo "Not cprNL";
105
+			} else {
106
+				echo "Not cprNL";
107
+			}
93 108
 			unset($this::$latlon[$icao]);
94 109
 		    }
95 110
 		} elseif ($tc == 19) {
@@ -98,11 +113,17 @@  discard block
 block discarded – undo
98 113
 		    $v_ew = intval(substr($bin,46,10),2);
99 114
 		    $v_ns_dir = intval(substr($bin,56,1));
100 115
 		    $v_ns = intval(substr($bin,57,10),2);
101
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
102
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
116
+		    if ($v_ew_dir) {
117
+		    	$v_ew = -1*$v_ew;
118
+		    }
119
+		    if ($v_ns_dir) {
120
+		    	$v_ns = -1*$v_ns;
121
+		    }
103 122
 		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
104 123
 		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
105
-		    if ($heading <0) $heading = $heading+360;
124
+		    if ($heading <0) {
125
+		    	$heading = $heading+360;
126
+		    }
106 127
 		    $data['speed'] = $speed;
107 128
 		    $data['heading'] = $heading;
108 129
 		}
@@ -117,72 +138,194 @@  discard block
 block discarded – undo
117 138
 
118 139
 	public function cprNL($lat) {
119 140
 	//Lookup table to convert the latitude to index.
120
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
121
-	if ($lat < 10.47047130) return 59;
122
-	if ($lat < 14.82817437) return 58;
123
-	if ($lat < 18.18626357) return 57;
124
-	if ($lat < 21.02939493) return 56;
125
-	if ($lat < 23.54504487) return 55;
126
-	if ($lat < 25.82924707) return 54;
127
-	if ($lat < 27.93898710) return 53;
128
-	if ($lat < 29.91135686) return 52;
129
-	if ($lat < 31.77209708) return 51;
130
-	if ($lat < 33.53993436) return 50;
131
-	if ($lat < 35.22899598) return 49;
132
-	if ($lat < 36.85025108) return 48;
133
-	if ($lat < 38.41241892) return 47;
134
-	if ($lat < 39.92256684) return 46;
135
-	if ($lat < 41.38651832) return 45;
136
-	if ($lat < 42.80914012) return 44;
137
-	if ($lat < 44.19454951) return 43;
138
-	if ($lat < 45.54626723) return 42;
139
-	if ($lat < 46.86733252) return 41;
140
-	if ($lat < 48.16039128) return 40;
141
-	if ($lat < 49.42776439) return 39;
142
-	if ($lat < 50.67150166) return 38;
143
-	if ($lat < 51.89342469) return 37;
144
-	if ($lat < 53.09516153) return 36;
145
-	if ($lat < 54.27817472) return 35;
146
-	if ($lat < 55.44378444) return 34;
147
-	if ($lat < 56.59318756) return 33;
148
-	if ($lat < 57.72747354) return 32;
149
-	if ($lat < 58.84763776) return 31;
150
-	if ($lat < 59.95459277) return 30;
151
-	if ($lat < 61.04917774) return 29;
152
-	if ($lat < 62.13216659) return 28;
153
-	if ($lat < 63.20427479) return 27;
154
-	if ($lat < 64.26616523) return 26;
155
-	if ($lat < 65.31845310) return 25;
156
-	if ($lat < 66.36171008) return 24;
157
-	if ($lat < 67.39646774) return 23;
158
-	if ($lat < 68.42322022) return 22;
159
-	if ($lat < 69.44242631) return 21;
160
-	if ($lat < 70.45451075) return 20;
161
-	if ($lat < 71.45986473) return 19;
162
-	if ($lat < 72.45884545) return 18;
163
-	if ($lat < 73.45177442) return 17;
164
-	if ($lat < 74.43893416) return 16;
165
-	if ($lat < 75.42056257) return 15;
166
-	if ($lat < 76.39684391) return 14;
167
-	if ($lat < 77.36789461) return 13;
168
-	if ($lat < 78.33374083) return 12;
169
-	if ($lat < 79.29428225) return 11;
170
-	if ($lat < 80.24923213) return 10;
171
-	if ($lat < 81.19801349) return 9;
172
-	if ($lat < 82.13956981) return 8;
173
-	if ($lat < 83.07199445) return 7;
174
-	if ($lat < 83.99173563) return 6;
175
-	if ($lat < 84.89166191) return 5;
176
-	if ($lat < 85.75541621) return 4;
177
-	if ($lat < 86.53536998) return 3;
178
-	if ($lat < 87.00000000) return 2;
141
+	if ($lat < 0) {
142
+		$lat = -$lat;
143
+	}
144
+	// Table is simmetric about the equator.
145
+	if ($lat < 10.47047130) {
146
+		return 59;
147
+	}
148
+	if ($lat < 14.82817437) {
149
+		return 58;
150
+	}
151
+	if ($lat < 18.18626357) {
152
+		return 57;
153
+	}
154
+	if ($lat < 21.02939493) {
155
+		return 56;
156
+	}
157
+	if ($lat < 23.54504487) {
158
+		return 55;
159
+	}
160
+	if ($lat < 25.82924707) {
161
+		return 54;
162
+	}
163
+	if ($lat < 27.93898710) {
164
+		return 53;
165
+	}
166
+	if ($lat < 29.91135686) {
167
+		return 52;
168
+	}
169
+	if ($lat < 31.77209708) {
170
+		return 51;
171
+	}
172
+	if ($lat < 33.53993436) {
173
+		return 50;
174
+	}
175
+	if ($lat < 35.22899598) {
176
+		return 49;
177
+	}
178
+	if ($lat < 36.85025108) {
179
+		return 48;
180
+	}
181
+	if ($lat < 38.41241892) {
182
+		return 47;
183
+	}
184
+	if ($lat < 39.92256684) {
185
+		return 46;
186
+	}
187
+	if ($lat < 41.38651832) {
188
+		return 45;
189
+	}
190
+	if ($lat < 42.80914012) {
191
+		return 44;
192
+	}
193
+	if ($lat < 44.19454951) {
194
+		return 43;
195
+	}
196
+	if ($lat < 45.54626723) {
197
+		return 42;
198
+	}
199
+	if ($lat < 46.86733252) {
200
+		return 41;
201
+	}
202
+	if ($lat < 48.16039128) {
203
+		return 40;
204
+	}
205
+	if ($lat < 49.42776439) {
206
+		return 39;
207
+	}
208
+	if ($lat < 50.67150166) {
209
+		return 38;
210
+	}
211
+	if ($lat < 51.89342469) {
212
+		return 37;
213
+	}
214
+	if ($lat < 53.09516153) {
215
+		return 36;
216
+	}
217
+	if ($lat < 54.27817472) {
218
+		return 35;
219
+	}
220
+	if ($lat < 55.44378444) {
221
+		return 34;
222
+	}
223
+	if ($lat < 56.59318756) {
224
+		return 33;
225
+	}
226
+	if ($lat < 57.72747354) {
227
+		return 32;
228
+	}
229
+	if ($lat < 58.84763776) {
230
+		return 31;
231
+	}
232
+	if ($lat < 59.95459277) {
233
+		return 30;
234
+	}
235
+	if ($lat < 61.04917774) {
236
+		return 29;
237
+	}
238
+	if ($lat < 62.13216659) {
239
+		return 28;
240
+	}
241
+	if ($lat < 63.20427479) {
242
+		return 27;
243
+	}
244
+	if ($lat < 64.26616523) {
245
+		return 26;
246
+	}
247
+	if ($lat < 65.31845310) {
248
+		return 25;
249
+	}
250
+	if ($lat < 66.36171008) {
251
+		return 24;
252
+	}
253
+	if ($lat < 67.39646774) {
254
+		return 23;
255
+	}
256
+	if ($lat < 68.42322022) {
257
+		return 22;
258
+	}
259
+	if ($lat < 69.44242631) {
260
+		return 21;
261
+	}
262
+	if ($lat < 70.45451075) {
263
+		return 20;
264
+	}
265
+	if ($lat < 71.45986473) {
266
+		return 19;
267
+	}
268
+	if ($lat < 72.45884545) {
269
+		return 18;
270
+	}
271
+	if ($lat < 73.45177442) {
272
+		return 17;
273
+	}
274
+	if ($lat < 74.43893416) {
275
+		return 16;
276
+	}
277
+	if ($lat < 75.42056257) {
278
+		return 15;
279
+	}
280
+	if ($lat < 76.39684391) {
281
+		return 14;
282
+	}
283
+	if ($lat < 77.36789461) {
284
+		return 13;
285
+	}
286
+	if ($lat < 78.33374083) {
287
+		return 12;
288
+	}
289
+	if ($lat < 79.29428225) {
290
+		return 11;
291
+	}
292
+	if ($lat < 80.24923213) {
293
+		return 10;
294
+	}
295
+	if ($lat < 81.19801349) {
296
+		return 9;
297
+	}
298
+	if ($lat < 82.13956981) {
299
+		return 8;
300
+	}
301
+	if ($lat < 83.07199445) {
302
+		return 7;
303
+	}
304
+	if ($lat < 83.99173563) {
305
+		return 6;
306
+	}
307
+	if ($lat < 84.89166191) {
308
+		return 5;
309
+	}
310
+	if ($lat < 85.75541621) {
311
+		return 4;
312
+	}
313
+	if ($lat < 86.53536998) {
314
+		return 3;
315
+	}
316
+	if ($lat < 87.00000000) {
317
+		return 2;
318
+	}
179 319
 	return 1;
180 320
     }
181 321
     
182 322
     public function cprN($lat,$isodd) {
183 323
 	$nl = $this->cprNL($lat) - $isodd;
184
-	if ($nl > 1) return $nl;
185
-	else return 1;
324
+	if ($nl > 1) {
325
+		return $nl;
326
+	} else {
327
+		return 1;
328
+	}
186 329
     }
187 330
 
188 331
 
@@ -208,10 +351,13 @@  discard block
 block discarded – undo
208 351
 	$checksum = intval(substr($msg,22,6),16);
209 352
 
210 353
 	for ($j = 0; $j < strlen($bin); $j++) {
211
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
354
+	    if ($bin[$j]) {
355
+	    	$crc = $crc^intval($modes_checksum_table[$j],0);
356
+	    }
212 357
 	}
213
-	if ($crc == $checksum) return true;
214
-	else {
358
+	if ($crc == $checksum) {
359
+		return true;
360
+	} else {
215 361
 	    //echo "**** CRC ERROR ****\n";
216 362
 	    return false;
217 363
 	}
@@ -258,22 +404,37 @@  discard block
 block discarded – undo
258 404
 	    $msg['date_log'] = date('Y/m/d',$data['timestamp']);
259 405
 	    $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180';
260 406
 	    $msg['callsign'] = '';
261
-	    if (isset($data['altitude'])) $msg['altitude'] = $data['altitude'];
262
-	    else $msg['altitude'] = '';
407
+	    if (isset($data['altitude'])) {
408
+	    	$msg['altitude'] = $data['altitude'];
409
+	    } else {
410
+	    	$msg['altitude'] = '';
411
+	    }
263 412
 	    $msg['speed'] = $data['speed'];
264
-	    if (isset($data['heading'])) $msg['track'] = $data['heading'];
265
-	    else $msg['track'] = '';
413
+	    if (isset($data['heading'])) {
414
+	    	$msg['track'] = $data['heading'];
415
+	    } else {
416
+	    	$msg['track'] = '';
417
+	    }
266 418
 	    $msg['latitude'] = $data['latitude'];
267 419
 	    $msg['longitude'] = $data['longitude'];
268
-	    if (isset($data['verticalrate'])) $msg['verticalrate'] = $data['verticalrate'];
269
-	    else $msg['verticalrate'] = '';
270
-	    if (isset($data['squawk'])) $msg['squawk'] = $data['squawk'];
271
-	    else $msg['squawk'] = 0;
420
+	    if (isset($data['verticalrate'])) {
421
+	    	$msg['verticalrate'] = $data['verticalrate'];
422
+	    } else {
423
+	    	$msg['verticalrate'] = '';
424
+	    }
425
+	    if (isset($data['squawk'])) {
426
+	    	$msg['squawk'] = $data['squawk'];
427
+	    } else {
428
+	    	$msg['squawk'] = 0;
429
+	    }
272 430
 	    $msg['alert'] = 0;
273 431
 	    $msg['emergency'] = 0;
274 432
 	    $msg['SPI'] = 0;
275
-	    if (isset($data['ground'])) $msg['ground'] = 1;
276
-	    else $msg['ground'] = 0;
433
+	    if (isset($data['ground'])) {
434
+	    	$msg['ground'] = 1;
435
+	    } else {
436
+	    	$msg['ground'] = 0;
437
+	    }
277 438
     	    $result[] = implode(',',$msg);
278 439
         }
279 440
         return $result;
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +162 added lines, -58 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,32 +128,54 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marine_id'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marine_id'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
136
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
137
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
138
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
139
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['type_id'])) {
146
+				$temp_array['type_id'] = $row['type_id'];
147
+			}
148
+			if (isset($row['ident'])) {
149
+				$temp_array['ident'] = $row['ident'];
150
+			}
151
+			if (isset($row['latitude'])) {
152
+				$temp_array['latitude'] = $row['latitude'];
153
+			}
154
+			if (isset($row['longitude'])) {
155
+				$temp_array['longitude'] = $row['longitude'];
156
+			}
157
+			if (isset($row['format_source'])) {
158
+				$temp_array['format_source'] = $row['format_source'];
159
+			}
140 160
 			if (isset($row['heading'])) {
141 161
 				$temp_array['heading'] = $row['heading'];
142 162
 				$heading_direction = $this->parseDirection($row['heading']);
143
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
163
+				if (isset($heading_direction[0]['direction_fullname'])) {
164
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
165
+				}
166
+			}
167
+			if (isset($row['ground_speed'])) {
168
+				$temp_array['ground_speed'] = $row['ground_speed'];
144 169
 			}
145
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
146 170
 
147 171
 			if($temp_array['mmsi'] != "")
148 172
 			{
149 173
 				$Image = new Image($this->db);
150
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
151
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
174
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
175
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
176
+				} else {
177
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
178
+				}
152 179
 				unset($Image);
153 180
 				if (count($image_array) > 0) {
154 181
 					$temp_array['image'] = $image_array[0]['image'];
@@ -200,13 +227,21 @@  discard block
 block discarded – undo
200 227
 			}
201 228
 			
202 229
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
230
+			if (isset($row['source_name']) && $row['source_name'] != '') {
231
+				$temp_array['source_name'] = $row['source_name'];
232
+			}
233
+			if (isset($row['over_country']) && $row['over_country'] != '') {
234
+				$temp_array['over_country'] = $row['over_country'];
235
+			}
236
+			if (isset($row['distance']) && $row['distance'] != '') {
237
+				$temp_array['distance'] = $row['distance'];
238
+			}
206 239
 			$temp_array['query_number_rows'] = $num_rows;
207 240
 			$spotter_array[] = $temp_array;
208 241
 		}
209
-		if ($num_rows == 0) return array();
242
+		if ($num_rows == 0) {
243
+			return array();
244
+		}
210 245
 		$spotter_array[0]['query_number_rows'] = $num_rows;
211 246
 		return $spotter_array;
212 247
 	}	
@@ -232,8 +267,12 @@  discard block
 block discarded – undo
232 267
 			{
233 268
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
234 269
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
235
-			} else $limit_query = "";
236
-		} else $limit_query = "";
270
+			} else {
271
+				$limit_query = "";
272
+			}
273
+		} else {
274
+			$limit_query = "";
275
+		}
237 276
 		if ($sort != "")
238 277
 		{
239 278
 			$search_orderby_array = $this->getOrderBy();
@@ -257,7 +296,9 @@  discard block
 block discarded – undo
257 296
 		global $global_query;
258 297
 		
259 298
 		date_default_timezone_set('UTC');
260
-		if ($id == '') return array();
299
+		if ($id == '') {
300
+			return array();
301
+		}
261 302
 		$additional_query = "marine_output.fammarine_id = :id";
262 303
 		$query_values = array(':id' => $id);
263 304
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -400,8 +441,11 @@  discard block
 block discarded – undo
400 441
 		$query .= " ORDER BY marine_output.source_name ASC";
401 442
 
402 443
 		$sth = $this->db->prepare($query);
403
-		if (!empty($query_values)) $sth->execute($query_values);
404
-		else $sth->execute();
444
+		if (!empty($query_values)) {
445
+			$sth->execute($query_values);
446
+		} else {
447
+			$sth->execute();
448
+		}
405 449
 
406 450
 		$source_array = array();
407 451
 		$temp_array = array();
@@ -456,8 +500,11 @@  discard block
 block discarded – undo
456 500
 		$sth = $this->db->prepare($query);
457 501
 		$sth->execute(array(':mmsi' => $mmsi));
458 502
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
459
-		if (isset($result[0])) return $result[0];
460
-		else return array();
503
+		if (isset($result[0])) {
504
+			return $result[0];
505
+		} else {
506
+			return array();
507
+		}
461 508
 	}
462 509
 
463 510
 	/*
@@ -473,7 +520,9 @@  discard block
 block discarded – undo
473 520
 			date_default_timezone_set($globalTimezone);
474 521
 			$datetime = new DateTime();
475 522
 			$offset = $datetime->format('P');
476
-		} else $offset = '+00:00';
523
+		} else {
524
+			$offset = '+00:00';
525
+		}
477 526
 
478 527
 		if ($globalDBdriver == 'mysql') {
479 528
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -703,9 +752,15 @@  discard block
 block discarded – undo
703 752
             		$latitude = 0;
704 753
             		$longitude = 0;
705 754
             	}
706
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
707
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
708
-                if ($arrival_date == '') $arrival_date = NULL;
755
+                if ($heading == '' || $Common->isInteger($heading) === false) {
756
+                	$heading = 0;
757
+                }
758
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
759
+                	$groundspeed = 0;
760
+                }
761
+                if ($arrival_date == '') {
762
+                	$arrival_date = NULL;
763
+                }
709 764
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
710 765
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
711 766
 
@@ -813,7 +868,9 @@  discard block
 block discarded – undo
813 868
 		global $globalDBdriver, $globalArchive;
814 869
 		//$filter_query = $this->getFilter($filters,true,true);
815 870
 		$Connection= new Connection($this->db);
816
-		if (!$Connection->tableExists('countries')) return array();
871
+		if (!$Connection->tableExists('countries')) {
872
+			return array();
873
+		}
817 874
 		require_once('class.SpotterLive.php');
818 875
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
819 876
 			$MarineLive = new MarineLive();
@@ -855,7 +912,9 @@  discard block
 block discarded – undo
855 912
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
856 913
 		}
857 914
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
858
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
915
+		if ($limit) {
916
+			$query .= " LIMIT 10 OFFSET 0";
917
+		}
859 918
       
860 919
 		
861 920
 		$sth = $this->db->prepare($query);
@@ -890,12 +949,18 @@  discard block
 block discarded – undo
890 949
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
891 950
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
892 951
 		 if ($olderthanmonths > 0) {
893
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
894
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
952
+			if ($globalDBdriver == 'mysql') {
953
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
954
+			} else {
955
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
956
+			}
895 957
 		}
896 958
 		if ($sincedate != '') {
897
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
898
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
959
+			if ($globalDBdriver == 'mysql') {
960
+				$query .= " AND marine_output.date > '".$sincedate."'";
961
+			} else {
962
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
963
+			}
899 964
 		}
900 965
 		$query_values = array();
901 966
 		if ($year != '') {
@@ -926,7 +991,9 @@  discard block
 block discarded – undo
926 991
 			}
927 992
 		}
928 993
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
929
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
994
+		if ($limit) {
995
+			$query .= " LIMIT 10 OFFSET 0";
996
+		}
930 997
       		
931 998
 		$sth = $this->db->prepare($query);
932 999
 		$sth->execute($query_values);
@@ -961,7 +1028,9 @@  discard block
 block discarded – undo
961 1028
 			date_default_timezone_set($globalTimezone);
962 1029
 			$datetime = new DateTime();
963 1030
 			$offset = $datetime->format('P');
964
-		} else $offset = '+00:00';
1031
+		} else {
1032
+			$offset = '+00:00';
1033
+		}
965 1034
 
966 1035
 		if ($globalDBdriver == 'mysql') {
967 1036
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1011,7 +1080,9 @@  discard block
 block discarded – undo
1011 1080
 			date_default_timezone_set($globalTimezone);
1012 1081
 			$datetime = new DateTime();
1013 1082
 			$offset = $datetime->format('P');
1014
-		} else $offset = '+00:00';
1083
+		} else {
1084
+			$offset = '+00:00';
1085
+		}
1015 1086
 		$filter_query = $this->getFilter($filters,true,true);
1016 1087
 		if ($globalDBdriver == 'mysql') {
1017 1088
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1057,7 +1128,9 @@  discard block
 block discarded – undo
1057 1128
 			date_default_timezone_set($globalTimezone);
1058 1129
 			$datetime = new DateTime();
1059 1130
 			$offset = $datetime->format('P');
1060
-		} else $offset = '+00:00';
1131
+		} else {
1132
+			$offset = '+00:00';
1133
+		}
1061 1134
 		$filter_query = $this->getFilter($filters,true,true);
1062 1135
 		if ($globalDBdriver == 'mysql') {
1063 1136
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1105,7 +1178,9 @@  discard block
 block discarded – undo
1105 1178
 			date_default_timezone_set($globalTimezone);
1106 1179
 			$datetime = new DateTime();
1107 1180
 			$offset = $datetime->format('P');
1108
-		} else $offset = '+00:00';
1181
+		} else {
1182
+			$offset = '+00:00';
1183
+		}
1109 1184
 
1110 1185
 		if ($globalDBdriver == 'mysql') {
1111 1186
 			$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
@@ -1154,7 +1229,9 @@  discard block
 block discarded – undo
1154 1229
 			date_default_timezone_set($globalTimezone);
1155 1230
 			$datetime = new DateTime();
1156 1231
 			$offset = $datetime->format('P');
1157
-		} else $offset = '+00:00';
1232
+		} else {
1233
+			$offset = '+00:00';
1234
+		}
1158 1235
 		$filter_query = $this->getFilter($filters,true,true);
1159 1236
 		if ($globalDBdriver == 'mysql') {
1160 1237
 			$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
@@ -1203,7 +1280,9 @@  discard block
 block discarded – undo
1203 1280
 			date_default_timezone_set($globalTimezone);
1204 1281
 			$datetime = new DateTime();
1205 1282
 			$offset = $datetime->format('P');
1206
-		} else $offset = '+00:00';
1283
+		} else {
1284
+			$offset = '+00:00';
1285
+		}
1207 1286
 
1208 1287
 		$orderby_sql = '';
1209 1288
 		if ($orderby == "hour")
@@ -1272,7 +1351,9 @@  discard block
 block discarded – undo
1272 1351
 			date_default_timezone_set($globalTimezone);
1273 1352
 			$datetime = new DateTime($date);
1274 1353
 			$offset = $datetime->format('P');
1275
-		} else $offset = '+00:00';
1354
+		} else {
1355
+			$offset = '+00:00';
1356
+		}
1276 1357
 
1277 1358
 		if ($globalDBdriver == 'mysql') {
1278 1359
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1320,7 +1401,9 @@  discard block
 block discarded – undo
1320 1401
 			date_default_timezone_set($globalTimezone);
1321 1402
 			$datetime = new DateTime();
1322 1403
 			$offset = $datetime->format('P');
1323
-		} else $offset = '+00:00';
1404
+		} else {
1405
+			$offset = '+00:00';
1406
+		}
1324 1407
 
1325 1408
 		if ($globalDBdriver == 'mysql') {
1326 1409
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1385,8 +1468,11 @@  discard block
 block discarded – undo
1385 1468
 				$query_values = array_merge($query_values,array(':month' => $month));
1386 1469
 			}
1387 1470
 		}
1388
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1389
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1471
+		if (empty($query_values)) {
1472
+			$queryi .= $this->getFilter($filters);
1473
+		} else {
1474
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1475
+		}
1390 1476
 		
1391 1477
 		$sth = $this->db->prepare($queryi);
1392 1478
 		$sth->execute($query_values);
@@ -1408,7 +1494,9 @@  discard block
 block discarded – undo
1408 1494
 			date_default_timezone_set($globalTimezone);
1409 1495
 			$datetime = new DateTime();
1410 1496
 			$offset = $datetime->format('P');
1411
-		} else $offset = '+00:00';
1497
+		} else {
1498
+			$offset = '+00:00';
1499
+		}
1412 1500
 
1413 1501
 		if ($globalDBdriver == 'mysql') {
1414 1502
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1512,7 +1600,9 @@  discard block
 block discarded – undo
1512 1600
 	*/
1513 1601
 	public function parseDirection($direction = 0)
1514 1602
 	{
1515
-		if ($direction == '') $direction = 0;
1603
+		if ($direction == '') {
1604
+			$direction = 0;
1605
+		}
1516 1606
 		$direction_array = array();
1517 1607
 		$temp_array = array();
1518 1608
 
@@ -1601,7 +1691,9 @@  discard block
 block discarded – undo
1601 1691
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1602 1692
 	
1603 1693
 		$Connection = new Connection($this->db);
1604
-		if (!$Connection->tableExists('countries')) return '';
1694
+		if (!$Connection->tableExists('countries')) {
1695
+			return '';
1696
+		}
1605 1697
 	
1606 1698
 		try {
1607 1699
 			/*
@@ -1621,9 +1713,13 @@  discard block
 block discarded – undo
1621 1713
 			$sth->closeCursor();
1622 1714
 			if (count($row) > 0) {
1623 1715
 				return $row;
1624
-			} else return '';
1716
+			} else {
1717
+				return '';
1718
+			}
1625 1719
 		} catch (PDOException $e) {
1626
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1720
+			if (isset($globalDebug) && $globalDebug) {
1721
+				echo 'Error : '.$e->getMessage()."\n";
1722
+			}
1627 1723
 			return '';
1628 1724
 		}
1629 1725
 	
@@ -1641,7 +1737,9 @@  discard block
 block discarded – undo
1641 1737
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1642 1738
 	
1643 1739
 		$Connection = new Connection($this->db);
1644
-		if (!$Connection->tableExists('countries')) return '';
1740
+		if (!$Connection->tableExists('countries')) {
1741
+			return '';
1742
+		}
1645 1743
 	
1646 1744
 		try {
1647 1745
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1653,9 +1751,13 @@  discard block
 block discarded – undo
1653 1751
 			$sth->closeCursor();
1654 1752
 			if (count($row) > 0) {
1655 1753
 				return $row;
1656
-			} else return '';
1754
+			} else {
1755
+				return '';
1756
+			}
1657 1757
 		} catch (PDOException $e) {
1658
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1758
+			if (isset($globalDebug) && $globalDebug) {
1759
+				echo 'Error : '.$e->getMessage()."\n";
1760
+			}
1659 1761
 			return '';
1660 1762
 		}
1661 1763
 	
@@ -1673,7 +1775,9 @@  discard block
 block discarded – undo
1673 1775
 	{
1674 1776
 		global $globalBitlyAccessToken;
1675 1777
 		
1676
-		if ($globalBitlyAccessToken == '') return $url;
1778
+		if ($globalBitlyAccessToken == '') {
1779
+			return $url;
1780
+		}
1677 1781
         
1678 1782
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1679 1783
 		
Please login to merge, or discard this patch.
statistics.php 1 patch
Braces   +103 added lines, -42 removed lines patch added patch discarded remove patch
@@ -18,11 +18,15 @@  discard block
 block discarded – undo
18 18
 	require_once('require/class.Spotter.php');
19 19
 }
20 20
 
21
-if (!isset($filter_name)) $filter_name = '';
21
+if (!isset($filter_name)) {
22
+	$filter_name = '';
23
+}
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($airline_icao == '' && isset($globalFilter)) {
24
-	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+	if (isset($globalFilter['airline'])) {
27
+		$airline_icao = $globalFilter['airline'][0];
28
+	}
29
+	}
26 30
 if ($airline_icao != '' && $airline_icao != 'all') {
27 31
 	$Spotter = new Spotter();
28 32
 	$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
@@ -53,14 +57,21 @@  discard block
 block discarded – undo
53 57
 <script type="text/javascript" src="<?php echo $globalURL; ?>/js/datamaps.world.min.js"></script>
54 58
 <div class="column">
55 59
     <div class="info">
56
-            <h1><?php if (isset($airline_name)) echo _("Statistics for ").$airline_name; else echo _("Statistics"); ?></h1>
60
+            <h1><?php if (isset($airline_name)) {
61
+	echo _("Statistics for ").$airline_name;
62
+} else {
63
+	echo _("Statistics");
64
+}
65
+?></h1>
57 66
     <?php 
58 67
 	$last_update = $Stats->getLastStatsUpdate();
59 68
 	//if (isset($last_update[0]['value'])) print '<!-- Last update : '.$last_update[0]['value'].' -->';
60 69
 	if (isset($last_update[0]['value'])) {
61 70
 		date_default_timezone_set('UTC');
62 71
 		$lastupdate = strtotime($last_update[0]['value']);
63
-		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
72
+		if (isset($globalTimezone) && $globalTimezone != '') {
73
+			date_default_timezone_set($globalTimezone);
74
+		}
64 75
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
65 76
 	}
66 77
     ?>
@@ -128,8 +139,9 @@  discard block
 block discarded – undo
128 139
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
129 140
                  <?php
130 141
                   $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
131
-		    if (count($aircraft_array) == 0) print _("No data available");
132
-		    else {
142
+		    if (count($aircraft_array) == 0) {
143
+		    	print _("No data available");
144
+		    } else {
133 145
                     print '<div id="chart1" class="chart" width="100%"></div><script>';
134 146
                     $aircraft_data = '';
135 147
                     foreach($aircraft_array as $aircraft_item)
@@ -151,11 +163,17 @@  discard block
 block discarded – undo
151 163
             	    <?php
152 164
             		if ($year != '' && $month != '') {
153 165
             	    ?>
154
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
166
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
167
+	echo '/'.$airline_icao;
168
+}
169
+?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
155 170
             	    <?php
156 171
             		} else {
157 172
             	    ?>
158
-            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
173
+            	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
174
+	echo '/'.$airline_icao;
175
+}
176
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
159 177
             	    <?php
160 178
             		}
161 179
             	    ?>
@@ -186,11 +204,15 @@  discard block
 block discarded – undo
186 204
             print '</script>';
187 205
 	    if ($year != '' && $month != '') {
188 206
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
207
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
208
+			echo '/'.$airline_icao;
209
+		}
190 210
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191 211
 	    } else {
192 212
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
193
-		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
213
+		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
214
+			echo '/'.$airline_icao;
215
+		}
194 216
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
195 217
 	    }
196 218
     	    print '</div>';
@@ -214,8 +236,9 @@  discard block
 block discarded – undo
214 236
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
215 237
 <?php
216 238
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
217
-	if (count($pilot_array) == 0) print _("No data available");
218
-	else {
239
+	if (count($pilot_array) == 0) {
240
+		print _("No data available");
241
+	} else {
219 242
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
220 243
 	    $pilot_data = '';
221 244
 	    foreach($pilot_array as $pilot_item)
@@ -234,7 +257,9 @@  discard block
 block discarded – undo
234 257
         }
235 258
         print '<div class="more">';
236 259
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
237
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
260
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
261
+		echo '/'.$airline_icao;
262
+	}
238 263
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
239 264
 	print '</div>';
240 265
 ?>
@@ -248,8 +273,9 @@  discard block
 block discarded – undo
248 273
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
249 274
 <?php
250 275
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
251
-	if (count($owner_array) == 0) print _("No data available");
252
-	else {
276
+	if (count($owner_array) == 0) {
277
+		print _("No data available");
278
+	} else {
253 279
 	    print '<div id="chart7" class="chart" width="100%"></div><script>';
254 280
 	    $owner_data = '';
255 281
 	    foreach($owner_array as $owner_item)
@@ -268,7 +294,10 @@  discard block
 block discarded – undo
268 294
 	}
269 295
 ?>
270 296
                 <div class="more">
271
-                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
297
+                    <a href="<?php print $globalURL; ?>/statistics/owner<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
298
+	echo '/'.$airline_icao;
299
+}
300
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
272 301
                 </div>
273 302
             </div>
274 303
         
@@ -281,8 +310,9 @@  discard block
 block discarded – undo
281 310
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
282 311
 <?php
283 312
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
284
-	if (count($flightover_array) == 0) print _("No data available");
285
-	else {
313
+	if (count($flightover_array) == 0) {
314
+		print _("No data available");
315
+	} else {
286 316
 	    print '<div id="chart10" class="chart" width="100%"></div><script>';
287 317
 	    print 'var series = [';
288 318
             $flightover_data = '';
@@ -325,7 +355,10 @@  discard block
 block discarded – undo
325 355
 	}
326 356
 ?>
327 357
                 <div class="more">
328
-                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
358
+                    <a href="<?php print $globalURL; ?>/statistics/country<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
359
+	echo '/'.$airline_icao;
360
+}
361
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
329 362
                 </div>
330 363
             </div>
331 364
 <?php
@@ -392,7 +425,9 @@  discard block
 block discarded – undo
392 425
 	print '</script>';
393 426
 
394 427
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
395
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
428
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
429
+		echo '/'.$airline_icao;
430
+	}
396 431
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
397 432
     }
398 433
 ?>
@@ -455,7 +490,9 @@  discard block
 block discarded – undo
455 490
 
456 491
 
457 492
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
458
-	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
493
+	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
494
+		echo '/'.$airline_icao;
495
+	}
459 496
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
460 497
     }
461 498
 ?>
@@ -470,8 +507,9 @@  discard block
 block discarded – undo
470 507
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
471 508
                 <?php
472 509
                   $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
473
-		    if (count($year_array) == 0) print _("No data available");
474
-		    else {
510
+		    if (count($year_array) == 0) {
511
+		    	print _("No data available");
512
+		    } else {
475 513
 			print '<div id="chart8" class="chart" width="100%"></div><script>';
476 514
 			$year_data = '';
477 515
 			$year_cnt = '';
@@ -491,7 +529,10 @@  discard block
 block discarded – undo
491 529
                     }
492 530
                   ?>
493 531
                 <div class="more">
494
-                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
532
+                    <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
533
+	echo '/'.$airline_icao;
534
+}
535
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
495 536
                 </div>
496 537
             </div>
497 538
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -499,8 +540,9 @@  discard block
 block discarded – undo
499 540
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
500 541
                 <?php
501 542
                   $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
502
-		    if (count($month_array) == 0) print _("No data available");
503
-		    else {
543
+		    if (count($month_array) == 0) {
544
+		    	print _("No data available");
545
+		    } else {
504 546
                 	print '<div id="chart9" class="chart" width="100%"></div><script>';
505 547
                         $month_data = '';
506 548
 			$month_cnt = '';
@@ -521,7 +563,10 @@  discard block
 block discarded – undo
521 563
                     }
522 564
                   ?>
523 565
                 <div class="more">
524
-                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
566
+                    <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
567
+	echo '/'.$airline_icao;
568
+}
569
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
525 570
                 </div>
526 571
             </div>
527 572
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -530,8 +575,9 @@  discard block
 block discarded – undo
530 575
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
531 576
                 <?php
532 577
                     $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
533
-		    if (empty($date_array)) print _("No data available");
534
-		    else {
578
+		    if (empty($date_array)) {
579
+		    	print _("No data available");
580
+		    } else {
535 581
                 	print '<div id="chart5" class="chart" width="100%"></div><script>';
536 582
                         $date_data = '';
537 583
 			$date_cnt = '';
@@ -552,7 +598,10 @@  discard block
 block discarded – undo
552 598
                     }
553 599
                   ?>
554 600
                 <div class="more">
555
-                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
601
+                    <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
602
+	echo '/'.$airline_icao;
603
+}
604
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
556 605
                 </div>
557 606
             </div>
558 607
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -560,8 +609,9 @@  discard block
 block discarded – undo
560 609
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
561 610
                 <?php
562 611
                   $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
563
-		    if (empty($hour_array)) print _("No data available");
564
-		    else {
612
+		    if (empty($hour_array)) {
613
+		    	print _("No data available");
614
+		    } else {
565 615
                 	print '<div id="chart6" class="chart" width="100%"></div><script>';
566 616
                         $hour_data = '';
567 617
 			$hour_cnt = '';
@@ -582,7 +632,10 @@  discard block
 block discarded – undo
582 632
                   }
583 633
                 ?>
584 634
                 <div class="more">
585
-                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635
+                    <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') {
636
+	echo '/'.$airline_icao;
637
+}
638
+?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
586 639
                 </div>
587 640
             </div>
588 641
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -599,8 +652,9 @@  discard block
 block discarded – undo
599 652
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
600 653
                 <?php
601 654
                   $year_array = $Stats->countFatalitiesByYear();
602
-		    if (count($year_array) == 0) print _("No data available");
603
-		    else {
655
+		    if (count($year_array) == 0) {
656
+		    	print _("No data available");
657
+		    } else {
604 658
 			print '<div id="chart32" class="chart" width="100%"></div><script>';
605 659
                         $year_data = '';
606 660
 			$year_cnt = '';
@@ -631,8 +685,9 @@  discard block
 block discarded – undo
631 685
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
632 686
                 <?php
633 687
                   $year_array = $Stats->countFatalitiesLast12Months();
634
-		    if (count($year_array) == 0) print _("No data available");
635
-		    else {
688
+		    if (count($year_array) == 0) {
689
+		    	print _("No data available");
690
+		    } else {
636 691
 			print '<div id="chart33" class="chart" width="100%"></div><script>';
637 692
                         $year_data = '';
638 693
 			$year_cnt = '';
@@ -692,8 +747,11 @@  discard block
 block discarded – undo
692 747
 					$distance = $distance;
693 748
 					$unit = 'km';
694 749
 				}
695
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
696
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
750
+        			if (!isset($polar_data)) {
751
+        				$polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
752
+        			} else {
753
+        	    			$polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
754
+        	    		}
697 755
         		    }
698 756
         	?>
699 757
             <div class="col-md-6">
@@ -745,8 +803,11 @@  discard block
 block discarded – undo
745 803
         		foreach ($msg as $eachmsg) {
746 804
         		    //$eachmsg = $msg[0];
747 805
         		    $data = $eachmsg['source_data'];
748
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
749
-        		    else $max = 500;
806
+        		    if ($data > 500) {
807
+        		    	$max = (round(($data+100)/100))*100;
808
+        		    } else {
809
+        		    	$max = 500;
810
+        		    }
750 811
         	?>
751 812
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
752 813
         	<script>
Please login to merge, or discard this patch.
index.php 1 patch
Braces   +393 added lines, -101 removed lines patch added patch discarded remove patch
@@ -154,11 +154,26 @@  discard block
 block discarded – undo
154 154
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
155 155
 				<li><?php echo _("NOTAM scope:"); ?>
156 156
 					<select class="selectpicker" onchange="notamscope(this);">
157
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
158
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
159
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
160
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
161
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
157
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
158
+	print ' selected';
159
+}
160
+?>>All</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport/Enroute warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
166
+	print ' selected';
167
+}
168
+?>>Airport warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
170
+	print ' selected';
171
+}
172
+?>>Navigation warning</option>
173
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
174
+	print ' selected';
175
+}
176
+?>>Enroute warning</option>
162 177
 					</select
163 178
 				</li>
164 179
 			</ul>
@@ -186,7 +201,12 @@  discard block
 block discarded – undo
186 201
 		        <div class="form-group">
187 202
 			    <label>From (UTC):</label>
188 203
 		            <div class='input-group date' id='datetimepicker1'>
189
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
204
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
205
+	print $_POST['start_date'];
206
+} elseif (isset($_COOKIE['archive_begin'])) {
207
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
208
+}
209
+?>" required />
190 210
 		                <span class="input-group-addon">
191 211
             			    <span class="glyphicon glyphicon-calendar"></span>
192 212
 		                </span>
@@ -195,7 +215,12 @@  discard block
 block discarded – undo
195 215
 		        <div class="form-group">
196 216
 			    <label>To (UTC):</label>
197 217
 		            <div class='input-group date' id='datetimepicker2'>
198
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
218
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
219
+	print $_POST['end_date'];
220
+} elseif (isset($_COOKIE['archive_end'])) {
221
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
222
+}
223
+?>" />
199 224
             			<span class="input-group-addon">
200 225
 		                    <span class="glyphicon glyphicon-calendar"></span>
201 226
             			</span>
@@ -221,8 +246,20 @@  discard block
 block discarded – undo
221 246
 
222 247
 		    <li><?php echo _("Playback speed:"); ?>
223 248
 			<div class="range">
224
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
225
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
249
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
250
+	print $_POST['archivespeed'];
251
+} elseif (isset($_COOKIE['archive_speed'])) {
252
+	print $_COOKIE['archive_speed'];
253
+} else {
254
+	print '1';
255
+}
256
+?>">
257
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
258
+	print $_COOKIE['archive_speed'];
259
+} else {
260
+	print '1';
261
+}
262
+?></output>
226 263
 			</div>
227 264
 		    </li>
228 265
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -244,15 +281,27 @@  discard block
 block discarded – undo
244 281
 		    <li><?php echo _("Type of Map:"); ?>
245 282
 			<select  class="selectpicker" onchange="mapType(this);">
246 283
 			    <?php
247
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
248
-				else $MapType = $_COOKIE['MapType'];
284
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
285
+					$MapType = $globalMapProvider;
286
+				} else {
287
+					$MapType = $_COOKIE['MapType'];
288
+				}
249 289
 			    ?>
250 290
 			    <?php
251 291
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
252 292
 			    ?>
253
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
254
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
255
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
293
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Aerial</option>
297
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Hybrid</option>
301
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
302
+	print ' selected';
303
+}
304
+?>>Bing-Road</option>
256 305
 			    <?php
257 306
 				}
258 307
 			    ?>
@@ -262,56 +311,131 @@  discard block
 block discarded – undo
262 311
 			    <?php
263 312
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
264 313
 			    ?>
265
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
266
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
267
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
314
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Aerial</option>
318
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Hybrid</option>
322
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
323
+	print ' selected';
324
+}
325
+?>>Here-Road</option>
268 326
 			    <?php
269 327
 				    }
270 328
 			    ?>
271 329
 			    <?php
272 330
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
273 331
 			    ?>
274
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
275
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
276
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
277
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
332
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
333
+	print ' selected';
334
+}
335
+?>>Google Roadmap</option>
336
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
337
+	print ' selected';
338
+}
339
+?>>Google Satellite</option>
340
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
341
+	print ' selected';
342
+}
343
+?>>Google Hybrid</option>
344
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
345
+	print ' selected';
346
+}
347
+?>>Google Terrain</option>
278 348
 			    <?php
279 349
 				    }
280 350
 			    ?>
281 351
 			    <?php
282 352
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
283 353
 			    ?>
284
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
285
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
286
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
354
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-OSM</option>
358
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Aerial</option>
362
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
363
+	print ' selected';
364
+}
365
+?>>MapQuest-Hybrid</option>
287 366
 			    <?php
288 367
 				    }
289 368
 			    ?>
290
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
369
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
370
+	print ' selected';
371
+}
372
+?>>Yandex</option>
291 373
 			    <?php
292 374
 				}
293 375
 			    ?>
294 376
 			    <?php
295 377
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
296
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
297
-					else $MapBoxId = $_COOKIE['MapTypeId'];
378
+					if (!isset($_COOKIE['MapTypeId'])) {
379
+						$MapBoxId = 'default';
380
+					} else {
381
+						$MapBoxId = $_COOKIE['MapTypeId'];
382
+					}
298 383
 			    ?>
299
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
300
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
301
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
302
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
303
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
304
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
305
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
306
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
307
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
308
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
309
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
310
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
384
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox default</option>
388
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox streets</option>
392
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox light</option>
396
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox dark</option>
400
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-satellite</option>
408
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox streets-basic</option>
412
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox comic</option>
416
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox outdoors</option>
420
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pencil</option>
424
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox pirates</option>
428
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
429
+	print ' selected';
430
+}
431
+?>>Mapbox emerald</option>
311 432
 			    <?php
312 433
 				    }
313 434
 			    ?>
314
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
435
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
436
+	print ' selected';
437
+}
438
+?>>OpenStreetMap</option>
315 439
 			</select>
316 440
 		    </li>
317 441
 <?php
@@ -319,9 +443,18 @@  discard block
 block discarded – undo
319 443
 ?>
320 444
 		    <li><?php echo _("Type of Terrain:"); ?>
321 445
 			<select  class="selectpicker" onchange="terrainType(this);">
322
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
323
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
324
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
446
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
447
+	print ' selected';
448
+}
449
+?>>stk terrain</option>
450
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
451
+	print ' selected';
452
+}
453
+?>>ellipsoid</option>
454
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
455
+	print ' selected';
456
+}
457
+?>>vr terrain</option>
325 458
 			</select>
326 459
 		    </li>
327 460
 <?php
@@ -331,18 +464,36 @@  discard block
 block discarded – undo
331 464
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
332 465
 ?>
333 466
 		    
334
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
335
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
336
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
471
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight path"); ?></label></div></li>
475
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
479
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
480
+	print 'checked';
481
+}
482
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
338 483
 <?php
339 484
     }
340 485
 ?>
341
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
486
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
487
+	print 'checked';
488
+}
489
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
342 490
 <?php
343 491
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
344 492
 ?>
345
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
493
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
494
+	print 'checked';
495
+}
496
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
346 497
 <?php
347 498
     }
348 499
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -356,17 +507,25 @@  discard block
 block discarded – undo
356 507
 			if (function_exists('array_column')) {
357 508
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
358 509
 		    ?>
359
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
510
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
511
+	print 'checked';
512
+}
513
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
360 514
 		    <?php
361 515
 			    }
362 516
 			} elseif (isset($globalSources)) {
363 517
 			    $dispolar = false;
364 518
 			    foreach ($globalSources as $testsource) {
365
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
519
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
520
+			        	$dispolar = true;
521
+			        }
366 522
 			    }
367 523
 			    if ($dispolar) {
368 524
 		    ?>
369
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
525
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
526
+	print 'checked';
527
+}
528
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
370 529
 		    <?php
371 530
 			    }
372 531
 		        }
@@ -379,12 +538,22 @@  discard block
 block discarded – undo
379 538
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
380 539
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
381 540
 		    ?>
382
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
541
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
542
+	print 'checked';
543
+}
544
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
383 545
 		    <?php 
384 546
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
385 547
 		    ?>
386 548
 		    <li><?php echo _("Aircraft icon color:"); ?>
387
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>">
549
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
550
+	print $_COOKIE['IconColor'];
551
+} elseif (isset($globalAircraftIconColor)) {
552
+	print $globalAircraftIconColor;
553
+} else {
554
+	print '1a3151';
555
+}
556
+?>">
388 557
 		    </li>
389 558
 		    <?php
390 559
 				}
@@ -396,7 +565,14 @@  discard block
 block discarded – undo
396 565
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
397 566
 		    ?>
398 567
 		    <li><?php echo _("Marine icon color:"); ?>
399
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
568
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
569
+	print $_COOKIE['MarineIconColor'];
570
+} elseif (isset($globalMarineIconColor)) {
571
+	print $globalMarineIconColor;
572
+} else {
573
+	print '1a3151';
574
+}
575
+?>">
400 576
 		    </li>
401 577
 		    <?php
402 578
 			    }
@@ -407,8 +583,22 @@  discard block
 block discarded – undo
407 583
 		    ?>
408 584
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
409 585
 			<div class="range">
410
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
411
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
586
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
587
+	print $_COOKIE['AirportZoom'];
588
+} elseif (isset($globalAirportZoom)) {
589
+	print $globalAirportZoom;
590
+} else {
591
+	print '7';
592
+}
593
+?>">
594
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
595
+	print $_COOKIE['AirportZoom'];
596
+} elseif (isset($globalAirportZoom)) {
597
+	print $globalAirportZoom;
598
+} else {
599
+	print '7';
600
+}
601
+?></output>
412 602
 			</div>
413 603
 		    </li>
414 604
 		    <?php
@@ -420,9 +610,19 @@  discard block
 block discarded – undo
420 610
 <?php
421 611
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
422 612
 ?>
423
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
613
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Force Aircraft color"); ?></li>
424 617
 		    <li><?php echo _("Aircraft icon color:"); ?>
425
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
618
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
619
+	print $_COOKIE['IconColor'];
620
+} elseif (isset($globalAircraftIconColor)) {
621
+	print $globalAircraftIconColor;
622
+} else {
623
+	print 'ff0000';
624
+}
625
+?>">
426 626
 		    </li>
427 627
 <?php
428 628
 	}
@@ -430,9 +630,19 @@  discard block
 block discarded – undo
430 630
 <?php
431 631
 	if (isset($globalMarine) && $globalMarine === TRUE) {
432 632
 ?>
433
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
633
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
634
+	print 'checked';
635
+}
636
+?> ><?php echo _("Force Marine color"); ?></li>
434 637
 		    <li><?php echo _("Marine icon color:"); ?>
435
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
638
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
639
+	print $_COOKIE['MarineIconColor'];
640
+} elseif (isset($globalMarineIconColor)) {
641
+	print $globalMarineIconColor;
642
+} else {
643
+	print 'ff0000';
644
+}
645
+?>">
436 646
 		    </li>
437 647
 <?php
438 648
 	}
@@ -440,22 +650,46 @@  discard block
 block discarded – undo
440 650
 ?>
441 651
 		    <li><?php echo _("Distance unit:"); ?>
442 652
 			<select class="selectpicker" onchange="unitdistance(this);">
443
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
444
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
445
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
653
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
654
+	echo ' selected';
655
+}
656
+?>>km</option>
657
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
658
+	echo ' selected';
659
+}
660
+?>>nm</option>
661
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
662
+	echo ' selected';
663
+}
664
+?>>mi</option>
446 665
 		        </select>
447 666
 		    </li>
448 667
 		    <li><?php echo _("Altitude unit:"); ?>
449 668
 			<select class="selectpicker" onchange="unitaltitude(this);">
450
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
451
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
669
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
670
+	echo ' selected';
671
+}
672
+?>>m</option>
673
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
674
+	echo ' selected';
675
+}
676
+?>>feet</option>
452 677
 		        </select>
453 678
 		    </li>
454 679
 		    <li><?php echo _("Speed unit:"); ?>
455 680
 			<select class="selectpicker" onchange="unitspeed(this);">
456
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
457
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
458
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
681
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
682
+	echo ' selected';
683
+}
684
+?>>km/h</option>
685
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
686
+	echo ' selected';
687
+}
688
+?>>mph</option>
689
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
690
+	echo ' selected';
691
+}
692
+?>>knots</option>
459 693
 		        </select>
460 694
 		    </li>
461 695
 
@@ -473,9 +707,18 @@  discard block
 block discarded – undo
473 707
 		    <?php
474 708
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
475 709
 		    ?>
476
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
477
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
478
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
710
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
711
+	print 'checked';
712
+}
713
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
714
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
715
+	print 'checked';
716
+}
717
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
718
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
719
+	print 'checked';
720
+}
721
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
479 722
 		    <?php
480 723
 			}
481 724
 		    ?>
@@ -483,10 +726,16 @@  discard block
 block discarded – undo
483 726
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
484 727
 		    ?>
485 728
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
486
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
729
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
730
+	print 'checked';
731
+}
732
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
487 733
 			<?php } ?>
488 734
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
489
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
735
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
736
+	print 'checked';
737
+}
738
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
490 739
 			<?php } ?>
491 740
 		    <?php
492 741
 			}
@@ -503,7 +752,9 @@  discard block
 block discarded – undo
503 752
 				}
504 753
 				foreach($allairlinenames as $airline) {
505 754
 					$airline_name = $airline['airline_name'];
506
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
755
+					if (strlen($airline_name) > 30) {
756
+						$airline_name = substr($airline_name,0,30).'...';
757
+					}
507 758
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
508 759
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
509 760
 					} else {
@@ -521,7 +772,10 @@  discard block
 block discarded – undo
521 772
 		    <li><?php echo _("Display alliance:"); ?>
522 773
 		    <br/>
523 774
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
524
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
775
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
776
+	echo ' selected';
777
+}
778
+?>><?php echo _("All"); ?></option>
525 779
 			    <?php
526 780
 				foreach($allalliancenames as $alliance) {
527 781
 					$alliance_name = $alliance['alliance'];
@@ -568,10 +822,22 @@  discard block
 block discarded – undo
568 822
 		    ?>
569 823
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
570 824
 			<select class="selectpicker" onchange="airlinestype(this);">
571
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
572
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
573
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
574
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
825
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
826
+	echo ' selected';
827
+}
828
+?>><?php echo _("All"); ?></option>
829
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
830
+	echo ' selected';
831
+}
832
+?>><?php echo _("Passenger"); ?></option>
833
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
834
+	echo ' selected';
835
+}
836
+?>><?php echo _("Cargo"); ?></option>
837
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
838
+	echo ' selected';
839
+}
840
+?>><?php echo _("Military"); ?></option>
575 841
 			</select>
576 842
 		    </li>
577 843
 		    <?php
@@ -579,7 +845,10 @@  discard block
 block discarded – undo
579 845
 		    ?>
580 846
 		    <li>
581 847
 			<?php echo _("Display flight with ident:"); ?>
582
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
848
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
849
+	print $_COOKIE['filter_ident'];
850
+}
851
+?>" />
583 852
 		    </li>
584 853
 		    <?php
585 854
 			}
@@ -598,7 +867,10 @@  discard block
 block discarded – undo
598 867
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
599 868
 	    <form>
600 869
 		<ul>
601
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
870
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
871
+	print 'checked';
872
+}
873
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
602 874
 		    <li><?php echo _("Type:"); ?>
603 875
 			<select class="selectpicker" multiple onchange="sattypes(this);">
604 876
 			    <?php
@@ -606,25 +878,45 @@  discard block
 block discarded – undo
606 878
 				$types = $Satellite->get_tle_types();
607 879
 				foreach ($types as $type) {
608 880
 					$type_name = $type['tle_type'];
609
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
610
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
611
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
612
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
613
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
614
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
615
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
616
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
617
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
618
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
619
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
620
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
621
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
622
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
623
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
624
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
625
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
626
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
627
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
881
+					if ($type_name == 'musson') {
882
+						$type_name = 'Russian LEO Navigation';
883
+					} else if ($type_name == 'nnss') {
884
+						$type_name = 'Navi Navigation Satellite System';
885
+					} else if ($type_name == 'sbas') {
886
+						$type_name = 'Satellite-Based Augmentation System';
887
+					} else if ($type_name == 'glo-ops') {
888
+						$type_name = 'Glonass Operational';
889
+					} else if ($type_name == 'gps-ops') {
890
+						$type_name = 'GPS Operational';
891
+					} else if ($type_name == 'argos') {
892
+						$type_name = 'ARGOS Data Collection System';
893
+					} else if ($type_name == 'tdrss') {
894
+						$type_name = 'Tracking and Data Relay Satellite System';
895
+					} else if ($type_name == 'sarsat') {
896
+						$type_name = 'Search & Rescue';
897
+					} else if ($type_name == 'dmc') {
898
+						$type_name = 'Disaster Monitoring';
899
+					} else if ($type_name == 'resource') {
900
+						$type_name = 'Earth Resources';
901
+					} else if ($type_name == 'stations') {
902
+						$type_name = 'Space Stations';
903
+					} else if ($type_name == 'geo') {
904
+						$type_name = 'Geostationary';
905
+					} else if ($type_name == 'amateur') {
906
+						$type_name = 'Amateur Radio';
907
+					} else if ($type_name == 'x-comm') {
908
+						$type_name = 'Experimental';
909
+					} else if ($type_name == 'other-comm') {
910
+						$type_name = 'Other Comm';
911
+					} else if ($type_name == 'science') {
912
+						$type_name = 'Space & Earth Science';
913
+					} else if ($type_name == 'military') {
914
+						$type_name = 'Miscellaneous Military';
915
+					} else if ($type_name == 'radar') {
916
+						$type_name = 'Radar Calibration';
917
+					} else if ($type_name == 'tle-new') {
918
+						$type_name = 'Last 30 days launches';
919
+					}
628 920
 					
629 921
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
630 922
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.