Completed
Push — master ( f7c9fa...92ea23 )
by Yannick
27:20
created
require/class.ATC.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,7 +7,9 @@  discard block
 block discarded – undo
7 7
 	public function __construct($dbc = null) {
8 8
 		$Connection = new Connection($dbc);
9 9
 		$this->db = $Connection->db;
10
-		if ($this->db === null) die('Error: No DB connection. (ATC)');
10
+		if ($this->db === null) {
11
+			die('Error: No DB connection. (ATC)');
12
+		}
11 13
 	}
12 14
 
13 15
 	/**
@@ -20,20 +22,27 @@  discard block
 block discarded – undo
20 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 24
 				foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-					if (isset($source['source'])) $filter['source'][] = $source['source'];
25
+					if (isset($source['source'])) {
26
+						$filter['source'][] = $source['source'];
27
+					}
24 28
 				}
25 29
 			} else {
26 30
 				$filter = $globalStatsFilters[$globalFilterName];
27 31
 			}
28 32
 		}
29
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) {
34
+			$filter = array_merge($filter,$globalFilter);
35
+		}
30 36
 		$filter_query_join = '';
31 37
 		$filter_query_where = '';
32 38
 		if (isset($filter['source']) && !empty($filter['source'])) {
33 39
 			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 40
 		}
35
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
41
+		if ($filter_query_where == '' && $where) {
42
+			$filter_query_where = ' WHERE';
43
+		} elseif ($filter_query_where != '' && $and) {
44
+			$filter_query_where .= ' AND';
45
+		}
37 46
 		$filter_query = $filter_query_join.$filter_query_where;
38 47
 		return $filter_query;
39 48
 	}
@@ -90,7 +99,9 @@  discard block
 block discarded – undo
90 99
 		$info = str_replace('^','<br />',$info);
91 100
 		$info = str_replace('&amp;sect;','',$info);
92 101
 		$info = str_replace('"','',$info);
93
-		if ($type == '') $type = NULL;
102
+		if ($type == '') {
103
+			$type = NULL;
104
+		}
94 105
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95 106
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
96 107
 		try {
@@ -106,7 +117,9 @@  discard block
 block discarded – undo
106 117
 		$info = str_replace('^','<br />',$info);
107 118
 		$info = str_replace('&amp;sect;','',$info);
108 119
 		$info = str_replace('"','',$info);
109
-		if ($type == '') $type = NULL;
120
+		if ($type == '') {
121
+			$type = NULL;
122
+		}
110 123
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111 124
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
112 125
 		try {
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +113 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (MarineLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -119,9 +126,13 @@  discard block
 block discarded – undo
119 126
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
120 127
 			}
121 128
 		}
122
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
129
+		if ($orderby_query == '') {
130
+			$orderby_query= ' ORDER BY date DESC';
131
+		}
123 132
 
124
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
133
+		if (!isset($globalLiveInterval)) {
134
+			$globalLiveInterval = '200';
135
+		}
125 136
 		if ($globalDBdriver == 'mysql') {
126 137
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
127 138
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -146,7 +157,9 @@  discard block
 block discarded – undo
146 157
 
147 158
 		$filter_query = $this->getFilter($filter,true,true);
148 159
 
149
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
160
+		if (!isset($globalLiveInterval)) {
161
+			$globalLiveInterval = '200';
162
+		}
150 163
 		if ($globalDBdriver == 'mysql') {
151 164
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
152 165
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -187,48 +200,72 @@  discard block
 block discarded – undo
187 200
 		}
188 201
 		$filter_query = $this->getFilter($filter,true,true);
189 202
 
190
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
191
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
203
+		if (!isset($globalLiveInterval)) {
204
+			$globalLiveInterval = '200';
205
+		}
206
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
207
+			$globalMap3DMarinesLimit = '300';
208
+		}
192 209
 		if ($globalDBdriver == 'mysql') {
193 210
 			if (isset($globalArchive) && $globalArchive === TRUE) {
194 211
 				$query  = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
195 212
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
196
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
213
+				if ($usecoord) {
214
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				}
197 216
 				$query .= "UNION
198 217
 				    SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
199 218
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
200
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
219
+				if ($usecoord) {
220
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				}
201 222
 				$query .= ") AS marine 
202 223
 				    WHERE latitude <> '0' AND longitude <> '0' 
203 224
 				    ORDER BY fammarine_id, date";
204
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
225
+				if ($limit) {
226
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
227
+				}
205 228
 			} else {
206 229
 				$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
207 230
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
208
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
231
+				if ($usecoord) {
232
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				}
209 234
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
210 235
 				ORDER BY marine_live.fammarine_id, marine_live.date";
211
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
236
+				if ($limit) {
237
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
238
+				}
212 239
 			}
213 240
 		} else {
214 241
 			if (isset($globalArchive) && $globalArchive === TRUE) {
215 242
 				$query  = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source 
216 243
 				    FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id ";
217
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
244
+				if ($usecoord) {
245
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
246
+				}
218 247
 				$query .= "UNION
219 248
 				    SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
220 249
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
221
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
250
+				if ($usecoord) {
251
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
252
+				}
222 253
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
223 254
 				$query .= "ORDER BY fammarine_id, date";
224
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
255
+				if ($limit) {
256
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
257
+				}
225 258
 			} else {
226 259
 				$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
227 260
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
228
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
261
+				if ($usecoord) {
262
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
263
+				}
229 264
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
230 265
 				ORDER BY marine_live.fammarine_id, marine_live.date";
231
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
266
+				if ($limit) {
267
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
268
+				}
232 269
 			}
233 270
 		}
234 271
 		try {
@@ -253,7 +290,9 @@  discard block
 block discarded – undo
253 290
 		global $globalDBdriver, $globalLiveInterval;
254 291
 		$filter_query = $this->getFilter($filter,true,true);
255 292
 
256
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
293
+		if (!isset($globalLiveInterval)) {
294
+			$globalLiveInterval = '200';
295
+		}
257 296
 		if ($globalDBdriver == 'mysql') {
258 297
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
259 298
 		} else {
@@ -281,7 +320,9 @@  discard block
 block discarded – undo
281 320
 	{
282 321
 		global $globalDBdriver, $globalLiveInterval;
283 322
 		$Marine = new Marine($this->db);
284
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
323
+		if (!isset($globalLiveInterval)) {
324
+			$globalLiveInterval = '200';
325
+		}
285 326
 		$filter_query = $this->getFilter($filter);
286 327
 
287 328
 		if (is_array($coord)) {
@@ -289,7 +330,9 @@  discard block
 block discarded – undo
289 330
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
290 331
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
291 332
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
292
-		} else return array();
333
+		} else {
334
+			return array();
335
+		}
293 336
 		if ($globalDBdriver == 'mysql') {
294 337
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
295 338
 		} else {
@@ -309,7 +352,9 @@  discard block
 block discarded – undo
309 352
 	{
310 353
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
311 354
 		$Marine = new Marine($this->db);
312
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
355
+		if (!isset($globalLiveInterval)) {
356
+			$globalLiveInterval = '200';
357
+		}
313 358
 		$filter_query = $this->getFilter($filter,true,true);
314 359
 
315 360
 		if (is_array($coord)) {
@@ -317,7 +362,9 @@  discard block
 block discarded – undo
317 362
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
318 363
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
319 364
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
320
-		} else return array();
365
+		} else {
366
+			return array();
367
+		}
321 368
 		/*
322 369
 		if ($globalDBdriver == 'mysql') {
323 370
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
@@ -526,11 +573,15 @@  discard block
 block discarded – undo
526 573
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
527 574
 		if ($globalDBdriver == 'mysql') {
528 575
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
529
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
576
+			if ($liveinterval) {
577
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
578
+			}
530 579
 			$query .= ' ORDER BY date';
531 580
 		} else {
532 581
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
533
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
582
+			if ($liveinterval) {
583
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
584
+			}
534 585
 			$query .= ' ORDER BY date';
535 586
 		}
536 587
 
@@ -625,7 +676,9 @@  discard block
 block discarded – undo
625 676
 				$i++;
626 677
 				$j++;
627 678
 				if ($j == 30) {
628
-					if ($globalDebug) echo ".";
679
+					if ($globalDebug) {
680
+						echo ".";
681
+					}
629 682
 				    	try {
630 683
 						
631 684
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -905,7 +958,9 @@  discard block
 block discarded – undo
905 958
 			{
906 959
 				return false;
907 960
 			}
908
-		} else return '';
961
+		} else {
962
+			return '';
963
+		}
909 964
 
910 965
 		if ($longitude != '')
911 966
 		{
@@ -913,7 +968,9 @@  discard block
 block discarded – undo
913 968
 			{
914 969
 				return false;
915 970
 			}
916
-		} else return '';
971
+		} else {
972
+			return '';
973
+		}
917 974
 
918 975
 
919 976
 		if ($heading != '')
@@ -922,7 +979,9 @@  discard block
 block discarded – undo
922 979
 			{
923 980
 				return false;
924 981
 			}
925
-		} else $heading = 0;
982
+		} else {
983
+			$heading = 0;
984
+		}
926 985
 
927 986
 		if ($groundspeed != '')
928 987
 		{
@@ -930,9 +989,13 @@  discard block
 block discarded – undo
930 989
 			{
931 990
 				return false;
932 991
 			}
933
-		} else $groundspeed = 0;
992
+		} else {
993
+			$groundspeed = 0;
994
+		}
934 995
 		date_default_timezone_set('UTC');
935
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
996
+		if ($date == '') {
997
+			$date = date("Y-m-d H:i:s", time());
998
+		}
936 999
 
937 1000
         
938 1001
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,20 @@  discard block
 block discarded – undo
953 1016
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
954 1017
 		
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
958
-            	if ($arrival_date == '') $arrival_date = NULL;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
1025
+            	if ($arrival_date == '') {
1026
+            		$arrival_date = NULL;
1027
+            	}
959 1028
             	$query = '';
960 1029
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1030
+			if ($globalDebug) {
1031
+				echo '-- Delete previous data -- ';
1032
+			}
962 1033
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
963 1034
 		}
964 1035
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
@@ -974,10 +1045,14 @@  discard block
 block discarded – undo
974 1045
 		}
975 1046
 		
976 1047
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
977
-			if ($globalDebug) echo '(Add to Marine archive : ';
1048
+			if ($globalDebug) {
1049
+				echo '(Add to Marine archive : ';
1050
+			}
978 1051
 			$MarineArchive = new MarineArchive($this->db);
979 1052
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country);
980
-			if ($globalDebug) echo $result.')';
1053
+			if ($globalDebug) {
1054
+				echo $result.')';
1055
+			}
981 1056
 		}
982 1057
 		return "success";
983 1058
 	}
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +110 added lines, -37 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (TrackerLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (TrackerLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -77,8 +81,11 @@  discard block
 block discarded – undo
77 81
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
78 82
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
79 83
 		}
80
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
81
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
84
+		if ($filter_query_where == '' && $where) {
85
+			$filter_query_where = ' WHERE';
86
+		} elseif ($filter_query_where != '' && $and) {
87
+			$filter_query_where .= ' AND';
88
+		}
82 89
 		if ($filter_query_where != '') {
83 90
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
84 91
 		}
@@ -120,7 +127,9 @@  discard block
 block discarded – undo
120 127
 			}
121 128
 		}
122 129
 
123
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
130
+		if (!isset($globalLiveInterval)) {
131
+			$globalLiveInterval = '200';
132
+		}
124 133
 		if ($globalDBdriver == 'mysql') {
125 134
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
126 135
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -145,7 +154,9 @@  discard block
 block discarded – undo
145 154
 
146 155
 		$filter_query = $this->getFilter($filter,true,true);
147 156
 
148
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
157
+		if (!isset($globalLiveInterval)) {
158
+			$globalLiveInterval = '200';
159
+		}
149 160
 		if ($globalDBdriver == 'mysql') {
150 161
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
151 162
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -190,50 +201,74 @@  discard block
 block discarded – undo
190 201
 		}
191 202
 		$filter_query = $this->getFilter($filter,true,true);
192 203
 
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
-		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') $globalMap3DTrackersLimit = '300';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
207
+		if (!isset($globalMap3DTrackersLimit) || $globalMap3DTrackersLimit == '') {
208
+			$globalMap3DTrackersLimit = '300';
209
+		}
195 210
 		if ($globalDBdriver == 'mysql') {
196 211
 			if (isset($globalArchive) && $globalArchive) {
197 212
 				$query  = "SELECT * FROM (
198 213
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
199 214
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
200
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
215
+				if ($usecoord) {
216
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
217
+				}
201 218
 				$query .= "UNION
202 219
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
203 220
 					FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
204
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
221
+				if ($usecoord) {
222
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
223
+				}
205 224
 				$query .= ") AS tracker
206 225
 				    WHERE latitude <> '0' AND longitude <> '0' 
207 226
 				    ORDER BY famtrackid, date";
208
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
227
+				if ($limit) {
228
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
229
+				}
209 230
 			} else {
210 231
 				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
211 232
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date ";
212
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
233
+				if ($usecoord) {
234
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
235
+				}
213 236
 				$query .= "AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
214 237
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
215
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
238
+				if ($limit) {
239
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
240
+				}
216 241
 			}
217 242
 		} else {
218 243
 			if (isset($globalArchive) && $globalArchive) {
219 244
 				$query  = "SELECT * FROM (
220 245
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
221 246
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid ";
222
-				if ($usecoord) $query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
247
+				if ($usecoord) {
248
+					$query .= "AND tracker_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
249
+				}
223 250
 				$query .= "UNION
224 251
 					SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
225 252
 					FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date";
226
-				if ($usecoord) $query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
253
+				if ($usecoord) {
254
+					$query .= " AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
255
+				}
227 256
 				$query .= ") AS tracker
228 257
 				    WHERE latitude <> '0' AND longitude <> '0' 
229 258
 				    ORDER BY famtrackid, date";
230
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
259
+				if ($limit) {
260
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
261
+				}
231 262
 			} else {
232 263
 				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
233 264
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' ";
234
-				if ($usecoord) $query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
265
+				if ($usecoord) {
266
+					$query .= "AND tracker_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND tracker_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
267
+				}
235 268
 				$query .= "ORDER BY tracker_live.famtrackid, tracker_live.date";
236
-				if ($limit) $query .= " LIMIT ".$globalMap3DTrackersLimit;
269
+				if ($limit) {
270
+					$query .= " LIMIT ".$globalMap3DTrackersLimit;
271
+				}
237 272
 			}
238 273
 		}
239 274
 
@@ -259,7 +294,9 @@  discard block
 block discarded – undo
259 294
 		global $globalDBdriver, $globalLiveInterval;
260 295
 		$filter_query = $this->getFilter($filter,true,true);
261 296
 
262
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
297
+		if (!isset($globalLiveInterval)) {
298
+			$globalLiveInterval = '200';
299
+		}
263 300
 		if ($globalDBdriver == 'mysql') {
264 301
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
265 302
 		} else {
@@ -287,7 +324,9 @@  discard block
 block discarded – undo
287 324
 	{
288 325
 		global $globalDBdriver, $globalLiveInterval;
289 326
 		$Tracker = new Tracker($this->db);
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
327
+		if (!isset($globalLiveInterval)) {
328
+			$globalLiveInterval = '200';
329
+		}
291 330
 		$filter_query = $this->getFilter($filter);
292 331
 
293 332
 		if (is_array($coord)) {
@@ -295,7 +334,9 @@  discard block
 block discarded – undo
295 334
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
296 335
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
297 336
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
298
-		} else return array();
337
+		} else {
338
+			return array();
339
+		}
299 340
 		if ($globalDBdriver == 'mysql') {
300 341
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
301 342
 		} else {
@@ -315,7 +356,9 @@  discard block
 block discarded – undo
315 356
 	{
316 357
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
317 358
 		$Tracker = new Tracker($this->db);
318
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
+		if (!isset($globalLiveInterval)) {
360
+			$globalLiveInterval = '200';
361
+		}
319 362
 		$filter_query = $this->getFilter($filter,true,true);
320 363
 
321 364
 		if (is_array($coord)) {
@@ -323,7 +366,9 @@  discard block
 block discarded – undo
323 366
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324 367
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325 368
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-		} else return array();
369
+		} else {
370
+			return array();
371
+		}
327 372
 		/*
328 373
 		if ($globalDBdriver == 'mysql') {
329 374
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
@@ -557,11 +602,15 @@  discard block
 block discarded – undo
557 602
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
558 603
 		if ($globalDBdriver == 'mysql') {
559 604
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
560
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
605
+			if ($liveinterval) {
606
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
607
+			}
561 608
 			$query .= ' ORDER BY date';
562 609
 		} else {
563 610
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
564
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
611
+			if ($liveinterval) {
612
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
613
+			}
565 614
 			$query .= ' ORDER BY date';
566 615
 		}
567 616
 
@@ -656,7 +705,9 @@  discard block
 block discarded – undo
656 705
 				$i++;
657 706
 				$j++;
658 707
 				if ($j == 30) {
659
-					if ($globalDebug) echo ".";
708
+					if ($globalDebug) {
709
+						echo ".";
710
+					}
660 711
 				    	try {
661 712
 						
662 713
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -903,7 +954,9 @@  discard block
 block discarded – undo
903 954
 			{
904 955
 				return false;
905 956
 			}
906
-		} else return '';
957
+		} else {
958
+			return '';
959
+		}
907 960
 
908 961
 		if ($longitude != '')
909 962
 		{
@@ -911,7 +964,9 @@  discard block
 block discarded – undo
911 964
 			{
912 965
 				return false;
913 966
 			}
914
-		} else return '';
967
+		} else {
968
+			return '';
969
+		}
915 970
 
916 971
 		if ($altitude != '')
917 972
 		{
@@ -919,7 +974,9 @@  discard block
 block discarded – undo
919 974
 			{
920 975
 				return false;
921 976
 			}
922
-		} else $altitude = 0;
977
+		} else {
978
+			$altitude = 0;
979
+		}
923 980
 
924 981
 		if ($heading != '')
925 982
 		{
@@ -927,7 +984,9 @@  discard block
 block discarded – undo
927 984
 			{
928 985
 				return false;
929 986
 			}
930
-		} else $heading = 0;
987
+		} else {
988
+			$heading = 0;
989
+		}
931 990
 
932 991
 		if ($groundspeed != '')
933 992
 		{
@@ -935,9 +994,13 @@  discard block
 block discarded – undo
935 994
 			{
936 995
 				return false;
937 996
 			}
938
-		} else $groundspeed = 0;
997
+		} else {
998
+			$groundspeed = 0;
999
+		}
939 1000
 		date_default_timezone_set('UTC');
940
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1001
+		if ($date == '') {
1002
+			$date = date("Y-m-d H:i:s", time());
1003
+		}
941 1004
 
942 1005
         
943 1006
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -953,12 +1016,18 @@  discard block
 block discarded – undo
953 1016
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
954 1017
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
955 1018
 
956
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
957
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1019
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1020
+            		$groundspeed = 0;
1021
+            	}
1022
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1023
+            		$heading = 0;
1024
+            	}
958 1025
             	
959 1026
 		$query = '';
960 1027
 		if ($globalArchive) {
961
-			if ($globalDebug) echo '-- Delete previous data -- ';
1028
+			if ($globalDebug) {
1029
+				echo '-- Delete previous data -- ';
1030
+			}
962 1031
 			$query .= 'DELETE FROM tracker_live WHERE famtrackid = :famtrackid;';
963 1032
 		}
964 1033
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
@@ -977,10 +1046,14 @@  discard block
 block discarded – undo
977 1046
                 echo 'noarchive : '.$noarchive."\n";
978 1047
                 */
