Completed
Push — master ( 36f624...bc4f96 )
by Yannick
11:00 queued 04:11
created
require/class.Marine.php 1 patch
Braces   +145 added lines, -52 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 		if (isset($filter[0]['source'])) {
32 32
 			$filters = array_merge($filters,$filter);
33 33
 		}
34
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
34
+		if (is_array($globalFilter)) {
35
+			$filter = array_merge($filter,$globalFilter);
36
+		}
35 37
 		$filter_query_join = '';
36 38
 		$filter_query_where = '';
37 39
 		foreach($filters as $flt) {
@@ -70,8 +72,11 @@  discard block
 block discarded – undo
70 72
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
71 73
 			}
72 74
 		}
73
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
74
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
75
+		if ($filter_query_where == '' && $where) {
76
+			$filter_query_where = ' WHERE';
77
+		} elseif ($filter_query_where != '' && $and) {
78
+			$filter_query_where .= ' AND';
79
+		}
75 80
 		if ($filter_query_where != '') {
76 81
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
77 82
 		}
@@ -125,25 +130,40 @@  discard block
 block discarded – undo
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
126 131
 			} elseif (isset($row['spotter_archive_output_id'])) {
127 132
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
128
-			*/} 
129
-			elseif (isset($row['marineid'])) {
133
+			*/} elseif (isset($row['marineid'])) {
130 134
 				$temp_array['marineid'] = $row['marineid'];
131 135
 			} else {
132 136
 				$temp_array['marineid'] = '';
133 137
 			}
134
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
135
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
136
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
138
+			if (isset($row['fammarine_id'])) {
139
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
140
+			}
141
+			if (isset($row['mmsi'])) {
142
+				$temp_array['mmsi'] = $row['mmsi'];
143
+			}
144
+			if (isset($row['type'])) {
145
+				$temp_array['type'] = $row['type'];
146
+			}
137 147
 			$temp_array['ident'] = $row['ident'];
138
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
139
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
140
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
141 157
 			if (isset($row['heading'])) {
142 158
 				$temp_array['heading'] = $row['heading'];
143 159
 				$heading_direction = $this->parseDirection($row['heading']);
144
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
145 166
 			}
146
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
147 167
 			
148 168
 			if (isset($row['date'])) {
149 169
 				$dateArray = $this->parseDateString($row['date']);
@@ -186,13 +206,21 @@  discard block
 block discarded – undo
186 206
 			}
187 207
 			
188 208
 			$fromsource = NULL;
189
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
190
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
191
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
209
+			if (isset($row['source_name']) && $row['source_name'] != '') {
210
+				$temp_array['source_name'] = $row['source_name'];
211
+			}
212
+			if (isset($row['over_country']) && $row['over_country'] != '') {
213
+				$temp_array['over_country'] = $row['over_country'];
214
+			}
215
+			if (isset($row['distance']) && $row['distance'] != '') {
216
+				$temp_array['distance'] = $row['distance'];
217
+			}
192 218
 			$temp_array['query_number_rows'] = $num_rows;
193 219
 			$spotter_array[] = $temp_array;
194 220
 		}
195
-		if ($num_rows == 0) return array();
221
+		if ($num_rows == 0) {
222
+			return array();
223
+		}
196 224
 		$spotter_array[0]['query_number_rows'] = $num_rows;
197 225
 		return $spotter_array;
198 226
 	}	
@@ -223,8 +251,12 @@  discard block
 block discarded – undo
223 251
 			{
224 252
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
225 253
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
226
-			} else $limit_query = "";
227
-		} else $limit_query = "";
254
+			} else {
255
+				$limit_query = "";
256
+			}
257
+		} else {
258
+			$limit_query = "";
259
+		}
228 260
 		
229 261
 		if ($sort != "")
230 262
 		{
@@ -252,7 +284,9 @@  discard block
 block discarded – undo
252 284
 		global $global_query;
253 285
 		
254 286
 		date_default_timezone_set('UTC');
255
-		if ($id == '') return array();
287
+		if ($id == '') {
288
+			return array();
289
+		}
256 290
 		$additional_query = "marine_output.fammarine_id = :id";
257 291
 		$query_values = array(':id' => $id);
258 292
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -395,8 +429,11 @@  discard block
 block discarded – undo
395 429
 		$query .= " ORDER BY marine_output.source_name ASC";
396 430
 
397 431
 		$sth = $this->db->prepare($query);
398
-		if (!empty($query_values)) $sth->execute($query_values);
399
-		else $sth->execute();
432
+		if (!empty($query_values)) {
433
+			$sth->execute($query_values);
434
+		} else {
435
+			$sth->execute();
436
+		}
400 437
 
401 438
 		$source_array = array();
402 439
 		$temp_array = array();
@@ -451,8 +488,11 @@  discard block
 block discarded – undo
451 488
 		$sth = $this->db->prepare($query);
452 489
 		$sth->execute(array(':mmsi' => $mmsi));
453 490
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
454
-		if (isset($result[0])) return $result[0];
455
-		else return array();
491
+		if (isset($result[0])) {
492
+			return $result[0];
493
+		} else {
494
+			return array();
495
+		}
456 496
 	}
457 497
 
458 498
 	/*
@@ -468,7 +508,9 @@  discard block
 block discarded – undo
468 508
 			date_default_timezone_set($globalTimezone);
469 509
 			$datetime = new DateTime();
470 510
 			$offset = $datetime->format('P');
471
-		} else $offset = '+00:00';
511
+		} else {
512
+			$offset = '+00:00';
513
+		}
472 514
 
473 515
 		if ($globalDBdriver == 'mysql') {
474 516
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -663,9 +705,15 @@  discard block
 block discarded – undo
663 705
             		$latitude = 0;
664 706
             		$longitude = 0;
665 707
             	}
666
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
667
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
668
-                if ($arrival_date == '') $arrival_date = NULL;
708
+                if ($heading == '' || $Common->isInteger($heading) === false) {
709
+                	$heading = 0;
710
+                }
711
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
712
+                	$groundspeed = 0;
713
+                }
714
+                if ($arrival_date == '') {
715
+                	$arrival_date = NULL;
716
+                }
669 717
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
670 718
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
671 719
 
@@ -829,12 +877,18 @@  discard block
 block discarded – undo
829 877
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
830 878
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
831 879
 		 if ($olderthanmonths > 0) {
832
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
833
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
880
+			if ($globalDBdriver == 'mysql') {
881
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
882
+			} else {
883
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
884
+			}
834 885
 		}
835 886
 		if ($sincedate != '') {
836
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
837
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
887
+			if ($globalDBdriver == 'mysql') {
888
+				$query .= " AND marine_output.date > '".$sincedate."'";
889
+			} else {
890
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
891
+			}
838 892
 		}
839 893
 		$query_values = array();
840 894
 		if ($year != '') {
@@ -865,7 +919,9 @@  discard block
 block discarded – undo
865 919
 			}
866 920
 		}
867 921
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
868
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
922
+		if ($limit) {
923
+			$query .= " LIMIT 10 OFFSET 0";
924
+		}
869 925
       		
870 926
 		$sth = $this->db->prepare($query);
871 927
 		$sth->execute($query_values);
@@ -900,7 +956,9 @@  discard block
 block discarded – undo
900 956
 			date_default_timezone_set($globalTimezone);
901 957
 			$datetime = new DateTime();
902 958
 			$offset = $datetime->format('P');
903
-		} else $offset = '+00:00';
959
+		} else {
960
+			$offset = '+00:00';
961
+		}
904 962
 
905 963
 		if ($globalDBdriver == 'mysql') {
906 964
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -950,7 +1008,9 @@  discard block
 block discarded – undo
950 1008
 			date_default_timezone_set($globalTimezone);
951 1009
 			$datetime = new DateTime();
952 1010
 			$offset = $datetime->format('P');
953
-		} else $offset = '+00:00';
1011
+		} else {
1012
+			$offset = '+00:00';
1013
+		}
954 1014
 		$filter_query = $this->getFilter($filters,true,true);
955 1015
 		if ($globalDBdriver == 'mysql') {
956 1016
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -996,7 +1056,9 @@  discard block
 block discarded – undo
996 1056
 			date_default_timezone_set($globalTimezone);
997 1057
 			$datetime = new DateTime();
998 1058
 			$offset = $datetime->format('P');
999
-		} else $offset = '+00:00';
1059
+		} else {
1060
+			$offset = '+00:00';
1061
+		}
1000 1062
 		$filter_query = $this->getFilter($filters,true,true);
1001 1063
 		if ($globalDBdriver == 'mysql') {
1002 1064
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1044,7 +1106,9 @@  discard block
 block discarded – undo
1044 1106
 			date_default_timezone_set($globalTimezone);
1045 1107
 			$datetime = new DateTime();
1046 1108
 			$offset = $datetime->format('P');
1047
-		} else $offset = '+00:00';
1109
+		} else {
1110
+			$offset = '+00:00';
1111
+		}
1048 1112
 
1049 1113
 		if ($globalDBdriver == 'mysql') {
1050 1114
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1093,7 +1157,9 @@  discard block
 block discarded – undo
1093 1157
 			date_default_timezone_set($globalTimezone);
1094 1158
 			$datetime = new DateTime();
1095 1159
 			$offset = $datetime->format('P');
1096
-		} else $offset = '+00:00';
1160
+		} else {
1161
+			$offset = '+00:00';
1162
+		}
1097 1163
 		$filter_query = $this->getFilter($filters,true,true);
1098 1164
 		if ($globalDBdriver == 'mysql') {
1099 1165
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1142,7 +1208,9 @@  discard block
 block discarded – undo
1142 1208
 			date_default_timezone_set($globalTimezone);
1143 1209
 			$datetime = new DateTime();
1144 1210
 			$offset = $datetime->format('P');
1145
-		} else $offset = '+00:00';
1211
+		} else {
1212
+			$offset = '+00:00';
1213
+		}
1146 1214
 
1147 1215
 		$orderby_sql = '';
1148 1216
 		if ($orderby == "hour")
@@ -1211,7 +1279,9 @@  discard block
 block discarded – undo
1211 1279
 			date_default_timezone_set($globalTimezone);
1212 1280
 			$datetime = new DateTime($date);
1213 1281
 			$offset = $datetime->format('P');
1214
-		} else $offset = '+00:00';
1282
+		} else {
1283
+			$offset = '+00:00';
1284
+		}
1215 1285
 
1216 1286
 		if ($globalDBdriver == 'mysql') {
1217 1287
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1259,7 +1329,9 @@  discard block
 block discarded – undo
1259 1329
 			date_default_timezone_set($globalTimezone);
1260 1330
 			$datetime = new DateTime();
1261 1331
 			$offset = $datetime->format('P');
1262
-		} else $offset = '+00:00';
1332
+		} else {
1333
+			$offset = '+00:00';
1334
+		}
1263 1335
 
1264 1336
 		if ($globalDBdriver == 'mysql') {
1265 1337
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1323,8 +1395,11 @@  discard block
 block discarded – undo
1323 1395
 				$query_values = array_merge($query_values,array(':month' => $month));
1324 1396
 			}
1325 1397
 		}
1326
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1327
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1398
+		if (empty($query_values)) {
1399
+			$queryi .= $this->getFilter($filters);
1400
+		} else {
1401
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1402
+		}
1328 1403
 		
1329 1404
 		$sth = $this->db->prepare($queryi);
1330 1405
 		$sth->execute($query_values);
@@ -1346,7 +1421,9 @@  discard block
 block discarded – undo
1346 1421
 			date_default_timezone_set($globalTimezone);
1347 1422
 			$datetime = new DateTime();
1348 1423
 			$offset = $datetime->format('P');
1349
-		} else $offset = '+00:00';
1424
+		} else {
1425
+			$offset = '+00:00';
1426
+		}
1350 1427
 
1351 1428
 		if ($globalDBdriver == 'mysql') {
1352 1429
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1450,7 +1527,9 @@  discard block
 block discarded – undo
1450 1527
 	*/
1451 1528
 	public function parseDirection($direction = 0)
1452 1529
 	{
1453
-		if ($direction == '') $direction = 0;
1530
+		if ($direction == '') {
1531
+			$direction = 0;
1532
+		}
1454 1533
 		$direction_array = array();
1455 1534
 		$temp_array = array();
1456 1535
 
@@ -1539,7 +1618,9 @@  discard block
 block discarded – undo
1539 1618
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1540 1619
 	
1541 1620
 		$Connection = new Connection($this->db);
1542
-		if (!$Connection->tableExists('countries')) return '';
1621
+		if (!$Connection->tableExists('countries')) {
1622
+			return '';
1623
+		}
1543 1624
 	
1544 1625
 		try {
1545 1626
 			/*
@@ -1559,9 +1640,13 @@  discard block
 block discarded – undo
1559 1640
 			$sth->closeCursor();
1560 1641
 			if (count($row) > 0) {
1561 1642
 				return $row;
1562
-			} else return '';
1643
+			} else {
1644
+				return '';
1645
+			}
1563 1646
 		} catch (PDOException $e) {
1564
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1647
+			if (isset($globalDebug) && $globalDebug) {
1648
+				echo 'Error : '.$e->getMessage()."\n";
1649
+			}
1565 1650
 			return '';
1566 1651
 		}
1567 1652
 	
@@ -1579,7 +1664,9 @@  discard block
 block discarded – undo
1579 1664
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1580 1665
 	
1581 1666
 		$Connection = new Connection($this->db);
1582
-		if (!$Connection->tableExists('countries')) return '';
1667
+		if (!$Connection->tableExists('countries')) {
1668
+			return '';
1669
+		}
1583 1670
 	
1584 1671
 		try {
1585 1672
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1591,9 +1678,13 @@  discard block
 block discarded – undo
1591 1678
 			$sth->closeCursor();
1592 1679
 			if (count($row) > 0) {
1593 1680
 				return $row;
1594
-			} else return '';
1681
+			} else {
1682
+				return '';
1683
+			}
1595 1684
 		} catch (PDOException $e) {
1596
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1685
+			if (isset($globalDebug) && $globalDebug) {
1686
+				echo 'Error : '.$e->getMessage()."\n";
1687
+			}
1597 1688
 			return '';
1598 1689
 		}
1599 1690
 	
@@ -1611,7 +1702,9 @@  discard block
 block discarded – undo
1611 1702
 	{
1612 1703
 		global $globalBitlyAccessToken;
1613 1704
 		
1614
-		if ($globalBitlyAccessToken == '') return $url;
1705
+		if ($globalBitlyAccessToken == '') {
1706
+			return $url;
1707
+		}
1615 1708
         
1616 1709
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1617 1710
 		
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +149 added lines, -51 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 
46 46
     public function checkAll() {
47 47
 	global $globalDebug;
48
-	if ($globalDebug) echo "Update last seen tracked data...\n";
48
+	if ($globalDebug) {
49
+		echo "Update last seen tracked data...\n";
50
+	}
49 51
 	foreach ($this->all_tracked as $key => $flight) {
50 52
 	    if (isset($this->all_tracked[$key]['id'])) {
51 53
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -58,12 +60,16 @@  discard block
 block discarded – undo
58 60
     public function del() {
59 61
 	global $globalDebug;
60 62
 	// Delete old infos
61
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
63
+	if ($globalDebug) {
64
+		echo 'Delete old values and update latest data...'."\n";
65
+	}
62 66
 	foreach ($this->all_tracked as $key => $flight) {
63 67
     	    if (isset($flight['lastupdate'])) {
64 68
         	if ($flight['lastupdate'] < (time()-3000)) {
65 69
             	    if (isset($this->all_tracked[$key]['id'])) {
66
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
70
+            		if ($globalDebug) {
71
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
72
+            		}
67 73
 			/*
68 74
 			$MarineLive = new MarineLive();
69 75
             		$MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -73,7 +79,9 @@  discard block
 block discarded – undo
73 79
             		$Marine = new Marine($this->db);
74 80
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
75 81
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed']);
76
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
82
+				if ($globalDebug && $result != 'success') {
83
+					echo '!!! ERROR : '.$result."\n";
84
+				}
77 85
 			}
78 86
 			// Put in archive
79 87
 //			$Marine->db = null;
@@ -86,7 +94,9 @@  discard block
 block discarded – undo
86 94
 
87 95
     public function add($line) {
88 96
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
89
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
97
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
98
+		$globalCoordMinChange = '0.02';
99
+	}
90 100
 	date_default_timezone_set('UTC');
91 101
 	$dataFound = false;
92 102
 	$send = false;
@@ -111,8 +121,11 @@  discard block
 block discarded – undo
111 121
 		
112 122
 		$Common = new Common();
113 123
 		$AIS = new AIS();
114
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
115
-	        else $id = trim($line['id']);
124
+	        if (!isset($line['id'])) {
125
+	        	$id = trim($line['mmsi']);
126
+	        } else {
127
+	        	$id = trim($line['id']);
128
+	        }
116 129
 		
117 130
 		if (!isset($this->all_tracked[$id])) {
118 131
 		    $this->all_tracked[$id] = array();
@@ -120,10 +133,16 @@  discard block
 block discarded – undo
120 133
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => ''));
121 134
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
122 135
 		    if (!isset($line['id'])) {
123
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
136
+			if (!isset($globalDaemon)) {
137
+				$globalDaemon = TRUE;
138
+			}
124 139
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
125
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
126
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
140
+		     } else {
141
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
142
+		     }
143
+		    if ($globalAllTracked !== FALSE) {
144
+		    	$dataFound = true;
145
+		    }
127 146
 		}
128 147
 		
129 148
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -166,11 +185,17 @@  discard block
 block discarded – undo
166 185
             		$Marine = new Marine($this->db);
167 186
             		$fromsource = NULL;
168 187
             		$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
169
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
188
+			if ($globalDebug && $result != 'success') {
189
+				echo '!!! ERROR : '.$result."\n";
190
+			}
170 191
 			$Marine->db = null;
171
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+			if ($globalDebugTimeElapsed) {
193
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
194
+			}
195
+		    }
196
+		    if (!isset($this->all_tracked[$id]['id'])) {
197
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
172 198
 		    }
173
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
174 199
 		}
175 200
 
176 201
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -181,14 +206,21 @@  discard block
 block discarded – undo
181 206
 		    if ($distance > 1000 && $distance < 10000) {
182 207
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
183 208
 			$speed = $speed*3.6;
184
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
185
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
209
+			if ($speed < 1000) {
210
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
211
+			}
212
+  			if ($globalDebug) {
213
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
214
+  			}
186 215
 		    }
187 216
 		}
188 217
 
189 218
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
190
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
191
-	    	    else unset($timediff);
219
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
220
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
221
+	    	    } else {
222
+	    	    	unset($timediff);
223
+	    	    }
192 224
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
193 225
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
194 226
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -196,20 +228,30 @@  discard block
 block discarded – undo
196 228
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
197 229
 				$this->all_tracked[$id]['putinarchive'] = true;
198 230
 				
199
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
231
+				if ($globalDebug) {
232
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
233
+				}
200 234
 				$timeelapsed = microtime(true);
201 235
 				$Marine = new Marine($this->db);
202 236
 				$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
203
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
237
+				if (!empty($all_country)) {
238
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
239
+				}
204 240
 				$Marine->db = null;
205
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
241
+				if ($globalDebugTimeElapsed) {
242
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
243
+				}
206 244
 				$this->tmd = 0;
207
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
245
+				if ($globalDebug) {
246
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
247
+				}
208 248
 			    }
209 249
 			}
210 250
 
211 251
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
212
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
252
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
253
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
254
+				}
213 255
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
214 256
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
215 257
 				    $dataFound = true;
@@ -218,8 +260,12 @@  discard block
 block discarded – undo
218 260
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
219 261
 			}
220 262
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
221
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
222
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
263
+			    if ($line['longitude'] > 180) {
264
+			    	$line['longitude'] = $line['longitude'] - 360;
265
+			    }
266
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
267
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
268
+				}
223 269
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
224 270
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
225 271
 				    $dataFound = true;
@@ -237,7 +283,9 @@  discard block
 block discarded – undo
237 283
 		    }
238 284
 		}
239 285
 		if (isset($line['last_update']) && $line['last_update'] != '') {
240
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
286
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
287
+		    	$dataFound = true;
288
+		    }
241 289
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
242 290
 		}
243 291
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -255,15 +303,21 @@  discard block
 block discarded – undo
255 303
 		}
256 304
 		
257 305
 		if (isset($line['heading']) && $line['heading'] != '') {
258
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
306
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
307
+		    	$this->all_tracked[$id]['putinarchive'] = true;
308
+		    }
259 309
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
260 310
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261 311
 		    //$dataFound = true;
262 312
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
263 313
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
264 314
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
265
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
315
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
316
+		    	$this->all_tracked[$id]['putinarchive'] = true;
317
+		    }
318
+  		    if ($globalDebug) {
319
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
320
+  		    }
267 321
   		}
268 322
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
269 323
 
@@ -271,8 +325,11 @@  discard block
 block discarded – undo
271 325
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
272 326
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
273 327
 		    } else {
274
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
275
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
328
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
329
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
330
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
331
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
332
+				}
276 333
 				return '';
277 334
 		    }
278 335
 		} else {
@@ -286,22 +343,35 @@  discard block
 block discarded – undo
286 343
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
287 344
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
288 345
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
289
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
346
+				if ($globalDebug) {
347
+					echo "Check if aircraft is already in DB...";
348
+				}
290 349
 				$timeelapsed = microtime(true);
291 350
 				$MarineLive = new MarineLive($this->db);
292 351
 				if (isset($line['id'])) {
293 352
 				    $recent_ident = $MarineLive->checkIdRecent($line['id']);
294
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
353
+				    if ($globalDebugTimeElapsed) {
354
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
355
+				    }
295 356
 				} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
296 357
 				    $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
297
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
358
+				    if ($globalDebugTimeElapsed) {
359
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+				    }
298 361
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
299 362
 				    $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
300
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
-				} else $recent_ident = '';
363
+				    if ($globalDebugTimeElapsed) {
364
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
365
+				    }
366
+				} else {
367
+					$recent_ident = '';
368
+				}
302 369
 				$MarineLive->db=null;
303
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
304
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
305 375
 			    } else {
306 376
 				$recent_ident = '';
307 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -309,16 +379,24 @@  discard block
 block discarded – undo
309 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
310 380
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
311 381
 			    {
312
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
384
+				}
313 385
 				//adds the spotter data for the archive
314 386
 				    $highlight = '';
315
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
389
+				    }
316 390
 				    $timeelapsed = microtime(true);
317 391
 				    $Marine = new Marine($this->db);
318 392
 				    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
319 393
 				    $Marine->db = null;
320
-				    if ($globalDebug && isset($result)) echo $result."\n";
321
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
322 400
 				    
323 401
 				    /*
324 402
 				    // Add source stat in DB
@@ -352,12 +430,16 @@  discard block
 block discarded – undo
352 430
 				$this->all_tracked[$id]['addedMarine'] = 1;
353 431
 				//print_r($this->all_tracked[$id]);
354 432
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
355
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
433
+				    if ($globalDebug) {
434
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
435
+				    }
356 436
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
357 437
 				    $MarineLive = new MarineLive($this->db);
358 438
 				    $MarineLive->deleteLiveMarineData();
359 439
 				    $MarineLive->db=null;
360
-				    if ($globalDebug) echo " Done\n";
440
+				    if ($globalDebug) {
441
+				    	echo " Done\n";
442
+				    }
361 443
 				    $this->last_delete = time();
362 444
 				}
363 445
 			    } elseif ($recent_ident != '') {
@@ -380,13 +462,17 @@  discard block
 block discarded – undo
380 462
 
381 463
 		    if (!$ignoreImport) {
382 464
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
383
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
465
+				if ($globalDebug) {
466
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
467
+				}
384 468
 				$timeelapsed = microtime(true);
385 469
 				$MarineLive = new MarineLive($this->db);
386 470
 				$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
387 471
 				$MarineLive->db = null;
388 472
 				$this->all_tracked[$id]['putinarchive'] = false;
389
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+				if ($globalDebugTimeElapsed) {
474
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
475
+				}
390 476
 
391 477
 				// Put statistics in $this->stats variable
392 478
 				/*
@@ -443,19 +529,29 @@  discard block
 block discarded – undo
443 529
 				*/
444 530
 
445 531
 				$this->all_tracked[$id]['lastupdate'] = time();
446
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
447
-				if ($globalDebug) echo $result."\n";
448
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
532
+				if ($this->all_tracked[$id]['putinarchive']) {
533
+					$send = true;
534
+				}
535
+				if ($globalDebug) {
536
+					echo $result."\n";
537
+				}
538
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
539
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
540
+			}
449 541
 			//$this->del();
450 542
 			
451 543
 			
452 544
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
453
-			    if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
545
+			    if ($globalDebug) {
546
+			    	echo "---- Deleting Live Marine data Not updated since 2 hour...";
547
+			    }
454 548
 			    $MarineLive = new MarineLive($this->db);
455 549
 			    $MarineLive->deleteLiveMarineDataNotUpdated();
456 550
 			    $MarineLive->db = null;
457 551
 			    //MarineLive->deleteLiveMarineData();
458
-			    if ($globalDebug) echo " Done\n";
552
+			    if ($globalDebug) {
553
+			    	echo " Done\n";
554
+			    }
459 555
 			    $this->last_delete_hourly = time();
460 556
 			}