979 1048
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
980
-		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
1049
+		    if ($globalDebug) {
1050
+		    	echo '(Add to Tracker archive '.$famtrackid.' : ';
1051
+		    }
981 1052
 		    $TrackerArchive = new TrackerArchive($this->db);
982 1053
 		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
983
-		    if ($globalDebug) echo $result.')';
1054
+		    if ($globalDebug) {
1055
+		    	echo $result.')';
1056
+		    }
984 1057
 		}
985 1058
 
986 1059
 		return "success";
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +122 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -123,8 +127,11 @@  discard block
 block discarded – undo
123 127
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
124 128
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
125 129
 		}
126
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
127
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
130
+		if ($filter_query_where == '' && $where) {
131
+			$filter_query_where = ' WHERE';
132
+		} elseif ($filter_query_where != '' && $and) {
133
+			$filter_query_where .= ' AND';
134
+		}
128 135
 		if ($filter_query_where != '') {
129 136
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
130 137
 		}
@@ -165,9 +172,13 @@  discard block
 block discarded – undo
165 172
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
166 173
 			}
167 174
 		}
168
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
175
+		if ($orderby_query == '') {
176
+			$orderby_query = ' ORDER BY date DESC';
177
+		}
169 178
 
170
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
179
+		if (!isset($globalLiveInterval)) {
180
+			$globalLiveInterval = '200';
181
+		}
171 182
 		if ($globalDBdriver == 'mysql') {
172 183
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
173 184
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -190,7 +201,9 @@  discard block
 block discarded – undo
190 201
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
191 202
 		date_default_timezone_set('UTC');
192 203
 		$filter_query = $this->getFilter($filter,true,true);
193
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
204
+		if (!isset($globalLiveInterval)) {
205
+			$globalLiveInterval = '200';
206
+		}
194 207
 		if ($globalDBdriver == 'mysql') {
195 208
 			if (isset($globalArchive) && $globalArchive === TRUE) {
196 209
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -240,8 +253,12 @@  discard block
 block discarded – undo
240 253
 		}
241 254
 		$filter_query = $this->getFilter($filter,true,true);
242 255
 
243
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
244
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
256
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
257
+			$globalLiveInterval = '200';
258
+		}
259
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
260
+			$globalMap3DAircraftsLimit = '300';
261
+		}
245 262
 		if ($globalDBdriver == 'mysql') {
246 263
 			if (isset($globalArchive) && $globalArchive === TRUE) {
247 264
 				/*
@@ -252,22 +269,32 @@  discard block
 block discarded – undo
252 269
 				*/
253 270
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
254 271
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
255
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
272
+				if ($usecoord) {
273
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
274
+				}
256 275
 				$query .= "UNION
257 276
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
258 277
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
259
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
278
+				if ($usecoord) {
279
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
280
+				}
260 281
 				$query .= ") AS spotter 
261 282
 				WHERE latitude <> '0' AND longitude <> '0' 
262 283
 				ORDER BY flightaware_id, date";
263
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
284
+				if ($limit) {
285
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
286
+				}
264 287
 			} else {
265 288
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
266 289
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
267
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
290
+				if ($usecoord) {
291
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
292
+				}
268 293
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
269 294
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
270
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
295
+				if ($limit) {
296
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
297
+				}
271 298
 			}
272 299
 		} else {
273 300
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -279,21 +306,31 @@  discard block
 block discarded – undo
279 306
                                */
280 307
 				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
281 308
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
282
-				if ($usecoord) $query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
309
+				if ($usecoord) {
310
+					$query .= "AND spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
311
+				}
283 312
 				$query .= "UNION
284 313
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
285 314
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
286
-				if ($usecoord) $query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
315
+				if ($usecoord) {
316
+					$query .= " AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
317
+				}
287 318
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
288 319
 				$query .= "ORDER BY flightaware_id, date";
289
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
320
+				if ($limit) {
321
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
322
+				}
290 323
 			} else {
291 324
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
292 325
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
293
-				if ($usecoord) $query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
326
+				if ($usecoord) {
327
+					$query .= "AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
328
+				}
294 329
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
295 330
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
296
-				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
331
+				if ($limit) {
332
+					$query .= " LIMIT ".$globalMap3DAircraftsLimit;
333
+				}
297 334
 			}