461 557
 			
@@ -463,7 +559,9 @@  discard block
 block discarded – undo
463 559
 		    //$ignoreImport = false;
464 560
 		}
465 561
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
466
-		if ($send) return $this->all_tracked[$id];
562
+		if ($send) {
563
+			return $this->all_tracked[$id];
564
+		}
467 565
 	    }
468 566
 	}
469 567
     }
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Braces   +322 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,7 +35,9 @@  discard block
 block discarded – undo
35 35
 			$temp += 1;
36 36
 			$flat = (float)($temp / (60.0 * 10000.0));
37 37
 			$flat *= -1.0;
38
-		} else $flat = (float)($temp / (60.0 * 10000.0));
38
+		} else {
39
+			$flat = (float)($temp / (60.0 * 10000.0));
40
+		}
39 41
 		return $flat; // float
40 42
 	}
41 43
 
@@ -47,7 +49,9 @@  discard block
 block discarded – undo
47 49
 			$temp += 1;
48 50
 			$flon = (float)($temp / (60.0 * 10000.0));
49 51
 			$flon *= -1.0;
50
-		} else $flon = (float)($temp / (60.0 * 10000.0));
52
+		} else {
53
+			$flon = (float)($temp / (60.0 * 10000.0));
54
+		}
51 55
 		return $flon;
52 56
 	}
53 57
 
@@ -70,10 +74,8 @@  discard block
 block discarded – undo
70 74
     */
71 75
 	private function asciidec_2_8bit($ascii) {
72 76
 		//only process in the following range: 48-87, 96-119
73
-		if ($ascii < 48) { }
74
-		else {
75
-			if($ascii>119) { }
76
-			else {
77
+		if ($ascii < 48) { } else {
78
+			if($ascii>119) { } else {
77 79
 				if ($ascii>87 && $ascii<96) ;
78 80
 				else {
79 81
 					$ascii=$ascii+40;
@@ -175,7 +177,9 @@  discard block
 block discarded – undo
175 177
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,57,28)));
176 178
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,85,27)));
177 179
 			$ro->heading = bindec(substr($_aisdata,124,9));
178
-			if ($ro->heading == 511) $ro->heading = '';
180
+			if ($ro->heading == 511) {
181
+				$ro->heading = '';
182
+			}
179 183
 			$ro->cls = 2; // class B
180 184
 		} else if ($ro->id == 19) {
181 185
 			$ro->cog = bindec(substr($_aisdata,112,12))/10;
@@ -185,7 +189,9 @@  discard block
 block discarded – undo
185 189
 			$ro->name = $this->binchar($_aisdata,143,120);
186 190
 			$ro->cls = 2; // class B
187 191
 			$ro->heading = bindec(substr($_aisdata,124,9));
188
-			if ($ro->heading == 511) $ro->heading = '';
192
+			if ($ro->heading == 511) {
193
+				$ro->heading = '';
194
+			}
189 195
 			$ro->typeid = bindec(substr($_aisdata,263,8));
190 196
 			$ro->type = $this->getShipType($ro->typeid);
191 197
 			//$ro->to_bow = bindec(substr($_aisdata,271,9));
@@ -216,9 +222,13 @@  discard block
 block discarded – undo
216 222
 			$ro->cls = 2; // class B
217 223
 		} else if ($ro->id == 27) {
218 224
 			$ro->cog = bindec(substr($_aisdata,85,9));
219
-			if ($ro->cog == 511) $ro->cog = 0.0;
225
+			if ($ro->cog == 511) {
226
+				$ro->cog = 0.0;
227
+			}
220 228
 			$ro->sog = bindec(substr($_aisdata,79,6));
221
-			if ($ro->sog == 63) $ro->sog = 0.0;
229
+			if ($ro->sog == 63) {
230
+				$ro->sog = 0.0;
231
+			}
222 232
 			$ro->lon = $this->make_lonf(bindec(substr($_aisdata,44,18))*10);
223 233
 			$ro->lat = $this->make_latf(bindec(substr($_aisdata,62,17))*10);
224 234
 			$ro->cls = 1; // class A
@@ -267,88 +277,171 @@  discard block
 block discarded – undo
267 277
 	}
268 278
 	
269 279
 	public function getShipType($code) {
270
-		if ($code == 0) return 'Not available (default)';
271
-		elseif ($code >= 1 && $code <= 19) return 'Reserved for future use';
272
-		elseif ($code == 20) return 'Wing in ground (WIG), all ships of this type';
273
-		elseif ($code == 21) return 'Wing in ground (WIG), Hazardous category A';
274
-		elseif ($code == 22) return 'Wing in ground (WIG), Hazardous category B';
275
-		elseif ($code == 23) return 'Wing in ground (WIG), Hazardous category C';
276
-		elseif ($code == 24) return 'Wing in ground (WIG), Hazardous category D';
277
-		elseif ($code == 25) return 'Wing in ground (WIG), Reserved for future use';
278
-		elseif ($code == 26) return 'Wing in ground (WIG), Reserved for future use';
279
-		elseif ($code == 27) return 'Wing in ground (WIG), Reserved for future use';
280
-		elseif ($code == 28) return 'Wing in ground (WIG), Reserved for future use';
281
-		elseif ($code == 29) return 'Wing in ground (WIG), Reserved for future use';
282
-		elseif ($code == 30) return 'Fishing';
283
-		elseif ($code == 31) return 'Towing';
284
-		elseif ($code == 32) return 'Towing: length exceeds 200m or breadth exceeds 25m';
285
-		elseif ($code == 33) return 'Dredging or underwater ops';
286
-		elseif ($code == 34) return 'Diving ops';
287
-		elseif ($code == 35) return 'Military ops';
288
-		elseif ($code == 36) return 'Sailing';
289
-		elseif ($code == 37) return 'Pleasure Craft';
290
-		elseif ($code == 38) return 'Reserved';
291
-		elseif ($code == 39) return 'Reserved';
292
-		elseif ($code == 40) return 'High speed craft (HSC), all ships of this type';
293
-		elseif ($code == 41) return 'High speed craft (HSC), Hazardous category A';
294
-		elseif ($code == 42) return 'High speed craft (HSC), Hazardous category B';
295
-		elseif ($code == 43) return 'High speed craft (HSC), Hazardous category C';
296
-		elseif ($code == 44) return 'High speed craft (HSC), Hazardous category D';
297
-		elseif ($code == 45) return 'High speed craft (HSC), Reserved for future use';
298
-		elseif ($code == 46) return 'High speed craft (HSC), Reserved for future use';
299
-		elseif ($code == 47) return 'High speed craft (HSC), Reserved for future use';
300
-		elseif ($code == 48) return 'High speed craft (HSC), Reserved for future use';
301
-		elseif ($code == 49) return 'High speed craft (HSC), No additional information';
302
-		elseif ($code == 50) return 'Pilot Vessel';
303
-		elseif ($code == 51) return 'Search and Rescue vessel';
304
-		elseif ($code == 52) return 'Tug';
305
-		elseif ($code == 53) return 'Port Tender';
306
-		elseif ($code == 54) return 'Anti-pollution equipment';
307
-		elseif ($code == 55) return 'Law Enforcement';
308
-		elseif ($code == 56) return 'Spare - Local Vessel';
309
-		elseif ($code == 57) return 'Spare - Local Vessel';
310
-		elseif ($code == 58) return 'Medical Transport';
311
-		elseif ($code == 59) return 'Noncombatant ship according to RR Resolution No. 18';
312
-		elseif ($code == 60) return 'Passenger, all ships of this type';
313
-		elseif ($code == 61) return 'Passenger, Hazardous category A';
314
-		elseif ($code == 62) return 'Passenger, Hazardous category B';
315
-		elseif ($code == 63) return 'Passenger, Hazardous category C';
316
-		elseif ($code == 64) return 'Passenger, Hazardous category D';
317
-		elseif ($code == 65) return 'Passenger, Reserved for future use';
318
-		elseif ($code == 66) return 'Passenger, Reserved for future use';
319
-		elseif ($code == 67) return 'Passenger, Reserved for future use';
320
-		elseif ($code == 68) return 'Passenger, Reserved for future use';
321
-		elseif ($code == 69) return 'Passenger, No additional information';
322
-		elseif ($code == 70) return 'Cargo, all ships of this type';
323
-		elseif ($code == 71) return 'Cargo, Hazardous category A';
324
-		elseif ($code == 72) return 'Cargo, Hazardous category B';
325
-		elseif ($code == 73) return 'Cargo, Hazardous category C';
326
-		elseif ($code == 74) return 'Cargo, Hazardous category D';
327
-		elseif ($code == 75) return 'Cargo, Reserved for future use';
328
-		elseif ($code == 76) return 'Cargo, Reserved for future use';
329
-		elseif ($code == 77) return 'Cargo, Reserved for future use';
330
-		elseif ($code == 78) return 'Cargo, Reserved for future use';
331
-		elseif ($code == 79) return 'Cargo, No additional information';
332
-		elseif ($code == 80) return 'Tanker, all ships of this type';
333
-		elseif ($code == 81) return 'Tanker, Hazardous category A';
334
-		elseif ($code == 82) return 'Tanker, Hazardous category B';
335
-		elseif ($code == 83) return 'Tanker, Hazardous category C';
336
-		elseif ($code == 84) return 'Tanker, Hazardous category D';
337
-		elseif ($code == 85) return 'Tanker, Reserved for future use';
338
-		elseif ($code == 86) return 'Tanker, Reserved for future use';
339
-		elseif ($code == 87) return 'Tanker, Reserved for future use';
340
-		elseif ($code == 88) return 'Tanker, Reserved for future use';
341
-		elseif ($code == 89) return 'Tanker, No additional information';
342
-		elseif ($code == 90) return 'Other Type, all ships of this type';
343
-		elseif ($code == 91) return 'Other Type, Hazardous category A';
344
-		elseif ($code == 92) return 'Other Type, Hazardous category B';
345
-		elseif ($code == 93) return 'Other Type, Hazardous category C';
346
-		elseif ($code == 94) return 'Other Type, Hazardous category D';
347
-		elseif ($code == 95) return 'Other Type, Reserved for future use';
348
-		elseif ($code == 96) return 'Other Type, Reserved for future use';
349
-		elseif ($code == 97) return 'Other Type, Reserved for future use';
350
-		elseif ($code == 98) return 'Other Type, Reserved for future use';
351
-		elseif ($code == 99) return 'Other Type, no additional information';
280
+		if ($code == 0) {
281
+			return 'Not available (default)';
282
+		} elseif ($code >= 1 && $code <= 19) {
283
+			return 'Reserved for future use';
284
+		} elseif ($code == 20) {
285
+			return 'Wing in ground (WIG), all ships of this type';
286
+		} elseif ($code == 21) {
287
+			return 'Wing in ground (WIG), Hazardous category A';
288
+		} elseif ($code == 22) {
289
+			return 'Wing in ground (WIG), Hazardous category B';
290
+		} elseif ($code == 23) {
291
+			return 'Wing in ground (WIG), Hazardous category C';
292
+		} elseif ($code == 24) {
293
+			return 'Wing in ground (WIG), Hazardous category D';
294
+		} elseif ($code == 25) {
295
+			return 'Wing in ground (WIG), Reserved for future use';
296
+		} elseif ($code == 26) {
297
+			return 'Wing in ground (WIG), Reserved for future use';
298
+		} elseif ($code == 27) {
299
+			return 'Wing in ground (WIG), Reserved for future use';
300
+		} elseif ($code == 28) {
301
+			return 'Wing in ground (WIG), Reserved for future use';
302
+		} elseif ($code == 29) {
303
+			return 'Wing in ground (WIG), Reserved for future use';
304
+		} elseif ($code == 30) {
305
+			return 'Fishing';
306
+		} elseif ($code == 31) {
307
+			return 'Towing';
308
+		} elseif ($code == 32) {
309
+			return 'Towing: length exceeds 200m or breadth exceeds 25m';
310
+		} elseif ($code == 33) {
311
+			return 'Dredging or underwater ops';
312
+		} elseif ($code == 34) {
313
+			return 'Diving ops';
314
+		} elseif ($code == 35) {
315
+			return 'Military ops';
316
+		} elseif ($code == 36) {
317
+			return 'Sailing';
318
+		} elseif ($code == 37) {
319
+			return 'Pleasure Craft';
320
+		} elseif ($code == 38) {
321
+			return 'Reserved';
322
+		} elseif ($code == 39) {
323
+			return 'Reserved';
324
+		} elseif ($code == 40) {
325
+			return 'High speed craft (HSC), all ships of this type';
326
+		} elseif ($code == 41) {
327
+			return 'High speed craft (HSC), Hazardous category A';
328
+		} elseif ($code == 42) {
329
+			return 'High speed craft (HSC), Hazardous category B';
330
+		} elseif ($code == 43) {
331
+			return 'High speed craft (HSC), Hazardous category C';
332
+		} elseif ($code == 44) {
333
+			return 'High speed craft (HSC), Hazardous category D';
334
+		} elseif ($code == 45) {
335
+			return 'High speed craft (HSC), Reserved for future use';
336
+		} elseif ($code == 46) {
337
+			return 'High speed craft (HSC), Reserved for future use';
338
+		} elseif ($code == 47) {
339
+			return 'High speed craft (HSC), Reserved for future use';
340
+		} elseif ($code == 48) {
341
+			return 'High speed craft (HSC), Reserved for future use';
342
+		} elseif ($code == 49) {
343
+			return 'High speed craft (HSC), No additional information';
344
+		} elseif ($code == 50) {
345
+			return 'Pilot Vessel';
346
+		} elseif ($code == 51) {
347
+			return 'Search and Rescue vessel';
348
+		} elseif ($code == 52) {
349
+			return 'Tug';
350
+		} elseif ($code == 53) {
351
+			return 'Port Tender';
352
+		} elseif ($code == 54) {
353
+			return 'Anti-pollution equipment';
354
+		} elseif ($code == 55) {
355
+			return 'Law Enforcement';
356
+		} elseif ($code == 56) {
357
+			return 'Spare - Local Vessel';
358
+		} elseif ($code == 57) {
359
+			return 'Spare - Local Vessel';
360
+		} elseif ($code == 58) {
361
+			return 'Medical Transport';
362
+		} elseif ($code == 59) {
363
+			return 'Noncombatant ship according to RR Resolution No. 18';
364
+		} elseif ($code == 60) {
365
+			return 'Passenger, all ships of this type';
366
+		} elseif ($code == 61) {
367
+			return 'Passenger, Hazardous category A';
368
+		} elseif ($code == 62) {
369
+			return 'Passenger, Hazardous category B';
370
+		} elseif ($code == 63) {
371
+			return 'Passenger, Hazardous category C';
372
+		} elseif ($code == 64) {
373
+			return 'Passenger, Hazardous category D';
374
+		} elseif ($code == 65) {
375
+			return 'Passenger, Reserved for future use';
376
+		} elseif ($code == 66) {
377
+			return 'Passenger, Reserved for future use';
378
+		} elseif ($code == 67) {
379
+			return 'Passenger, Reserved for future use';
380
+		} elseif ($code == 68) {
381
+			return 'Passenger, Reserved for future use';
382
+		} elseif ($code == 69) {
383
+			return 'Passenger, No additional information';
384
+		} elseif ($code == 70) {
385
+			return 'Cargo, all ships of this type';
386
+		} elseif ($code == 71) {
387
+			return 'Cargo, Hazardous category A';
388
+		} elseif ($code == 72) {
389
+			return 'Cargo, Hazardous category B';
390
+		} elseif ($code == 73) {
391
+			return 'Cargo, Hazardous category C';
392
+		} elseif ($code == 74) {
393
+			return 'Cargo, Hazardous category D';
394
+		} elseif ($code == 75) {
395
+			return 'Cargo, Reserved for future use';
396
+		} elseif ($code == 76) {
397
+			return 'Cargo, Reserved for future use';
398
+		} elseif ($code == 77) {
399
+			return 'Cargo, Reserved for future use';
400
+		} elseif ($code == 78) {
401
+			return 'Cargo, Reserved for future use';
402
+		} elseif ($code == 79) {
403
+			return 'Cargo, No additional information';
404
+		} elseif ($code == 80) {
405
+			return 'Tanker, all ships of this type';
406
+		} elseif ($code == 81) {
407
+			return 'Tanker, Hazardous category A';
408
+		} elseif ($code == 82) {
409
+			return 'Tanker, Hazardous category B';
410
+		} elseif ($code == 83) {
411
+			return 'Tanker, Hazardous category C';
412
+		} elseif ($code == 84) {
413
+			return 'Tanker, Hazardous category D';
414
+		} elseif ($code == 85) {
415
+			return 'Tanker, Reserved for future use';
416
+		} elseif ($code == 86) {
417
+			return 'Tanker, Reserved for future use';
418
+		} elseif ($code == 87) {
419
+			return 'Tanker, Reserved for future use';
420
+		} elseif ($code == 88) {
421
+			return 'Tanker, Reserved for future use';
422
+		} elseif ($code == 89) {
423
+			return 'Tanker, No additional information';
424
+		} elseif ($code == 90) {
425
+			return 'Other Type, all ships of this type';
426
+		} elseif ($code == 91) {
427
+			return 'Other Type, Hazardous category A';
428
+		} elseif ($code == 92) {
429
+			return 'Other Type, Hazardous category B';
430
+		} elseif ($code == 93) {
431
+			return 'Other Type, Hazardous category C';
432
+		} elseif ($code == 94) {
433
+			return 'Other Type, Hazardous category D';
434
+		} elseif ($code == 95) {
435
+			return 'Other Type, Reserved for future use';
436
+		} elseif ($code == 96) {
437
+			return 'Other Type, Reserved for future use';
438
+		} elseif ($code == 97) {
439
+			return 'Other Type, Reserved for future use';
440
+		} elseif ($code == 98) {
441
+			return 'Other Type, Reserved for future use';
442
+		} elseif ($code == 99) {
443
+			return 'Other Type, no additional information';
444
+		}
352 445
 	}
353 446
 
354 447
 	public function process_ais_itu($_itu, $_len, $_filler, $aux /*, $ais_ch*/) {
@@ -386,19 +479,34 @@  discard block
 block discarded – undo
386 479
 		// assume 1st ! is valid
387 480
 		// find * ensure that it is at correct position
388 481
 		$end = strrpos ( $rawdata , '*' );
389
-		if ($end === FALSE) return -1; // check for NULLS!!!
482
+		if ($end === FALSE) {
483
+			return -1;
484
+		}
485
+		// check for NULLS!!!
390 486
 		$cs = substr( $rawdata, $end + 1 );
391
-		if ( strlen($cs) != 2 ) return -1; // correct cs length
487
+		if ( strlen($cs) != 2 ) {
488
+			return -1;
489
+		}
490
+		// correct cs length
392 491
 		$dcs = (int)hexdec( $cs );
393
-		for ( $alias=1; $alias<$end; $alias++) $chksum ^= ord( $rawdata[$alias] ); // perform XOR for NMEA checksum
492
+		for ( $alias=1; $alias<$end; $alias++) {
493
+			$chksum ^= ord( $rawdata[$alias] );
494
+		}
495
+		// perform XOR for NMEA checksum
394 496
 		if ( $chksum == $dcs ) { // NMEA checksum pass
395 497
 			$pcs = explode(',', $rawdata);
396 498
 			// !AI??? identifier
397 499
 			$num_seq = (int)$pcs[1]; // number of sequences
398 500
 			$seq = (int)$pcs[2]; // get sequence
399 501
 			// get msg sequence id
400
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
401
-			else $msg_sid = (int)$pcs[3]; // multipart message
502
+			if ($pcs[3] == '') {
503
+				$msg_sid = -1;
504
+			}
505
+			// non-multipart message, set to -1
506
+			else {
507
+				$msg_sid = (int)$pcs[3];
508
+			}
509
+			// multipart message
402 510
 			$ais_ch = $pcs[4]; // get AIS channel
403 511
 			// message sequence checking
404 512
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -459,10 +567,18 @@  discard block
 block discarded – undo
459 567
 				//DEBUG echo "[$start $end $tst]\n";
460 568
 				$result = $this->process_ais_raw( $tst, "" );
461 569
 				$last_pos = $end + 1;
462
-			} else break;
570
+			} else {
571
+				break;
572
+			}
573
+		}
574
+		if ($last_pos > 0) {
575
+			$cbuf = substr($cbuf, $last_pos);
463 576
 		}
464
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
465
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
577
+		// move...
578
+		if (strlen($cbuf) > 1024) {
579
+			$cbuf = "";
580
+		}
581
+		// prevent overflow simple mode...
466 582
 		return $result;
467 583
 	}
468 584
 
@@ -482,7 +598,9 @@  discard block
 block discarded – undo
482 598
 		if ($lat<0.0) {
483 599
 			$lat = -$lat;
484 600
 			$neg=true;
485
-		} else $neg=false;
601
+		} else {
602
+			$neg=false;
603
+		}
486 604
 		$latd = 0x00000000;
487 605
 		$latd = intval ($lat * 600000.0);
488 606
 		if ($neg==true) {
@@ -498,7 +616,9 @@  discard block
 block discarded – undo
498 616
 		if ($lon<0.0) {
499 617
 			$lon = -$lon;
500 618
 			$neg=true;
501
-		} else $neg=false;
619
+		} else {
620
+			$neg=false;
621
+		}
502 622
 		$lond = 0x00000000;
503 623
 		$lond = intval ($lon * 600000.0);
504 624
 		if ($neg==true) {
@@ -511,9 +631,14 @@  discard block
 block discarded – undo
511 631
 
512 632
 	private function char2bin($name, $max_len) {
513 633
 		$len = strlen($name);
514
-		if ($len > $max_len) $name = substr($name,0,$max_len);
515
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
516
-		else $pad = '';
634
+		if ($len > $max_len) {
635
+			$name = substr($name,0,$max_len);
636
+		}
637
+		if ($len < $max_len) {
638
+			$pad = str_repeat('0', ($max_len - $len) * 6);
639
+		} else {
640
+			$pad = '';
641
+		}
517 642
 		$rv = '';
518 643
 		$ais_chars = array(
519 644
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -526,9 +651,12 @@  discard block
 block discarded – undo
526 651
 		);
527 652
 		// "
528 653
 		$_a = str_split($name);
529
-		if ($_a) foreach ($_a as $_1) {
654
+		if ($_a) {
655
+			foreach ($_a as $_1) {
530 656
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
531
-			else $dec = 0;
657
+		} else {
658
+				$dec = 0;
659
+			}
532 660
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
533 661
 			$rv .= $bin;
534 662
 			//echo "$_1 $dec ($bin)<br/>";
@@ -540,7 +668,9 @@  discard block
 block discarded – undo
540 668
 		$len_bit = strlen($_enc);
541 669
 		$rem6 = $len_bit % 6;
542 670
 		$pad6_len = 0;
543
-		if ($rem6) $pad6_len = 6 - $rem6;
671
+		if ($rem6) {
672
+			$pad6_len = 6 - $rem6;
673
+		}
544 674
 		//echo  $pad6_len.'<br>';
545 675
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
546 676
 		$len_enc = strlen($_enc) / 6;
@@ -549,8 +679,11 @@  discard block
 block discarded – undo
549 679
 		for ($i=0; $i<$len_enc; $i++) {
550 680
 			$offset = $i * 6;
551 681
 			$dec = bindec(substr($_enc,$offset,6));
552
-			if ($dec < 40) $dec += 48;
553
-			else $dec += 56;
682
+			if ($dec < 40) {
683
+				$dec += 48;
684
+			} else {
685
+				$dec += 56;
686
+			}
554 687
 			//echo chr($dec)." $dec<br/>";
555 688
 			$itu .= chr($dec);
556 689
 		}
@@ -563,25 +696,41 @@  discard block
 block discarded – undo
563 696
 		}
564 697
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
565 698
 		$lsb = $chksum & 0x0F;
566
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
567
-		else $lsbc = '0';
699
+		if ($lsb >=0 && $lsb <= 15 ) {
700
+			$lsbc = $hex_arr[$lsb];
701
+		} else {
702
+			$lsbc = '0';
703
+		}
568 704
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
569
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
570
-		else $msbc = '0';
705
+		if ($msb >=0 && $msb <= 15 ) {
706
+			$msbc = $hex_arr[$msb];
707
+		} else {
708
+			$msbc = '0';
709
+		}
571 710
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
572 711
 		return $itu;
573 712
 	}
574 713
 
575 714
 	public function parse($buffer) {
576 715
 		$data = $this->process_ais_buf($buffer);
577
-		if (!is_object($data)) return array();
578
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
579
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
716
+		if (!is_object($data)) {
717
+			return array();
718
+		}
719
+		if ($data->lon != 0) {
720
+			$result['longitude'] = $data->lon;
721
+		}
722
+		if ($data->lat != 0) {
723
+			$result['latitude'] = $data->lat;
724
+		}
580 725
 		$result['ident'] = trim($data->name);
581 726
 		$result['timestamp'] = $data->ts;
582 727
 		$result['mmsi'] = $data->mmsi;
583
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
584
-		if ($data->cog != 0) $result['heading'] = $data->cog;
728
+		if ($data->sog != -1.0) {
729
+			$result['speed'] = $data->sog;
730
+		}
731
+		if ($data->cog != 0) {
732
+			$result['heading'] = $data->cog;
733
+		}
585 734
 		/*
586 735
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
587 736
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -591,15 +740,25 @@  discard block
 block discarded – undo
591 740
 
592 741
 	public function mmsitype($mmsi) {
593 742
 		if (strlen($mmsi) == 9) {
594
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
595
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
596
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
597
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
598
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
599
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
600
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
601
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
602
-			else return 'Ship';
743
+			if (substr($mmsi,0,3) == '974') {
744
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
745
+			} elseif (substr($mmsi,0,3) == '972') {
746
+				return 'MOB (Man Overboard) device';
747
+			} elseif (substr($mmsi,0,3) == '970') {
748
+				return 'AIS SART (Search and Rescue Transmitter)';
749
+			} elseif (substr($mmsi,0,3) == '111') {
750
+				return 'SAR (Search and Rescue) aircraft';
751
+			} elseif (substr($mmsi,0,2) == '98') {
752
+				return 'Auxiliary craft associated with a parent ship';
753
+			} elseif (substr($mmsi,0,2) == '99') {
754
+				return 'Aids to Navigation';
755
+			} elseif (substr($mmsi,0,2) == '00') {
756
+				return 'Coastal stations';
757
+			} elseif (substr($mmsi,0,1) == '0') {
758
+				return 'Group of ships';
759
+			} else {
760
+				return 'Ship';
761
+			}
603 762
 		}
604 763
 
605 764
 	
@@ -616,25 +775,48 @@  discard block
 block discarded – undo
616 775
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
617 776
 			return array();
618 777
 		}
619
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
620
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
778
+		if ($data->lon != 0) {
779
+			$result['longitude'] = $data->lon;
780
+		}
781
+		if ($data->lat != 0) {
782
+			$result['latitude'] = $data->lat;
783
+		}
621 784
 		$result['ident'] = trim(str_replace('@','',$data->name));
622 785
 		$result['timestamp'] = $data->ts;
623 786
 		$result['mmsi'] = $data->mmsi;
624
-		if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
787
+		if (strlen($result['mmsi']) == 8 && susbtr($result['mmsi'],0,3) == '669') {
788
+			$result['mmsi'] = '3'.$result['mmsi'];
789
+		}
625 790
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
626
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
627
-		if ($data->heading != '') $result['heading'] = $data->heading;
628
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
629
-		if ($data->status != '') $result['status'] = $data->status;
630
-		if ($data->type != '') $result['type'] = $data->type;
631
-		if ($data->typeid != '') $result['typeid'] = $data->typeid;
632
-		if ($data->imo != '') $result['imo'] = $data->imo;
633
-		if ($data->callsign != '') $result['callsign'] = $data->callsign;
791
+		if ($data->sog != -1.0) {
792
+			$result['speed'] = $data->sog;
793
+		}
794
+		if ($data->heading != '') {
795
+			$result['heading'] = $data->heading;
796
+		} elseif ($data->cog != 0) {
797
+			$result['heading'] = $data->cog;
798
+		}
799
+		if ($data->status != '') {
800
+			$result['status'] = $data->status;
801
+		}
802
+		if ($data->type != '') {
803
+			$result['type'] = $data->type;
804
+		}
805
+		if ($data->typeid != '') {
806
+			$result['typeid'] = $data->typeid;
807
+		}
808
+		if ($data->imo != '') {
809
+			$result['imo'] = $data->imo;
810
+		}
811
+		if ($data->callsign != '') {
812
+			$result['callsign'] = $data->callsign;
813
+		}
634 814
 		if ($data->eta_month != '' && $data->eta_day != '' && $data->eta_hour != '' && $data->eta_minute != '') {
635 815
 			$result['eta_ts'] = strtotime(date('Y').'-'.$data->eta_month.'-'.$data->eta_day.' '.$data->eta_hour.':'.$data->eta_minute.':00');
636 816
 		}
637
-		if ($data->destination != '') $result['destination'] = $data->destination;
817
+		if ($data->destination != '') {
818
+			$result['destination'] = $data->destination;
819
+		}
638 820
 		$result['all'] = (array) $data;
639 821
 		/*
640 822
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
Please login to merge, or discard this patch.
require/class.Common.php 1 patch
Braces   +73 added lines, -30 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
 		} else {
38 38
 			curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
39 39
 		}
40
-		if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
41
-		else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 
40
+		if ($timeout == '') {
41
+			curl_setopt($ch, CURLOPT_TIMEOUT, 10);
42
+		} else {
43
+			curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
44
+		}
42 45
 		curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback"));
43 46
 		if ($type == 'post') {
44 47
 			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
@@ -85,8 +88,9 @@  discard block
 block discarded – undo
85 88
 	private function curlResponseHeaderCallback($ch, $headerLine) {
86 89
 		//global $cookies;
87 90
 		$cookies = array();
88
-		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1)
89
-			$cookies[] = $cookie;
91
+		if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) {
92
+					$cookies[] = $cookie;
93
+		}
90 94
 		return strlen($headerLine); // Needed by curl
91 95
 	}
92 96
 
@@ -97,11 +101,15 @@  discard block
 block discarded – undo
97 101
 		curl_setopt($ch, CURLOPT_URL, $url);
98 102
 		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
99 103
 		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
100
-		if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer);
104
+		if ($referer != '') {
105
+			curl_setopt($ch, CURLOPT_REFERER, $referer);
106
+		}
101 107
 		curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5');
102 108
 		curl_setopt($ch, CURLOPT_FILE, $fp);
103 109
 		curl_exec($ch);
104
-		if (curl_errno($ch) && $globalDebug) echo 'Download error: '.curl_error($ch);
110
+		if (curl_errno($ch) && $globalDebug) {
111
+			echo 'Download error: '.curl_error($ch);
112
+		}
105 113
 		curl_close($ch);
106 114
 		fclose($fp);
107 115
 	}
@@ -112,10 +120,16 @@  discard block
 block discarded – undo
112 120
 	* @return Array array of the tables in HTML page
113 121
 	*/
114 122
 	public function table2array($data) {
115
-		if (!is_string($data)) return array();
116
-		if ($data == '') return array();
123
+		if (!is_string($data)) {
124
+			return array();
125
+		}
126
+		if ($data == '') {
127
+			return array();
128
+		}
117 129
 		$html = str_get_html($data);
118
-		if ($html === false) return array();
130
+		if ($html === false) {
131
+			return array();
132
+		}
119 133
 		$tabledata=array();
120 134
 		foreach($html->find('tr') as $element)
121 135
 		{
@@ -150,7 +164,9 @@  discard block
 block discarded – undo
150 164
 	*/
151 165
 	public function text2array($data) {
152 166
 		$html = str_get_html($data);
153
-		if ($html === false) return array();
167
+		if ($html === false) {
168
+			return array();
169
+		}
154 170
 		$tabledata=array();
155 171
 		foreach($html->find('p') as $element)
156 172
 		{
@@ -171,7 +187,9 @@  discard block
 block discarded – undo
171 187
 	* @return Float Distance in $unit
172 188
 	*/
173 189
 	public function distance($lat, $lon, $latc, $lonc, $unit = 'km') {
174
-		if ($lat == $latc && $lon == $lonc) return 0;
190
+		if ($lat == $latc && $lon == $lonc) {
191
+			return 0;
192
+		}
175 193
 		$dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515;
176 194
 		if ($unit == "km") {
177 195
 			return round($dist * 1.609344);
@@ -195,10 +213,16 @@  discard block
 block discarded – undo
195 213
 	public function withinThreshold ($timeDifference, $distance) {
196 214
 		$x = abs($timeDifference);
197 215
 		$d = abs($distance);
198
-		if ($x == 0 || $d == 0) return true;
216
+		if ($x == 0 || $d == 0) {
217
+			return true;
218
+		}
199 219
 		// may be due to Internet jitter; distance is realistic
200
-		if ($x < 0.7 && $d < 2000) return true;
201
-		else return $d/$x < 1500*0.27778; // 1500 km/h max
220
+		if ($x < 0.7 && $d < 2000) {
221
+			return true;
222
+		} else {
223
+			return $d/$x < 1500*0.27778;
224
+		}
225
+		// 1500 km/h max
202 226
 	}
203 227
 
204 228
 
@@ -226,11 +250,17 @@  discard block
 block discarded – undo
226 250
 	
227 251
 	public function convertDM($coord,$latlong) {
228 252
 		if ($latlong == 'latitude') {
229
-			if ($coord < 0) $NSEW = 'S';
230
-			else $NSEW = 'N';
253
+			if ($coord < 0) {
254
+				$NSEW = 'S';
255
+			} else {
256
+				$NSEW = 'N';
257
+			}
231 258
 		} elseif ($latlong == 'longitude') {
232
-			if ($coord < 0) $NSEW = 'W';
233
-			else $NSEW = 'E';
259
+			if ($coord < 0) {
260
+				$NSEW = 'W';
261
+			} else {
262
+				$NSEW = 'E';
263
+			}
234 264
 		}
235 265
 		$coord = abs($coord);
236 266
 		$deg = floor($coord);
@@ -273,7 +303,9 @@  discard block
 block discarded – undo
273 303
 	public function hex2str($hex) {
274 304
 		$str = '';
275 305
 		$hexln = strlen($hex);
276
-		for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2)));
306
+		for($i=0;$i<$hexln;$i+=2) {
307
+			$str .= chr(hexdec(substr($hex,$i,2)));
308
+		}
277 309
 		return $str;
278 310
 	}
279 311
 	
@@ -301,8 +333,11 @@  discard block
 block discarded – undo
301 333
 		$b = $lat2 - $lat1;
302 334
 		$c = -($a*$lat1+$b*$lon1);
303 335
 		$d = $a*$lat3+$b*$lon3+$c;
304
-		if ($d > -$approx && $d < $approx) return true;
305
-		else return false;
336
+		if ($d > -$approx && $d < $approx) {
337
+			return true;
338
+		} else {
339
+			return false;
340
+		}
306 341
 	}
307 342
 	
308 343
 	public function array_merge_noappend() {
@@ -361,7 +396,9 @@  discard block
 block discarded – undo
361 396
 			return $result;
362 397
 		}
363 398
 		$handle = @opendir('./locale');
364
-		if ($handle === false) return $result;
399
+		if ($handle === false) {
400
+			return $result;
401
+		}
365 402
 		while (false !== ($file = readdir($handle))) {
366 403
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
367 404
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -428,8 +465,9 @@  discard block
 block discarded – undo
428 465
 		$error = false; 
429 466
 		if ($fp_out = gzopen($dest, $mode)) { 
430 467
 			if ($fp_in = fopen($source,'rb')) { 
431
-				while (!feof($fp_in)) 
432
-					gzwrite($fp_out, fread($fp_in, 1024 * 512)); 
468
+				while (!feof($fp_in)) {
469
+									gzwrite($fp_out, fread($fp_in, 1024 * 512));
470
+				}
433 471
 				fclose($fp_in); 
434 472
 			} else {
435 473
 				$error = true; 
@@ -438,14 +476,17 @@  discard block
 block discarded – undo
438 476
 		} else {
439 477
 			$error = true; 
440 478
 		}
441
-		if ($error)
442
-			return false; 
443
-		else
444
-			return $dest; 
479
+		if ($error) {
480
+					return false;
481
+		} else {
482
+					return $dest;
483
+		}
445 484
 	} 
446 485
 	
447 486
 	public function remove_accents($string) {
448
-		if ( !preg_match('/[\x80-\xff]/', $string) ) return $string;
487
+		if ( !preg_match('/[\x80-\xff]/', $string) ) {
488
+			return $string;
489
+		}
449 490
 		$chars = array(
450 491
 		    // Decompositions for Latin-1 Supplement
451 492
 		    chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
@@ -569,7 +610,9 @@  discard block
 block discarded – undo
569 610
 		$ip = gethostbyname($host);
570 611
 		$s = socket_create(AF_INET, SOCK_STREAM, 0);
571 612
 		$r = @socket_connect($s, $ip, $port);
572
-		if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
613
+		if (!socket_set_nonblock($s)) {
614
+			echo "Unable to set nonblock on socket\n";
615
+		}
573 616
 		if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
574 617
 			return $s;
575 618
 		}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +334 added lines, -118 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 	$dbc = $this->db;
60 60
 	$this->all_flights[$id]['schedule_check'] = true;
61 61
 	if ($globalSchedulesFetch) {
62
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
62
+	if ($globalDebug) {
63
+		echo 'Getting schedule info...'."\n";
64
+	}
63 65
 	$Spotter = new Spotter($dbc);
64 66
 	$Schedule = new Schedule($dbc);
65 67
 	$Translation = new Translation($dbc);
@@ -70,7 +72,9 @@  discard block
 block discarded – undo
70 72
 	    if ($Schedule->checkSchedule($operator) == 0) {
71 73
 		$schedule = $Schedule->fetchSchedule($operator);
72 74
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
73
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
75
+		    if ($globalDebug) {
76
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
77
+		    }
74 78
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
75 79
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
76 80
 		    // Should also check if route schedule = route from DB
@@ -79,7 +83,9 @@  discard block
 block discarded – undo
79 83
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
80 84
 			    if (trim($airport_icao) != '') {
81 85
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
82
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
86
+				if ($globalDebug) {
87
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
88
+				}
83 89
 			    }
84 90
 			}
85 91
 		    }
@@ -88,17 +94,25 @@  discard block
 block discarded – undo
88 94
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
89 95
 			    if (trim($airport_icao) != '') {
90 96
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
91
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
97
+				if ($globalDebug) {
98
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
99
+				}
92 100
 			    }
93 101
 			}
94 102
 		    }
95 103
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
96 104
 		}
97
-	    } else $scheduleexist = true;
98
-	} else $scheduleexist = true;
105
+	    } else {
106
+	    	$scheduleexist = true;
107
+	    }
108
+	} else {
109
+		$scheduleexist = true;
110
+	}
99 111
 	// close connection, at least one way will work ?
100 112
        if ($scheduleexist) {
101
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
113
+		if ($globalDebug) {
114
+			echo "-> get arrival/departure airport info for ".$ident."\n";
115
+		}
102 116
     		$sch = $Schedule->getSchedule($operator);
103 117
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
104 118
        }
@@ -120,7 +134,9 @@  discard block
 block discarded – undo
120 134
 
121 135
     public function checkAll() {
122 136
 	global $globalDebug, $globalNoImport;
123
-	if ($globalDebug) echo "Update last seen flights data...\n";
137
+	if ($globalDebug) {
138
+		echo "Update last seen flights data...\n";
139
+	}
124 140
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
125 141
 	    foreach ($this->all_flights as $key => $flight) {
126 142
 		if (isset($this->all_flights[$key]['id'])) {
@@ -135,24 +151,32 @@  discard block
 block discarded – undo
135 151
 
136 152
     public function arrival($key) {
137 153
 	global $globalClosestMinDist, $globalDebug;
138
-	if ($globalDebug) echo 'Update arrival...'."\n";
154
+	if ($globalDebug) {
155
+		echo 'Update arrival...'."\n";
156
+	}
139 157
 	$Spotter = new Spotter($this->db);
140 158
         $airport_icao = '';
141 159
         $airport_time = '';
142
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
160
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
161
+        	$globalClosestMinDist = 50;
162
+        }
143 163
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
144 164
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
145 165
     	    if (isset($closestAirports[0])) {
146 166
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
147 167
         	    $airport_icao = $closestAirports[0]['icao'];
148 168
         	    $airport_time = $this->all_flights[$key]['datetime'];
149
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        	    if ($globalDebug) {
170
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        	    }
150 172
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
151 173
         	    foreach ($closestAirports as $airport) {
152 174
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
153 175
         		    $airport_icao = $airport['icao'];
154 176
         		    $airport_time = $this->all_flights[$key]['datetime'];
155
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        		    if ($globalDebug) {
178
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
179
+        		    }
156 180
         		    break;
157 181
         		}
158 182
         	    }
@@ -160,14 +184,20 @@  discard block
 block discarded – undo
160 184
         		$airport_icao = $closestAirports[0]['icao'];
161 185
         		$airport_time = $this->all_flights[$key]['datetime'];
162 186
         	} else {
163
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
187
+        		if ($globalDebug) {
188
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
189
+        		}
164 190
         	}
165 191
     	    } else {
166
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
192
+    		    if ($globalDebug) {
193
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
194
+    		    }
167 195
     	    }
168 196
 
169 197
         } else {
170
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
198
+        	if ($globalDebug) {
199
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
200
+        	}
171 201
         }
172 202
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
173 203
     }