298 335
 		}
299 336
 		try {
@@ -318,7 +355,9 @@  discard block
 block discarded – undo
318 355
 		global $globalDBdriver, $globalLiveInterval;
319 356
 		$filter_query = $this->getFilter($filter,true,true);
320 357
 
321
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
358
+		if (!isset($globalLiveInterval)) {
359
+			$globalLiveInterval = '200';
360
+		}
322 361
 		if ($globalDBdriver == 'mysql') {
323 362
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
324 363
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -348,7 +387,9 @@  discard block
 block discarded – undo
348 387
 	{
349 388
 		global $globalDBdriver, $globalLiveInterval;
350 389
 		$Spotter = new Spotter($this->db);
351
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
390
+		if (!isset($globalLiveInterval)) {
391
+			$globalLiveInterval = '200';
392
+		}
352 393
 		$filter_query = $this->getFilter($filter);
353 394
 
354 395
 		if (is_array($coord)) {
@@ -356,7 +397,9 @@  discard block
 block discarded – undo
356 397
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357 398
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
358 399
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
359
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
360 403
 		if ($globalDBdriver == 'mysql') {
361 404
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
362 405
 		} else {
@@ -377,7 +420,9 @@  discard block
 block discarded – undo
377 420
 	{
378 421
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
379 422
 		$Spotter = new Spotter($this->db);
380
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
423
+		if (!isset($globalLiveInterval)) {
424
+			$globalLiveInterval = '200';
425
+		}
381 426
 		$filter_query = $this->getFilter($filter,true,true);
382 427
 
383 428
 		if (is_array($coord)) {
@@ -385,7 +430,9 @@  discard block
 block discarded – undo
385 430
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
386 431
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
387 432
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
388
-		} else return array();
433
+		} else {
434
+			return array();
435
+		}
389 436
 		if ($globalDBdriver == 'mysql') {
390 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
391 438
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -612,11 +659,15 @@  discard block
 block discarded – undo
612 659
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
613 660
 		if ($globalDBdriver == 'mysql') {
614 661
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
615
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
662
+			if ($liveinterval) {
663
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
664
+			}
616 665
 			$query .= ' ORDER BY date';
617 666
 		} else {
618 667
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
619
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
668
+			if ($liveinterval) {
669
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
670
+			}
620 671
 			$query .= ' ORDER BY date';
621 672
 		}
622 673
 
@@ -711,7 +762,9 @@  discard block
 block discarded – undo
711 762
 				$i++;
712 763
 				$j++;
713 764
 				if ($j == 30) {
714
-					if ($globalDebug) echo ".";
765
+					if ($globalDebug) {
766
+						echo ".";
767
+					}
715 768
 				    	try {
716 769
 						
717 770
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1018,7 +1071,9 @@  discard block
 block discarded – undo
1018 1071
 			{
1019 1072
 				return false;
1020 1073
 			}
1021
-		} else return '';
1074
+		} else {
1075
+			return '';
1076
+		}
1022 1077
 
1023 1078
 		if ($longitude != '')
1024 1079
 		{
@@ -1026,7 +1081,9 @@  discard block
 block discarded – undo
1026 1081
 			{
1027 1082
 				return false;
1028 1083
 			}
1029
-		} else return '';
1084
+		} else {
1085
+			return '';
1086
+		}
1030 1087
 
1031 1088
 		if ($waypoints != '')
1032 1089
 		{
@@ -1042,14 +1099,18 @@  discard block
 block discarded – undo
1042 1099
 			{
1043 1100
 				return false;
1044 1101
 			}
1045
-		} else $altitude = 0;
1102
+		} else {
1103
+			$altitude = 0;
1104
+		}
1046 1105
 		if ($altitude_real != '')
1047 1106
 		{
1048 1107
 			if (!is_numeric($altitude_real))
1049 1108
 			{
1050 1109
 				return false;
1051 1110
 			}
1052
-		} else $altitude_real = 0;
1111
+		} else {
1112
+			$altitude_real = 0;
1113
+		}
1053 1114
 
1054 1115
 		if ($heading != '')
1055 1116
 		{
@@ -1057,7 +1118,9 @@  discard block
 block discarded – undo
1057 1118
 			{
1058 1119
 				return false;
1059 1120
 			}
1060
-		} else $heading = 0;
1121
+		} else {
1122
+			$heading = 0;
1123
+		}
1061 1124
 
1062 1125
 		if ($groundspeed != '')
1063 1126
 		{
@@ -1065,9 +1128,13 @@  discard block
 block discarded – undo
1065 1128
 			{
1066 1129
 				return false;
1067 1130
 			}
1068
-		} else $groundspeed = 0;
1131
+		} else {
1132
+			$groundspeed = 0;
1133
+		}
1069 1134
 		date_default_timezone_set('UTC');
1070
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1135
+		if ($date == '') {
1136
+			$date = date("Y-m-d H:i:s", time());
1137
+		}
1071 1138
 
1072 1139
         
1073 1140
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1112,14 +1179,24 @@  discard block
 block discarded – undo
1112 1179
 		$arrival_airport_country = '';
1113 1180
 		
1114 1181
             	
1115
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1116
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1117
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1118
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1182
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1183
+            		$squawk = NULL;
1184
+            	}
1185
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1186
+            		$verticalrate = NULL;
1187
+            	}
1188
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1189
+            		$groundspeed = 0;
1190
+            	}
1191
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1192
+            		$heading = 0;
1193
+            	}
1119 1194
 		
1120 1195
 		$query = '';
1121 1196
 		if ($globalArchive) {
1122
-			if ($globalDebug) echo '-- Delete previous data -- ';
1197
+			if ($globalDebug) {
1198
+				echo '-- Delete previous data -- ';
1199
+			}
1123 1200
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1124 1201
 		}
1125 1202
 
@@ -1136,10 +1213,14 @@  discard block
 block discarded – undo
1136 1213
 			return "error : ".$e->getMessage();
1137 1214
 		}
1138 1215
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1139
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1216
+		    if ($globalDebug) {
1217
+		    	echo '(Add to SBS archive : ';
1218
+		    }
1140 1219
 		    $SpotterArchive = new SpotterArchive($this->db);
1141 1220
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1142
-		    if ($globalDebug) echo $result.')';
1221
+		    if ($globalDebug) {
1222
+		    	echo $result.')';
1223
+		    }
1143 1224
 		} elseif ($globalDebug && $putinarchive !== true) {
1144 1225
 			echo '(Not adding to archive)';
1145 1226
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +401 added lines, -143 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,17 +108,25 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $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']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$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']));
116 132
        }
@@ -132,14 +148,18 @@  discard block
 block discarded – undo
132 148
 
133 149
     public function checkAll() {
134 150
 	global $globalDebug, $globalNoImport;
135
-	if ($globalDebug) echo "Update last seen flights data...\n";
151
+	if ($globalDebug) {
152
+		echo "Update last seen flights data...\n";
153
+	}
136 154
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137 155
 	    foreach ($this->all_flights as $key => $flight) {
138 156
 		if (isset($this->all_flights[$key]['id'])) {
139 157
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140 158
     		    $Spotter = new Spotter($this->db);
141 159
         	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
160
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
161
+        	    	$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']);
162
+        	    }
143 163
         	}
144 164
 	    }
145 165
 	}
@@ -147,24 +167,32 @@  discard block
 block discarded – undo
147 167
 
148 168
     public function arrival($key) {
149 169
 	global $globalClosestMinDist, $globalDebug;
150
-	if ($globalDebug) echo 'Update arrival...'."\n";
170
+	if ($globalDebug) {
171
+		echo 'Update arrival...'."\n";
172
+	}
151 173
 	$Spotter = new Spotter($this->db);
152 174
         $airport_icao = '';
153 175
         $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
176
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
177
+        	$globalClosestMinDist = 50;
178
+        }
155 179
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156 180
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157 181
     	    if (isset($closestAirports[0])) {
158 182
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159 183
         	    $airport_icao = $closestAirports[0]['icao'];
160 184
         	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        	    if ($globalDebug) {
186
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
187
+        	    }
162 188
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163 189
         	    foreach ($closestAirports as $airport) {
164 190
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165 191
         		    $airport_icao = $airport['icao'];
166 192
         		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
193
+        		    if ($globalDebug) {
194
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        		    }
168 196
         		    break;
169 197
         		}
170 198
         	    }
@@ -172,14 +200,20 @@  discard block
 block discarded – undo
172 200
         		$airport_icao = $closestAirports[0]['icao'];
173 201
         		$airport_time = $this->all_flights[$key]['datetime'];
174 202
         	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
203
+        		if ($globalDebug) {
204
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
205
+        		}
176 206
         	}
177 207
     	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
208
+    		    if ($globalDebug) {
209
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
210
+    		    }
179 211
     	    }
180 212
 
181 213
         } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
214
+        	if ($globalDebug) {
215
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
216
+        	}
183 217
         }
184 218
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185 219
     }
@@ -189,7 +223,9 @@  discard block
 block discarded – undo
189 223
     public function del() {
190 224
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 225
 	// Delete old infos
192
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
226
+	if ($globalDebug) {
227
+		echo 'Delete old values and update latest data...'."\n";
228
+	}
193 229
 	foreach ($this->all_flights as $key => $flight) {
194 230
 	    if (isset($flight['lastupdate'])) {
195 231
 		if ($flight['lastupdate'] < (time()-5900)) {
@@ -203,13 +239,17 @@  discard block
 block discarded – undo
203 239
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 240
 	// Delete old infos
205 241
 	if (isset($this->all_flights[$key]['id'])) {
206
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
242
+		if ($globalDebug) {
243
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
244
+		}
207 245
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
208 246
 			$real_arrival = $this->arrival($key);
209 247
 			$Spotter = new Spotter($this->db);
210 248
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
211 249
 				$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']);
212
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250
+				if ($globalDebug && $result != 'success') {
251
+					echo '!!! ERROR : '.$result."\n";
252
+				}
213 253
 			}
214 254
 		}
215 255
 	}
@@ -219,9 +259,13 @@  discard block
 block discarded – undo
219 259
     public function add($line) {
220 260
 	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, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass;
221 261
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
223
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
224
-/*
262
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
263
+		$globalCoordMinChange = '0.01';
264
+	}
265
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
266
+		$globalAircraftMaxUpdate = 3000;
267
+	}
268
+	/*
225 269
 	$Spotter = new Spotter();
226 270
 	$dbc = $Spotter->db;
227 271
 	$SpotterLive = new SpotterLive($dbc);
@@ -243,19 +287,28 @@  discard block
 block discarded – undo
243 287
 	// SBS format is CSV format
244 288
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245 289
 	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
290
+	    if (isset($line['hex'])) {
291
+	    	$line['hex'] = strtoupper($line['hex']);
292
+	    }
247 293
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 294
 
249 295
 		// Increment message number
250 296
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251 297
 		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
298
+		    if (isset($line['source_name'])) {
299
+		    	$source = $line['source_name'];
300
+		    } else {
301
+		    	$source = '';
302
+		    }
303
+		    if ($source == '' || $line['format_source'] == 'aprs') {
304
+		    	$source = $line['format_source'];
305
+		    }
255 306
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256 307
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257 308
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
309
+		    } else {
310
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
311
+		    }
259 312
 		}
260 313
 		
261 314
 		/*
@@ -271,23 +324,38 @@  discard block
 block discarded – undo
271 324
 		//$this->db = $dbc;
272 325
 
273 326
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
327
+	        if (!isset($line['id'])) {
328
+	        	$id = trim($line['hex']);
329
+	        } else {
330
+	        	$id = trim($line['id']);
331
+	        }
276 332
 		
277 333
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
334
+		    if ($globalDebug) {
335
+		    	echo 'New flight...'."\n";
336
+		    }
279 337
 		    $this->all_flights[$id] = array();
280 338
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', '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' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
340
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
341
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
342
+		    }
283 343
 		    if (!isset($line['id'])) {
284
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285
-//			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')));
344
+			if (!isset($globalDaemon)) {
345
+				$globalDaemon = TRUE;
346
+			}
347
+			//			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')));
286 348
 //			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')));
287
-			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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
349
+			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' || $line['format_source'] === 'famaprs')) {
350
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
351
+			}
288 352
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
353
+		     } else {
354
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
355
+		     }
356
+		    if ($globalAllFlights !== FALSE) {
357
+		    	$dataFound = true;
358
+		    }
291 359
 		}
292 360
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -309,12 +377,20 @@  discard block
 block discarded – undo
309 377
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310 378
 			    }
311 379
 			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
380
+			    if ($globalDebugTimeElapsed) {
381
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+			    }
383
+			    if ($aircraft_icao != '') {
384
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
385
+			    }
314 386
 			}
315 387
 		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
388
+		    if ($globalAllFlights !== FALSE) {
389
+		    	$dataFound = true;
390
+		    }
391
+		    if ($globalDebug) {
392
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
393
+		    }
318 394
 		}
319 395
 	        if (isset($line['id']) && !isset($line['hex'])) {
320 396
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -323,7 +399,9 @@  discard block
 block discarded – undo
323 399
 			$icao = $line['aircraft_icao'];
324 400
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
325 401
 				$Spotter = new Spotter($this->db);
326
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
402
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
403
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
404
+				}
327 405
 				$Spotter->db = null;
328 406
 			}
329 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -334,15 +412,24 @@  discard block
 block discarded – undo
334 412
 				$Spotter = new Spotter($this->db);
335 413
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
336 414
 				$Spotter->db = null;
337
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
415
+				if ($aircraft_icao != '') {
416
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
417
+				}
338 418
 			}
339 419
 		}
340 420
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
341
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
342
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
343
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
344
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
345
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
421
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
422
+				$aircraft_icao = 'GLID';
423
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
424
+				$aircraft_icao = 'UHEL';
425
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
426
+				$aircraft_icao = 'TOWPLANE';
427
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
428
+				$aircraft_icao = 'POWAIRC';
429
+			}
430
+			if (isset($aircraft_icao)) {
431
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
432
+			}
346 433
 		}
347 434
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
348 435
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -352,8 +439,11 @@  discard block
 block discarded – undo
352 439
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353 440
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
354 441
 		    } else {
355
-				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";
356
-				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";
442
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
443
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
444
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
445
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
446
+				}
357 447
 				/*
358 448
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
359 449
 				print_r($this->all_flights[$id]);
@@ -362,16 +452,22 @@  discard block
 block discarded – undo
362 452
 				return '';
363 453
 		    }
364 454
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
365
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
455
+			if ($globalDebug) {
456
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
457
+			}
366 458
 			return '';
367 459
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
368
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
460
+			if ($globalDebug) {
461
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
462
+			}
369 463
 			return '';
370 464
 		} elseif (!isset($line['datetime'])) {
371 465
 			date_default_timezone_set('UTC');
372 466
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
373 467
 		} else {
374
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
468
+			if ($globalDebug) {
469
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
470
+			}
375 471
 			return '';
376 472
 		}
377 473
 
@@ -392,30 +488,48 @@  discard block
 block discarded – undo
392 488
 
393 489
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 490
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
491
+				if ($globalDebug) {
492
+					echo '---!!!! New ident, reset aircraft data...'."\n";
493
+				}
396 494
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
397 495
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
398
-				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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
399
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400
-				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']));
496
+				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' || $line['format_source'] === 'famaprs')) {
497
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
498
+				} elseif (isset($line['id'])) {
499
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
500
+				} elseif (isset($this->all_flights[$id]['ident'])) {
501
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
502
+				}
401 503
 			} else {
402 504
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403 505
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 506
 				$timeelapsed = microtime(true);
405 507
             			$Spotter = new Spotter($this->db);
406 508
             			$fromsource = NULL;
407
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
409
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
509
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
510
+            				$fromsource = $globalAirlinesSource;
511
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
512
+            				$fromsource = 'vatsim';
513
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
514
+					$fromsource = 'ivao';
515
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
516
+					$fromsource = 'vatsim';
517
+				} elseif (isset($globalIVAO) && $globalIVAO) {
518
+					$fromsource = 'ivao';
519
+				}
412 520
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
413
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
521
+				if ($globalDebug && $result != 'success') {
522
+					echo '!!! ERROR : '.$result."\n";
523
+				}
414 524
 				$Spotter->db = null;
415
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
525
+				if ($globalDebugTimeElapsed) {
526
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
527
+				}
416 528
 			    }
417 529
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
530
+		    } else {
531
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
532
+		    }
419 533
 		    
420 534
 /*
421 535
 		    if (!isset($line['id'])) {
@@ -425,7 +539,9 @@  discard block
 block discarded – undo
425 539
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 540
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 541
   */
428
-		    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']));
542
+		    if (!isset($this->all_flights[$id]['id'])) {
543
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
544
+		    }
429 545
 
430 546
 		    //$putinarchive = true;
431 547
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -443,7 +559,9 @@  discard block
 block discarded – undo
443 559
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 560
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445 561
 		    		$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' => ''));
446
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
562
+				if ($globalDebugTimeElapsed) {
563
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
564
+				}
447 565
                         }
448 566
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 567
 			$timeelapsed = microtime(true);
@@ -457,7 +575,9 @@  discard block
 block discarded – undo
457 575
 				$Translation->db = null;
458 576
 			    }
459 577
 			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+			    if ($globalDebugTimeElapsed) {
579
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
580
+			    }
461 581
                     	}
462 582
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463 583
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -466,9 +586,13 @@  discard block
 block discarded – undo
466 586
 		    		$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']));
467 587
 		    	    }
468 588
 			}
469
-			if (!isset($globalFork)) $globalFork = TRUE;
589
+			if (!isset($globalFork)) {
590
+				$globalFork = TRUE;
591
+			}
470 592
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
593
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
594
+					$this->get_Schedule($id,trim($line['ident']));
595
+				}
472 596
 			}
473 597
 		    }
474 598
 		}
@@ -486,9 +610,13 @@  discard block
 block discarded – undo
486 610
 			$speed = $speed*3.6;
487 611
 			if ($speed < 1000) {
488 612
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
489
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
613
+	  			if ($globalDebug) {
614
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
615
+	  			}
490 616
 	  		} else {
491
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
617
+	  			if ($globalDebug) {
618
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
619
+	  			}
492 620
 	  		}
493 621
 		    }
494 622
 		}
@@ -497,13 +625,21 @@  discard block
 block discarded – undo
497 625
 
498 626
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499 627
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
628
+	    	    	if ($globalDebug) {
629
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
630
+	    	    	}
501 631
 	    	    	return false;
502 632
 	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
-	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
-	    	    else unset($timediff_archive);
633
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
634
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
635
+	    	    } else {
636
+	    	    	unset($timediff);
637
+	    	    }
638
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
639
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
640
+	    	    } else {
641
+	    	    	unset($timediff_archive);
642
+	    	    }
507 643
 	    	    if ($this->tmd > 5
508 644
 	    	        || (isset($line['format_source']) 
509 645
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -539,16 +675,25 @@  discard block
 block discarded – undo
539 675
 				$this->all_flights[$id]['putinarchive'] = true;
540 676
 				$this->tmd = 0;
541 677
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
542
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
678
+				    if ($globalDebug) {
679
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
680
+				    }
543 681
 				    $timeelapsed = microtime(true);
544 682
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
545 683
 					$Spotter = new Spotter($this->db);
546 684
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
547
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
548
-					else $this->all_flights[$id]['over_country'] = '';
685
+					if (!empty($all_country)) {
686
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
687
+					} else {
688
+						$this->all_flights[$id]['over_country'] = '';
689
+					}
549 690
 					$Spotter->db = null;
550
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
551
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
691
+					if ($globalDebugTimeElapsed) {
692
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
693
+					}
694
+					if ($globalDebug) {
695
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
696
+					}
552 697
 				    }
553 698
 				}
554 699
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -594,7 +739,9 @@  discard block
 block discarded – undo
594 739
 			    */
595 740
 			}
596 741
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
597
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
742
+			    if ($line['longitude'] > 180) {
743
+			    	$line['longitude'] = $line['longitude'] - 360;
744
+			    }
598 745
 			    //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) {
599 746
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
600 747
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -631,7 +778,9 @@  discard block
 block discarded – undo
631 778
 		    }
632 779
 		}
633 780
 		if (isset($line['last_update']) && $line['last_update'] != '') {
634
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
781
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
782
+		    	$dataFound = true;
783
+		    }
635 784
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
636 785
 		}
637 786
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -653,35 +802,53 @@  discard block
 block discarded – undo
653 802
 			// Here we force archive of flight because after ground it's a new one (or should be)
654 803
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
655 804
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
656
-			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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
657
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
-			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']));
805
+			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' || $line['format_source'] === 'famaprs')) {
806
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
807
+			} elseif (isset($line['id'])) {
808
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
809
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
810
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
811
+			}
812
+		    }
813
+		    if ($line['ground'] != 1) {
814
+		    	$line['ground'] = 0;
659 815
 		    }
660
-		    if ($line['ground'] != 1) $line['ground'] = 0;
661 816
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
662 817
 		    //$dataFound = true;
663 818
 		}