@@ -177,12 +207,16 @@  discard block
 block discarded – undo
177 207
     public function del() {
178 208
 	global $globalDebug, $globalNoImport;
179 209
 	// Delete old infos
180
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
210
+	if ($globalDebug) {
211
+		echo 'Delete old values and update latest data...'."\n";
212
+	}
181 213
 	foreach ($this->all_flights as $key => $flight) {
182 214
     	    if (isset($flight['lastupdate'])) {
183 215
         	if ($flight['lastupdate'] < (time()-3000)) {
184 216
             	    if (isset($this->all_flights[$key]['id'])) {
185
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
217
+            		if ($globalDebug) {
218
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
219
+            		}
186 220
 			/*
187 221
 			$SpotterLive = new SpotterLive();
188 222
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -193,7 +227,9 @@  discard block
 block discarded – undo
193 227
             		    $Spotter = new Spotter($this->db);
194 228
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
195 229
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
196
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
230
+				if ($globalDebug && $result != 'success') {
231
+					echo '!!! ERROR : '.$result."\n";
232
+				}
197 233
 			    }
198 234
 			// Put in archive
199 235
 //				$Spotter->db = null;
@@ -208,8 +244,10 @@  discard block
 block discarded – undo
208 244
     public function add($line) {
209 245
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport;
210 246
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
211
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
212
-/*
247
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
248
+		$globalCoordMinChange = '0.02';
249
+	}
250
+	/*
213 251
 	$Spotter = new Spotter();
214 252
 	$dbc = $Spotter->db;
215 253
 	$SpotterLive = new SpotterLive($dbc);
@@ -237,11 +275,15 @@  discard block
 block discarded – undo
237 275
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
238 276
 		    $current_date = date('Y-m-d');
239 277
 		    $source = $line['source_name'];
240
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
278
+		    if ($source == '' || $line['format_source'] == 'aprs') {
279
+		    	$source = $line['format_source'];
280
+		    }
241 281
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
242 282
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
243 283
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
244
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
284
+		    } else {
285
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
286
+		    }
245 287
 		}
246 288
 		
247 289
 		/*
@@ -257,8 +299,11 @@  discard block
 block discarded – undo
257 299
 		//$this->db = $dbc;
258 300
 
259 301
 		//$hex = trim($line['hex']);
260
-	        if (!isset($line['id'])) $id = trim($line['hex']);
261
-	        else $id = trim($line['id']);
302
+	        if (!isset($line['id'])) {
303
+	        	$id = trim($line['hex']);
304
+	        } else {
305
+	        	$id = trim($line['id']);
306
+	        }
262 307
 		
263 308
 		if (!isset($this->all_flights[$id])) {
264 309
 		    $this->all_flights[$id] = array();
@@ -266,13 +311,21 @@  discard block
 block discarded – undo
266 311
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
267 312
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
268 313
 		    if (!isset($line['id'])) {
269
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
270
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
314
+			if (!isset($globalDaemon)) {
315
+				$globalDaemon = TRUE;
316
+			}
317
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
271 318
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
272
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
319
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
320
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
321
+			}
273 322
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
274
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
275
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
323
+		     } else {
324
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
325
+		     }
326
+		    if ($globalAllFlights !== FALSE) {
327
+		    	$dataFound = true;
328
+		    }
276 329
 		}
277 330
 		if (isset($line['source_type']) && $line['source_type'] != '') {
278 331
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -293,11 +346,19 @@  discard block
 block discarded – undo
293 346
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
294 347
 			}
295 348
 			$Spotter->db = null;
296
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
297
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
349
+			if ($globalDebugTimeElapsed) {
350
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
351
+			}
352
+			if ($aircraft_icao != '') {
353
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
354
+			}
355
+		    }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
359
+		    if ($globalDebug) {
360
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
298 361
 		    }
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
300
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
301 362
 		}
302 363
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
303 364
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -307,14 +368,23 @@  discard block
 block discarded – undo
307 368
 			$Spotter = new Spotter($this->db);
308 369
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
309 370
 			$Spotter->db = null;
310
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
371
+			if ($aircraft_icao != '') {
372
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
373
+			}
311 374
 		}
312 375
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
313
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
314
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
315
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
316
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
317
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
376
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
377
+				$aircraft_icao = 'GLID';
378
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
379
+				$aircraft_icao = 'UHEL';
380
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
381
+				$aircraft_icao = 'TOWPLANE';
382
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
383
+				$aircraft_icao = 'POWAIRC';
384
+			}
385
+			if (isset($aircraft_icao)) {
386
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
387
+			}
318 388
 		}
319 389
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
320 390
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -324,8 +394,11 @@  discard block
 block discarded – undo
324 394
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
325 395
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
326 396
 		    } else {
327
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
328
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
397
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
398
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
399
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
400
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
401
+				}
329 402
 				/*
330 403
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
331 404
 				print_r($this->all_flights[$id]);
@@ -357,15 +430,25 @@  discard block
 block discarded – undo
357 430
 			$timeelapsed = microtime(true);
358 431
             		$Spotter = new Spotter($this->db);
359 432
             		$fromsource = NULL;
360
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
361
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
362
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
363
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
364
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
433
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
434
+            			$fromsource = $globalAirlinesSource;
435
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
436
+            			$fromsource = 'vatsim';
437
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
438
+				$fromsource = 'ivao';
439
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
440
+				$fromsource = 'vatsim';
441
+			} elseif (isset($globalIVAO) && $globalIVAO) {
442
+				$fromsource = 'ivao';
443
+			}
365 444
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
366
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
445
+			if ($globalDebug && $result != 'success') {
446
+				echo '!!! ERROR : '.$result."\n";
447
+			}
367 448
 			$Spotter->db = null;
368
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
449
+			if ($globalDebugTimeElapsed) {
450
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+			}
369 452
 		    }
370 453
 
371 454
 /*
@@ -376,7 +459,9 @@  discard block
 block discarded – undo
376 459
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
377 460
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
378 461
   */
379
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
462
+		    if (!isset($this->all_flights[$id]['id'])) {
463
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
464
+		    }
380 465
 
381 466
 		    //$putinarchive = true;
382 467
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -393,7 +478,9 @@  discard block
 block discarded – undo
393 478
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
394 479
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
395 480
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
396
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
397 484
 
398 485
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
399 486
 			$timeelapsed = microtime(true);
@@ -406,7 +493,9 @@  discard block
 block discarded – undo
406 493
 				$Translation->db = null;
407 494
 			}
408 495
 			$Spotter->db = null;
409
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+			if ($globalDebugTimeElapsed) {
497
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+			}
410 499
 
411 500
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
412 501
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -415,9 +504,13 @@  discard block
 block discarded – undo
415 504
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
416 505
 		    	    }
417 506
 			}
418
-			if (!isset($globalFork)) $globalFork = TRUE;
507
+			if (!isset($globalFork)) {
508
+				$globalFork = TRUE;
509
+			}
419 510
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
420
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
511
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
512
+					$this->get_Schedule($id,trim($line['ident']));
513
+				}
421 514
 			}
422 515
 		    }
423 516
 		}
@@ -433,16 +526,23 @@  discard block
 block discarded – undo
433 526
 		    // use datetime
434 527
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
435 528
 			$speed = $speed*3.6;
436
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
437
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
529
+			if ($speed < 1000) {
530
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
531
+			}
532
+  			if ($globalDebug) {
533
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
534
+  			}
438 535
 		    }
439 536
 		}
440 537
 
441 538
 
442 539
 
443 540
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
444
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
445
-	    	    else unset($timediff);
541
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
542
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
543
+	    	    } else {
544
+	    	    	unset($timediff);
545
+	    	    }
446 546
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
447 547
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
448 548
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -451,21 +551,31 @@  discard block
 block discarded – undo
451 551
 				$this->all_flights[$id]['putinarchive'] = true;
452 552
 				$this->tmd = 0;
453 553
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
454
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
554
+				    if ($globalDebug) {
555
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
556
+				    }
455 557
 				    $timeelapsed = microtime(true);
456 558
 				    $Spotter = new Spotter($this->db);
457 559
 				    $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
458
-				    if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
560
+				    if (!empty($all_country)) {
561
+				    	$this->all_flights[$id]['over_country'] = $all_country['iso2'];
562
+				    }
459 563
 				    $Spotter->db = null;
460
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
461
-				    if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
564
+				    if ($globalDebugTimeElapsed) {
565
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
566
+				    }
567
+				    if ($globalDebug) {
568
+				    	echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
569
+				    }
462 570
 				}
463 571
 			    }
464 572
 			}
465 573
 
466 574
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
467 575
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
468
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
576
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
577
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
578
+				}
469 579
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
470 580
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
471 581
 				    $dataFound = true;
@@ -487,9 +597,13 @@  discard block
 block discarded – undo
487 597
 			    */
488 598
 			}
489 599
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
490
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
600
+			    if ($line['longitude'] > 180) {
601
+			    	$line['longitude'] = $line['longitude'] - 360;
602
+			    }
491 603
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
492
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
604
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
605
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
606
+				}
493 607
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
494 608
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
495 609
 				    $dataFound = true;
@@ -520,7 +634,9 @@  discard block
 block discarded – undo
520 634
 		    }
521 635
 		}
522 636
 		if (isset($line['last_update']) && $line['last_update'] != '') {
523
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
637
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
638
+		    	$dataFound = true;
639
+		    }
524 640
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
525 641
 		}
526 642
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -542,40 +658,60 @@  discard block
 block discarded – undo
542 658
 			// Here we force archive of flight because after ground it's a new one (or should be)
543 659
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
544 660
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
545
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
546
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
547
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
661
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
662
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
663
+			} elseif (isset($line['id'])) {
664
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
665
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
666
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
667
+			}
668
+		    }
669
+		    if ($line['ground'] != 1) {
670
+		    	$line['ground'] = 0;
548 671
 		    }
549
-		    if ($line['ground'] != 1) $line['ground'] = 0;
550 672
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
551 673
 		    //$dataFound = true;
552 674
 		}
553 675
 		if (isset($line['squawk']) && $line['squawk'] != '') {
554 676
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
555
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
677
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
678
+			    	$this->all_flights[$id]['putinarchive'] = true;
679
+			    }
556 680
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
557 681
 			    $highlight = '';
558
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
559
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
560
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
682
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
683
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
684
+			    }
685
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
686
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
687
+			    }
688
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
689
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
690
+			    }
561 691
 			    if ($highlight != '') {
562 692
 				$timeelapsed = microtime(true);
563 693
 				$Spotter = new Spotter($this->db);
564 694
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
565 695
 				$Spotter->db = null;
566
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
696
+				if ($globalDebugTimeElapsed) {
697
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
698
+				}
567 699
 
568 700
 				//$putinarchive = true;
569 701
 				//$highlight = '';
570 702
 			    }
571 703
 			    
572
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
704
+		    } else {
705
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
706
+		    }
573 707
 		    //$dataFound = true;
574 708
 		}
575 709
 
576 710
 		if (isset($line['altitude']) && $line['altitude'] != '') {
577 711
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
578
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
712
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
713
+				$this->all_flights[$id]['putinarchive'] = true;
714
+			}
579 715
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
580 716
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
581 717
 			//$dataFound = true;
@@ -587,21 +723,30 @@  discard block
 block discarded – undo
587 723
 		}
588 724
 		
589 725
 		if (isset($line['heading']) && $line['heading'] != '') {
590
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
726
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
727
+		    	$this->all_flights[$id]['putinarchive'] = true;
728
+		    }
591 729
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
592 730
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
593 731
 		    //$dataFound = true;
594 732
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
595 733
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
596 734
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
597
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
598
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
735
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
736
+		    	$this->all_flights[$id]['putinarchive'] = true;
737
+		    }
738
+  		    if ($globalDebug) {
739
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
740
+  		    }
599 741
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
600 742
   		    // If not enough messages and ACARS set heading to 0
601 743
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
602 744
   		}
603
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
604
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
745
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
746
+			$dataFound = false;
747
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
748
+			$dataFound = false;
749
+		}
605 750
 
606 751
 //		print_r($this->all_flights[$id]);
607 752
 		//gets the callsign from the last hour
@@ -616,23 +761,36 @@  discard block
 block discarded – undo
616 761
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
617 762
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
618 763
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
619
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
764
+				if ($globalDebug) {
765
+					echo "Check if aircraft is already in DB...";
766
+				}
620 767
 				$timeelapsed = microtime(true);
621 768
 				$SpotterLive = new SpotterLive($this->db);
622 769
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
623 770
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
624
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
771
+				    if ($globalDebugTimeElapsed) {
772
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
773
+				    }
625 774
 				} elseif (isset($line['id'])) {
626 775
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
627
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
776
+				    if ($globalDebugTimeElapsed) {
777
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
778
+				    }
628 779
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
629 780
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
630
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
631
-				} else $recent_ident = '';
781
+				    if ($globalDebugTimeElapsed) {
782
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
783
+				    }
784
+				} else {
785
+					$recent_ident = '';
786
+				}
632 787
 				$SpotterLive->db=null;
633 788
 
634
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
635
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
789
+				if ($globalDebug && $recent_ident == '') {
790
+					echo " Not in DB.\n";
791
+				} elseif ($globalDebug && $recent_ident != '') {
792
+					echo " Already in DB.\n";
793
+				}
636 794
 			    } else {
637 795
 				$recent_ident = '';
638 796
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -640,7 +798,9 @@  discard block
 block discarded – undo
640 798
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
641 799
 			    if($recent_ident == "")
642 800
 			    {
643
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
801
+				if ($globalDebug) {
802
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
803
+				}
644 804
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
645 805
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
646 806
 				//adds the spotter data for the archive
@@ -684,28 +844,46 @@  discard block
 block discarded – undo
684 844
 				
685 845
 				if (!$ignoreImport) {
686 846
 				    $highlight = '';
687
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
688
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
689
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
690
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
847
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
848
+				    	$highlight = 'Squawk 7500 : Hijack';
849
+				    }
850
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
851
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
+				    }
853
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
854
+				    	$highlight = 'Squawk 7700 : Emergency';
855
+				    }
856
+				    if (!isset($this->all_flights[$id]['id'])) {
857
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
858
+				    }
691 859
 				    $timeelapsed = microtime(true);
692 860
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
693 861
 					$Spotter = new Spotter($this->db);
694 862
 					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
695 863
 					$Spotter->db = null;
696
-					if ($globalDebug && isset($result)) echo $result."\n";
864
+					if ($globalDebug && isset($result)) {
865
+						echo $result."\n";
866
+					}
867
+				    }
868
+				    if ($globalDebugTimeElapsed) {
869
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
697 870
 				    }
698
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
699 871
 				    
700 872
 				    // Add source stat in DB
701 873
 				    $Stats = new Stats($this->db);
702 874
 				    if (!empty($this->stats)) {
703
-					if ($globalDebug) echo 'Add source stats : ';
875
+					if ($globalDebug) {
876
+						echo 'Add source stats : ';
877
+					}
704 878
 				        foreach($this->stats as $date => $data) {
705 879
 					    foreach($data as $source => $sourced) {
706 880
 					        //print_r($sourced);
707
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
708
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
881
+				    	        if (isset($sourced['polar'])) {
882
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
883
+				    	        }
884
+				    	        if (isset($sourced['hist'])) {
885
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
886
+				    	        }
709 887
 				    		if (isset($sourced['msg'])) {
710 888
 				    		    if (time() - $sourced['msg']['date'] > 10) {
711 889
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -718,13 +896,17 @@  discard block
 block discarded – undo
718 896
 			    			unset($this->stats[$date]);
719 897
 			    		    }
720 898
 				    	}
721
-				    	if ($globalDebug) echo 'Done'."\n";
899
+				    	if ($globalDebug) {
900
+				    		echo 'Done'."\n";
901
+				    	}
722 902
 
723 903
 				    }
724 904
 				    $Stats->db = null;
725 905
 				    
726 906
 				    $this->del();
727
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
907
+				} elseif ($globalDebug) {
908
+					echo 'Ignore data'."\n";
909
+				}
728 910
 				//$ignoreImport = false;
729 911
 				$this->all_flights[$id]['addedSpotter'] = 1;
730 912
 				//print_r($this->all_flights[$id]);
@@ -741,14 +923,18 @@  discard block
 block discarded – undo
741 923
 			*/
742 924
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
743 925
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
744
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
926
+				    if ($globalDebug) {
927
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
928
+				    }
745 929
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
746 930
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
747 931
 					$SpotterLive = new SpotterLive($this->db);
748 932
 					$SpotterLive->deleteLiveSpotterData();
749 933
 					$SpotterLive->db=null;
750 934
 				    }
751
-				    if ($globalDebug) echo " Done\n";
935
+				    if ($globalDebug) {
936
+				    	echo " Done\n";
937
+				    }
752 938
 				    $this->last_delete = time();
753 939
 				}
754 940
 			    } else {
@@ -773,11 +959,17 @@  discard block
 block discarded – undo
773 959
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
774 960
 		    if ($globalDebug) {
775 961
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
776
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
777
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
962
+				if (isset($this->all_flights[$id]['source_name'])) {
963
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
964
+				} else {
965
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
966
+				}
778 967
 			} else {
779
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
780
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
968
+				if (isset($this->all_flights[$id]['source_name'])) {
969
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
970
+				} else {
971
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
972
+				}
781 973
 			}
782 974
 		    }
783 975
 		    $ignoreImport = false;
@@ -823,27 +1015,37 @@  discard block
 block discarded – undo
823 1015
 
824 1016
 		    if (!$ignoreImport) {
825 1017
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
826
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1018
+				if (!isset($this->all_flights[$id]['id'])) {
1019
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1020
+				}
827 1021
 				$timeelapsed = microtime(true);
828 1022
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
829
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1023
+					if ($globalDebug) {
1024
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1025
+					}
830 1026
 					$SpotterLive = new SpotterLive($this->db);
831 1027
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
832 1028
 					$SpotterLive->db = null;
833
-					if ($globalDebug) echo $result."\n";
1029
+					if ($globalDebug) {
1030
+						echo $result."\n";
1031
+					}
834 1032
 				}
835 1033
 				if (isset($globalServerAPRS) && $globalServerAPRS) {
836 1034
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
837 1035
 				}
838 1036
 				$this->all_flights[$id]['putinarchive'] = false;
839
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1037
+				if ($globalDebugTimeElapsed) {
1038
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1039
+				}
840 1040
 
841 1041
 				// Put statistics in $this->stats variable
842 1042
 				//if ($line['format_source'] != 'aprs') {
843 1043
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
844 1044
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
845 1045
 					$source = $this->all_flights[$id]['source_name'];
846
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1046
+					if ($source == '') {
1047
+						$source = $this->all_flights[$id]['format_source'];
1048
+					}
847 1049
 					if (!isset($this->source_location[$source])) {
848 1050
 						$Location = new Source();
849 1051
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -864,7 +1066,9 @@  discard block
 block discarded – undo
864 1066
 					$stats_heading = round($stats_heading/22.5);
865 1067
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
866 1068
 					$current_date = date('Y-m-d');
867
-					if ($stats_heading == 16) $stats_heading = 0;
1069
+					if ($stats_heading == 16) {
1070
+						$stats_heading = 0;
1071
+					}
868 1072
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
869 1073
 						for ($i=0;$i<=15;$i++) {
870 1074
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -882,7 +1086,9 @@  discard block
 block discarded – undo
882 1086
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
883 1087
 						    end($this->stats[$current_date][$source]['hist']);
884 1088
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
885
-						} else $mini = 0;
1089
+						} else {
1090
+							$mini = 0;
1091
+						}
886 1092
 						for ($i=$mini;$i<=$distance;$i+=10) {
887 1093
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
888 1094
 						}
@@ -893,19 +1099,27 @@  discard block
 block discarded – undo
893 1099
 				}
894 1100
 
895 1101
 				$this->all_flights[$id]['lastupdate'] = time();
896
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1102
+				if ($this->all_flights[$id]['putinarchive']) {
1103
+					$send = true;
1104
+				}
897 1105
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
898
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1106
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1107
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1108
+			}
899 1109
 			//$this->del();
900 1110
 			
901 1111
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
902 1112
 			    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
903
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1113
+				if ($globalDebug) {
1114
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1115
+				}
904 1116
 				$SpotterLive = new SpotterLive($this->db);
905 1117
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
906 1118
 				$SpotterLive->db = null;
907 1119
 				//SpotterLive->deleteLiveSpotterData();
908
-				if ($globalDebug) echo " Done\n";
1120
+				if ($globalDebug) {
1121
+					echo " Done\n";
1122
+				}
909 1123
 				$this->last_delete_hourly = time();
910 1124
 			    } else {
911 1125
 				$this->del();
@@ -917,7 +1131,9 @@  discard block
 block discarded – undo
917 1131
 		    //$ignoreImport = false;
918 1132
 		}
919 1133
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
920
-		if ($send) return $this->all_flights[$id];
1134
+		if ($send) {
1135
+			return $this->all_flights[$id];
1136
+		}
921 1137
 	    }
922 1138
 	}
923 1139
     }
Please login to merge, or discard this patch.
install/index.php 1 patch
Braces   +432 added lines, -114 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
236 284
 			</div>
@@ -239,42 +287,86 @@  discard block
 block discarded – undo
239 287
 			<legend>Coverage area</legend>
240 288
 			<p>
241 289
 				<label for="latitudemax">The maximum latitude (north)</label>
242
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
290
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
291
+	print $globalLatitudeMax;
292
+}
293
+?>" />
243 294
 			</p>
244 295
 			<p>
245 296
 				<label for="latitudemin">The minimum latitude (south)</label>
246
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
297
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
298
+	print $globalLatitudeMin;
299
+}
300
+?>" />
247 301
 			</p>
248 302
 			<p>
249 303
 				<label for="longitudemax">The maximum longitude (west)</label>
250
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
304
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
305
+	print $globalLongitudeMax;
306
+}
307
+?>" />
251 308
 			</p>
252 309
 			<p>
253 310
 				<label for="longitudemin">The minimum longitude (east)</label>