664 819
 		if (isset($line['squawk']) && $line['squawk'] != '') {
665 820
 		    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'])) {
666
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
821
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
822
+			    	$this->all_flights[$id]['putinarchive'] = true;
823
+			    }
667 824
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
668 825
 			    $highlight = '';
669
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
670
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
826
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
827
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
828
+			    }
829
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
830
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
831
+			    }
832
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
833
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
834
+			    }
672 835
 			    if ($highlight != '') {
673 836
 				$timeelapsed = microtime(true);
674 837
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
675 838
 				    $Spotter = new Spotter($this->db);
676 839
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
677 840
 				    $Spotter->db = null;
678
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
841
+				    if ($globalDebugTimeElapsed) {
842
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
843
+				    }
679 844
 				}
680 845
 				//$putinarchive = true;
681 846
 				//$highlight = '';
682 847
 			    }
683 848
 			    
684
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
849
+		    } else {
850
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
851
+		    }
685 852
 		    //$dataFound = true;
686 853
 		}
687 854
 
@@ -694,19 +861,27 @@  discard block
 block discarded – undo
694 861
 				}
695 862
 			}
696 863
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
-			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;
864
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
865
+				$this->all_flights[$id]['putinarchive'] = true;
866
+			}
698 867
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
699 868
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
700 869
 			//$dataFound = true;
701 870
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
702 871
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
703 872
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
704
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
873
+				if ($globalDebug) {
874
+					echo '--- Reset because of altitude'."\n";
875
+				}
705 876
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
706 877
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
707
-				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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
708
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
709
-				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']));
878
+				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' || $line['format_source'] === 'famaprs')) {
879
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
880
+				} elseif (isset($line['id'])) {
881
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
882
+				} elseif (isset($this->all_flights[$id]['ident'])) {
883
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
884
+				}
710 885
 			}
711 886
 		    }
712 887
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -717,22 +892,32 @@  discard block
 block discarded – undo
717 892
 		}
718 893
 		
719 894
 		if (isset($line['heading']) && $line['heading'] != '') {
720
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
895
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
896
+		    	$this->all_flights[$id]['putinarchive'] = true;
897
+		    }
721 898
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
722 899
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
723 900
 		    //$dataFound = true;
724 901
   		} 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']) {
725 902
   		    $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']);
726 903
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
727
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
728
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
904
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
905
+		    	$this->all_flights[$id]['putinarchive'] = true;
906
+		    }
907
+  		    if ($globalDebug) {
908
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
909
+  		    }
729 910
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
730 911
   		    // If not enough messages and ACARS set heading to 0
731 912
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
732 913
   		}
733
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
734
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
735
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
914
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
915
+			$dataFound = false;
916
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
917
+			$dataFound = false;
918
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
919
+			$dataFound = false;
920
+		}
736 921
 
737 922
 //		print_r($this->all_flights[$id]);
738 923
 		//gets the callsign from the last hour
@@ -749,23 +934,38 @@  discard block
 block discarded – undo
749 934
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
750 935
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
751 936
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
752
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
937
+				    if ($globalDebug) {
938
+				    	echo "Check if aircraft is already in DB...";
939
+				    }
753 940
 				    $timeelapsed = microtime(true);
754 941
 				    $SpotterLive = new SpotterLive($this->db);
755 942
 				    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' || $line['format_source'] === 'famaprs')) {
756 943
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
757
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
944
+					if ($globalDebugTimeElapsed) {
945
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
946
+					}
758 947
 				    } elseif (isset($line['id'])) {
759 948
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
760
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
949
+					if ($globalDebugTimeElapsed) {
950
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
951
+					}
761 952
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762 953
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
763
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
764
-				    } else $recent_ident = '';
954
+					if ($globalDebugTimeElapsed) {
955
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
956
+					}
957
+				    } else {
958
+				    	$recent_ident = '';
959
+				    }
765 960
 				    $SpotterLive->db=null;
766
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
767
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
768
-				} else $recent_ident = '';
961
+				    if ($globalDebug && $recent_ident == '') {
962
+				    	echo " Not in DB.\n";
963
+				    } elseif ($globalDebug && $recent_ident != '') {
964
+				    	echo " Already in DB.\n";
965
+				    }
966
+				} else {
967
+					$recent_ident = '';
968
+				}
769 969
 			    } else {
770 970
 				$recent_ident = '';
771 971
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -773,7 +973,9 @@  discard block
 block discarded – undo
773 973
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
774 974
 			    if($recent_ident == "")
775 975
 			    {
776
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
976
+				if ($globalDebug) {
977
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
978
+				}
777 979
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
778 980
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
779 981
 				//adds the spotter data for the archive
@@ -817,31 +1019,49 @@  discard block
 block discarded – undo
817 1019
 				
818 1020
 				if (!$ignoreImport) {
819 1021
 				    $highlight = '';
820
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
821
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
822
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
823
-				    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')));
1022
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1023
+				    	$highlight = 'Squawk 7500 : Hijack';
1024
+				    }
1025
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1026
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1027
+				    }
1028
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1029
+				    	$highlight = 'Squawk 7700 : Emergency';
1030
+				    }
1031
+				    if (!isset($this->all_flights[$id]['id'])) {
1032
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1033
+				    }
824 1034
 				    $timeelapsed = microtime(true);
825 1035
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
826 1036
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
827 1037
 					    $Spotter = new Spotter($this->db);
828 1038
 					    $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']);
829 1039
 					    $Spotter->db = null;
830
-					    if ($globalDebug && isset($result)) echo $result."\n";
1040
+					    if ($globalDebug && isset($result)) {
1041
+					    	echo $result."\n";
1042
+					    }
831 1043
 					}
832 1044
 				    }
833
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1045
+				    if ($globalDebugTimeElapsed) {
1046
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1047
+				    }
834 1048
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
835 1049
 
836 1050
 				    // Add source stat in DB
837 1051
 				    $Stats = new Stats($this->db);
838 1052
 				    if (!empty($this->stats)) {
839
-					if ($globalDebug) echo 'Add source stats : ';
1053
+					if ($globalDebug) {
1054
+						echo 'Add source stats : ';
1055
+					}
840 1056
 				        foreach($this->stats as $date => $data) {
841 1057
 					    foreach($data as $source => $sourced) {
842 1058
 					        //print_r($sourced);
843
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
844
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1059
+				    	        if (isset($sourced['polar'])) {
1060
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1061
+				    	        }
1062
+				    	        if (isset($sourced['hist'])) {
1063
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1064
+				    	        }
845 1065
 				    		if (isset($sourced['msg'])) {
846 1066
 				    		    if (time() - $sourced['msg']['date'] > 10) {
847 1067
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -854,13 +1074,17 @@  discard block
 block discarded – undo
854 1074
 			    			unset($this->stats[$date]);
855 1075
 			    		    }
856 1076
 				    	}
857
-				    	if ($globalDebug) echo 'Done'."\n";
1077
+				    	if ($globalDebug) {
1078
+				    		echo 'Done'."\n";
1079
+				    	}
858 1080
 
859 1081
 				    }
860 1082
 				    $Stats->db = null;
861 1083
 				    }
862 1084
 				    $this->del();
863
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1085
+				} elseif ($globalDebug) {
1086
+					echo 'Ignore data'."\n";
1087
+				}
864 1088
 				//$ignoreImport = false;
865 1089
 				$this->all_flights[$id]['addedSpotter'] = 1;
866 1090
 				//print_r($this->all_flights[$id]);
@@ -877,7 +1101,9 @@  discard block
 block discarded – undo
877 1101
 			*/
878 1102
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
879 1103
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
880
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1104
+				    if ($globalDebug) {
1105
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1106
+				    }
881 1107
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
882 1108
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
883 1109
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -886,7 +1112,9 @@  discard block
 block discarded – undo
886 1112
 					    $SpotterLive->db=null;
887 1113
 					}
888 1114
 				    }
889
-				    if ($globalDebug) echo " Done\n";
1115
+				    if ($globalDebug) {
1116
+				    	echo " Done\n";
1117
+				    }
890 1118
 				    $this->last_delete = time();
891 1119
 				}
892 1120
 			    } else {
@@ -913,11 +1141,17 @@  discard block
 block discarded – undo
913 1141
 		    //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";
914 1142
 		    if ($globalDebug) {
915 1143
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
916
-				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";
917
-				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";
1144
+				if (isset($this->all_flights[$id]['source_name'])) {
1145
+					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";
1146
+				} else {
1147
+					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";
1148
+				}
918 1149
 			} else {
919
-				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";
920
-				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";
1150
+				if (isset($this->all_flights[$id]['source_name'])) {
1151
+					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";
1152
+				} else {
1153
+					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";
1154
+				}
921 1155
 			}
922 1156
 		    }
923 1157
 		    $ignoreImport = false;
@@ -963,22 +1197,30 @@  discard block
 block discarded – undo
963 1197
 
964 1198
 		    if (!$ignoreImport) {
965 1199
 			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'])) {
966
-				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')));
1200
+				if (!isset($this->all_flights[$id]['id'])) {
1201
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1202
+				}
967 1203
 				$timeelapsed = microtime(true);
968 1204
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
969 1205
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1206
+					if ($globalDebug) {
1207
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1208
+					}
971 1209
 					$SpotterLive = new SpotterLive($this->db);
972 1210
 					$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']);
973 1211
 					$SpotterLive->db = null;
974
-					if ($globalDebug) echo $result."\n";
1212
+					if ($globalDebug) {
1213
+						echo $result."\n";
1214
+					}
975 1215
 				    }
976 1216
 				}
977 1217
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
978 1218
 					$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']);
979 1219
 				}
980 1220
 				$this->all_flights[$id]['putinarchive'] = false;
981
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1221
+				if ($globalDebugTimeElapsed) {
1222
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1223
+				}
982 1224
 
983 1225
 				// Put statistics in $this->stats variable
984 1226
 				//if ($line['format_source'] != 'aprs') {
@@ -986,7 +1228,9 @@  discard block
 block discarded – undo
986 1228
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 1229
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
988 1230
 					$source = $this->all_flights[$id]['source_name'];
989
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1231
+					if ($source == '') {
1232
+						$source = $this->all_flights[$id]['format_source'];
1233
+					}
990 1234
 					if (!isset($this->source_location[$source])) {
991 1235
 						$Location = new Source($this->db);
992 1236
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1007,7 +1251,9 @@  discard block
 block discarded – undo
1007 1251
 					$stats_heading = round($stats_heading/22.5);
1008 1252
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1009 1253
 					$current_date = date('Y-m-d');
1010
-					if ($stats_heading == 16) $stats_heading = 0;
1254
+					if ($stats_heading == 16) {
1255
+						$stats_heading = 0;
1256
+					}
1011 1257
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1012 1258
 						for ($i=0;$i<=15;$i++) {
1013 1259
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1025,7 +1271,9 @@  discard block
 block discarded – undo
1025 1271
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1026 1272
 						    end($this->stats[$current_date][$source]['hist']);
1027 1273
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1028
-						} else $mini = 0;
1274
+						} else {
1275
+							$mini = 0;
1276
+						}
1029 1277
 						for ($i=$mini;$i<=$distance;$i+=10) {
1030 1278
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031 1279
 						}
@@ -1037,19 +1285,27 @@  discard block
 block discarded – undo
1037 1285
 				}