254
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
311
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
312
+	print $globalLongitudeMin;
313
+}
314
+?>" />
255 315
 			</p>
256 316
 			<p>
257 317
 				<label for="latitudecenter">The latitude center</label>
258
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
318
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
319
+	print $globalCenterLatitude;
320
+}
321
+?>" />
259 322
 			</p>
260 323
 			<p>
261 324
 				<label for="longitudecenter">The longitude center</label>
262
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
325
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
326
+	print $globalCenterLongitude;
327
+}
328
+?>" />
263 329
 			</p>
264 330
 			<p>
265 331
 				<label for="livezoom">Default Zoom on live map</label>
266
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
332
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
333
+	print $globalLiveZoom;
334
+} else {
335
+	print '9';
336
+}
337
+?>" />
267 338
 			</p>
268 339
 			<p>
269 340
 				<label for="squawk_country">Country for squawk usage</label>
270 341
 				<select name="squawk_country" id="squawk_country">
271
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
272
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
273
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
274
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
275
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
276
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
277
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
342
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
343
+	print ' selected ';
344
+}
345
+?>>UK</option>
346
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
347
+	print ' selected ';
348
+}
349
+?>>NZ</option>
350
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
351
+	print ' selected ';
352
+}
353
+?>>US</option>
354
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
355
+	print ' selected ';
356
+}
357
+?>>AU</option>
358
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
359
+	print ' selected ';
360
+}
361
+?>>NL</option>
362
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
363
+	print ' selected ';
364
+}
365
+?>>FR</option>
366
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
367
+	print ' selected ';
368
+}
369
+?>>TR</option>
278 370
 				</select>
279 371
 			</p>
280 372
 		</fieldset>
@@ -283,15 +375,24 @@  discard block
 block discarded – undo
283 375
 			<p><i>Only put in DB flights that are inside a circle</i></p>
284 376
 			<p>
285 377
 				<label for="latitude">Center latitude</label>
286
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
378
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
379
+	echo $globalDistanceIgnore['latitude'];
380
+}
381
+?>" />
287 382
 			</p>
288 383
 			<p>
289 384
 				<label for="longitude">Center longitude</label>
290
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
385
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
386
+	echo $globalDistanceIgnore['longitude'];
387
+}
388
+?>" />
291 389
 			</p>
292 390
 			<p>
293 391
 				<label for="Distance">Distance (in km)</label>
294
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
392
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
393
+	echo $globalDistanceIgnore['distance'];
394
+}
395
+?>" />
295 396
 			</p>
296 397
 		</fieldset>
297 398
 		<fieldset id="sourceloc">
@@ -397,11 +498,17 @@  discard block
 block discarded – undo
397 498
 			<div id="flightaware_data">
398 499
 				<p>
399 500
 					<label for="flightawareusername">FlightAware username</label>
400
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
501
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
502
+	print $globalFlightAwareUsername;
503
+}
504
+?>" />
401 505
 				</p>
402 506
 				<p>
403 507
 					<label for="flightawarepassword">FlightAware password/API key</label>
404
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
508
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
509
+	print $globalFlightAwarePassword;
510
+}
511
+?>" />
405 512
 				</p>
406 513
 			</div>
407 514
 -->
@@ -460,27 +567,84 @@  discard block
 block discarded – undo
460 567
 								?>
461 568
 								<td>
462 569
 									<select name="format[]" id="format">
463
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
464
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
465
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
466
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
467
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
468
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
469
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
470
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
471
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
472
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
473
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
474
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
475
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
476
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
477
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
478
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
479
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
570
+										<option value="auto" <?php if (!isset($source['format'])) {
571
+	print 'selected';
572
+}
573
+?>>Auto</option>
574
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
575
+	print 'selected';
576
+}
577
+?>>SBS</option>
578
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
579
+	print 'selected';
580
+}
581
+?>>TSV</option>
582
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
583
+	print 'selected';
584
+}
585
+?>>Raw</option>
586
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
587
+	print 'selected';
588
+}
589
+?>>APRS</option>
590
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
591
+	print 'selected';
592
+}
593
+?>>Radarcape deltadb.txt</option>
594
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
595
+	print 'selected';
596
+}
597
+?>>Vatsim</option>
598
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
599
+	print 'selected';
600
+}
601
+?>>Virtual Radar Server AircraftList.json</option>
602
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
603
+	print 'selected';
604
+}
605
+?>>Virtual Radar Server TCP</option>
606
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
607
+	print 'selected';
608
+}
609
+?>>phpVMS</option>
610
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
611
+	print 'selected';
612
+}
613
+?>>Virtual Airlines Manager</option>
614
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
615
+	print 'selected';
616
+}
617
+?>>IVAO</option>
618
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
619
+	print 'selected';
620
+}
621
+?>>FlightGear Multiplayer</option>
622
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
623
+	print 'selected';
624
+}
625
+?>>FlightGear Singleplayer</option>
626
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
627
+	print 'selected';
628
+}
629
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
630
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
631
+	print 'selected';
632
+}
633
+?>>ACARS SBS-3 over TCP</option>
634
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
635
+	print 'selected';
636
+}
637
+?>>NMEA AIS over TCP</option>
480 638
 									</select>
481 639
 								</td>
482
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
483
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
640
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
641
+	print $source['name'];
642
+}
643
+?>" /></td>
644
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
645
+	print 'checked';
646
+}
647
+?> /></td>
484 648
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
485 649
 							</tr>
486 650
 <?php
@@ -528,11 +692,17 @@  discard block
 block discarded – undo
528 692
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
529 693
 					<p>
530 694
 						<label for="acarshost">ACARS UDP host</label>
531
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
695
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
696
+	print $globalACARSHost;
697
+}
698
+?>" />
532 699
 					</p>
533 700
 					<p>
534 701
 						<label for="acarsport">ACARS UDP port</label>
535
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
702
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
703
+	print $globalACARSPort;
704
+}
705
+?>" />
536 706
 					</p>
537 707
 				</fieldset>
538 708
 			</div>
@@ -612,13 +782,19 @@  discard block
 block discarded – undo
612 782
 			<div id="schedules_options">
613 783
 				<p>
614 784
 					<label for="britishairways">British Airways API Key</label>
615
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
785
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
786
+	print $globalBritishAirwaysKey;
787
+}
788
+?>" />
616 789
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
617 790
 				</p>
618 791
 				<!--
619 792
 				<p>
620 793
 					<label for="transavia">Transavia Test API Consumer Key</label>
621
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
794
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
795
+	print $globalTransaviaKey;
796
+}
797
+?>" />
622 798
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
623 799
 				</p>
624 800
 				-->
@@ -627,10 +803,16 @@  discard block
 block discarded – undo
627 803
 						<b>Lufthansa API Key</b>
628 804
 						<p>
629 805
 							<label for="lufthansakey">Key</label>
630
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
806
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
807
+	print $globalLufthansaKey['key'];
808
+}
809
+?>" />
631 810
 						</p><p>
632 811
 							<label for="lufthansasecret">Secret</label>
633
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
812
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
813
+	print $globalLufthansaKey['secret'];
814
+}
815
+?>" />
634 816
 						</p>
635 817
 					</div>
636 818
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -650,7 +832,10 @@  discard block
 block discarded – undo
650 832
 			</p>
651 833
 			<p>
652 834
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
653
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
835
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
836
+	print $globalNOTAMSource;
837
+}
838
+?>" />
654 839
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
655 840
 			</p>
656 841
 			<br />
@@ -666,14 +851,20 @@  discard block
 block discarded – undo
666 851
 			<div id="metarsrc">
667 852
 				<p>
668 853
 					<label for="metarsource">URL of your METAR source</label>
669
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
854
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
855
+	print $globalMETARurl;
856
+}
857
+?>" />
670 858
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
671 859
 				</p>
672 860
 			</div>
673 861
 			<br />
674 862
 			<p>
675 863
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
676
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
864
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
865
+	print $globalBitlyAccessToken;
866
+}
867
+?>" />
677 868
 			</p>
678 869
 			<br />
679 870
 			<p>
@@ -693,7 +884,12 @@  discard block
 block discarded – undo
693 884
 			</p>
694 885
 			<p>
695 886
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
696
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
887
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
888
+	print $globalArchiveMonths;
889
+} else {
890
+	echo '0';
891
+}
892
+?>" />
697 893
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
698 894
 			</p>
699 895
 			<p>
@@ -703,12 +899,22 @@  discard block
 block discarded – undo
703 899
 			</p>
704 900
 			<p>
705 901
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
706
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
902
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
903
+	print $globalArchiveKeepMonths;
904
+} else {
905
+	echo '0';
906
+}
907
+?>" />
707 908
 				<p class="help-block">0 to disable</p>
708 909
 			</p>
709 910
 			<p>
710 911
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
711
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
912
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
913
+	print $globalArchiveKeepTrackMonths;
914
+} else {
915
+	echo '0';
916
+}
917
+?>" />
712 918
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
713 919
 			</p>
714 920
 			<br />
@@ -718,7 +924,12 @@  discard block
 block discarded – undo
718 924
 				<p class="help-block">Uncheck if the script is running as cron job</p>
719 925
 				<div id="cronends"> 
720 926
 					<label for="cronend">Run script for xx seconds</label>
721
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
927
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
928
+	print $globalCronEnd;
929
+} else {
930
+	print '0';
931
+}
932
+?>" />
722 933
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
723 934
 				</div>
724 935
 			</p>
@@ -763,26 +974,49 @@  discard block
 block discarded – undo
763 974
 			<br />
764 975
 			<p>
765 976
 				<label for="refresh">Show flights detected since xxx seconds</label>
766
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
977
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
978
+	echo $globalLiveInterval;
979
+} else {
980
+	echo '200';
981
+}
982
+?>" />
767 983
 			</p>
768 984
 			<p>
769 985
 				<label for="maprefresh">Live map refresh (in seconds)</label>
770
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
986
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
987
+	echo $globalMapRefresh;
988
+} else {
989
+	echo '30';
990
+}
991
+?>" />
771 992
 			</p>
772 993
 			<p>
773 994
 				<label for="mapidle">Map idle timeout (in minutes)</label>
774
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
995
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
996
+	echo $globalMapIdleTimeout;
997
+} else {
998
+	echo '30';
999
+}
1000
+?>" />
775 1001
 				<p class="help-block">0 to disable</p>
776 1002
 			</p>
777 1003
 			<br />
778 1004
 			<p>
779 1005
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
780
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1006
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1007
+	echo $globalClosestMinDist;
1008
+} else {
1009
+	echo '50';
1010
+}
1011
+?>" />
781 1012
 			</p>
782 1013
 			<br />
783 1014
 			<p>
784 1015
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
785
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1016
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1017
+	echo $globalAircraftSize;
1018
+}
1019
+?>" />
786 1020
 			</p>
787 1021
 			<br />
788 1022
 			<p>
@@ -790,7 +1024,12 @@  discard block
 block discarded – undo
790 1024
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
791 1025
 			?>
792 1026
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
793
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1027
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1028
+	echo $globalAircraftIconColor;
1029
+} else {
1030
+	echo '1a3151';
1031
+}
1032
+?>" />
794 1033
 			<?php
795 1034
 				if (!is_writable('../cache')) {
796 1035
 			?>
@@ -808,8 +1047,18 @@  discard block
 block discarded – undo
808 1047
 			<p>
809 1048
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
810 1049
 				<div class="range">
811
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
812
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1050
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1051
+	echo $globalAirportZoom;
1052
+} else {
1053
+	echo '7';
1054
+}
1055
+?>" />
1056
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1057
+	echo $globalAirportZoom;
1058
+} else {
1059
+	echo '7';
1060
+}
1061
+?></output>
813 1062
 				</div>
814 1063
 			</p>
815 1064
 		</fieldset>
@@ -837,8 +1086,12 @@  discard block
 block discarded – undo
837 1086
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
838 1087
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
839 1088
 
840
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
841
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1089
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1090
+		$error .= 'Mysql driver for PDO must be loaded';
1091
+	}
1092
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1093
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1094
+	}
842 1095
 	
843 1096
 	$_SESSION['database_root'] = $dbroot;
844 1097
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -905,15 +1158,23 @@  discard block
 block discarded – undo
905 1158
 	$source_city = $_POST['source_city'];
906 1159
 	$source_country = $_POST['source_country'];
907 1160
 	$source_ref = $_POST['source_ref'];
908
-	if (isset($source_id)) $source_id = $_POST['source_id'];
909
-	else $source_id = array();
1161
+	if (isset($source_id)) {
1162
+		$source_id = $_POST['source_id'];
1163
+	} else {
1164
+		$source_id = array();
1165
+	}
910 1166
 	
911 1167
 	$sources = array();
912 1168
 	foreach ($source_name as $keys => $name) {
913
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
914
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1169
+	    if (isset($source_id[$keys])) {
1170
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1171
+	    } else {
1172
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1173
+	    }
1174
+	}
1175
+	if (count($sources) > 0) {
1176
+		$_SESSION['sources'] = $sources;
915 1177
 	}
916
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
917 1178
 
918 1179
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
919 1180
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -933,14 +1194,23 @@  discard block
 block discarded – undo
933 1194
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
934 1195
 
935 1196
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
936
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
937
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1197
+	if ($globalaircraft == 'aircraft') {
1198
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1199
+	} else {
1200
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1201
+	}
938 1202
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
939
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
940
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1203
+	if ($globaltracker == 'tracker') {
1204
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1205
+	} else {
1206
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1207
+	}
941 1208
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
942
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
943
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1209
+	if ($globalmarine == 'marine') {
1210
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1211
+	} else {
1212
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1213
+	}
944 1214
 
945 1215
 /*	
946 1216
 	$globalSBS1Hosts = array();
@@ -961,13 +1231,21 @@  discard block
 block discarded – undo
961 1231
 	$port = $_POST['port'];
962 1232
 	$name = $_POST['name'];
963 1233
 	$format = $_POST['format'];
964
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
965
-	else $sourcestats = array();
1234
+	if (isset($_POST['sourcestats'])) {
1235
+		$sourcestats = $_POST['sourcestats'];
1236
+	} else {
1237
+		$sourcestats = array();
1238
+	}
966 1239
 	$gSources = array();
967 1240
 	foreach ($host as $key => $h) {
968
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
969
-		else $cov = 'FALSE';
970
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1241
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1242
+			$cov = 'TRUE';
1243
+		} else {
1244
+			$cov = 'FALSE';
1245
+		}
1246
+		if ($h != '') {
1247
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1248
+		}
971 1249
 	}
972 1250
 	$settings = array_merge($settings,array('globalSources' => $gSources));
973 1251
 
@@ -992,7 +1270,9 @@  discard block
 block discarded – undo
992 1270
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
993 1271
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
994 1272
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
995
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1273
+	} else {
1274
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1275
+	}
996 1276
 
997 1277
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
998 1278
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1031,7 +1311,9 @@  discard block
 block discarded – undo
1031 1311
 
1032 1312
 	// Create in settings.php keys not yet configurable if not already here
1033 1313
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1034
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1314
+	if (!isset($globalDebug)) {
1315
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1316
+	}
1035 1317
 
1036 1318
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1037 1319
 	if ($resetyearstats == 'resetyearstats') {
@@ -1068,27 +1350,43 @@  discard block
 block discarded – undo
1068 1350
 	}
1069 1351
 */
1070 1352
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1071
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1072
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1073
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1074
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1353
+	if ($globalsbs == 'sbs') {
1354
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1355
+	} else {
1356
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1357
+	}
1358
+	if ($globalaprs == 'aprs') {
1359
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1360
+	} else {
1361
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1362
+	}
1075 1363
 	if ($globalivao == 'ivao') {
1076 1364
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1077 1365
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1078
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1366
+	} else {
1367
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1368
+	}
1079 1369
 	if ($globalvatsim == 'vatsim') {
1080 1370
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1081 1371
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1082
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1372
+	} else {
1373
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1374
+	}
1083 1375
 	if ($globalphpvms == 'phpvms') {
1084 1376
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1085
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1377
+	} else {
1378
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1379
+	}
1086 1380
 	if ($globalvam == 'vam') {
1087 1381
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1088
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1382
+	} else {
1383
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1384
+	}
1089 1385
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1090 1386
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1091
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1387
+	} else {
1388
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1389
+	}
1092 1390
 	
1093 1391
 
1094 1392
 
@@ -1224,7 +1522,9 @@  discard block
 block discarded – undo
1224 1522
 		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1225 1523
 	}
1226 1524
 
1227
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1525
+	if (!isset($globalTransaction)) {
1526
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1527
+	}
1228 1528
 
1229 1529
 	// Set some defaults values...
1230 1530
 	if (!isset($globalAircraftImageSources)) {
@@ -1239,15 +1539,23 @@  discard block
 block discarded – undo
1239 1539
 
1240 1540
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1241 1541
 
1242
-	if ($error == '') settings::modify_settings($settings);
1243
-	if ($error == '') settings::comment_settings($settings_comment);
1542
+	if ($error == '') {
1543
+		settings::modify_settings($settings);
1544
+	}
1545
+	if ($error == '') {
1546
+		settings::comment_settings($settings_comment);
1547
+	}
1244 1548
 	if ($error != '') {
1245 1549
 		print '<div class="info column">'.$error.'</div>';
1246 1550
 		require('../footer.php');
1247 1551
 		exit;
1248 1552
 	} else {
1249
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1250
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1553
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1554
+			$_SESSION['waypoints'] = 1;
1555
+		}
1556
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1557
+			$_SESSION['owner'] = 1;
1558
+		}
1251 1559
 		if (isset($_POST['createdb'])) {
1252 1560
 			$_SESSION['install'] = 'database_create';
1253 1561
 		} else {
@@ -1288,10 +1596,18 @@  discard block
 block discarded – undo
1288 1596
 	$popw = false;
1289 1597
 	foreach ($_SESSION['done'] as $done) {
1290 1598
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1291
-	    if ($done == 'Create database') $pop = true;
1292
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1293
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1294
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1599
+	    if ($done == 'Create database') {
1600
+	    	$pop = true;
1601
+	    }
1602
+	    if ($_SESSION['install'] == 'database_create') {
1603
+	    	$pop = true;
1604
+	    }
1605
+	    if ($_SESSION['install'] == 'database_import') {
1606
+	    	$popi = true;
1607
+	    }
1608
+	    if ($_SESSION['install'] == 'waypoints') {
1609
+	    	$popw = true;
1610
+	    }
1295 1611
 	}
1296 1612
 	if ($pop) {
1297 1613
 	    sleep(5);
@@ -1302,7 +1618,9 @@  discard block
 block discarded – undo
1302 1618
 	} else if ($popw) {
1303 1619
 	    sleep(5);
1304 1620
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1305
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1621
+	} else {
1622
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1623
+	}
1306 1624
 	print '</div></ul>';
1307 1625
 	print '<div id="error"></div>';
1308 1626
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Braces   +152 added lines, -58 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,11 +168,15 @@  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
-		} else $result['ident'] = trim(substr($body,1,9));
177
+		} else {
178
+			$result['ident'] = trim(substr($body,1,9));
179
+		}
164 180
 	} elseif ($type == ',') {
165 181
 		// Invalid data or test data
166 182
 		return false;
@@ -228,7 +244,9 @@  discard block
 block discarded – undo
228 244
 		//$symbol_table = $matches[4];
229 245
 		$lat = intval($lat_deg);
230 246
 		$lon = intval($lon_deg);
231
-		if ($lat > 89 || $lon > 179) return false;
247
+		if ($lat > 89 || $lon > 179) {
248
+			return false;
249
+		}
232 250
 	    
233 251
 	    /*
234 252
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -238,8 +256,12 @@  discard block
 block discarded – undo
238 256
 	    */
239 257
 		$latitude = $lat + floatval($lat_min)/60;
240 258
 		$longitude = $lon + floatval($lon_min)/60;
241
-		if ($sind == 'S') $latitude = 0-$latitude;
242
-		if ($wind == 'W') $longitude = 0-$longitude;
259
+		if ($sind == 'S') {
260
+			$latitude = 0-$latitude;
261
+		}
262
+		if ($wind == 'W') {
263
+			$longitude = 0-$longitude;
264
+		}
243 265
 		$result['latitude'] = $latitude;
244 266
 		$result['longitude'] = $longitude;
245 267
 		$body_parse = substr($body_parse,18);
@@ -273,7 +295,9 @@  discard block
 block discarded – undo
273 295
 			$body_parse = substr($body_parse,1);
274 296
 			$body_parse_len = strlen($body_parse);
275 297
 			$result['symbol_code'] = $symbol_code;
276
-			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
298
+			if (isset($this->symbols[$symbol_code])) {
299
+				$result['symbol'] = $this->symbols[$symbol_code];
300
+			}
277 301
 			if ($symbol_code != '_') {
278 302
 			}
279 303
 		    //$body_parse = substr($body_parse,1);
@@ -284,7 +308,9 @@  discard block
 block discarded – undo
284 308
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285 309
 		    	    $course = substr($body_parse,0,3);
286 310
 		    	    $tmp_s = intval($course);
287
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
311
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
312
+		    	    	$result['heading'] = intval($course);
313
+		    	    }
288 314
 		    	    $speed = substr($body_parse,4,3);
289 315
 		    	    if ($speed != '...') {
290 316
 		    		//$result['speed'] = round($speed*1.852);
@@ -323,10 +349,16 @@  discard block
 block discarded – undo
323 349
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
324 350
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
325 351
 			    
326
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
327
-				else $result['latitude'] += $lat_off;
328
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
329
-				else $result['longitude'] += $lon_off;
352
+				if ($result['latitude'] < 0) {
353
+					$result['latitude'] -= $lat_off;
354
+				} else {
355
+					$result['latitude'] += $lat_off;
356
+				}
357
+				if ($result['longitude'] < 0) {
358
+					$result['longitude'] -= $lon_off;
359
+				} else {
360
+					$result['longitude'] += $lon_off;
361
+				}
330 362
 			    }
331 363
 		            $body_parse = substr($body_parse,6);
332 364
 		    }
@@ -361,27 +393,48 @@  discard block
 block discarded – undo
361 393
 			$address = substr($id,2);
362 394
 			//print_r($matches);
363 395
 			$addressType = (intval(substr($id,0,2),16))&3;
364
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
365
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
366
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
367
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
396
+			if ($addressType == 0) {
397
+				$result['addresstype'] = "RANDOM";
398
+			} elseif ($addressType == 1) {
399
+				$result['addresstype'] = "ICAO";
400
+			} elseif ($addressType == 2) {
401
+				$result['addresstype'] = "FLARM";
402
+			} elseif ($addressType == 3) {
403
+				$result['addresstype'] = "OGN";
404
+			}
368 405
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
369 406
 			$result['aircrafttype_code'] = $aircraftType;
370
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
371
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
372
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
373
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
374
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
375
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
376
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
377
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
378
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
379
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
380
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
381
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
382
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
383
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
384
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
407
+			if ($aircraftType == 0) {
408
+				$result['aircrafttype'] = "UNKNOWN";
409
+			} elseif ($aircraftType == 1) {
410
+				$result['aircrafttype'] = "GLIDER";
411
+			} elseif ($aircraftType == 2) {
412
+				$result['aircrafttype'] = "TOW_PLANE";
413
+			} elseif ($aircraftType == 3) {
414
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
415
+			} elseif ($aircraftType == 4) {
416
+				$result['aircrafttype'] = "PARACHUTE";
417
+			} elseif ($aircraftType == 5) {
418
+				$result['aircrafttype'] = "DROP_PLANE";
419
+			} elseif ($aircraftType == 6) {
420
+				$result['aircrafttype'] = "HANG_GLIDER";
421
+			} elseif ($aircraftType == 7) {
422
+				$result['aircrafttype'] = "PARA_GLIDER";
423
+			} elseif ($aircraftType == 8) {
424
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
425
+			} elseif ($aircraftType == 9) {
426
+				$result['aircrafttype'] = "JET_AIRCRAFT";
427
+			} elseif ($aircraftType == 10) {
428
+				$result['aircrafttype'] = "UFO";
429
+			} elseif ($aircraftType == 11) {
430
+				$result['aircrafttype'] = "BALLOON";
431
+			} elseif ($aircraftType == 12) {
432
+				$result['aircrafttype'] = "AIRSHIP";
433
+			} elseif ($aircraftType == 13) {
434
+				$result['aircrafttype'] = "UAV";
435
+			} elseif ($aircraftType == 15) {
436
+				$result['aircrafttype'] = "STATIC_OBJECT";
437
+			}
385 438
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
386 439
 			$result['stealth'] = $stealth;
387 440
 			$result['address'] = $address;
@@ -421,13 +474,21 @@  discard block
 block discarded – undo
421 474
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
422 475
 		    }
423 476
 		}
424
-		} else $result['comment'] = trim($body_parse);
477
+		} else {
478
+			$result['comment'] = trim($body_parse);
479
+		}
425 480
 
426 481
 	    }
427 482
 	//}
428
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
429
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
430
-	if ($debug) print_r($result);
483
+	if (isset($result['latitude'])) {
484
+		$result['latitude'] = round($result['latitude'],4);
485
+	}
486
+	if (isset($result['longitude'])) {
487
+		$result['longitude'] = round($result['longitude'],4);
488
+	}
489
+	if ($debug) {
490
+		print_r($result);
491
+	}
431 492
 	return $result;
432 493
     }
433 494
     
@@ -436,12 +497,21 @@  discard block
 block discarded – undo
436 497
 	$aprs_connect = 0;
437 498
 	$aprs_keep = 120;
438 499
 	$aprs_last_tx = time();
439
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
440
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
441
-	if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid;
442
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
443
-	if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass;
444
-	else $aprs_pass = '-1';
500
+	if (isset($globalAPRSversion)) {
501
+		$aprs_version = $globalAPRSversion;
502
+	} else {
503
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
504
+	}
505
+	if (isset($globalServerAPRSssid)) {
506
+		$aprs_ssid = $globalServerAPRSssid;
507
+	} else {
508
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
509
+	}
510
+	if (isset($globalServerAPRSpass)) {
511
+		$aprs_pass = $globalServerAPRSpass;
512
+	} else {
513
+		$aprs_pass = '-1';
514
+	}
445 515
 	
446 516
 	$aprs_filter  = '';
447 517
 	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
@@ -468,9 +538,13 @@  discard block
 block discarded – undo
468 538
     }
469 539
     
470 540
     function send($data) {
471
-	if ($this->connected === false) $this->connect();
541
+	if ($this->connected === false) {
542
+		$this->connect();
543
+	}
472 544
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
473
-	if ($send === FALSE) $this->connect();
545
+	if ($send === FALSE) {
546
+		$this->connect();
547
+	}
474 548
     }
475 549
 }
476 550
 
@@ -487,18 +561,26 @@  discard block
 block discarded – undo
487 561
 			//$w = '00';
488 562
 			$custom = '';
489 563
 			if ($ident != '') {
490
-				if ($custom != '') $custom .= '/';
564
+				if ($custom != '') {
565
+					$custom .= '/';
566
+				}
491 567
 				$custom .= 'CS='.$ident;
492 568
 			}
493 569
 			if ($squawk != '') {
494
-				if ($custom != '') $custom .= '/';
570
+				if ($custom != '') {
571
+					$custom .= '/';
572
+				}
495 573
 				$custom .= 'SQ='.$squawk;
496 574
 			}
497 575
 			if ($aircraft_icao != '' && $aircraft_icao != 'NA') {
498
-				if ($custom != '') $custom .= '/';
576
+				if ($custom != '') {
577
+					$custom .= '/';
578
+				}
499 579
 				$custom .= 'AI='.$aircraft_icao;
500 580
 			}
501
-			if ($custom != '') $custom = ' '.$custom;
581
+			if ($custom != '') {
582
+				$custom = ' '.$custom;
583
+			}
502 584
 			$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");
503 585
 		}
504 586
 	}
@@ -516,26 +598,38 @@  discard block
 block discarded – undo
516 598
 			//$w = '00';
517 599
 			$custom = '';
518 600
 			if ($ident != '') {
519
-				if ($custom != '') $custom .= '/';
601
+				if ($custom != '') {
602
+					$custom .= '/';
603
+				}
520 604
 				$custom .= 'CS='.$ident;
521 605
 			}
522 606
 			if ($typeid != '') {
523
-				if ($custom != '') $custom .= '/';
607
+				if ($custom != '') {
608
+					$custom .= '/';
609
+				}
524 610
 				$custom .= 'TI='.$typeid;
525 611
 			}
526 612
 			if ($imo != '') {
527
-				if ($custom != '') $custom .= '/';
613
+				if ($custom != '') {
614
+					$custom .= '/';
615
+				}
528 616
 				$custom .= 'IMO='.$imo;
529 617
 			}
530 618
 			if ($arrival_date != '') {
531
-				if ($custom != '') $custom .= '/';
619
+				if ($custom != '') {
620
+					$custom .= '/';
621
+				}
532 622
 				$custom .= 'AD='.strtotime($arrival_date);
533 623
 			}
534 624
 			if ($arrival_code != '') {
535
-				if ($custom != '') $custom .= '/';
625
+				if ($custom != '') {
626
+					$custom .= '/';
627
+				}
536 628
 				$custom .= 'AC='.$arrival_code;
537 629
 			}
538
-			if ($custom != '') $custom = ' '.$custom;
630
+			if ($custom != '') {
631
+				$custom = ' '.$custom;
632
+			}
539 633
 			$altitude = 0;
540 634
 			$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");
541 635
 		}
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +775 added lines, -264 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -59,22 +63,39 @@  discard block
 block discarded – undo
59 63
     $globalSources = array();
60 64
     $globalSources[] = array('host' => $options['source']);
61 65
 }
62
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
63
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
64
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
65
-if (isset($options['server'])) $globalServer = TRUE;
66
-if (isset($options['idsource'])) $id_source = $options['idsource'];
67
-else $id_source = 1;
66
+if (isset($options['aprsserverssid'])) {
67
+	$globalServerAPRSssid = $options['aprsserverssid'];
68
+}
69
+if (isset($options['aprsserverpass'])) {
70
+	$globalServerAPRSpass = $options['aprsserverpass'];
71
+}
72
+if (isset($options['nodaemon'])) {
73
+	$globalDaemon = FALSE;
74
+}
75
+if (isset($options['server'])) {
76
+	$globalServer = TRUE;
77
+}
78
+if (isset($options['idsource'])) {
79
+	$id_source = $options['idsource'];
80
+} else {
81
+	$id_source = 1;
82
+}
68 83
 if (isset($globalServer) && $globalServer) {
69
-    if ($globalDebug) echo "Using Server Mode\n";
84
+    if ($globalDebug) {
85
+    	echo "Using Server Mode\n";
86
+    }
70 87
     $SI=new SpotterServer();
71 88
 /*
72 89
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
73 90
     $SI = new adsb2aprs();
74 91
     $SI->connect();
75 92
 */
76
-} else $SI=new SpotterImport($Connection->db);
77
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
93
+} else {
94
+	$SI=new SpotterImport($Connection->db);
95
+}
96
+if (isset($globalTracker) && $globalTracker) {
97
+	$TI = new TrackerImport($Connection->db);
98
+}
78 99
 if (isset($globalMarine) && $globalMarine) {
79 100
     $AIS = new AIS();
80 101
     $MI = new MarineImport($Connection->db);
@@ -96,7 +117,9 @@  discard block
 block discarded – undo
96 117
 }
97 118
 
98 119
 // let's try and connect
99
-if ($globalDebug) echo "Connecting...\n";
120
+if ($globalDebug) {
121
+	echo "Connecting...\n";
122
+}
100 123
 $use_aprs = false;
101 124
 $aprs_full = false;
102 125
 $reset = 0;
@@ -105,7 +128,9 @@  discard block
 block discarded – undo
105 128
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106 129
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107 130
     $reset++;
108
-    if ($globalDebug) echo 'Connect to all...'."\n";
131
+    if ($globalDebug) {
132
+    	echo 'Connect to all...'."\n";
133
+    }
109 134
     foreach ($hosts as $id => $value) {
110 135
 	$host = $value['host'];
111 136
 	$globalSources[$id]['last_exec'] = 0;
@@ -115,27 +140,37 @@  discard block
 block discarded – undo
115 140
         	//$formats[$id] = 'deltadbtxt';
116 141
         	$globalSources[$id]['format'] = 'deltadbtxt';
117 142
         	//$last_exec['deltadbtxt'] = 0;
118
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
143
+        	if ($globalDebug) {
144
+        		echo "Connect to deltadb source (".$host.")...\n";
145
+        	}
119 146
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
120 147
         	//$formats[$id] = 'vatsimtxt';
121 148
         	$globalSources[$id]['format'] = 'vatsimtxt';
122 149
         	//$last_exec['vatsimtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
150
+        	if ($globalDebug) {
151
+        		echo "Connect to vatsim source (".$host.")...\n";
152
+        	}
124 153
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
125 154
         	//$formats[$id] = 'aircraftlistjson';
126 155
         	$globalSources[$id]['format'] = 'aircraftlistjson';
127 156
         	//$last_exec['aircraftlistjson'] = 0;
128
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
157
+        	if ($globalDebug) {
158
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
159
+        	}
129 160
     	    } else if (preg_match('/opensky/i',$host)) {
130 161
         	//$formats[$id] = 'aircraftlistjson';
131 162
         	$globalSources[$id]['format'] = 'opensky';
132 163
         	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
164
+        	if ($globalDebug) {
165
+        		echo "Connect to opensky source (".$host.")...\n";
166
+        	}
134 167
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135 168
         	//$formats[$id] = 'radarvirtueljson';
136 169
         	$globalSources[$id]['format'] = 'radarvirtueljson';
137 170
         	//$last_exec['radarvirtueljson'] = 0;
138
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
171
+        	if ($globalDebug) {
172
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
173
+        	}
139 174
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140 175
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141 176
         	    exit(0);
@@ -144,7 +179,9 @@  discard block
 block discarded – undo
144 179
         	//$formats[$id] = 'planeupdatefaa';
145 180
         	$globalSources[$id]['format'] = 'planeupdatefaa';
146 181
         	//$last_exec['planeupdatefaa'] = 0;
147
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
184
+        	}
148 185
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149 186
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150 187
         	    exit(0);
@@ -153,26 +190,36 @@  discard block
 block discarded – undo
153 190
         	//$formats[$id] = 'phpvmacars';
154 191
         	$globalSources[$id]['format'] = 'phpvmacars';
155 192
         	//$last_exec['phpvmacars'] = 0;
156
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
193
+        	if ($globalDebug) {
194
+        		echo "Connect to phpvmacars source (".$host.")...\n";
195
+        	}
157 196
             } else if (preg_match('/VAM-json.php$/i',$host)) {
158 197
         	//$formats[$id] = 'phpvmacars';
159 198
         	$globalSources[$id]['format'] = 'vam';
160
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
199
+        	if ($globalDebug) {
200
+        		echo "Connect to Vam source (".$host.")...\n";
201
+        	}
161 202
             } else if (preg_match('/whazzup/i',$host)) {
162 203
         	//$formats[$id] = 'whazzup';
163 204
         	$globalSources[$id]['format'] = 'whazzup';
164 205
         	//$last_exec['whazzup'] = 0;
165
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
206
+        	if ($globalDebug) {
207
+        		echo "Connect to whazzup source (".$host.")...\n";
208
+        	}
166 209
             } else if (preg_match('/recentpireps/i',$host)) {
167 210
         	//$formats[$id] = 'pirepsjson';
168 211
         	$globalSources[$id]['format'] = 'pirepsjson';
169 212
         	//$last_exec['pirepsjson'] = 0;
170
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
213
+        	if ($globalDebug) {
214
+        		echo "Connect to pirepsjson source (".$host.")...\n";
215
+        	}
171 216
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172 217
         	//$formats[$id] = 'fr24json';
173 218
         	$globalSources[$id]['format'] = 'fr24json';
174 219
         	//$last_exec['fr24json'] = 0;
175
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to fr24 source (".$host.")...\n";
222
+        	}
176 223
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177 224
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178 225
         	    exit(0);
@@ -181,7 +228,9 @@  discard block
 block discarded – undo
181 228
         	//$formats[$id] = 'fr24json';
182 229
         	$globalSources[$id]['format'] = 'myshiptracking';
183 230
         	//$last_exec['fr24json'] = 0;
184
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to myshiptracking source (".$host.")...\n";
233
+        	}
185 234
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186 235
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187 236
         	    exit(0);
@@ -190,17 +239,24 @@  discard block
 block discarded – undo
190 239
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191 240
         	//$formats[$id] = 'tsv';
192 241
         	$globalSources[$id]['format'] = 'tsv';
193
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to tsv source (".$host.")...\n";
244
+        	}
194 245
             }
195 246
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196 247
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197 248
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
198 249
     		    if ($idf !== false) {
199 250
     			$httpfeeds[$id] = $idf;
200
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
251
+        		if ($globalDebug) {
252
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
253
+        		}
254
+    		    } elseif ($globalDebug) {
255
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
201 256
     		    }
202
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
257
+    		} elseif ($globalDebug) {
258
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
259
+    		}
204 260
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205 261
 	    $hostport = explode(':',$host);
206 262
 	    if (isset($hostport[1])) {
@@ -240,17 +296,25 @@  discard block
 block discarded – undo
240 296
         		//$formats[$id] = 'beast';
241 297
         		$globalSources[$id]['format'] = 'beast';
242 298
 		    //} else $formats[$id] = 'sbs';
243
-		    } else $globalSources[$id]['format'] = 'sbs';
299
+		    } else {
300
+		    	$globalSources[$id]['format'] = 'sbs';
301
+		    }
244 302
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
245 303
 		}
246
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
304
+		if ($globalDebug) {
305
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
306
+		}
247 307
             } else {
248
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
308
+		if ($globalDebug) {
309
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
310
+		}
249 311
     	    }
250 312
         }
251 313
     }
252 314
 }
253
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
315
+if (!isset($globalMinFetch)) {
316
+	$globalMinFetch = 15;
317
+}
254 318
 
255 319
 // Initialize all
256 320
 $status = array();
@@ -259,13 +323,19 @@  discard block
 block discarded – undo
259 323
 $formats = array();
260 324
 $last_exec = array();
261 325
 $time = time();
262
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
263
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
264
-else $timeout = 20;
326
+if (isset($globalSourcesTimeout)) {
327
+	$timeout = $globalSourcesTimeOut;
328
+} else if (isset($globalSBS1TimeOut)) {
329
+	$timeout = $globalSBS1TimeOut;
330
+} else {
331
+	$timeout = 20;
332
+}
265 333
 $errno = '';
266 334
 $errstr='';
267 335
 
268
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
336
+if (!isset($globalDaemon)) {
337
+	$globalDaemon = TRUE;
338
+}
269 339
 /* Initiate connections to all the hosts simultaneously */
270 340
 //connect_all($hosts);
271 341
 //connect_all($globalSources);
@@ -291,7 +361,9 @@  discard block
 block discarded – undo
291 361
     if (isset($source['format']) && $source['format'] == 'aprs') {
292 362
 	$aprs_connect = 0;
293 363
 	$use_aprs = true;
294
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
364
+	if (isset($source['port']) && $source['port'] == '10152') {
365
+		$aprs_full = true;
366
+	}
295 367
 	break;
296 368
     }
297 369
 }
@@ -302,26 +374,49 @@  discard block
 block discarded – undo
302 374
 	$aprs_connect = 0;
303 375
 	$aprs_keep = 120;
304 376
 	$aprs_last_tx = time();
305
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
306
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
307
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
308
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
309
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
310
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
311
-	if ($aprs_full) $aprs_filter = '';
312
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
313
-	else $aprs_pass = '-1';
377
+	if (isset($globalAPRSversion)) {
378
+		$aprs_version = $globalAPRSversion;
379
+	} else {
380
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
381
+	}
382
+	if (isset($globalAPRSssid)) {
383
+		$aprs_ssid = $globalAPRSssid;
384
+	} else {
385
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
386
+	}
387
+	if (isset($globalAPRSfilter)) {
388
+		$aprs_filter = $globalAPRSfilter;
389
+	} else {
390
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
391
+	}
392
+	if ($aprs_full) {
393
+		$aprs_filter = '';
394
+	}
395
+	if (isset($globalAPRSpass)) {
396
+		$aprs_pass = $globalAPRSpass;
397
+	} else {
398
+		$aprs_pass = '-1';
399
+	}
314 400
 
315
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
316
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
401
+	if ($aprs_filter != '') {
402
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
403
+	} else {
404
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
405
+	}
317 406
 	echo $aprs_login."\n";
318 407
 }
319 408
 
320 409
 // connected - lets do some work
321
-if ($globalDebug) echo "Connected!\n";
410
+if ($globalDebug) {
411
+	echo "Connected!\n";
412
+}
322 413
 sleep(1);
323
-if ($globalDebug) echo "SCAN MODE \n\n";
324
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
414
+if ($globalDebug) {
415
+	echo "SCAN MODE \n\n";
416
+}
417
+if (!isset($globalCronEnd)) {
418
+	$globalCronEnd = 60;
419
+}
325 420
 $endtime = time()+$globalCronEnd;
326 421
 $i = 1;
327 422
 $tt = array();
@@ -335,10 +430,14 @@  discard block
 block discarded – undo
335 430
 
336 431
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
337 432
 while ($i > 0) {
338
-    if (!$globalDaemon) $i = $endtime-time();
433
+    if (!$globalDaemon) {
434
+    	$i = $endtime-time();
435
+    }
339 436
     // Delete old ATC
340 437
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
341
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
438
+	if ($globalDebug) {
439
+		echo 'Delete old ATC...'."\n";
440
+	}
342 441
         $ATC->deleteOldATC();
343 442
     }
344 443
     
@@ -346,10 +445,14 @@  discard block
 block discarded – undo
346 445
     if (count($last_exec) == count($globalSources)) {
347 446
 	$max = $globalMinFetch;
348 447
 	foreach ($last_exec as $last) {
349
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
448
+	    if ((time() - $last['last']) < $max) {
449
+	    	$max = time() - $last['last'];
450
+	    }
350 451
 	}
351 452
 	if ($max != $globalMinFetch) {
352
-	    if ($globalDebug) echo 'Sleeping...'."\n";
453
+	    if ($globalDebug) {
454
+	    	echo 'Sleeping...'."\n";
455
+	    }
353 456
 	    sleep($globalMinFetch-$max+2);
354 457
 	}
355 458
     }
@@ -358,11 +461,15 @@  discard block
 block discarded – undo
358 461
     //foreach ($formats as $id => $value) {