1038 1286
 
1039 1287
 				$this->all_flights[$id]['lastupdate'] = time();
1040
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1288
+				if ($this->all_flights[$id]['putinarchive']) {
1289
+					$send = true;
1290
+				}
1041 1291
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1042
-			} 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";
1292
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1293
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1294
+			}
1043 1295
 			//$this->del();
1044 1296
 			
1045 1297
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1046 1298
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1047
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1299
+				if ($globalDebug) {
1300
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1301
+				}
1048 1302
 				$SpotterLive = new SpotterLive($this->db);
1049 1303
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1050 1304
 				$SpotterLive->db = null;
1051 1305
 				//SpotterLive->deleteLiveSpotterData();
1052
-				if ($globalDebug) echo " Done\n";
1306
+				if ($globalDebug) {
1307
+					echo " Done\n";
1308
+				}
1053 1309
 				$this->last_delete_hourly = time();
1054 1310
 			    } else {
1055 1311
 				$this->del();
@@ -1061,7 +1317,9 @@  discard block
 block discarded – undo
1061 1317
 		    //$ignoreImport = false;
1062 1318
 		}
1063 1319
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1064
-		if ($send) return $this->all_flights[$id];
1320
+		if ($send) {
1321
+			return $this->all_flights[$id];
1322
+		}
1065 1323
 	    }
1066 1324
 	}