359 462
     foreach ($globalSources as $id => $value) {
360 463
 	date_default_timezone_set('UTC');
361
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
464
+	if (!isset($last_exec[$id]['last'])) {
465
+		$last_exec[$id]['last'] = 0;
466
+	}
362 467
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
363 468
 	    //$buffer = $Common->getData($hosts[$id]);
364 469
 	    $buffer = $Common->getData($value['host']);
365
-	    if ($buffer != '') $reset = 0;
470
+	    if ($buffer != '') {
471
+	    	$reset = 0;
472
+	    }
366 473
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367 474
 	    $buffer = explode('\n',$buffer);
368 475
 	    foreach ($buffer as $line) {
@@ -371,19 +478,38 @@  discard block
 block discarded – undo
371 478
 	            $data = array();
372 479
 	            $data['hex'] = $line[1]; // hex
373 480
 	            $data['ident'] = $line[2]; // ident
374
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
481
+	            if (isset($line[3])) {
482
+	            	$data['altitude'] = $line[3];
483
+	            }
484
+	            // altitude
485
+	            if (isset($line[4])) {
486
+	            	$data['speed'] = $line[4];
487
+	            }
488
+	            // speed
489
+	            if (isset($line[5])) {
490
+	            	$data['heading'] = $line[5];
491
+	            }
492
+	            // heading
493
+	            if (isset($line[6])) {
494
+	            	$data['latitude'] = $line[6];
495
+	            }
496
+	            // lat
497
+	            if (isset($line[7])) {
498
+	            	$data['longitude'] = $line[7];
499
+	            }
500
+	            // long
379 501
 	            $data['verticalrate'] = ''; // vertical rate
380 502
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381 503
 	            $data['emergency'] = ''; // emergency
382 504
 		    $data['datetime'] = date('Y-m-d H:i:s');
383 505
 		    $data['format_source'] = 'deltadbtxt';
384 506
     		    $data['id_source'] = $id_source;
385
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
507
+		    if (isset($value['name']) && $value['name'] != '') {
508
+		    	$data['source_name'] = $value['name'];
509
+		    }
510
+		    if (isset($value['sourcestats'])) {
511
+		    	$data['sourcestats'] = $value['sourcestats'];
512
+		    }
387 513
     		    $SI->add($data);
388 514
 		    unset($data);
389 515
     		}
@@ -393,7 +519,9 @@  discard block
 block discarded – undo
393 519
 	    date_default_timezone_set('CET');
394 520
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395 521
 	    date_default_timezone_set('UTC');
396
-	    if ($buffer != '') $reset = 0;
522
+	    if ($buffer != '') {
523
+	    	$reset = 0;
524
+	    }
397 525
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398 526
 	    $buffer = explode('\n',$buffer);
399 527
 	    foreach ($buffer as $line) {
@@ -402,16 +530,36 @@  discard block
 block discarded – undo
402 530
 		    $add = false;
403 531
 		    $ais_data = $AIS->parse_line(trim($line));
404 532
 		    $data = array();
405
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
533
+		    if (isset($ais_data['ident'])) {
534
+		    	$data['ident'] = $ais_data['ident'];
535
+		    }
536
+		    if (isset($ais_data['mmsi'])) {
537
+		    	$data['mmsi'] = $ais_data['mmsi'];
538
+		    }
539
+		    if (isset($ais_data['speed'])) {
540
+		    	$data['speed'] = $ais_data['speed'];
541
+		    }
542
+		    if (isset($ais_data['heading'])) {
543
+		    	$data['heading'] = $ais_data['heading'];
544
+		    }
545
+		    if (isset($ais_data['latitude'])) {
546
+		    	$data['latitude'] = $ais_data['latitude'];
547
+		    }
548
+		    if (isset($ais_data['longitude'])) {
549
+		    	$data['longitude'] = $ais_data['longitude'];
550
+		    }
551
+		    if (isset($ais_data['status'])) {
552
+		    	$data['status'] = $ais_data['status'];
553
+		    }
554
+		    if (isset($ais_data['type'])) {
555
+		    	$data['type'] = $ais_data['type'];
556
+		    }
557
+		    if (isset($ais_data['imo'])) {
558
+		    	$data['imo'] = $ais_data['imo'];
559
+		    }
560
+		    if (isset($ais_data['callsign'])) {
561
+		    	$data['callsign'] = $ais_data['callsign'];
562
+		    }
415 563
 		    if (isset($ais_data['timestamp'])) {
416 564
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
417 565
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -426,7 +574,9 @@  discard block
 block discarded – undo
426 574
     		    $data['id_source'] = $id_source;
427 575
 		    print_r($data);
428 576
 		    echo 'Add...'."\n";
429
-		    if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
577
+		    if ($add && $ais_data['mmsi_type'] == 'Ship') {
578
+		    	$MI->add($data);
579
+		    }
430 580
 		    unset($data);
431 581
 		}
432 582
     	    }
@@ -446,18 +596,42 @@  discard block
 block discarded – undo
446 596
 			if ($line != '') {
447 597
 			    $ais_data = $AIS->parse_line(trim($line));
448 598
 			    $data = array();
449
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
599
+			    if (isset($ais_data['ident'])) {
600
+			    	$data['ident'] = $ais_data['ident'];
601
+			    }
602
+			    if (isset($ais_data['mmsi'])) {
603
+			    	$data['mmsi'] = $ais_data['mmsi'];
604
+			    }
605
+			    if (isset($ais_data['speed'])) {
606
+			    	$data['speed'] = $ais_data['speed'];
607
+			    }
608
+			    if (isset($ais_data['heading'])) {
609
+			    	$data['heading'] = $ais_data['heading'];
610
+			    }
611
+			    if (isset($ais_data['latitude'])) {
612
+			    	$data['latitude'] = $ais_data['latitude'];
613
+			    }
614
+			    if (isset($ais_data['longitude'])) {
615
+			    	$data['longitude'] = $ais_data['longitude'];
616
+			    }
617
+			    if (isset($ais_data['status'])) {
618
+			    	$data['status'] = $ais_data['status'];
619
+			    }
620
+			    if (isset($ais_data['type'])) {
621
+			    	$data['type'] = $ais_data['type'];
622
+			    }
623
+			    if (isset($ais_data['imo'])) {
624
+			    	$data['imo'] = $ais_data['imo'];
625
+			    }
626
+			    if (isset($ais_data['callsign'])) {
627
+			    	$data['callsign'] = $ais_data['callsign'];
628
+			    }
629
+			    if (isset($ais_data['destination'])) {
630
+			    	$data['arrival_code'] = $ais_data['destination'];
631
+			    }
632
+			    if (isset($ais_data['eta_ts'])) {
633
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
634
+			    }
461 635
 			    if (isset($ais_data['timestamp'])) {
462 636
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
463 637
 			    } else {
@@ -465,7 +639,9 @@  discard block
 block discarded – undo
465 639
 			    }
466 640
 			    $data['format_source'] = 'aisnmeahttp';
467 641
 			    $data['id_source'] = $id_source;
468
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
642
+			    if ($ais_data['mmsi_type'] == 'Ship') {
643
+			    	$MI->add($data);
644
+			    }
469 645
 			    unset($data);
470 646
 			}
471 647
 		    }
@@ -514,7 +690,9 @@  discard block
 block discarded – undo
514 690
 			    $data['callsign'] = $line['callsign'];
515 691
 			    $data['mmsi'] = $line['mmsi'];
516 692
 			    $data['speed'] = $line['sog'];
517
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
+			    if ($line['heading'] != '511') {
694
+			    	$data['heading'] = $line['heading'];
695
+			    }
518 696
 			    $data['latitude'] = $line['latitude'];
519 697
 			    $data['longitude'] = $line['longitude'];
520 698
 			    $data['type_id'] = $line['shiptype'];
@@ -534,7 +712,9 @@  discard block
 block discarded – undo
534 712
 	    echo 'download...';
535 713
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536 714
 	    echo 'done !'."\n";
537
-	    if ($buffer != '') $reset = 0;
715
+	    if ($buffer != '') {
716
+	    	$reset = 0;
717
+	    }
538 718
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539 719
 	    $buffer = explode('\n',$buffer);
540 720
 	    foreach ($buffer as $line) {
@@ -578,16 +758,28 @@  discard block
 block discarded – undo
578 758
     		    $line = explode(':', $line);
579 759
     		    if (count($line) > 30 && $line[0] != 'callsign') {
580 760
 			$data = array();
581
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
582
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
761
+			if (isset($line[37]) && $line[37] != '') {
762
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
763
+			} else {
764
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
765
+			}
583 766
 			$data['pilot_id'] = $line[1];
584 767
 			$data['pilot_name'] = $line[2];
585 768
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
586 769
 			$data['ident'] = $line[0]; // ident
587
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
770
+			if ($line[7] != '' && $line[7] != 0) {
771
+				$data['altitude'] = $line[7];
772
+			}
773
+			// altitude
588 774
 			$data['speed'] = $line[8]; // speed
589
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
590
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
775
+			if (isset($line[45])) {
776
+				$data['heading'] = $line[45];
777
+			}
778
+			// heading
779
+			elseif (isset($line[38])) {
780
+				$data['heading'] = $line[38];
781
+			}
782
+			// heading
591 783
 			$data['latitude'] = $line[5]; // lat
592 784
 	        	$data['longitude'] = $line[6]; // long
593 785
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -603,7 +795,9 @@  discard block
 block discarded – undo
603 795
 			$data['frequency'] = $line[4];
604 796
 			$data['type'] = $line[18];
605 797
 			$data['range'] = $line[19];
606
-			if (isset($line[35])) $data['info'] = $line[35];
798
+			if (isset($line[35])) {
799
+				$data['info'] = $line[35];
800
+			}
607 801
     			$data['id_source'] = $id_source;
608 802
 	    		//$data['arrival_airport_time'] = ;
609 803
 	    		if ($line[9] != '') {
@@ -617,24 +811,41 @@  discard block
 block discarded – undo
617 811
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
618 812
 	    		*/
619 813
 	    		$data['format_source'] = $value['format'];
620
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
621
-    			if ($line[3] == 'PILOT') $SI->add($data);
622
-			elseif ($line[3] == 'ATC') {
814
+			if (isset($value['name']) && $value['name'] != '') {
815
+				$data['source_name'] = $value['name'];
816
+			}
817
+    			if ($line[3] == 'PILOT') {
818
+    				$SI->add($data);
819
+    			} elseif ($line[3] == 'ATC') {
623 820
 				//print_r($data);
624 821
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
625 822
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
626 823
 				$typec = substr($data['ident'],-3);
627
-				if ($typec == 'APP') $data['type'] = 'Approach';
628
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
629
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
630
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
631
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
632
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
633
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
634
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
635
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
636
-				if (!isset($data['source_name'])) $data['source_name'] = '';
637
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
824
+				if ($typec == 'APP') {
825
+					$data['type'] = 'Approach';
826
+				} elseif ($typec == 'TWR') {
827
+					$data['type'] = 'Tower';
828
+				} elseif ($typec == 'OBS') {
829
+					$data['type'] = 'Observer';
830
+				} elseif ($typec == 'GND') {
831
+					$data['type'] = 'Ground';
832
+				} elseif ($typec == 'DEL') {
833
+					$data['type'] = 'Delivery';
834
+				} elseif ($typec == 'DEP') {
835
+					$data['type'] = 'Departure';
836
+				} elseif ($typec == 'FSS') {
837
+					$data['type'] = 'Flight Service Station';
838
+				} elseif ($typec == 'CTR') {
839
+					$data['type'] = 'Control Radar or Centre';
840
+				} elseif ($data['type'] == '') {
841
+					$data['type'] = 'Observer';
842
+				}
843
+				if (!isset($data['source_name'])) {
844
+					$data['source_name'] = '';
845
+				}
846
+				if (isset($ATC)) {
847
+					echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
848
+				}
638 849
 			}
639 850
     			unset($data);
640 851
     		    }
@@ -653,26 +864,55 @@  discard block
 block discarded – undo
653 864
 		foreach ($all_data['acList'] as $line) {
654 865
 		    $data = array();
655 866
 		    $data['hex'] = $line['Icao']; // hex
656
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
867
+		    if (isset($line['Call'])) {
868
+		    	$data['ident'] = $line['Call'];
869
+		    }
870
+		    // ident
871
+		    if (isset($line['Alt'])) {
872
+		    	$data['altitude'] = $line['Alt'];
873
+		    }
874
+		    // altitude
875
+		    if (isset($line['Spd'])) {
876
+		    	$data['speed'] = $line['Spd'];
877
+		    }
878
+		    // speed
879
+		    if (isset($line['Trak'])) {
880
+		    	$data['heading'] = $line['Trak'];
881
+		    }
882
+		    // heading
883
+		    if (isset($line['Lat'])) {
884
+		    	$data['latitude'] = $line['Lat'];
885
+		    }
886
+		    // lat
887
+		    if (isset($line['Long'])) {
888
+		    	$data['longitude'] = $line['Long'];
889
+		    }
890
+		    // long
662 891
 		    //$data['verticalrate'] = $line['']; // verticale rate
663
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
892
+		    if (isset($line['Sqk'])) {
893
+		    	$data['squawk'] = $line['Sqk'];
894
+		    }
895
+		    // squawk
664 896
 		    $data['emergency'] = ''; // emergency
665
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
897
+		    if (isset($line['Reg'])) {
898
+		    	$data['registration'] = $line['Reg'];
899
+		    }
666 900
 		    /*
667 901
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
668 902
 		    else $data['datetime'] = date('Y-m-d H:i:s');
669 903
 		    */
670 904
 		    $data['datetime'] = date('Y-m-d H:i:s');
671
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
905
+		    if (isset($line['Type'])) {
906
+		    	$data['aircraft_icao'] = $line['Type'];
907
+		    }
672 908
 	    	    $data['format_source'] = 'aircraftlistjson';
673 909
 		    $data['id_source'] = $id_source;
674
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
-		    if (isset($data['latitude'])) $SI->add($data);
910
+		    if (isset($value['name']) && $value['name'] != '') {
911
+		    	$data['source_name'] = $value['name'];
912
+		    }
913
+		    if (isset($data['latitude'])) {
914
+		    	$SI->add($data);
915
+		    }
676 916
 		    unset($data);
677 917
 		}
678 918
 	    } elseif (is_array($all_data)) {
@@ -692,7 +932,9 @@  discard block
 block discarded – undo
692 932
 		    $data['datetime'] = date('Y-m-d H:i:s');
693 933
 	    	    $data['format_source'] = 'aircraftlistjson';
694 934
     		    $data['id_source'] = $id_source;
695
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
935
+		    if (isset($value['name']) && $value['name'] != '') {
936
+		    	$data['source_name'] = $value['name'];
937
+		    }
696 938
 		    $SI->add($data);
697 939
 		    unset($data);
698 940
 		}
@@ -728,7 +970,9 @@  discard block
 block discarded – undo
728 970
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729 971
 	    	    $data['format_source'] = 'planeupdatefaa';
730 972
     		    $data['id_source'] = $id_source;
731
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
973
+		    if (isset($value['name']) && $value['name'] != '') {
974
+		    	$data['source_name'] = $value['name'];
975
+		    }
732 976
 		    $SI->add($data);
733 977
 		    unset($data);
734 978
 		}
@@ -768,7 +1012,9 @@  discard block
 block discarded – undo
768 1012
 	    //$buffer = $Common->getData($hosts[$id]);
769 1013
 	    $buffer = $Common->getData($value['host']);
770 1014
 	    $all_data = json_decode($buffer,true);
771
-	    if (!empty($all_data)) $reset = 0;
1015
+	    if (!empty($all_data)) {
1016
+	    	$reset = 0;
1017
+	    }
772 1018
 	    foreach ($all_data as $key => $line) {
773 1019
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
774 1020
 		    $data = array();
@@ -789,7 +1035,9 @@  discard block
 block discarded – undo
789 1035
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790 1036
 	    	    $data['format_source'] = 'fr24json';
791 1037
     		    $data['id_source'] = $id_source;
792
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1038
+		    if (isset($value['name']) && $value['name'] != '') {
1039
+		    	$data['source_name'] = $value['name'];
1040
+		    }
793 1041
 		    $SI->add($data);
794 1042
 		    unset($data);
795 1043
 		}
@@ -813,23 +1061,39 @@  discard block
 block discarded – undo
813 1061
 		    if (isset($line['inf'])) {
814 1062
 			$data = array();
815 1063
 			$data['hex'] = $line['inf']['ia'];
816
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1064
+			if (isset($line['inf']['cs'])) {
1065
+				$data['ident'] = $line['inf']['cs'];
1066
+			}
1067
+			//$line[13]
817 1068
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1069
+	    		if (isset($line['inf']['gs'])) {
1070
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1071
+	    		}
1072
+	    		// speed
1073
+	    		if (isset($line['inf']['tr'])) {
1074
+	    			$data['heading'] = $line['inf']['tr'];
1075
+	    		}
1076
+	    		// heading
820 1077
 	    		$data['latitude'] = $line['pt'][0]; // lat
821 1078
 	    		$data['longitude'] = $line['pt'][1]; // long
822 1079
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1080
+	    		if (isset($line['inf']['sq'])) {
1081
+	    			$data['squawk'] = $line['inf']['sq'];
1082
+	    		}
1083
+	    		// squawk
824 1084
 	    		//$data['aircraft_icao'] = $line[8];
825
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1085
+	    		if (isset($line['inf']['rc'])) {
1086
+	    			$data['registration'] = $line['inf']['rc'];
1087
+	    		}
826 1088
 			//$data['departure_airport_iata'] = $line[11];
827 1089
 			//$data['arrival_airport_iata'] = $line[12];
828 1090
 	    		//$data['emergency'] = ''; // emergency
829 1091
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
830 1092
 	    		$data['format_source'] = 'radarvirtueljson';
831 1093
     			$data['id_source'] = $id_source;
832
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1094
+			if (isset($value['name']) && $value['name'] != '') {
1095
+				$data['source_name'] = $value['name'];
1096
+			}
833 1097
 			$SI->add($data);
834 1098
 			unset($data);
835 1099
 		    }
@@ -850,29 +1114,62 @@  discard block
 block discarded – undo
850 1114
 		    $data['id'] = $line['id'];
851 1115
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852 1116
 		    $data['ident'] = $line['callsign']; // ident
853
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1117
+		    if (isset($line['pilotid'])) {
1118
+		    	$data['pilot_id'] = $line['pilotid'];
1119
+		    }
1120
+		    // pilot id
1121
+		    if (isset($line['name'])) {
1122
+		    	$data['pilot_name'] = $line['name'];
1123
+		    }
1124
+		    // pilot name
1125
+		    if (isset($line['alt'])) {
1126
+		    	$data['altitude'] = $line['alt'];
1127
+		    }
1128
+		    // altitude
1129
+		    if (isset($line['gs'])) {
1130
+		    	$data['speed'] = $line['gs'];
1131
+		    }
1132
+		    // speed
1133
+		    if (isset($line['heading'])) {
1134
+		    	$data['heading'] = $line['heading'];
1135
+		    }
1136
+		    // heading
1137
+		    if (isset($line['route'])) {
1138
+		    	$data['waypoints'] = $line['route'];
1139
+		    }
1140
+		    // route
859 1141
 		    $data['latitude'] = $line['lat']; // lat
860 1142
 		    $data['longitude'] = $line['lon']; // long
861 1143
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
862 1144
 		    //$data['squawk'] = $line['squawk']; // squawk
863 1145
 		    //$data['emergency'] = ''; // emergency
864
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1146
+		    if (isset($line['depicao'])) {
1147
+		    	$data['departure_airport_icao'] = $line['depicao'];
1148
+		    }
1149
+		    if (isset($line['deptime'])) {
1150
+		    	$data['departure_airport_time'] = $line['deptime'];
1151
+		    }
1152
+		    if (isset($line['arricao'])) {
1153
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1154
+		    }
867 1155
 		    //$data['arrival_airport_time'] = $line['arrtime'];
868
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
871
-		    else $data['info'] = '';
1156
+		    if (isset($line['aircraft'])) {
1157
+		    	$data['aircraft_icao'] = $line['aircraft'];
1158
+		    }
1159
+		    if (isset($line['transponder'])) {
1160
+		    	$data['squawk'] = $line['transponder'];
1161
+		    }
1162
+		    if (isset($line['atis'])) {
1163
+		    	$data['info'] = $line['atis'];
1164
+		    } else {
1165
+		    	$data['info'] = '';
1166
+		    }
872 1167
 		    $data['format_source'] = 'pireps';
873 1168
     		    $data['id_source'] = $id_source;
874 1169
 		    $data['datetime'] = date('Y-m-d H:i:s');
875
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1170
+		    if (isset($value['name']) && $value['name'] != '') {
1171
+		    	$data['source_name'] = $value['name'];
1172
+		    }
876 1173
 		    if ($line['icon'] == 'plane') {
877 1174
 			$SI->add($data);
878 1175
 		    //    print_r($data);
@@ -881,16 +1178,28 @@  discard block
 block discarded – undo
881 1178
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
882 1179
 			$typec = substr($data['ident'],-3);
883 1180
 			$data['type'] = '';
884
-			if ($typec == 'APP') $data['type'] = 'Approach';
885
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
886
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
887
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
888
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
889
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
890
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
891
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
892
-			else $data['type'] = 'Observer';
893
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1181
+			if ($typec == 'APP') {
1182
+				$data['type'] = 'Approach';
1183
+			} elseif ($typec == 'TWR') {
1184
+				$data['type'] = 'Tower';
1185
+			} elseif ($typec == 'OBS') {
1186
+				$data['type'] = 'Observer';
1187
+			} elseif ($typec == 'GND') {
1188
+				$data['type'] = 'Ground';
1189
+			} elseif ($typec == 'DEL') {
1190
+				$data['type'] = 'Delivery';
1191
+			} elseif ($typec == 'DEP') {
1192
+				$data['type'] = 'Departure';
1193
+			} elseif ($typec == 'FSS') {
1194
+				$data['type'] = 'Flight Service Station';
1195
+			} elseif ($typec == 'CTR') {
1196
+				$data['type'] = 'Control Radar or Centre';
1197
+			} else {
1198
+				$data['type'] = 'Observer';
1199
+			}
1200
+			if (isset($ATC)) {
1201
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1202
+			}
894 1203
 		    }
895 1204
 		    unset($data);
896 1205
 		}
@@ -900,7 +1209,9 @@  discard block
 block discarded – undo
900 1209
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901 1210
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902 1211
 	    //$buffer = $Common->getData($hosts[$id]);
903
-	    if ($globalDebug) echo 'Get Data...'."\n";
1212
+	    if ($globalDebug) {
1213
+	    	echo 'Get Data...'."\n";
1214
+	    }
904 1215
 	    $buffer = $Common->getData($value['host']);
905 1216
 	    $all_data = json_decode($buffer,true);
906 1217
 	    if ($buffer != '' && is_array($all_data)) {
@@ -908,10 +1219,16 @@  discard block
 block discarded – undo
908 1219
 		foreach ($all_data as $line) {
909 1220
 	    	    $data = array();
910 1221
 	    	    //$data['id'] = $line['id']; // id not usable
911
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1222
+	    	    if (isset($line['pilotid'])) {
1223
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1224
+	    	    }
912 1225
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1226
+	    	    if (isset($line['pilotname'])) {
1227
+	    	    	$data['pilot_name'] = $line['pilotname'];
1228
+	    	    }
1229
+	    	    if (isset($line['pilotid'])) {
1230
+	    	    	$data['pilot_id'] = $line['pilotid'];
1231
+	    	    }
915 1232
 	    	    $data['ident'] = $line['flightnum']; // ident
916 1233
 	    	    $data['altitude'] = $line['alt']; // altitude
917 1234
 	    	    $data['speed'] = $line['gs']; // speed
@@ -929,27 +1246,41 @@  discard block
 block discarded – undo
929 1246
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
930 1247
     		    $data['arrival_airport_time'] = $line['arrtime'];
931 1248
     		    $data['registration'] = $line['aircraft'];
932
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1249
+		    if (isset($line['route'])) {
1250
+		    	$data['waypoints'] = $line['route'];
1251
+		    }
1252
+		    // route
933 1253
 		    if (isset($line['aircraftname'])) {
934 1254
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
935 1255
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
936 1256
 	    		$aircraft_data = explode('-',$line['aircraftname']);
937
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
-	    		else {
1257
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
1258
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1259
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
1260
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1261
+	    		} else {
940 1262
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
941
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
1263
+	    		    if (isset($aircraft_data[1])) {
1264
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
1265
+	    		    } else {
1266
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
1267
+	    		    }
943 1268
 	    		}
944 1269
 	    	    }
945
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1270
+    		    if (isset($line['route'])) {
1271
+    		    	$data['waypoints'] = $line['route'];
1272
+    		    }
946 1273
     		    $data['id_source'] = $id_source;
947 1274
 	    	    $data['format_source'] = 'phpvmacars';
948
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1275
+		    if (isset($value['name']) && $value['name'] != '') {
1276
+		    	$data['source_name'] = $value['name'];
1277
+		    }
949 1278
 		    $SI->add($data);
950 1279
 		    unset($data);
951 1280
 		}
952
-		if ($globalDebug) echo 'No more data...'."\n";
1281
+		if ($globalDebug) {
1282
+			echo 'No more data...'."\n";
1283
+		}
953 1284
 		unset($buffer);
954 1285
 		unset($all_data);
955 1286
 	    }
@@ -957,7 +1288,9 @@  discard block
 block discarded – undo
957 1288
     	    $last_exec[$id]['last'] = time();
958 1289
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959 1290
 	    //$buffer = $Common->getData($hosts[$id]);
960
-	    if ($globalDebug) echo 'Get Data...'."\n";
1291
+	    if ($globalDebug) {
1292
+	    	echo 'Get Data...'."\n";
1293
+	    }
961 1294
 	    $buffer = $Common->getData($value['host']);
962 1295
 	    $all_data = json_decode($buffer,true);
963 1296
 	    if ($buffer != '' && is_array($all_data)) {
@@ -986,15 +1319,22 @@  discard block
 block discarded – undo
986 1319
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
987 1320
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
988 1321
     		    //$data['registration'] = $line['aircraft'];
989
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1322
+		    if (isset($line['route'])) {
1323
+		    	$data['waypoints'] = $line['route'];
1324
+		    }
1325
+		    // route
990 1326
 	    	    $data['aircraft_icao'] = $line['plane_type'];
991 1327
     		    $data['id_source'] = $id_source;
992 1328
 	    	    $data['format_source'] = 'vam';
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1329
+		    if (isset($value['name']) && $value['name'] != '') {
1330
+		    	$data['source_name'] = $value['name'];
1331
+		    }
994 1332
 		    $SI->add($data);
995 1333
 		    unset($data);
996 1334
 		}
997
-		if ($globalDebug) echo 'No more data...'."\n";
1335
+		if ($globalDebug) {
1336
+			echo 'No more data...'."\n";
1337
+		}
998 1338
 		unset($buffer);
999 1339
 		unset($all_data);
1000 1340
 	    }
@@ -1002,7 +1342,9 @@  discard block
 block discarded – undo
1002 1342
     	    $last_exec[$id]['last'] = time();
1003 1343
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1004 1344
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1005
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1345
+	    if (function_exists('pcntl_fork')) {
1346
+	    	pcntl_signal_dispatch();
1347
+	    }
1006 1348
     	    //$last_exec[$id]['last'] = time();
1007 1349
 
1008 1350
 	    //$read = array( $sockets[$id] );
@@ -1010,7 +1352,9 @@  discard block
 block discarded – undo
1010 1352
 	    $write = NULL;
1011 1353
 	    $e = NULL;
1012 1354
 	    $n = socket_select($read, $write, $e, $timeout);
1013
-	    if ($e != NULL) var_dump($e);
1355
+	    if ($e != NULL) {
1356
+	    	var_dump($e);
1357
+	    }
1014 1358
 	    if ($n > 0) {
1015 1359
 		$reset = 0;
1016 1360
 		foreach ($read as $nb => $r) {
@@ -1029,12 +1373,16 @@  discard block
 block discarded – undo
1029 1373
 		    //$SI::del();
1030 1374
 		    if ($format == 'vrstcp') {
1031 1375
 			$buffer = explode('},{',$buffer);
1032
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1376
+		    } else {
1377
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1378
+		    }
1033 1379
 		    // SBS format is CSV format
1034 1380
 		    if ($buffer != '') {
1035 1381
 			$tt[$format] = 0;
1036 1382
 			if ($format == 'acarssbs3') {
1037
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1383
+                    	    if ($globalDebug) {
1384
+                    	    	echo 'ACARS : '.$buffer."\n";
1385
+                    	    }
1038 1386
 			    $ACARS->add(trim($buffer));
1039 1387
 			    $ACARS->deleteLiveAcarsData();
1040 1388
 			} elseif ($format == 'raw') {
@@ -1043,25 +1391,55 @@  discard block
 block discarded – undo
1043 1391
 			    if (is_array($data)) {
1044 1392
 				$data['datetime'] = date('Y-m-d H:i:s');
1045 1393
 				$data['format_source'] = 'raw';
1046
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1047
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1394
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1395
+					$data['source_name'] = $globalSources[$nb]['name'];
1396
+				}
1397
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1398
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1399
+    				}
1400
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1401
+                                	$SI->add($data);
1402
+                                }
1049 1403
                             }
1050 1404
                         } elseif ($format == 'ais') {
1051 1405
 			    $ais_data = $AIS->parse_line(trim($buffer));
1052 1406
 			    $data = array();
1053
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1407
+			    if (isset($ais_data['ident'])) {
1408
+			    	$data['ident'] = $ais_data['ident'];
1409
+			    }
1410
+			    if (isset($ais_data['mmsi'])) {
1411
+			    	$data['mmsi'] = $ais_data['mmsi'];
1412
+			    }
1413
+			    if (isset($ais_data['speed'])) {
1414
+			    	$data['speed'] = $ais_data['speed'];
1415
+			    }
1416
+			    if (isset($ais_data['heading'])) {
1417
+			    	$data['heading'] = $ais_data['heading'];
1418
+			    }
1419
+			    if (isset($ais_data['latitude'])) {
1420
+			    	$data['latitude'] = $ais_data['latitude'];
1421
+			    }
1422
+			    if (isset($ais_data['longitude'])) {
1423
+			    	$data['longitude'] = $ais_data['longitude'];
1424
+			    }
1425
+			    if (isset($ais_data['status'])) {
1426
+			    	$data['status'] = $ais_data['status'];
1427
+			    }
1428
+			    if (isset($ais_data['type'])) {
1429
+			    	$data['type'] = $ais_data['type'];
1430
+			    }
1431
+			    if (isset($ais_data['imo'])) {
1432
+			    	$data['imo'] = $ais_data['imo'];
1433
+			    }
1434
+			    if (isset($ais_data['callsign'])) {
1435
+			    	$data['callsign'] = $ais_data['callsign'];
1436
+			    }
1437
+			    if (isset($ais_data['destination'])) {
1438
+			    	$data['arrival_code'] = $ais_data['destination'];
1439
+			    }
1440
+			    if (isset($ais_data['eta_ts'])) {
1441
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1442
+			    }
1065 1443
 
1066 1444
 			    if (isset($ais_data['timestamp'])) {
1067 1445
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1070,7 +1448,9 @@  discard block
 block discarded – undo
1070 1448
 			    }
1071 1449
 			    $data['format_source'] = 'aisnmea';
1072 1450
     			    $data['id_source'] = $id_source;
1073
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1451
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1452
+			    	$MI->add($data);
1453
+			    }
1074 1454
 			    unset($data);
1075 1455
                         } elseif ($format == 'flightgearsp') {
1076 1456
                     	    //echo $buffer."\n";
@@ -1088,11 +1468,15 @@  discard block
 block discarded – undo
1088 1468
 				$data['speed'] = round($line[5]*1.94384);
1089 1469
 				$data['datetime'] = date('Y-m-d H:i:s');
1090 1470
 				$data['format_source'] = 'flightgearsp';
1091
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1471
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1472
+					$SI->add($data);
1473
+				}
1092 1474
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1093 1475
 			    }
1094 1476
                         } elseif ($format == 'acars') {
1095
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1477
+                    	    if ($globalDebug) {
1478
+                    	    	echo 'ACARS : '.$buffer."\n";
1479
+                    	    }
1096 1480
 			    $ACARS->add(trim($buffer));
1097 1481
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098 1482
 			    $ACARS->deleteLiveAcarsData();
@@ -1113,7 +1497,9 @@  discard block
 block discarded – undo
1113 1497
 				    $aircraft_type = $line[10];
1114 1498
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1115 1499
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1500
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1501
+				    	$SI->add($data);
1502
+				    }
1117 1503
 				}
1118 1504
 			    }
1119 1505
 			} elseif ($format == 'beast') {
@@ -1123,27 +1509,59 @@  discard block
 block discarded – undo
1123 1509
 			    foreach($buffer as $all_data) {
1124 1510
 				$line = json_decode('{'.$all_data.'}',true);
1125 1511
 				$data = array();
1126
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1127
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1128
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1129
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1130
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1131
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1132
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1512
+				if (isset($line['Icao'])) {
1513
+					$data['hex'] = $line['Icao'];
1514
+				}
1515
+				// hex
1516
+				if (isset($line['Call'])) {
1517
+					$data['ident'] = $line['Call'];
1518
+				}
1519
+				// ident
1520
+				if (isset($line['Alt'])) {
1521
+					$data['altitude'] = $line['Alt'];
1522
+				}
1523
+				// altitude
1524
+				if (isset($line['Spd'])) {
1525
+					$data['speed'] = $line['Spd'];
1526
+				}
1527
+				// speed
1528
+				if (isset($line['Trak'])) {
1529
+					$data['heading'] = $line['Trak'];
1530
+				}
1531
+				// heading
1532
+				if (isset($line['Lat'])) {
1533
+					$data['latitude'] = $line['Lat'];
1534
+				}
1535
+				// lat
1536
+				if (isset($line['Long'])) {
1537
+					$data['longitude'] = $line['Long'];
1538
+				}
1539
+				// long
1133 1540
 				//$data['verticalrate'] = $line['']; // verticale rate
1134
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1541
+				if (isset($line['Sqk'])) {
1542
+					$data['squawk'] = $line['Sqk'];
1543
+				}
1544
+				// squawk
1135 1545
 				$data['emergency'] = ''; // emergency
1136
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1546
+				if (isset($line['Reg'])) {
1547
+					$data['registration'] = $line['Reg'];
1548
+				}
1137 1549
 				/*
1138 1550
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1139 1551
 				else $data['datetime'] = date('Y-m-d H:i:s');
1140 1552
 				*/
1141 1553
 				$data['datetime'] = date('Y-m-d H:i:s');
1142
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1554
+				if (isset($line['Type'])) {
1555
+					$data['aircraft_icao'] = $line['Type'];
1556
+				}
1143 1557
 		    		$data['format_source'] = 'vrstcp';
1144 1558
 				$data['id_source'] = $id_source;
1145
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1146
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1559
+				if (isset($value['name']) && $value['name'] != '') {
1560
+					$data['source_name'] = $value['name'];
1561
+				}
1562
+				if (isset($data['latitude']) && isset($data['hex'])) {
1563
+					$SI->add($data);
1564
+				}
1147 1565
 				unset($data);
1148 1566
 			    }
1149 1567
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1156,21 +1574,43 @@  discard block
 block discarded – undo
1156 1574
     				$data['hex'] = $lined['hexid'];
1157 1575
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158 1576
     				$data['datetime'] = date('Y-m-d H:i:s');;
1159
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1577
+    				if (isset($lined['ident'])) {
1578
+    					$data['ident'] = $lined['ident'];
1579
+    				}
1580
+    				if (isset($lined['lat'])) {
1581
+    					$data['latitude'] = $lined['lat'];
1582
+    				}
1583
+    				if (isset($lined['lon'])) {
1584
+    					$data['longitude'] = $lined['lon'];
1585
+    				}
1586
+    				if (isset($lined['speed'])) {
1587
+    					$data['speed'] = $lined['speed'];
1588
+    				}
1589
+    				if (isset($lined['squawk'])) {
1590
+    					$data['squawk'] = $lined['squawk'];
1591
+    				}
1592
+    				if (isset($lined['alt'])) {
1593
+    					$data['altitude'] = $lined['alt'];
1594
+    				}
1595
+    				if (isset($lined['heading'])) {
1596
+    					$data['heading'] = $lined['heading'];
1597
+    				}
1166 1598
     				$data['id_source'] = $id_source;
1167 1599
     				$data['format_source'] = 'tsv';
1168
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1600
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1601
+    					$data['source_name'] = $globalSources[$nb]['name'];
1602
+    				}
1603
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1604
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1605
+    				}
1606
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1607
+    					$SI->add($data);
1608
+    				}
1171 1609
     				unset($lined);
1172 1610
     				unset($data);
1173
-    			    } else $error = true;
1611
+    			    } else {
1612
+    			    	$error = true;
1613
+    			    }
1174 1614
 			} elseif ($format == 'aprs' && $use_aprs) {
1175 1615
 			    if ($aprs_connect == 0) {
1176 1616
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1196,49 +1636,82 @@  discard block
 block discarded – undo
1196 1636
 				    $aprs_last_tx = time();
1197 1637
 				    $data = array();
1198 1638
 				    //print_r($line);
1199
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1200
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1639
+				    if (isset($line['address'])) {
1640
+				    	$data['hex'] = $line['address'];
1641
+				    }
1642
+				    if (isset($line['timestamp'])) {
1643
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1644
+				    } else {
1645
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1646
+				    }
1202 1647
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1203
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1648
+				    if (isset($line['ident'])) {
1649
+				    	$data['ident'] = $line['ident'];
1650
+				    }
1204 1651
 				    $data['latitude'] = $line['latitude'];
1205 1652
 				    $data['longitude'] = $line['longitude'];
1206 1653
 				    //$data['verticalrate'] = $line[16];
1207
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
-				    else $data['speed'] = 0;
1209
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1654
+				    if (isset($line['speed'])) {
1655
+				    	$data['speed'] = $line['speed'];
1656
+				    } else {
1657
+				    	$data['speed'] = 0;
1658
+				    }
1659
+				    if (isset($line['altitude'])) {
1660
+				    	$data['altitude'] = $line['altitude'];
1661
+				    }
1662
+				    if (isset($line['comment'])) {
1663
+				    	$data['comment'] = $line['comment'];
1664
+				    }
1665
+				    if (isset($line['symbol'])) {
1666
+				    	$data['type'] = $line['symbol'];
1667
+				    }
1668
+				    if (isset($line['heading'])) {
1669
+				    	$data['heading'] = $line['heading'];
1670
+				    }
1213 1671
 				    //else $data['heading'] = 0;
1214
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1672
+				    if (isset($line['stealth'])) {
1673
+				    	$data['aircraft_type'] = $line['stealth'];
1674
+				    }
1675
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1676
+				    	$data['noarchive'] = true;
1677
+				    }
1216 1678
     				    $data['id_source'] = $id_source;
1217
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
-				    else $data['format_source'] = 'aprs';
1679
+    				    if (isset($line['format_source'])) {
1680
+    				    	$data['format_source'] = $line['format_source'];
1681
+    				    } else {
1682
+				    	$data['format_source'] = 'aprs';
1683
+				    }
1219 1684
 				    $data['source_name'] = $line['source'];
1220
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
-				    else $data['source_type'] = 'flarm';
1222
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1685
+				    if (isset($line['source_type'])) {
1686
+				    	$data['source_type'] = $line['source_type'];
1687
+				    } else {
1688
+				    	$data['source_type'] = 'flarm';
1689
+				    }
1690
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1691
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1692
+    				    }
1223 1693
 				    $currentdate = date('Y-m-d H:i:s');
1224 1694
 				    $aprsdate = strtotime($data['datetime']);
1225 1695
 				    // Accept data if time <= system time + 20s
1226 1696
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1227 1697
 					$send = $SI->add($data);
1228 1698
 				    } elseif (isset($line['stealth'])) {
1229
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1230
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1699
+					if ($line['stealth'] != 0) {
1700
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1701
+					} else {
1702
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1703
+					}
1231 1704
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232 1705
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1233 1706
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1234
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1707
+					if (isset($globalTracker) && $globalTracker) {
1708
+						$send = $TI->add($data);
1709
+					}
1235 1710
 				    }
1236 1711
 				    unset($data);
1237
-				} 
1238
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1712
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1239 1713
 					echo '!! Weather Station not yet supported'."\n";
1240
-				}
1241
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1714
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1242 1715
 					echo '!! Car & Trucks not yet supported'."\n";
1243 1716
 				}
1244 1717
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1271,25 +1744,42 @@  discard block
 block discarded – undo
1271 1744
     				$data['ground'] = $line[21];
1272 1745
     				$data['emergency'] = $line[19];
1273 1746
     				$data['format_source'] = 'sbs';
1274
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1275
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1748
+					$data['source_name'] = $globalSources[$nb]['name'];
1749
+				}
1750
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1751
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1752
+    				}
1276 1753
     				$data['id_source'] = $id_source;
1277
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
-    				else $error = true;
1754
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1755
+    					$send = $SI->add($data);
1756
+    				} else {
1757
+    					$error = true;
1758
+    				}
1279 1759
     				unset($data);
1280
-    			    } else $error = true;
1760
+    			    } else {
1761
+    			    	$error = true;
1762
+    			    }
1281 1763
 			    if ($error) {
1282 1764
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1283
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1765
+					if ($globalDebug) {
1766
+						echo "Not a message. Ignoring... \n";
1767
+					}
1284 1768
 				} else {
1285
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1769
+					if ($globalDebug) {
1770
+						echo "Wrong line format. Ignoring... \n";
1771
+					}
1286 1772
 					if ($globalDebug) {
1287 1773
 						echo $buffer;
1288 1774
 						print_r($line);
1289 1775
 					}
1290 1776
 					//socket_close($r);
1291
-					if ($globalDebug) echo "Reconnect after an error...\n";
1292
-					if ($format == 'aprs') $aprs_connect = 0;
1777
+					if ($globalDebug) {
1778
+						echo "Reconnect after an error...\n";
1779
+					}
1780
+					if ($format == 'aprs') {
1781
+						$aprs_connect = 0;
1782
+					}
1293 1783
 					$sourceer[$nb] = $globalSources[$nb];
1294 1784
 					connect_all($sourceer);
1295 1785
 					$sourceer = array();
@@ -1297,10 +1787,14 @@  discard block
 block discarded – undo
1297 1787
 			    }
1298 1788
 			}
1299 1789
 			// Sleep for xxx microseconds
1300
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1790
+			if (isset($globalSBSSleep)) {
1791
+				usleep($globalSBSSleep);
1792
+			}
1301 1793
 		    } else {
1302 1794
 			if ($format == 'flightgearmp') {
1303
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1795
+			    	if ($globalDebug) {
1796
+			    		echo "Reconnect FlightGear MP...";
1797
+			    	}
1304 1798
 				//@socket_close($r);
1305 1799
 				sleep($globalMinFetch);
1306 1800
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1309,10 +1803,15 @@  discard block
 block discarded – undo
1309 1803
 				break;
1310 1804
 				
1311 1805
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1312
-			    if (isset($tt[$format])) $tt[$format]++;
1313
-			    else $tt[$format] = 0;
1806
+			    if (isset($tt[$format])) {
1807
+			    	$tt[$format]++;
1808
+			    } else {
1809
+			    	$tt[$format] = 0;
1810
+			    }
1314 1811
 			    if ($tt[$format] > 30) {
1315
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1812
+				if ($globalDebug) {
1813
+					echo "ERROR : Reconnect ".$format."...";
1814
+				}
1316 1815
 				//@socket_close($r);
1317 1816
 				sleep(2);
1318 1817
 				$aprs_connect = 0;
@@ -1329,11 +1828,17 @@  discard block
 block discarded – undo
1329 1828
 	    } else {
1330 1829
 		$error = socket_strerror(socket_last_error());
1331 1830
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1332
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1333
-			if (isset($globalDebug)) echo "Restarting...\n";
1831
+			if ($globalDebug) {
1832
+				echo "ERROR : socket_select give this error ".$error . "\n";
1833
+			}
1834
+			if (isset($globalDebug)) {
1835
+				echo "Restarting...\n";
1836
+			}
1334 1837
 			// Restart the script if possible
1335 1838
 			if (is_array($sockets)) {
1336
-			    if ($globalDebug) echo "Shutdown all sockets...";
1839
+			    if ($globalDebug) {
1840
+			    	echo "Shutdown all sockets...";
1841
+			    }
1337 1842
 			    
1338 1843
 			    foreach ($sockets as $sock) {
1339 1844
 				@socket_shutdown($sock,2);
@@ -1341,18 +1846,24 @@  discard block
 block discarded – undo
1341 1846
 			    }
1342 1847
 			    
1343 1848
 			}
1344
-			if ($globalDebug) echo "Restart all connections...";
1849
+			if ($globalDebug) {
1850
+				echo "Restart all connections...";
1851
+			}
1345 1852
 			sleep(2);
1346 1853
 			$time = time();
1347 1854
 			//connect_all($hosts);
1348 1855
 			$aprs_connect = 0;
1349
-			if ($reset > 40) exit('Too many attempts...');
1856
+			if ($reset > 40) {
1857
+				exit('Too many attempts...');
1858
+			}
1350 1859
 			connect_all($globalSources);
1351 1860
 		}
1352 1861
 	    }
1353 1862
 	}
1354 1863
 	if ($globalDaemon === false) {
1355
-	    if ($globalDebug) echo 'Check all...'."\n";
1864
+	    if ($globalDebug) {
1865
+	    	echo 'Check all...'."\n";
1866
+	    }
1356 1867
 	    $SI->checkAll();
1357 1868
 	}
1358 1869
     }
Please login to merge, or discard this patch.
date.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/require/settings.php');
3 3
 $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING);
4
-if ($date == '') $date = date('Y-m-d');
4
+if ($date == '') {
5
+	$date = date('Y-m-d');
6
+}
5 7
 header('Location: '.$globalURL.'/date/'.$date);
6 8
 ?>
7 9
\ No newline at end of file
Please login to merge, or discard this patch.