1067 1325
     }
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +193 added lines, -66 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
     public function checkAll() {
55 55
 	global $globalDebug, $globalNoDB;
56 56
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
57
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
57
+	    if ($globalDebug) {
58
+	    	echo "Update last seen tracked data...\n";
59
+	    }
58 60
 	    foreach ($this->all_tracked as $key => $flight) {
59 61
 		if (isset($this->all_tracked[$key]['id'])) {
60 62
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -68,13 +70,17 @@  discard block
 block discarded – undo
68 70
     public function del() {
69 71
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 72
 	// Delete old infos
71
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
73
+	if ($globalDebug) {
74
+		echo 'Delete old values and update latest data...'."\n";
75
+	}
72 76
 	foreach ($this->all_tracked as $key => $flight) {
73 77
     	    if (isset($flight['lastupdate'])) {
74 78
         	if ($flight['lastupdate'] < (time()-3000)) {
75 79
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76 80
             		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    if ($globalDebug) {
82
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
83
+            		    }
78 84
 			    /*
79 85
 			    $MarineLive = new MarineLive();
80 86
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -84,7 +90,9 @@  discard block
 block discarded – undo
84 90
             		    $Marine = new Marine($this->db);
85 91
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 92
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
87
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
93
+				if ($globalDebug && $result != 'success') {
94
+					echo '!!! ERROR : '.$result."\n";
95
+				}
88 96
 			    }
89 97
 			    // Put in archive
90 98
 //				$Marine->db = null;
@@ -98,7 +106,9 @@  discard block
 block discarded – undo
98 106
 
99 107
     public function add($line) {
100 108
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
101
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
109
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
110
+		$globalCoordMinChange = '0.02';
111
+	}
102 112
 	date_default_timezone_set('UTC');
103 113
 	$dataFound = false;
104 114
 	$send = false;
@@ -112,20 +122,30 @@  discard block
 block discarded – undo
112 122
 		// Increment message number
113 123
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114 124
 		    $current_date = date('Y-m-d');
115
-		    if (isset($line['source_name'])) $source = $line['source_name'];
116
-		    else $source = '';
117
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
125
+		    if (isset($line['source_name'])) {
126
+		    	$source = $line['source_name'];
127
+		    } else {
128
+		    	$source = '';
129
+		    }
130
+		    if ($source == '' || $line['format_source'] == 'aprs') {
131
+		    	$source = $line['format_source'];
132
+		    }
118 133
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119 134
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120 135
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
136
+		    } else {
137
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
138
+		    }
122 139
 		}
123 140
 		
124 141
 		
125 142
 		$Common = new Common();
126 143
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
144
+	        if (!isset($line['id'])) {
145
+	        	$id = trim($line['mmsi']);
146
+	        } else {
147
+	        	$id = trim($line['id']);
148
+	        }
129 149
 		
130 150
 		if (!isset($this->all_tracked[$id])) {
131 151
 		    $this->all_tracked[$id] = array();
@@ -133,10 +153,16 @@  discard block
 block discarded – undo
133 153
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
134 154
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135 155
 		    if (!isset($line['id'])) {
136
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
156
+			if (!isset($globalDaemon)) {
157
+				$globalDaemon = TRUE;
158
+			}
137 159
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
138
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
160
+		     } else {
161
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
162
+		     }
163
+		    if ($globalAllTracked !== FALSE) {
164
+		    	$dataFound = true;
165
+		    }
140 166
 		}
141 167
 		
142 168
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -186,34 +212,49 @@  discard block
 block discarded – undo
186 212
 				$Marine = new Marine($this->db);
187 213
 				$fromsource = NULL;
188 214
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
189
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
215
+				if ($globalDebug && $result != 'success') {
216
+					echo '!!! ERROR : '.$result."\n";
217
+				}
190 218
 				$Marine->db = null;
191
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
219
+				if ($globalDebugTimeElapsed) {
220
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
221
+				}
192 222
 			    }
193 223
 			}
194 224
 		    }
195
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
225
+		    if (!isset($this->all_tracked[$id]['id'])) {
226
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
227
+		    }
196 228
 		}
197 229
 
198 230
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
199 231
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
200 232
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
201 233
 		    } else {
202
-				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";
203
-				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";
234
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
235
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
236
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
237
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
238
+				}
204 239
 				return '';
205 240
 		    }
206 241
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
207
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
242
+			if ($globalDebug) {
243
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
244
+			}
208 245
 			return '';
209 246
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
210
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
247
+			if ($globalDebug) {
248
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!";
249
+			}
211 250
 			return '';
212 251
 		} elseif (!isset($line['datetime'])) {
213 252
 			date_default_timezone_set('UTC');
214 253
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
215 254
 		} else {
216
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!";
255
+			if ($globalDebug) {
256
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!";
257
+			}
217 258
 			return '';
218 259
 		}
219 260
 
@@ -226,14 +267,21 @@  discard block
 block discarded – undo
226 267
 		    if ($distance > 1000 && $distance < 10000) {
227 268
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
228 269
 			$speed = $speed*3.6;
229
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
230
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
270
+			if ($speed < 1000) {
271
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
272
+			}
273
+  			if ($globalDebug) {
274
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
275
+  			}
231 276
 		    }
232 277
 		}
233 278
 
234 279
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
235
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
236
-	    	    else unset($timediff);
280
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
281
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
282
+	    	    } else {
283
+	    	    	unset($timediff);
284
+	    	    }
237 285
 	    	    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')))) {
238 286
 			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'])) {
239 287
 			    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'])) {
@@ -241,22 +289,32 @@  discard block
 block discarded – undo
241 289
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
242 290
 				$this->all_tracked[$id]['putinarchive'] = true;
243 291
 				
244
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
292
+				if ($globalDebug) {
293
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
294
+				}
245 295
 				$timeelapsed = microtime(true);
246 296
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
247 297
 				    $Marine = new Marine($this->db);
248 298
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
249
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
299
+				    if (!empty($all_country)) {
300
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
301
+				    }
250 302
 				    $Marine->db = null;
251
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
303
+				    if ($globalDebugTimeElapsed) {
304
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
+				    }
252 306
 				}
253 307
 				$this->tmd = 0;
254
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
308
+				if ($globalDebug) {
309
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
310
+				}
255 311
 			    }
256 312
 			}
257 313
 
258 314
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
259
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
315
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
316
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
317
+				}
260 318
 				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') {
261 319
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
262 320
 				    $dataFound = true;
@@ -265,8 +323,12 @@  discard block
 block discarded – undo
265 323
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
266 324
 			}
267 325
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
268
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
269
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
326
+			    if ($line['longitude'] > 180) {
327
+			    	$line['longitude'] = $line['longitude'] - 360;
328
+			    }
329
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
330
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
331
+				}
270 332
 				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') {
271 333
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
272 334
 				    $dataFound = true;
@@ -284,7 +346,9 @@  discard block
 block discarded – undo
284 346
 		    }
285 347
 		}
286 348
 		if (isset($line['last_update']) && $line['last_update'] != '') {
287
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
349
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
350
+		    	$dataFound = true;
351
+		    }
288 352
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
289 353
 		}
290 354
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -314,15 +378,21 @@  discard block
 block discarded – undo
314 378
 		}
315 379
 		
316 380
 		if (isset($line['heading']) && $line['heading'] != '') {
317
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
381
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
382
+		    	$this->all_tracked[$id]['putinarchive'] = true;
383
+		    }
318 384
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
319 385
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
320 386
 		    //$dataFound = true;
321 387
   		} 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']) {
322 388
   		    $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']);
323 389
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
324
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
325
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
390
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
391
+		    	$this->all_tracked[$id]['putinarchive'] = true;
392
+		    }
393
+  		    if ($globalDebug) {
394
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
395
+  		    }
326 396
   		}
327 397
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
328 398
 
@@ -334,23 +404,38 @@  discard block
 block discarded – undo
334 404
 		        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'])) {
335 405
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
336 406
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
337
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
407
+				    if ($globalDebug) {
408
+				    	echo "Check if aircraft is already in DB...";
409
+				    }
338 410
 				    $timeelapsed = microtime(true);
339 411
 				    $MarineLive = new MarineLive($this->db);
340 412
 				    if (isset($line['id'])) {
341 413
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
342
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
414
+					if ($globalDebugTimeElapsed) {
415
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
416
+					}
343 417
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
344 418
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
345
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
419
+					if ($globalDebugTimeElapsed) {
420
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+					}
346 422
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
347 423
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
348
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
349
-				    } else $recent_ident = '';
424
+					if ($globalDebugTimeElapsed) {
425
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
+					}
427
+				    } else {
428
+				    	$recent_ident = '';
429
+				    }
350 430
 				    $MarineLive->db=null;
351
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
352
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
353
-				} else $recent_ident = '';
431
+				    if ($globalDebug && $recent_ident == '') {
432
+				    	echo " Not in DB.\n";
433
+				    } elseif ($globalDebug && $recent_ident != '') {
434
+				    	echo " Already in DB.\n";
435
+				    }
436
+				} else {
437
+					$recent_ident = '';
438
+				}
354 439
 			    } else {
355 440
 				$recent_ident = '';
356 441
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -358,30 +443,44 @@  discard block
 block discarded – undo
358 443
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
359 444
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
360 445
 			    {
361
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
446
+				if ($globalDebug) {
447
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
448
+				}
362 449
 				//adds the spotter data for the archive
363 450
 				    $highlight = '';
364
-				    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')));
451
+				    if (!isset($this->all_tracked[$id]['id'])) {
452
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
453
+				    }
365 454
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
366 455
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
367 456
 					    $timeelapsed = microtime(true);
368 457
 					    $Marine = new Marine($this->db);
369 458
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
370 459
 					    $Marine->db = null;
371
-					    if ($globalDebug && isset($result)) echo $result."\n";
372
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
460
+					    if ($globalDebug && isset($result)) {
461
+					    	echo $result."\n";
462
+					    }
463
+					    if ($globalDebugTimeElapsed) {
464
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
465
+					    }
373 466
 					}
374 467
 				    }
375 468
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
376 469
 					// Add source stat in DB
377 470
 					$Stats = new Stats($this->db);
378 471
 					if (!empty($this->stats)) {
379
-					    if ($globalDebug) echo 'Add source stats : ';
472
+					    if ($globalDebug) {
473
+					    	echo 'Add source stats : ';
474
+					    }
380 475
 				    	    foreach($this->stats as $date => $data) {
381 476
 						foreach($data as $source => $sourced) {
382 477
 					    	    //print_r($sourced);
383
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
384
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
478
+				    	    	    if (isset($sourced['polar'])) {
479
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
480
+				    	    	    }
481
+				    	    	    if (isset($sourced['hist'])) {
482
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
483
+				    	    	    }
385 484
 				    		    if (isset($sourced['msg'])) {
386 485
 				    			if (time() - $sourced['msg']['date'] > 10) {
387 486
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -394,7 +493,9 @@  discard block
 block discarded – undo
394 493
 			    			    unset($this->stats[$date]);
395 494
 			    			}
396 495
 				    	    }
397
-				    	    if ($globalDebug) echo 'Done'."\n";
496
+				    	    if ($globalDebug) {
497
+				    	    	echo 'Done'."\n";
498
+				    	    }
398 499
 					}
399 500
 					$Stats->db = null;
400 501
 				    }
@@ -404,13 +505,17 @@  discard block
 block discarded – undo
404 505
 				$this->all_tracked[$id]['addedMarine'] = 1;
405 506
 				//print_r($this->all_tracked[$id]);
406 507
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
407
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
508
+				    if ($globalDebug) {
509
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
510
+				    }
408 511
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
409 512
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410 513
 					$MarineLive = new MarineLive($this->db);
411 514
 					$MarineLive->deleteLiveMarineData();
412 515
 					$MarineLive->db=null;
413
-					if ($globalDebug) echo " Done\n";
516
+					if ($globalDebug) {
517
+						echo " Done\n";
518
+					}
414 519
 				    }
415 520
 				    $this->last_delete = time();
416 521
 				}
@@ -436,15 +541,21 @@  discard block
 block discarded – undo
436 541
 
437 542
 		    if (!$ignoreImport) {
438 543
 			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'])) {
439
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
544
+				if ($globalDebug) {
545
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
546
+				}
440 547
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
441 548
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 549
 					$timeelapsed = microtime(true);
443 550
 					$MarineLive = new MarineLive($this->db);
444 551
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
445 552
 					$MarineLive->db = null;
446
-					if ($globalDebug) echo $result."\n";
447
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
553
+					if ($globalDebug) {
554
+						echo $result."\n";
555
+					}
556
+					if ($globalDebugTimeElapsed) {
557
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
558
+					}
448 559
 				    }
449 560
 				}
450 561
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -456,7 +567,9 @@  discard block
 block discarded – undo
456 567
 				
457 568
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
458 569
 					$source = $this->all_tracked[$id]['source_name'];
459
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
570
+					if ($source == '') {
571
+						$source = $this->all_tracked[$id]['format_source'];
572
+					}
460 573
 					if (!isset($this->source_location[$source])) {
461 574
 						$Location = new Source($this->db);
462 575
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -477,7 +590,9 @@  discard block
 block discarded – undo
477 590
 					$stats_heading = round($stats_heading/22.5);
478 591
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
479 592
 					$current_date = date('Y-m-d');
480
-					if ($stats_heading == 16) $stats_heading = 0;
593
+					if ($stats_heading == 16) {
594
+						$stats_heading = 0;
595
+					}
481 596
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
482 597
 						for ($i=0;$i<=15;$i++) {
483 598
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -495,7 +610,9 @@  discard block
 block discarded – undo
495 610
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
496 611
 						    end($this->stats[$current_date][$source]['hist']);
497 612
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
498
-						} else $mini = 0;
613
+						} else {
614
+							$mini = 0;
615
+						}
499 616
 						for ($i=$mini;$i<=$distance;$i+=10) {
500 617
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
501 618
 						}
@@ -507,19 +624,27 @@  discard block
 block discarded – undo
507 624
 				
508 625
 
509 626
 				$this->all_tracked[$id]['lastupdate'] = time();
510
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
511
-			} 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";
627
+				if ($this->all_tracked[$id]['putinarchive']) {
628
+					$send = true;
629
+				}
630
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
631
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
632
+			}
512 633
 			//$this->del();
513 634
 			
514 635
 			
515 636
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
516 637
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
517
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
638
+				if ($globalDebug) {
639
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
640
+				}
518 641
 				$MarineLive = new MarineLive($this->db);
519 642
 				$MarineLive->deleteLiveMarineDataNotUpdated();
520 643
 				$MarineLive->db = null;
521 644
 				//MarineLive->deleteLiveMarineData();
522
-				if ($globalDebug) echo " Done\n";
645
+				if ($globalDebug) {
646
+					echo " Done\n";
647
+				}
523 648
 			    }
524 649
 			    $this->last_delete_hourly = time();
525 650
 			}
@@ -528,7 +653,9 @@  discard block
 block discarded – undo
528 653
 		    //$ignoreImport = false;
529 654
 		}
530 655
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
531
-		if ($send) return $this->all_tracked[$id];
656
+		if ($send) {
657
+			return $this->all_tracked[$id];
658
+		}
532 659
 	    }
533 660
 	}
534 661
     }
Please login to merge, or discard this patch.
require/class.AIS.php 1 patch
Braces   +331 added lines, -143 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,11 +479,20 @@  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
@@ -401,8 +503,14 @@  discard block
 block discarded – undo
401 503
 			$num_seq = (int)$pcs[1]; // number of sequences
402 504
 			$seq = (int)$pcs[2]; // get sequence
403 505
 			// get msg sequence id
404
-			if ($pcs[3] == '') $msg_sid = -1; // non-multipart message, set to -1
405
-			else $msg_sid = (int)$pcs[3]; // multipart message
506
+			if ($pcs[3] == '') {
507
+				$msg_sid = -1;
508
+			}
509
+			// non-multipart message, set to -1
510
+			else {
511
+				$msg_sid = (int)$pcs[3];
512
+			}
513
+			// multipart message
406 514
 			$ais_ch = $pcs[4]; // get AIS channel
407 515
 			// message sequence checking
408 516
 			if ($num_seq < 1 || $num_seq > 9) {
@@ -463,10 +571,18 @@  discard block
 block discarded – undo
463 571
 				//DEBUG echo "[$start $end $tst]\n";
464 572
 				$result = $this->process_ais_raw( $tst, "" );
465 573
 				$last_pos = $end + 1;
466
-			} else break;
574
+			} else {
575
+				break;
576
+			}
467 577
 		}
468
-		if ($last_pos > 0) $cbuf = substr($cbuf, $last_pos); // move...
469
-		if (strlen($cbuf) > 1024) $cbuf = ""; // prevent overflow simple mode...
578
+		if ($last_pos > 0) {
579
+			$cbuf = substr($cbuf, $last_pos);
580
+		}
581
+		// move...
582
+		if (strlen($cbuf) > 1024) {
583
+			$cbuf = "";
584
+		}
585
+		// prevent overflow simple mode...
470 586
 		return $result;
471 587
 	}
472 588
 
@@ -486,7 +602,9 @@  discard block
 block discarded – undo
486 602
 		if ($lat<0.0) {
487 603
 			$lat = -$lat;
488 604
 			$neg=true;
489
-		} else $neg=false;
605
+		} else {
606
+			$neg=false;
607
+		}
490 608
 		$latd = 0x00000000;
491 609
 		$latd = intval ($lat * 600000.0);
492 610
 		if ($neg==true) {
@@ -502,7 +620,9 @@  discard block
 block discarded – undo
502 620
 		if ($lon<0.0) {
503 621
 			$lon = -$lon;
504 622
 			$neg=true;
505
-		} else $neg=false;
623
+		} else {
624
+			$neg=false;
625
+		}
506 626
 		$lond = 0x00000000;
507 627
 		$lond = intval ($lon * 600000.0);
508 628
 		if ($neg==true) {
@@ -515,9 +635,14 @@  discard block
 block discarded – undo
515 635
 
516 636
 	private function char2bin($name, $max_len) {
517 637
 		$len = strlen($name);
518
-		if ($len > $max_len) $name = substr($name,0,$max_len);
519
-		if ($len < $max_len) $pad = str_repeat('0', ($max_len - $len) * 6);
520
-		else $pad = '';
638
+		if ($len > $max_len) {
639
+			$name = substr($name,0,$max_len);
640
+		}
641
+		if ($len < $max_len) {
642
+			$pad = str_repeat('0', ($max_len - $len) * 6);
643
+		} else {
644
+			$pad = '';
645
+		}
521 646
 		$rv = '';
522 647
 		$ais_chars = array(
523 648
 		    '@'=>0, 'A'=>1, 'B'=>2, 'C'=>3, 'D'=>4, 'E'=>5, 'F'=>6, 'G'=>7, 'H'=>8, 'I'=>9,
@@ -530,9 +655,12 @@  discard block
 block discarded – undo
530 655
 		);
531 656
 		// "
532 657
 		$_a = str_split($name);
533
-		if ($_a) foreach ($_a as $_1) {
658
+		if ($_a) {
659
+			foreach ($_a as $_1) {
534 660
 			if (isset($ais_chars[$_1])) $dec = $ais_chars[$_1];
535
-			else $dec = 0;
661
+		} else {
662
+				$dec = 0;
663
+			}
536 664
 			$bin = str_pad(decbin( $dec ), 6, '0', STR_PAD_LEFT);
537 665
 			$rv .= $bin;
538 666
 			//echo "$_1 $dec ($bin)<br/>";
@@ -544,7 +672,9 @@  discard block
 block discarded – undo
544 672
 		$len_bit = strlen($_enc);
545 673
 		$rem6 = $len_bit % 6;
546 674
 		$pad6_len = 0;
547
-		if ($rem6) $pad6_len = 6 - $rem6;
675
+		if ($rem6) {
676
+			$pad6_len = 6 - $rem6;
677
+		}
548 678
 		//echo  $pad6_len.'<br>';
549 679
 		$_enc .= str_repeat("0", $pad6_len); // pad the text...
550 680
 		$len_enc = strlen($_enc) / 6;
@@ -553,8 +683,11 @@  discard block
 block discarded – undo
553 683
 		for ($i=0; $i<$len_enc; $i++) {
554 684
 			$offset = $i * 6;
555 685
 			$dec = bindec(substr($_enc,$offset,6));
556
-			if ($dec < 40) $dec += 48;
557
-			else $dec += 56;
686
+			if ($dec < 40) {
687
+				$dec += 48;
688
+			} else {
689
+				$dec += 56;
690
+			}
558 691
 			//echo chr($dec)." $dec<br/>";
559 692
 			$itu .= chr($dec);
560 693
 		}
@@ -567,25 +700,41 @@  discard block
 block discarded – undo
567 700
 		}
568 701
 		$hex_arr = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
569 702
 		$lsb = $chksum & 0x0F;
570
-		if ($lsb >=0 && $lsb <= 15 ) $lsbc = $hex_arr[$lsb];
571
-		else $lsbc = '0';
703
+		if ($lsb >=0 && $lsb <= 15 ) {
704
+			$lsbc = $hex_arr[$lsb];
705
+		} else {
706
+			$lsbc = '0';
707
+		}
572 708
 		$msb = (($chksum & 0xF0) >> 4) & 0x0F;
573
-		if ($msb >=0 && $msb <= 15 ) $msbc = $hex_arr[$msb];
574
-		else $msbc = '0';
709
+		if ($msb >=0 && $msb <= 15 ) {
710
+			$msbc = $hex_arr[$msb];
711
+		} else {
712
+			$msbc = '0';
713
+		}
575 714
 		$itu = '!'.$itu."*{$msbc}{$lsbc}\r\n";
576 715
 		return $itu;
577 716
 	}
578 717
 
579 718
 	public function parse($buffer) {
580 719
 		$data = $this->process_ais_buf($buffer);
581
-		if (!is_object($data)) return array();
582
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
583
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
720
+		if (!is_object($data)) {
721
+			return array();
722
+		}
723
+		if ($data->lon != 0) {
724
+			$result['longitude'] = $data->lon;
725
+		}
726
+		if ($data->lat != 0) {
727
+			$result['latitude'] = $data->lat;
728
+		}
584 729
 		$result['ident'] = trim($data->name);
585 730
 		$result['timestamp'] = $data->ts;
586 731
 		$result['mmsi'] = $data->mmsi;
587
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
588
-		if ($data->cog != 0) $result['heading'] = $data->cog;
732
+		if ($data->sog != -1.0) {
733
+			$result['speed'] = $data->sog;
734
+		}
735
+		if ($data->cog != 0) {
736
+			$result['heading'] = $data->cog;
737
+		}
589 738
 		/*
590 739
 		    $ro->cls = 0; // AIS class undefined, also indicate unparsed msg
591 740
 		    $ro->id = bindec(substr($_aisdata,0,6));
@@ -595,15 +744,25 @@  discard block
 block discarded – undo
595 744
 
596 745
 	public function mmsitype($mmsi) {
597 746
 		if (strlen($mmsi) == 9) {
598
-			if (substr($mmsi,0,3) == '974') return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
599
-			elseif (substr($mmsi,0,3) == '972') return 'MOB (Man Overboard) device';
600
-			elseif (substr($mmsi,0,3) == '970') return 'AIS SART (Search and Rescue Transmitter)';
601
-			elseif (substr($mmsi,0,3) == '111') return 'SAR (Search and Rescue) aircraft';
602
-			elseif (substr($mmsi,0,2) == '98') return 'Auxiliary craft associated with a parent ship';
603
-			elseif (substr($mmsi,0,2) == '99') return 'Aids to Navigation';
604
-			elseif (substr($mmsi,0,2) == '00') return 'Coastal stations';
605
-			elseif (substr($mmsi,0,1) == '0') return 'Group of ships';
606
-			else return 'Ship';
747
+			if (substr($mmsi,0,3) == '974') {
748
+				return 'EPIRB (Emergency Position Indicating Radio Beacon) AIS';
749
+			} elseif (substr($mmsi,0,3) == '972') {
750
+				return 'MOB (Man Overboard) device';
751
+			} elseif (substr($mmsi,0,3) == '970') {
752
+				return 'AIS SART (Search and Rescue Transmitter)';
753
+			} elseif (substr($mmsi,0,3) == '111') {
754
+				return 'SAR (Search and Rescue) aircraft';
755
+			} elseif (substr($mmsi,0,2) == '98') {
756
+				return 'Auxiliary craft associated with a parent ship';
757
+			} elseif (substr($mmsi,0,2) == '99') {
758
+				return 'Aids to Navigation';
759
+			} elseif (substr($mmsi,0,2) == '00') {
760
+				return 'Coastal stations';
761
+			} elseif (substr($mmsi,0,1) == '0') {
762
+				return 'Group of ships';
763
+			} else {
764
+				return 'Ship';
765
+			}
607 766
 		}
608 767
 
609 768
 	
@@ -620,32 +779,61 @@  discard block
 block discarded – undo
620 779
 			//if ($globalDebug) echo '==== Line format not supported : '.$buffer."\n";
621 780
 			return array();
622 781
 		}
623
-		if ($data->lon != 0) $result['longitude'] = $data->lon;
624
-		if ($data->lat != 0) $result['latitude'] = $data->lat;
782
+		if ($data->lon != 0) {
783
+			$result['longitude'] = $data->lon;
784
+		}
785
+		if ($data->lat != 0) {
786
+			$result['latitude'] = $data->lat;
787
+		}
625 788
 		$result['ident'] = trim(str_replace('@','',$data->name));
626 789
 		$result['timestamp'] = $data->ts;
627 790
 		$result['mmsi'] = $data->mmsi;
628
-		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') $result['mmsi'] = '3'.$result['mmsi'];
791
+		if (strlen($result['mmsi']) == 8 && substr($result['mmsi'],0,3) == '669') {
792
+			$result['mmsi'] = '3'.$result['mmsi'];
793
+		}
629 794
 		$result['mmsi_type'] = $this->mmsitype($result['mmsi']);
630
-		if ($data->sog != -1.0) $result['speed'] = $data->sog;
631
-		if ($data->heading !== '') $result['heading'] = $data->heading;
632
-		elseif ($data->cog != 0) $result['heading'] = $data->cog;
633
-		if ($data->status != '') $result['status'] = $data->status;
634
-		if ($data->statusid !== '') $result['statusid'] = $data->statusid;
635
-		if ($data->type !== '') $result['type'] = $data->type;
636
-		if ($data->typeid !== '') $result['typeid'] = $data->typeid;
637
-		if ($data->imo !== '') $result['imo'] = $data->imo;
638
-		if ($data->callsign !== '') $result['callsign'] = trim(str_replace('@','',$data->callsign));
795
+		if ($data->sog != -1.0) {
796
+			$result['speed'] = $data->sog;
797
+		}
798
+		if ($data->heading !== '') {
799
+			$result['heading'] = $data->heading;
800
+		} elseif ($data->cog != 0) {
801
+			$result['heading'] = $data->cog;
802
+		}
803
+		if ($data->status != '') {
804
+			$result['status'] = $data->status;
805
+		}
806
+		if ($data->statusid !== '') {
807
+			$result['statusid'] = $data->statusid;
808
+		}
809
+		if ($data->type !== '') {
810
+			$result['type'] = $data->type;
811
+		}
812
+		if ($data->typeid !== '') {
813
+			$result['typeid'] = $data->typeid;
814
+		}
815
+		if ($data->imo !== '') {
816
+			$result['imo'] = $data->imo;
817
+		}
818
+		if ($data->callsign !== '') {
819
+			$result['callsign'] = trim(str_replace('@','',$data->callsign));
820
+		}
639 821
 		if (is_numeric($data->eta_month) && $data->eta_month != 0 && is_numeric($data->eta_day) && $data->eta_day != 0 && $data->eta_hour !== '' && $data->eta_minute !== '') {
640 822
 			$eta_ts = strtotime(date('Y').'-'.sprintf("%02d",$data->eta_month).'-'.sprintf("%02d",$data->eta_day).' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
641
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
823
+			if ($eta_ts != '') {
824
+				$result['eta_ts'] = $eta_ts;
825
+			}
642 826
 		} elseif (is_numeric($data->eta_hour) && is_numeric($data->eta_minute)) {
643 827
 			$eta_ts = strtotime(date('Y-m-d').' '.sprintf("%02d",$data->eta_hour).':'.sprintf("%02d",$data->eta_minute).':00');
644
-			if ($eta_ts != '') $result['eta_ts'] = $eta_ts;
828
+			if ($eta_ts != '') {
829
+				$result['eta_ts'] = $eta_ts;
830
+			}
645 831
 		}
646 832
 		if ($data->destination != '') {
647 833
 			$dest = trim(str_replace('@','',$data->destination));
648
-			if ($dest != '') $result['destination'] = $dest;
834
+			if ($dest != '') {
835
+				$result['destination'] = $dest;
836
+			}
649 837
 		}
650 838
 		$result['all'] = (array) $data;
651 839
 		/*
Please login to merge, or discard this patch.
sitemap.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@  discard block
 block discarded – undo
34 34
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
35 35
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
36 36
 		$aircraft_types = $Stats->getAllAircraftTypes();
37
-		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
37
+		if (empty($aircraft_types)) {
38
+			$aircraft_types = $Spotter->getAllAircraftTypes();
39
+		}
38 40
 		foreach($aircraft_types as $aircraft_item)
39 41
 		{
40 42
 			$output .= '<url>';
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
85 87
 
86 88
 		$airport_names = $Stats->getAllAirportNames();
87
-		if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
89
+		if (empty($airport_names)) {
90
+			$airport_names = $Spotter->getAllAirportNames();
91
+		}
88 92
 		foreach($airport_names as $airport_item)
89 93
 		{
90 94
 			$output .= '<url>';
@@ -99,7 +103,9 @@  discard block
 block discarded – undo
99 103
 	$output .= '<?xml version="1.0" encoding="UTF-8"?>';
100 104
 	$output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">';
101 105
 	$manufacturer_names = $Stats->getAllManufacturers();
102
-	if (empty($manufacturer_names)) $manufacturer_names = $Spotter->getAllManufacturers();
106
+	if (empty($manufacturer_names)) {
107
+		$manufacturer_names = $Spotter->getAllManufacturers();
108
+	}
103 109
 	foreach($manufacturer_names as $manufacturer_item)
104 110
 	{
105 111
 		$output .= '<url>';
Please login to merge, or discard this patch.
statistics-country.php 1 patch
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Language.php');
5 5
 $Stats = new Stats();
6 6
 
7
-if (!isset($filter_name)) $filter_name = '';
7
+if (!isset($filter_name)) {
8
+	$filter_name = '';
9
+}
8 10
 $type = 'aircraft';
9 11
 if (isset($_GET['marine'])) {
10 12
 	$type = 'marine';
@@ -21,8 +23,10 @@  discard block
 block discarded – undo
21 23
 }
22 24
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
23 25
 if ($airline_icao == '' && isset($globalFilter)) {
24
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
25
-}
26
+    if (isset($globalFilter['airline'])) {
27
+    	$airline_icao = $globalFilter['airline'][0];
28
+    }
29
+    }
26 30
 
27 31
 require_once('header.php');
28 32
 include('statistics-sub-menu.php'); 
@@ -64,10 +68,14 @@  discard block
 block discarded – undo
64 68
 $flightover_data = '';
65 69
 foreach($flightover_array as $flightover_item)
66 70
 {
67
-	if ($type == 'aircraft') $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
68
-	elseif ($type == 'marine') $flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
69
-	elseif ($type == 'tracker') $flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
70
-}
71
+	if ($type == 'aircraft') {
72
+		$flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],';
73
+	} elseif ($type == 'marine') {
74
+		$flightover_data .= '[ "'.$flightover_item['marine_country_iso3'].'",'.$flightover_item['marine_count'].'],';
75
+	} elseif ($type == 'tracker') {
76
+		$flightover_data .= '[ "'.$flightover_item['tracker_country_iso3'].'",'.$flightover_item['tracker_count'].'],';
77
+	}
78
+	}
71 79
 $flightover_data = substr($flightover_data, 0, -1);
72 80
 print $flightover_data;
73 81
 print '];';
Please login to merge, or discard this patch.