Completed
Push — master ( f32ba6...d43b85 )
by Yannick
30:30
created
js/map-marine.2d.js.php 1 patch
Braces   +36 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,11 +5,18 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
10
-if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor'];
11
-elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor;
12
-else $MarineIconColor = '1a3151';
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
13
+if (isset($_COOKIE['MarineIconColor'])) {
14
+	$MarineIconColor = $_COOKIE['MarineIconColor'];
15
+} elseif (isset($globalMarineIconColor)) {
16
+	$MarineIconColor = $globalMarineIconColor;
17
+} else {
18
+	$MarineIconColor = '1a3151';
19
+}
13 20
 
14 21
 ?>
15 22
 
@@ -181,7 +188,12 @@  discard block
 block discarded – undo
181 188
 <?php
182 189
 		} else {
183 190
 ?>
184
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
191
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
192
+	print $archiveupdatetime*1000;
193
+} else {
194
+	print $globalMapRefresh*1000+20000;
195
+}
196
+?>+feature.properties.sqt*1000);
185 197
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
186 198
 <?php
187 199
 		}
@@ -238,7 +250,12 @@  discard block
 block discarded – undo
238 250
 <?php
239 251
 		} else {
240 252
 ?>
241
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
253
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
254
+	print $archiveupdatetime*1000;
255
+} else {
256
+	print $globalMapRefresh*1000+20000;
257
+}
258
+?>+feature.properties.sqt*1000);
242 259
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
243 260
 <?php
244 261
 		}
@@ -294,7 +311,12 @@  discard block
 block discarded – undo
294 311
 <?php
295 312
 		} else {
296 313
 ?>
297
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
314
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
315
+	print $archiveupdatetime*1000;
316
+} else {
317
+	print $globalMapRefresh*1000+20000;
318
+}
319
+?>+feature.properties.sqt*1000);
298 320
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
299 321
 <?php
300 322
 		}
@@ -702,7 +724,12 @@  discard block
 block discarded – undo
702 724
 } else {
703 725
 	//then load it again every 30 seconds
704 726
 	reloadMarinePage = setInterval(
705
-	function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
727
+	function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
728
+	print $globalMapRefresh*1000;
729
+} else {
730
+	print '30000';
731
+}
732
+?>);
706 733
 }
707 734
 
708 735
 if (getCookie('openseamap') == 'true') loadOpenSeaMap(getCookie('openseamap'));
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Braces   +134 added lines, -30 removed lines patch added patch discarded remove patch
@@ -4,10 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 setcookie("MapFormat",'2d');
6 6
 
7
-if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
7
+if (!isset($globalOpenWeatherMapKey)) {
8
+	$globalOpenWeatherMapKey = '';
9
+}
8 10
 // Compressed GeoJson is used if true
9
-if (!isset($globalJsonCompress)) $compress = true;
10
-else $compress = $globalJsonCompress;
11
+if (!isset($globalJsonCompress)) {
12
+	$compress = true;
13
+} else {
14
+	$compress = $globalJsonCompress;
15
+}
11 16
 
12 17
 /*
13 18
 if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') {
@@ -119,7 +124,17 @@  discard block
 block discarded – undo
119 124
 	}
120 125
 
121 126
 	//create the map
122
-	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) print $latitude; else print $globalCenterLatitude; ?>,<?php if (isset($longitude)) print $longitude; else print $globalCenterLongitude; ?>], zoom);
127
+	map = L.map('archive-map', { zoomControl:false }).setView([<?php if (isset($latitude)) {
128
+	print $latitude;
129
+} else {
130
+	print $globalCenterLatitude;
131
+}
132
+?>,<?php if (isset($longitude)) {
133
+	print $longitude;
134
+} else {
135
+	print $globalCenterLongitude;
136
+}
137
+?>], zoom);
123 138
 <?php
124 139
 	} else {
125 140
 		if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) {
@@ -145,9 +160,21 @@  discard block
 block discarded – undo
145 160
 	     || navigator.userAgent.match(/BlackBerry/i)
146 161
 	     || navigator.userAgent.match(/Windows Phone/i))
147 162
 	{
148
-		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>;
163
+		var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) {
164
+	print $viewzoom-1;
165
+} elseif (isset($viewzoom)) {
166
+	print $viewzoom;
167
+} else {
168
+	print '8';
169
+}
170
+?>;
149 171
 	} else {
150
-		var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>;
172
+		var zoom = <?php if (isset($viewzoom)) {
173
+	print $viewzoom;
174
+} else {
175
+	print '9';
176
+}
177
+?>;
151 178
 	}
152 179
 
153 180
 	//create the map
@@ -173,16 +200,27 @@  discard block
 block discarded – undo
173 200
 	bounds = L.latLngBounds(southWest,northEast);
174 201
 	//a few title layers
175 202
 <?php
176
-	if (isset($_COOKIE['MapType'])) $MapType = $_COOKIE['MapType'];
177
-	else $MapType = $globalMapProvider;
203
+	if (isset($_COOKIE['MapType'])) {
204
+		$MapType = $_COOKIE['MapType'];
205
+	} else {
206
+		$MapType = $globalMapProvider;
207
+	}
178 208
 
179 209
 	if ($MapType == 'Mapbox') {
180
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
181
-		else $MapBoxId = $_COOKIE['MapTypeId'];
182
-?>
210
+		if ($_COOKIE['MapTypeId'] == 'default') {
211
+			$MapBoxId = $globalMapboxId;
212
+		} else {
213
+			$MapBoxId = $_COOKIE['MapTypeId'];
214
+		}
215
+		?>
183 216
 	L.tileLayer('https://{s}.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={token}', {
184 217
 	    maxZoom: 18,
185
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
218
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
219
+	print 'false';
220
+} else {
221
+	print 'true';
222
+}
223
+?>,
186 224
 	    attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a></strong>',
187 225
 	    id: '<?php print $MapBoxId; ?>',
188 226
 	    token: '<?php print $globalMapboxToken; ?>'
@@ -201,7 +239,12 @@  discard block
 block discarded – undo
201 239
 ?>
202 240
 	L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
203 241
 	    maxZoom: 18,
204
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
242
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
243
+	print 'false';
244
+} else {
245
+	print 'true';
246
+}
247
+?>,
205 248
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
206 249
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
207 250
 	}).addTo(map);
@@ -210,7 +253,12 @@  discard block
 block discarded – undo
210 253
 ?>
211 254
 	L.tileLayer('https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', {
212 255
 	    maxZoom: 18,
213
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
256
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
257
+	print 'false';
258
+} else {
259
+	print 'true';
260
+}
261
+?>,
214 262
 	    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
215 263
 		'&copy; <a href="http://openseamap.org">OpenSeaMap</a> contributors, ' +
216 264
 	      '<a href="www.openstreetmap.org/copyright">Open Database Licence</a>'
@@ -220,7 +268,12 @@  discard block
 block discarded – undo
220 268
 ?>
221 269
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}', {
222 270
 	    maxZoom: 18,
223
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
271
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
272
+	print 'false';
273
+} else {
274
+	print 'true';
275
+}
276
+?>,
224 277
 	    attribution: 'Tiles &copy; Esri &mdash; Sources: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
225 278
 	}).addTo(map);
226 279
 <?php
@@ -228,7 +281,12 @@  discard block
 block discarded – undo
228 281
 ?>
229 282
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
230 283
 	    maxZoom: 18,
231
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
284
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
285
+	print 'false';
286
+} else {
287
+	print 'true';
288
+}
289
+?>,
232 290
 	    attribution: 'Tiles &copy; Esri &mdash; Sources: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
233 291
 	}).addTo(map);
234 292
 <?php
@@ -236,7 +294,12 @@  discard block
 block discarded – undo
236 294
 ?>
237 295
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer/tile/{z}/{y}/{x}', {
238 296
 	    maxZoom: 18,
239
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
297
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
298
+	print 'false';
299
+} else {
300
+	print 'true';
301
+}
302
+?>,
240 303
 	    attribution: 'Tiles &copy; Esri &mdash; Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
241 304
 	}).addTo(map);
242 305
 <?php
@@ -244,7 +307,12 @@  discard block
 block discarded – undo
244 307
 ?>
245 308
 	L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}', {
246 309
 	    maxZoom: 18,
247
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
310
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
311
+	print 'false';
312
+} else {
313
+	print 'true';
314
+}
315
+?>,
248 316
 	    attribution: 'Tiles &copy; Esri &mdash; Sources: National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
249 317
 	}).addTo(map);
250 318
 <?php
@@ -289,20 +357,26 @@  discard block
 block discarded – undo
289 357
 	map.addLayer(yandexLayer);
290 358
 <?php
291 359
 	} elseif ($MapType == 'Bing-Aerial') {
292
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
293
-?>
360
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
361
+			setcookie('MapType','OpenStreetMap');
362
+		}
363
+		?>
294 364
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
295 365
 	map.addLayer(bingLayer);
296 366
 <?php
297 367
 	} elseif ($MapType == 'Bing-Hybrid') {
298
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
299
-?>
368
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
369
+			setcookie('MapType','OpenStreetMap');
370
+		}
371
+		?>
300 372
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
301 373
 	map.addLayer(bingLayer);
302 374
 <?php
303 375
 	} elseif ($MapType == 'Bing-Road') {
304
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
305
-?>
376
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') {
377
+			setcookie('MapType','OpenStreetMap');
378
+		}
379
+		?>
306 380
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
307 381
 	map.addLayer(bingLayer);
308 382
 <?php
@@ -331,7 +405,12 @@  discard block
 block discarded – undo
331 405
 	    maxZoom: 5,
332 406
 	    tms : true,
333 407
 	    zindex : 3,
334
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
408
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
409
+	print 'false';
410
+} else {
411
+	print 'true';
412
+}
413
+?>,
335 414
 	    attribution: 'Natural Earth'
336 415
 	}).addTo(map);
337 416
 <?php
@@ -339,9 +418,24 @@  discard block
 block discarded – undo
339 418
 		$customid = $MapType;
340 419
 ?>
341 420
 	L.tileLayer('<?php print $globalMapCustomLayer[$customid]['url']; ?>/{z}/{x}/{y}.png', {
342
-	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '18'; ?>,
343
-	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
344
-	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) print 'false'; else print 'true'; ?>,
421
+	    maxZoom: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
422
+	print $globalMapCustomLayer[$customid]['maxZoom'];
423
+} else {
424
+	print '18';
425
+}
426
+?>,
427
+	    minZoom: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
428
+	print $globalMapCustomLayer[$customid]['minZoom'];
429
+} else {
430
+	print '0';
431
+}
432
+?>,
433
+	    noWrap: <?php if (isset($globalMapWrap) && !$globalMapWrap) {
434
+	print 'false';
435
+} else {
436
+	print 'true';
437
+}
438
+?>,
345 439
 	    attribution: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
346 440
 	}).addTo(map);
347 441
 
@@ -381,7 +475,12 @@  discard block
 block discarded – undo
381 475
 		}
382 476
 	} elseif ($globalBounding == 'circle') {
383 477
 ?>
384
-	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) print $globalBoundingCircleSize; else print '70000'; ?>,{
478
+	var circle = L.circle([<?php print $globalCenterLatitude; ?>, <?php print $globalCenterLongitude; ?>],<?php if (isset($globalBoundingCircleSize)) {
479
+	print $globalBoundingCircleSize;
480
+} else {
481
+	print '70000';
482
+}
483
+?>,{
385 484
 	    color: '#92C7D1',
386 485
 	    fillColor: '#92C7D1',
387 486
 	    fillOpacity: 0.3,
@@ -471,7 +570,12 @@  discard block
 block discarded – undo
471 570
 	});
472 571
 	if (archive === false) {
473 572
 		update_locationsLayer();
474
-		setInterval(function(){if (noTimeout) { map.removeLayer(locationsLayer); update_locationsLayer();} },<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
573
+		setInterval(function(){if (noTimeout) { map.removeLayer(locationsLayer); update_locationsLayer();} },<?php if (isset($globalMapRefresh)) {
574
+	print $globalMapRefresh*1000*2;
575
+} else {
576
+	print '60000';
577
+}
578
+?>);
475 579
 	}
476 580
 <?php
477 581
     // Add support for custom json via $globalMapJson
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 2 patches
Indentation   +1103 added lines, -1103 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 if (isset($options['idsource'])) $id_source = $options['idsource'];
104 104
 else $id_source = 1;
105 105
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
107
-    $SI=new SpotterServer();
106
+	if ($globalDebug) echo "Using Server Mode\n";
107
+	$SI=new SpotterServer();
108 108
 /*
109 109
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 110
     $SI = new adsb2aprs();
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 
115 115
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
116 116
 if (isset($globalMarine) && $globalMarine) {
117
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
117
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
118
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 119
 }
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    $AIS = new AIS();
124
-    $MI = new MarineImport($Connection->db);
123
+	$AIS = new AIS();
124
+	$MI = new MarineImport($Connection->db);
125 125
 }
126 126
 //$APRS=new APRS($Connection->db);
127 127
 $SBS=new SBS();
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
 //$servertz = system('date +%Z');
135 135
 // signal handler - playing nice with sockets and dump1090
136 136
 if (function_exists('pcntl_fork')) {
137
-    pcntl_signal(SIGINT,  function() {
138
-        global $sockets;
139
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
-        die("Bye!\n");
141
-    });
142
-    pcntl_signal_dispatch();
137
+	pcntl_signal(SIGINT,  function() {
138
+		global $sockets;
139
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
140
+		die("Bye!\n");
141
+	});
142
+	pcntl_signal_dispatch();
143 143
 }
144 144
 
145 145
 // let's try and connect
@@ -149,46 +149,46 @@  discard block
 block discarded – undo
149 149
 $reset = 0;
150 150
 
151 151
 function connect_all($hosts) {
152
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
-    $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
156
-    foreach ($hosts as $id => $value) {
152
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154
+	$reset++;
155
+	if ($globalDebug) echo 'Connect to all...'."\n";
156
+	foreach ($hosts as $id => $value) {
157 157
 	$host = $value['host'];
158 158
 	$globalSources[$id]['last_exec'] = 0;
159 159
 	// Here we check type of source(s)
160 160
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
161
-            if (preg_match('/deltadb.txt$/i',$host)) {
162
-        	//$formats[$id] = 'deltadbtxt';
163
-        	$globalSources[$id]['format'] = 'deltadbtxt';
164
-        	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
-        	//$formats[$id] = 'vatsimtxt';
168
-        	$globalSources[$id]['format'] = 'vatsimtxt';
169
-        	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172
-        	//$formats[$id] = 'aircraftlistjson';
173
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
174
-        	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
177
-        	//$formats[$id] = 'aircraftjson';
178
-        	$globalSources[$id]['format'] = 'aircraftjson';
179
-        	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraft$/i',$host)) {
182
-        	//$formats[$id] = 'planefinderclient';
183
-        	$globalSources[$id]['format'] = 'planefinderclient';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
-    	    } else if (preg_match('/opensky/i',$host)) {
187
-        	//$formats[$id] = 'aircraftlistjson';
188
-        	$globalSources[$id]['format'] = 'opensky';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
-    	    /*
161
+			if (preg_match('/deltadb.txt$/i',$host)) {
162
+			//$formats[$id] = 'deltadbtxt';
163
+			$globalSources[$id]['format'] = 'deltadbtxt';
164
+			//$last_exec['deltadbtxt'] = 0;
165
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
166
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
167
+			//$formats[$id] = 'vatsimtxt';
168
+			$globalSources[$id]['format'] = 'vatsimtxt';
169
+			//$last_exec['vatsimtxt'] = 0;
170
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
171
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
172
+			//$formats[$id] = 'aircraftlistjson';
173
+			$globalSources[$id]['format'] = 'aircraftlistjson';
174
+			//$last_exec['aircraftlistjson'] = 0;
175
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
176
+			} else if (preg_match('/aircraft.json$/i',$host)) {
177
+			//$formats[$id] = 'aircraftjson';
178
+			$globalSources[$id]['format'] = 'aircraftjson';
179
+			//$last_exec['aircraftlistjson'] = 0;
180
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
181
+			} else if (preg_match('/aircraft$/i',$host)) {
182
+			//$formats[$id] = 'planefinderclient';
183
+			$globalSources[$id]['format'] = 'planefinderclient';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
186
+			} else if (preg_match('/opensky/i',$host)) {
187
+			//$formats[$id] = 'aircraftlistjson';
188
+			$globalSources[$id]['format'] = 'opensky';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
191
+			/*
192 192
     	    // Disabled for now, site change source format
193 193
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
194 194
         	//$formats[$id] = 'radarvirtueljson';
@@ -200,128 +200,128 @@  discard block
 block discarded – undo
200 200
         	    exit(0);
201 201
         	}
202 202
     	    */
203
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
-        	//$formats[$id] = 'planeupdatefaa';
205
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
206
-        	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
-        	//$formats[$id] = 'phpvmacars';
214
-        	$globalSources[$id]['format'] = 'phpvmacars';
215
-        	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
-        	//$formats[$id] = 'phpvmacars';
219
-        	$globalSources[$id]['format'] = 'vaos';
220
-        	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
-            } else if (preg_match('/whazzup/i',$host)) {
227
-        	//$formats[$id] = 'whazzup';
228
-        	$globalSources[$id]['format'] = 'whazzup';
229
-        	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
-            } else if (preg_match('/blitzortung/i',$host)) {
232
-        	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
-            } else if (preg_match('/airwhere/i',$host)) {
235
-        	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
-            } else if (preg_match('/recentpireps/i',$host)) {
238
-        	//$formats[$id] = 'pirepsjson';
239
-        	$globalSources[$id]['format'] = 'pirepsjson';
240
-        	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
-        	//$formats[$id] = 'fr24json';
244
-        	$globalSources[$id]['format'] = 'fr24json';
245
-        	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
-        	    exit(0);
250
-        	}
251
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
252
-        	//$formats[$id] = 'fr24json';
253
-        	$globalSources[$id]['format'] = 'myshiptracking';
254
-        	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
-        	    exit(0);
259
-        	}
260
-            //} else if (preg_match('/10001/',$host)) {
261
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
-        	//$formats[$id] = 'tsv';
263
-        	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
-            }
266
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
-    		    if ($idf !== false) {
270
-    			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
-	    $hostport = explode(':',$host);
277
-	    if (isset($hostport[1])) {
203
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
204
+			//$formats[$id] = 'planeupdatefaa';
205
+			$globalSources[$id]['format'] = 'planeupdatefaa';
206
+			//$last_exec['planeupdatefaa'] = 0;
207
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
213
+			//$formats[$id] = 'phpvmacars';
214
+			$globalSources[$id]['format'] = 'phpvmacars';
215
+			//$last_exec['phpvmacars'] = 0;
216
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
217
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218
+			//$formats[$id] = 'phpvmacars';
219
+			$globalSources[$id]['format'] = 'vaos';
220
+			//$last_exec['phpvmacars'] = 0;
221
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
222
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'vam';
225
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
226
+			} else if (preg_match('/whazzup/i',$host)) {
227
+			//$formats[$id] = 'whazzup';
228
+			$globalSources[$id]['format'] = 'whazzup';
229
+			//$last_exec['whazzup'] = 0;
230
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
231
+			} else if (preg_match('/blitzortung/i',$host)) {
232
+			$globalSources[$id]['format'] = 'blitzortung';
233
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
234
+			} else if (preg_match('/airwhere/i',$host)) {
235
+			$globalSources[$id]['format'] = 'airwhere';
236
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+			} else if (preg_match('/recentpireps/i',$host)) {
238
+			//$formats[$id] = 'pirepsjson';
239
+			$globalSources[$id]['format'] = 'pirepsjson';
240
+			//$last_exec['pirepsjson'] = 0;
241
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
242
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243
+			//$formats[$id] = 'fr24json';
244
+			$globalSources[$id]['format'] = 'fr24json';
245
+			//$last_exec['fr24json'] = 0;
246
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
247
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249
+				exit(0);
250
+			}
251
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
252
+			//$formats[$id] = 'fr24json';
253
+			$globalSources[$id]['format'] = 'myshiptracking';
254
+			//$last_exec['fr24json'] = 0;
255
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
256
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258
+				exit(0);
259
+			}
260
+			//} else if (preg_match('/10001/',$host)) {
261
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262
+			//$formats[$id] = 'tsv';
263
+			$globalSources[$id]['format'] = 'tsv';
264
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
265
+			}
266
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
269
+				if ($idf !== false) {
270
+				$httpfeeds[$id] = $idf;
271
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276
+		$hostport = explode(':',$host);
277
+		if (isset($hostport[1])) {
278 278
 		$port = $hostport[1];
279 279
 		$hostn = $hostport[0];
280
-	    } else {
280
+		} else {
281 281
 		$port = $globalSources[$id]['port'];
282 282
 		$hostn = $globalSources[$id]['host'];
283
-	    }
284
-	    $Common = new Common();
285
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
-    	    } else {
288
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
-	    }
290
-	    if ($s) {
291
-    	        $sockets[$id] = $s;
292
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
283
+		}
284
+		$Common = new Common();
285
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
286
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
287
+			} else {
288
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
289
+		}
290
+		if ($s) {
291
+				$sockets[$id] = $s;
292
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
293
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
294 294
 			//$formats[$id] = 'aprs';
295 295
 			$globalSources[$id]['format'] = 'aprs';
296 296
 			//$aprs_connect = 0;
297 297
 			//$use_aprs = true;
298
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
298
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
299 299
 			$globalSources[$id]['format'] = 'vrstcp';
300
-    		    } elseif ($port == '10001') {
301
-        		//$formats[$id] = 'tsv';
302
-        		$globalSources[$id]['format'] = 'tsv';
303
-		    } elseif ($port == '30002') {
304
-        		//$formats[$id] = 'raw';
305
-        		$globalSources[$id]['format'] = 'raw';
306
-		    } elseif ($port == '5001') {
307
-        		//$formats[$id] = 'raw';
308
-        		$globalSources[$id]['format'] = 'flightgearmp';
309
-		    } elseif ($port == '30005') {
300
+				} elseif ($port == '10001') {
301
+				//$formats[$id] = 'tsv';
302
+				$globalSources[$id]['format'] = 'tsv';
303
+			} elseif ($port == '30002') {
304
+				//$formats[$id] = 'raw';
305
+				$globalSources[$id]['format'] = 'raw';
306
+			} elseif ($port == '5001') {
307
+				//$formats[$id] = 'raw';
308
+				$globalSources[$id]['format'] = 'flightgearmp';
309
+			} elseif ($port == '30005') {
310 310
 			// Not yet supported
311
-        		//$formats[$id] = 'beast';
312
-        		$globalSources[$id]['format'] = 'beast';
313
-		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
315
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
311
+				//$formats[$id] = 'beast';
312
+				$globalSources[$id]['format'] = 'beast';
313
+			//} else $formats[$id] = 'sbs';
314
+			} else $globalSources[$id]['format'] = 'sbs';
315
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 316
 		}
317 317
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
318
-            } else {
318
+			} else {
319 319
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
320 320
 		sleep(10);
321 321
 		connect_all($hosts);
322
-    	    }
323
-        }
324
-    }
322
+			}
323
+		}
324
+	}
325 325
 }
326 326
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
327 327
 
@@ -344,9 +344,9 @@  discard block
 block discarded – undo
344 344
 //connect_all($globalSources);
345 345
 
346 346
 if (isset($globalProxy) && $globalProxy) {
347
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
347
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
348 348
 } else {
349
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
349
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
350 350
 }
351 351
 
352 352
 // APRS Configuration
@@ -355,21 +355,21 @@  discard block
 block discarded – undo
355 355
 	die;
356 356
 }
357 357
 foreach ($globalSources as $key => $source) {
358
-    if (!isset($source['format'])) {
359
-        $globalSources[$key]['format'] = 'auto';
360
-    }
361
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
362
-        unset($globalSources[$key]);
363
-    }
358
+	if (!isset($source['format'])) {
359
+		$globalSources[$key]['format'] = 'auto';
360
+	}
361
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
362
+		unset($globalSources[$key]);
363
+	}
364 364
 }
365 365
 connect_all($globalSources);
366 366
 foreach ($globalSources as $key => $source) {
367
-    if (isset($source['format']) && $source['format'] == 'aprs') {
367
+	if (isset($source['format']) && $source['format'] == 'aprs') {
368 368
 	$aprs_connect = 0;
369 369
 	$use_aprs = true;
370 370
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
371 371
 	break;
372
-    }
372
+	}
373 373
 }
374 374
 
375 375
 if ($use_aprs) {
@@ -410,133 +410,133 @@  discard block
 block discarded – undo
410 410
 
411 411
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 412
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
413
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
414 414
 
415
-    if (!$globalDaemon) $i = $endtime-time();
416
-    // Delete old ATC
417
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
415
+	if (!$globalDaemon) $i = $endtime-time();
416
+	// Delete old ATC
417
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418 418
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
419
-        $ATC->deleteOldATC();
420
-    }
419
+		$ATC->deleteOldATC();
420
+	}
421 421
     
422
-    if (count($last_exec) == count($globalSources)) {
422
+	if (count($last_exec) == count($globalSources)) {
423 423
 	$max = $globalMinFetch;
424 424
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
425
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
426 426
 	}
427 427
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
429
-	    sleep($globalMinFetch-$max+2);
428
+		if ($globalDebug) echo 'Sleeping...'."\n";
429
+		sleep($globalMinFetch-$max+2);
430
+	}
430 431
 	}
431
-    }
432 432
 
433 433
     
434
-    //foreach ($formats as $id => $value) {
435
-    foreach ($globalSources as $id => $value) {
434
+	//foreach ($formats as $id => $value) {
435
+	foreach ($globalSources as $id => $value) {
436 436
 	date_default_timezone_set('UTC');
437 437
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438 438
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
439 439
 	if ($value['format'] === 'deltadbtxt' && 
440
-	    (
440
+		(
441 441
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
442 442
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
443
-	    )
443
+		)
444 444
 	) {
445
-	    //$buffer = $Common->getData($hosts[$id]);
446
-	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
448
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
-	    $buffer = explode('\n',$buffer);
450
-	    foreach ($buffer as $line) {
451
-    		if ($line != '' && count($line) > 7) {
452
-    		    $line = explode(',', $line);
453
-	            $data = array();
454
-	            $data['hex'] = $line[1]; // hex
455
-	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
-	            $data['verticalrate'] = ''; // vertical rate
462
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
-	            $data['emergency'] = ''; // emergency
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    $data['format_source'] = 'deltadbtxt';
466
-    		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
-    		    $SI->add($data);
471
-		    unset($data);
472
-    		}
473
-    	    }
474
-    	    $last_exec[$id]['last'] = time();
445
+		//$buffer = $Common->getData($hosts[$id]);
446
+		$buffer = $Common->getData($value['host']);
447
+		if ($buffer != '') $reset = 0;
448
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449
+		$buffer = explode('\n',$buffer);
450
+		foreach ($buffer as $line) {
451
+			if ($line != '' && count($line) > 7) {
452
+				$line = explode(',', $line);
453
+				$data = array();
454
+				$data['hex'] = $line[1]; // hex
455
+				$data['ident'] = $line[2]; // ident
456
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
461
+				$data['verticalrate'] = ''; // vertical rate
462
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463
+				$data['emergency'] = ''; // emergency
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			$data['format_source'] = 'deltadbtxt';
466
+				$data['id_source'] = $id_source;
467
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
470
+				$SI->add($data);
471
+			unset($data);
472
+			}
473
+			}
474
+			$last_exec[$id]['last'] = time();
475 475
 	} elseif ($value['format'] === 'aisnmeatxt' && 
476
-	    (
476
+		(
477 477
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
478 478
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
479
-	    )
479
+		)
480 480
 	) {
481
-	    date_default_timezone_set('CET');
482
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
-	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
485
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
-	    $buffer = explode('\n',$buffer);
487
-	    foreach ($buffer as $line) {
481
+		date_default_timezone_set('CET');
482
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483
+		date_default_timezone_set('UTC');
484
+		if ($buffer != '') $reset = 0;
485
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486
+		$buffer = explode('\n',$buffer);
487
+		foreach ($buffer as $line) {
488 488
 		if ($line != '') {
489
-		    //echo "'".$line."'\n";
490
-		    $add = false;
491
-		    $ais_data = $AIS->parse_line(trim($line));
492
-		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
-		    if (isset($ais_data['timestamp'])) {
489
+			//echo "'".$line."'\n";
490
+			$add = false;
491
+			$ais_data = $AIS->parse_line(trim($line));
492
+			$data = array();
493
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
505
+			if (isset($ais_data['timestamp'])) {
506 506
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 507
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
508
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
-			    $add = true;
508
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
509
+				$add = true;
510 510
 			}
511
-		    } else {
511
+			} else {
512 512
 			$data['datetime'] = date('Y-m-d H:i:s');
513 513
 			$add = true;
514
-		    }
515
-		    $data['format_source'] = 'aisnmeatxt';
516
-    		    $data['id_source'] = $id_source;
517
-		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
-		    unset($data);
514
+			}
515
+			$data['format_source'] = 'aisnmeatxt';
516
+				$data['id_source'] = $id_source;
517
+			//print_r($data);
518
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
520
+			unset($data);
521 521
 		}
522
-    	    }
523
-    	    $last_exec[$id]['last'] = time();
522
+			}
523
+			$last_exec[$id]['last'] = time();
524 524
 	} elseif ($value['format'] === 'aisnmeahttp') {
525
-	    $arr = $httpfeeds;
526
-	    $w = $e = null;
525
+		$arr = $httpfeeds;
526
+		$w = $e = null;
527 527
 	    
528
-	    if (isset($arr[$id])) {
528
+		if (isset($arr[$id])) {
529 529
 		$nn = stream_select($arr,$w,$e,$timeout);
530 530
 		if ($nn > 0) {
531
-		    foreach ($httpfeeds as $feed) {
531
+			foreach ($httpfeeds as $feed) {
532 532
 			$buffer = stream_get_line($feed,2000,"\n");
533 533
 			if ($buffer === FALSE) {
534
-			    connect_all($globalSources);
534
+				connect_all($globalSources);
535 535
 			}
536 536
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
537 537
 			$buffer = explode('\n',$buffer);
538 538
 			foreach ($buffer as $line) {
539
-			    if ($line != '') {
539
+				if ($line != '') {
540 540
 				$ais_data = $AIS->parse_line(trim($line));
541 541
 				$data = array();
542 542
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -554,117 +554,117 @@  discard block
 block discarded – undo
554 554
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555 555
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
556 556
 				if (isset($ais_data['timestamp'])) {
557
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
557
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 558
 				} else {
559
-				    $data['datetime'] = date('Y-m-d H:i:s');
559
+					$data['datetime'] = date('Y-m-d H:i:s');
560 560
 				}
561 561
 				$data['format_source'] = 'aisnmeahttp';
562 562
 				$data['id_source'] = $id_source;
563 563
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564 564
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
565 565
 				unset($data);
566
-			    }
566
+				}
567
+			}
567 568
 			}
568
-		    }
569 569
 		} else {
570
-		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
573
-		    if ($tt[$format] > 30) {
570
+			$format = $value['format'];
571
+			if (isset($tt[$format])) $tt[$format]++;
572
+			else $tt[$format] = 0;
573
+			if ($tt[$format] > 30) {
574 574
 			if ($globalDebug) echo 'Reconnect...'."\n";
575 575
 			sleep(2);
576 576
 			//$sourceeen[] = $value;
577 577
 			//connect_all($sourceeen);
578 578
 			//$sourceeen = array();
579 579
 			connect_all($globalSources);
580
-		    }
580
+			}
581
+		}
581 582
 		}
582
-	    }
583 583
 	} elseif ($value['format'] === 'myshiptracking' && 
584
-	    (
584
+		(
585 585
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
586 586
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
587
-	    )
587
+		)
588 588
 	) {
589
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
590
-	    if ($buffer != '') {
589
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
590
+		if ($buffer != '') {
591 591
 		//echo $buffer;
592 592
 		$all_data = json_decode($buffer,true);
593 593
 		//print_r($all_data);
594 594
 		if (isset($all_data[0]['DATA'])) {
595
-		    foreach ($all_data[0]['DATA'] as $line) {
595
+			foreach ($all_data[0]['DATA'] as $line) {
596 596
 			if ($line != '') {
597
-			    $data = array();
598
-			    $data['ident'] = $line['NAME'];
599
-			    $data['mmsi'] = $line['MMSI'];
600
-			    if (strlen($data['mmsi']) > 9) {
597
+				$data = array();
598
+				$data['ident'] = $line['NAME'];
599
+				$data['mmsi'] = $line['MMSI'];
600
+				if (strlen($data['mmsi']) > 9) {
601 601
 				$data['mmsi'] = substr($data['mmsi'],-9);
602
-			    }
603
-			    $data['speed'] = $line['SOG'];
604
-			    $data['heading'] = $line['COG'];
605
-			    $data['latitude'] = $line['LAT'];
606
-			    $data['longitude'] = $line['LNG'];
607
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
-			    //$data['type_id'] = $line['TYPE'];
609
-			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
-			    $data['format_source'] = 'myshiptracking';
614
-			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-			    $MI->add($data);
617
-			    unset($data);
602
+				}
603
+				$data['speed'] = $line['SOG'];
604
+				$data['heading'] = $line['COG'];
605
+				$data['latitude'] = $line['LAT'];
606
+				$data['longitude'] = $line['LNG'];
607
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608
+				//$data['type_id'] = $line['TYPE'];
609
+				$data['imo'] = $line['IMO'];
610
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
612
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613
+				$data['format_source'] = 'myshiptracking';
614
+				$data['id_source'] = $id_source;
615
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
+				$MI->add($data);
617
+				unset($data);
618
+			}
618 619
 			}
619
-		    }
620 620
 		}
621
-	    }
622
-	    $last_exec[$id]['last'] = time();
621
+		}
622
+		$last_exec[$id]['last'] = time();
623 623
 	} elseif ($value['format'] === 'boatbeaconapp' && 
624
-	    (
624
+		(
625 625
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
626 626
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
627
-	    )
627
+		)
628 628
 	) {
629
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
-	    if ($buffer != '') {
629
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
630
+		if ($buffer != '') {
631 631
 		$all_data = json_decode($buffer,true);
632 632
 		if (isset($all_data[0]['mmsi'])) {
633
-		    foreach ($all_data as $line) {
633
+			foreach ($all_data as $line) {
634 634
 			if ($line != '') {
635
-			    $data = array();
636
-			    $data['ident'] = $line['shipname'];
637
-			    $data['callsign'] = $line['callsign'];
638
-			    $data['mmsi'] = substr($line['mmsi'],-9);
639
-			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
-			    $data['latitude'] = $line['latitude'];
642
-			    $data['longitude'] = $line['longitude'];
643
-			    $data['type_id'] = $line['shiptype'];
644
-			    $data['arrival_code'] = $line['destination'];
645
-			    $data['datetime'] = $line['time'];
646
-			    $data['format_source'] = 'boatbeaconapp';
647
-			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
-			    $MI->add($data);
650
-			    unset($data);
635
+				$data = array();
636
+				$data['ident'] = $line['shipname'];
637
+				$data['callsign'] = $line['callsign'];
638
+				$data['mmsi'] = substr($line['mmsi'],-9);
639
+				$data['speed'] = $line['sog'];
640
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
641
+				$data['latitude'] = $line['latitude'];
642
+				$data['longitude'] = $line['longitude'];
643
+				$data['type_id'] = $line['shiptype'];
644
+				$data['arrival_code'] = $line['destination'];
645
+				$data['datetime'] = $line['time'];
646
+				$data['format_source'] = 'boatbeaconapp';
647
+				$data['id_source'] = $id_source;
648
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
649
+				$MI->add($data);
650
+				unset($data);
651
+			}
651 652
 			}
652
-		    }
653 653
 		}
654 654
 		
655
-	    }
656
-    	    $last_exec[$id]['last'] = time();
655
+		}
656
+			$last_exec[$id]['last'] = time();
657 657
 	} elseif ($value['format'] === 'boatnerd' && 
658
-	    (
658
+		(
659 659
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
660 660
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
661
-	    )
661
+		)
662 662
 	) {
663
-	    $buffer = $Common->getData($value['host']);
664
-	    if ($buffer != '') {
663
+		$buffer = $Common->getData($value['host']);
664
+		if ($buffer != '') {
665 665
 		$all_data = json_decode($buffer,true);
666 666
 		if (isset($all_data['features'][0]['id'])) {
667
-		    foreach ($all_data['features'] as $line) {
667
+			foreach ($all_data['features'] as $line) {
668 668
 			print_r($line);
669 669
 			$data = array();
670 670
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -684,66 +684,66 @@  discard block
 block discarded – undo
684 684
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685 685
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
686 686
 			unset($data);
687
-		    }
687
+			}
688 688
 		}
689 689
 		
690
-	    }
691
-    	    $last_exec[$id]['last'] = time();
690
+		}
691
+			$last_exec[$id]['last'] = time();
692 692
 	} elseif ($value['format'] === 'shipplotter' && 
693
-	    (
693
+		(
694 694
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
695 695
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696
-	    )
696
+		)
697 697
 	) {
698
-	    if ($globalDebug) echo 'download...';
699
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
701
-	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
703
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
-	    $buffer = explode('\n',$buffer);
705
-	    foreach ($buffer as $line) {
698
+		if ($globalDebug) echo 'download...';
699
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
+		if ($globalDebug) echo 'done !'."\n";
701
+		// FIXME: Need more work
702
+		if ($buffer != '') $reset = 0;
703
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704
+		$buffer = explode('\n',$buffer);
705
+		foreach ($buffer as $line) {
706 706
 		if ($line != '') {
707
-		    $data = array();
708
-		    //echo $line."\n";
709
-		    $data['mmsi'] = (int)substr($line,0,9);
710
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
-		    $data['status_id'] = substr($line,21,2);
712
-		    $data['type_id'] = substr($line,24,3);
713
-		    $data['latitude'] = substr($line,29,9);
714
-		    $data['longitude'] = substr($line,41,9);
715
-		    $data['speed'] = round(substr($line,51,5));
716
-		    //$data['course'] = substr($line,57,5);
717
-		    $data['heading'] = round(substr($line,63,3));
718
-		    //$data['draft'] = substr($line,67,4);
719
-		    //$data['length'] = substr($line,72,3);
720
-		    //$data['beam'] = substr($line,76,2);
721
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
-		    //$data['callsign'] = trim(substr($line,100,7);
723
-		    $data['arrival_code'] = substr($line,108,20);
724
-		    //$data['etaDate'] = substr($line,129,5);
725
-		    //$data['etaTime'] = substr($line,135,5);
726
-		    $data['format_source'] = 'shipplotter';
727
-    		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
-		    //print_r($data);
730
-		    //echo 'Add...'."\n";
731
-		    $MI->add($data);
732
-		    unset($data);
707
+			$data = array();
708
+			//echo $line."\n";
709
+			$data['mmsi'] = (int)substr($line,0,9);
710
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
711
+			$data['status_id'] = substr($line,21,2);
712
+			$data['type_id'] = substr($line,24,3);
713
+			$data['latitude'] = substr($line,29,9);
714
+			$data['longitude'] = substr($line,41,9);
715
+			$data['speed'] = round(substr($line,51,5));
716
+			//$data['course'] = substr($line,57,5);
717
+			$data['heading'] = round(substr($line,63,3));
718
+			//$data['draft'] = substr($line,67,4);
719
+			//$data['length'] = substr($line,72,3);
720
+			//$data['beam'] = substr($line,76,2);
721
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
722
+			//$data['callsign'] = trim(substr($line,100,7);
723
+			$data['arrival_code'] = substr($line,108,20);
724
+			//$data['etaDate'] = substr($line,129,5);
725
+			//$data['etaTime'] = substr($line,135,5);
726
+			$data['format_source'] = 'shipplotter';
727
+				$data['id_source'] = $id_source;
728
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
729
+			//print_r($data);
730
+			//echo 'Add...'."\n";
731
+			$MI->add($data);
732
+			unset($data);
733 733
 		}
734
-    	    }
735
-    	    $last_exec[$id]['last'] = time();
734
+			}
735
+			$last_exec[$id]['last'] = time();
736 736
 	} elseif ($value['format'] === 'sailaway' && 
737
-	    (
737
+		(
738 738
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
739 739
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740
-	    )
740
+		)
741 741
 	) {
742
-	    if ($globalDebug) echo 'download...';
743
-	    for ($i =0; $i <= 1; $i++) {
744
-	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
745
-	    if ($globalDebug) echo 'done'."\n";
746
-	    if ($buffer != '') {
742
+		if ($globalDebug) echo 'download...';
743
+		for ($i =0; $i <= 1; $i++) {
744
+		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
745
+		if ($globalDebug) echo 'done'."\n";
746
+		if ($buffer != '') {
747 747
 		$all_data = json_decode($buffer,true);
748 748
 		if (isset($all_data['missions'])) {
749 749
 			foreach ($all_data['missions'] as $mission) {
@@ -791,34 +791,34 @@  discard block
 block discarded – undo
791 791
 				}
792 792
 			}
793 793
 		}
794
-	    }
795
-	    }
796
-    	    $last_exec[$id]['last'] = time();
794
+		}
795
+		}
796
+			$last_exec[$id]['last'] = time();
797 797
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
798 798
 	} elseif (
799
-	    (
799
+		(
800 800
 		$value['format'] === 'whazzup' && 
801 801
 		(
802
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
803
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
802
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
803
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
804 804
 		)
805
-	    ) || (
805
+		) || (
806 806
 		$value['format'] === 'vatsimtxt' && 
807 807
 		(
808
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
809
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
808
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
809
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
810
+		)
810 811
 		)
811
-	    )
812 812
 	) {
813
-	    //$buffer = $Common->getData($hosts[$id]);
814
-	    $buffer = $Common->getData($value['host']);
815
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
816
-	    $buffer = explode('\n',$buffer);
817
-	    $reset = 0;
818
-	    foreach ($buffer as $line) {
819
-    		if ($line != '') {
820
-    		    $line = explode(':', $line);
821
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
813
+		//$buffer = $Common->getData($hosts[$id]);
814
+		$buffer = $Common->getData($value['host']);
815
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
816
+		$buffer = explode('\n',$buffer);
817
+		$reset = 0;
818
+		foreach ($buffer as $line) {
819
+			if ($line != '') {
820
+				$line = explode(':', $line);
821
+				if (count($line) > 30 && $line[0] != 'callsign') {
822 822
 			$data = array();
823 823
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
824 824
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -831,37 +831,37 @@  discard block
 block discarded – undo
831 831
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
832 832
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
833 833
 			$data['latitude'] = $line[5]; // lat
834
-	        	$data['longitude'] = $line[6]; // long
835
-	        	$data['verticalrate'] = ''; // vertical rate
836
-	        	$data['squawk'] = ''; // squawk
837
-	        	$data['emergency'] = ''; // emergency
838
-	        	$data['waypoints'] = $line[30];
834
+				$data['longitude'] = $line[6]; // long
835
+				$data['verticalrate'] = ''; // vertical rate
836
+				$data['squawk'] = ''; // squawk
837
+				$data['emergency'] = ''; // emergency
838
+				$data['waypoints'] = $line[30];
839 839
 			$data['datetime'] = date('Y-m-d H:i:s');
840 840
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
841 841
 			//if (isset($line[37])) $data['last_update'] = $line[37];
842
-		        $data['departure_airport_icao'] = $line[11];
843
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
844
-		        $data['arrival_airport_icao'] = $line[13];
842
+				$data['departure_airport_icao'] = $line[11];
843
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
844
+				$data['arrival_airport_icao'] = $line[13];
845 845
 			$data['frequency'] = $line[4];
846 846
 			$data['type'] = $line[18];
847 847
 			$data['range'] = $line[19];
848 848
 			if (isset($line[35])) $data['info'] = $line[35];
849
-    			$data['id_source'] = $id_source;
850
-	    		//$data['arrival_airport_time'] = ;
851
-	    		if ($line[9] != '') {
852
-	    		    $aircraft_data = explode('/',$line[9]);
853
-	    		    if (isset($aircraft_data[1])) {
854
-	    			$data['aircraft_icao'] = $aircraft_data[1];
855
-	    		    }
856
-        		}
857
-	    		/*
849
+				$data['id_source'] = $id_source;
850
+				//$data['arrival_airport_time'] = ;
851
+				if ($line[9] != '') {
852
+					$aircraft_data = explode('/',$line[9]);
853
+					if (isset($aircraft_data[1])) {
854
+					$data['aircraft_icao'] = $aircraft_data[1];
855
+					}
856
+				}
857
+				/*
858 858
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
859 859
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
860 860
 	    		*/
861
-	    		$data['format_source'] = $value['format'];
861
+				$data['format_source'] = $value['format'];
862 862
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
863 863
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
864
-    			if ($line[3] === 'PILOT') $SI->add($data);
864
+				if ($line[3] === 'PILOT') $SI->add($data);
865 865
 			elseif ($line[3] === 'ATC') {
866 866
 				//print_r($data);
867 867
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -882,21 +882,21 @@  discard block
 block discarded – undo
882 882
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
883 883
 				}
884 884
 			}
885
-    			unset($data);
886
-    		    }
887
-    		}
888
-    	    }
889
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
890
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
891
-    	    $last_exec[$id]['last'] = time();
892
-    	} elseif ($value['format'] === 'airwhere' && 
893
-    	    (
894
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
895
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
896
-    	    )
897
-    	) {
898
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
899
-	    if ($buffer != '') {
885
+				unset($data);
886
+				}
887
+			}
888
+			}
889
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
890
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
891
+			$last_exec[$id]['last'] = time();
892
+		} elseif ($value['format'] === 'airwhere' && 
893
+			(
894
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
895
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
896
+			)
897
+		) {
898
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
899
+		if ($buffer != '') {
900 900
 		$all_data = simplexml_load_string($buffer);
901 901
 		foreach($all_data->children() as $childdata) {
902 902
 			$data = array();
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
 			$SI->add($data);
919 919
 			unset($data);
920 920
 		}
921
-	    }
922
-	    $Source->deleteOldLocationByType('gs');
923
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
924
-	    if ($buffer != '') {
921
+		}
922
+		$Source->deleteOldLocationByType('gs');
923
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
924
+		if ($buffer != '') {
925 925
 		$all_data = simplexml_load_string($buffer);
926 926
 		foreach($all_data->children() as $childdata) {
927 927
 			$data = array();
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 			}
940 940
 			unset($data);
941 941
 		}
942
-	    }
943
-	    $last_exec[$id]['last'] = time();
942
+		}
943
+		$last_exec[$id]['last'] = time();
944 944
 	/*
945 945
 	} if ($value['format'] === 'aircraftlistjson') {
946 946
 	    print_r($globalSources);
@@ -948,17 +948,17 @@  discard block
 block discarded – undo
948 948
 	    echo $globalMinFetch;
949 949
 	*/
950 950
 	} elseif ($value['format'] === 'aircraftlistjson' && 
951
-	    (
951
+		(
952 952
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
953 953
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
954
-	    )
954
+		)
955 955
 	) {
956
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
957
-	    if ($buffer != '') {
958
-	        $all_data = json_decode($buffer,true);
956
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
957
+		if ($buffer != '') {
958
+			$all_data = json_decode($buffer,true);
959 959
 		if (isset($all_data['acList'])) {
960
-		    $reset = 0;
961
-		    foreach ($all_data['acList'] as $line) {
960
+			$reset = 0;
961
+			foreach ($all_data['acList'] as $line) {
962 962
 			$data = array();
963 963
 			$data['hex'] = $line['Icao']; // hex
964 964
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -981,10 +981,10 @@  discard block
 block discarded – undo
981 981
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
982 982
 			if (isset($data['latitude'])) $SI->add($data);
983 983
 			unset($data);
984
-		    }
984
+			}
985 985
 		} elseif (is_array($all_data)) {
986
-		    $reset = 0;
987
-		    foreach ($all_data as $line) {
986
+			$reset = 0;
987
+			foreach ($all_data as $line) {
988 988
 			$data = array();
989 989
 			$data['hex'] = $line['hex']; // hex
990 990
 			$data['ident'] = $line['flight']; // ident
@@ -1004,291 +1004,291 @@  discard block
 block discarded – undo
1004 1004
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1005 1005
 			$SI->add($data);
1006 1006
 			unset($data);
1007
-		    }
1007
+			}
1008 1008
 		}
1009
-	    } elseif ($globalDebug) echo 'No data'."\n";
1010
-    	    //$last_exec['aircraftlistjson'] = time();
1011
-    	    $last_exec[$id]['last'] = time();
1012
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1013
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1014
-    	    (
1015
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1016
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1017
-    	    )
1018
-    	) {
1019
-	    $buffer = $Common->getData($value['host']);
1020
-	    $all_data = json_decode($buffer,true);
1021
-	    if (isset($all_data['planes'])) {
1009
+		} elseif ($globalDebug) echo 'No data'."\n";
1010
+			//$last_exec['aircraftlistjson'] = time();
1011
+			$last_exec[$id]['last'] = time();
1012
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1013
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1014
+			(
1015
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1016
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1017
+			)
1018
+		) {
1019
+		$buffer = $Common->getData($value['host']);
1020
+		$all_data = json_decode($buffer,true);
1021
+		if (isset($all_data['planes'])) {
1022 1022
 		$reset = 0;
1023 1023
 		foreach ($all_data['planes'] as $key => $line) {
1024
-		    $data = array();
1025
-		    $data['hex'] = $key; // hex
1026
-		    $data['ident'] = $line[3]; // ident
1027
-		    $data['altitude'] = $line[6]; // altitude
1028
-		    $data['speed'] = $line[8]; // speed
1029
-		    $data['heading'] = $line[7]; // heading
1030
-		    $data['latitude'] = $line[4]; // lat
1031
-		    $data['longitude'] = $line[5]; // long
1032
-		    //$data['verticalrate'] = $line[]; // verticale rate
1033
-		    $data['squawk'] = $line[10]; // squawk
1034
-		    $data['emergency'] = ''; // emergency
1035
-		    $data['registration'] = $line[2];
1036
-		    $data['aircraft_icao'] = $line[0];
1037
-		    $deparr = explode('-',$line[1]);
1038
-		    if (count($deparr) === 2) {
1024
+			$data = array();
1025
+			$data['hex'] = $key; // hex
1026
+			$data['ident'] = $line[3]; // ident
1027
+			$data['altitude'] = $line[6]; // altitude
1028
+			$data['speed'] = $line[8]; // speed
1029
+			$data['heading'] = $line[7]; // heading
1030
+			$data['latitude'] = $line[4]; // lat
1031
+			$data['longitude'] = $line[5]; // long
1032
+			//$data['verticalrate'] = $line[]; // verticale rate
1033
+			$data['squawk'] = $line[10]; // squawk
1034
+			$data['emergency'] = ''; // emergency
1035
+			$data['registration'] = $line[2];
1036
+			$data['aircraft_icao'] = $line[0];
1037
+			$deparr = explode('-',$line[1]);
1038
+			if (count($deparr) === 2) {
1039 1039
 			$data['departure_airport_icao'] = $deparr[0];
1040 1040
 			$data['arrival_airport_icao'] = $deparr[1];
1041
-		    }
1042
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1043
-	    	    $data['format_source'] = 'planeupdatefaa';
1044
-    		    $data['id_source'] = $id_source;
1045
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1046
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1047
-		    $SI->add($data);
1048
-		    unset($data);
1041
+			}
1042
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1043
+				$data['format_source'] = 'planeupdatefaa';
1044
+				$data['id_source'] = $id_source;
1045
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1046
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1047
+			$SI->add($data);
1048
+			unset($data);
1049 1049
 		}
1050
-	    }
1051
-	    //$last_exec['planeupdatefaa'] = time();
1052
-	    $last_exec[$id]['last'] = time();
1050
+		}
1051
+		//$last_exec['planeupdatefaa'] = time();
1052
+		$last_exec[$id]['last'] = time();
1053 1053
 	} elseif ($value['format'] === 'opensky' && 
1054
-	    (
1054
+		(
1055 1055
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1056 1056
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1057
-	    )
1057
+		)
1058 1058
 	) {
1059
-	    $buffer = $Common->getData($value['host']);
1060
-	    $all_data = json_decode($buffer,true);
1061
-	    if (isset($all_data['states'])) {
1059
+		$buffer = $Common->getData($value['host']);
1060
+		$all_data = json_decode($buffer,true);
1061
+		if (isset($all_data['states'])) {
1062 1062
 		$reset = 0;
1063 1063
 		foreach ($all_data['states'] as $key => $line) {
1064
-		    $data = array();
1065
-		    $data['hex'] = $line[0]; // hex
1066
-		    $data['ident'] = trim($line[1]); // ident
1067
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1068
-		    $data['speed'] = round($line[9]*1.94384); // speed
1069
-		    $data['heading'] = round($line[10]); // heading
1070
-		    $data['latitude'] = $line[6]; // lat
1071
-		    $data['longitude'] = $line[5]; // long
1072
-		    $data['verticalrate'] = $line[11]; // verticale rate
1073
-		    //$data['squawk'] = $line[10]; // squawk
1074
-		    //$data['emergency'] = ''; // emergency
1075
-		    //$data['registration'] = $line[2];
1076
-		    //$data['aircraft_icao'] = $line[0];
1077
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1078
-		    $data['format_source'] = 'opensky';
1079
-		    $data['id_source'] = $id_source;
1080
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1081
-		    $SI->add($data);
1082
-		    unset($data);
1064
+			$data = array();
1065
+			$data['hex'] = $line[0]; // hex
1066
+			$data['ident'] = trim($line[1]); // ident
1067
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1068
+			$data['speed'] = round($line[9]*1.94384); // speed
1069
+			$data['heading'] = round($line[10]); // heading
1070
+			$data['latitude'] = $line[6]; // lat
1071
+			$data['longitude'] = $line[5]; // long
1072
+			$data['verticalrate'] = $line[11]; // verticale rate
1073
+			//$data['squawk'] = $line[10]; // squawk
1074
+			//$data['emergency'] = ''; // emergency
1075
+			//$data['registration'] = $line[2];
1076
+			//$data['aircraft_icao'] = $line[0];
1077
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1078
+			$data['format_source'] = 'opensky';
1079
+			$data['id_source'] = $id_source;
1080
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1081
+			$SI->add($data);
1082
+			unset($data);
1083
+		}
1083 1084
 		}
1084
-	    }
1085
-	    //$last_exec['planeupdatefaa'] = time();
1086
-	    $last_exec[$id]['last'] = time();
1085
+		//$last_exec['planeupdatefaa'] = time();
1086
+		$last_exec[$id]['last'] = time();
1087 1087
 	} elseif ($value['format'] === 'aircraftjson' && 
1088
-	    (
1088
+		(
1089 1089
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1090 1090
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1091
-	    )
1091
+		)
1092 1092
 	) {
1093
-	    $buffer = $Common->getData($value['host']);
1094
-	    $all_data = json_decode($buffer,true);
1095
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1093
+		$buffer = $Common->getData($value['host']);
1094
+		$all_data = json_decode($buffer,true);
1095
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1096 1096
 		$reset = 0;
1097 1097
 		foreach ($all_data['aircraft'] as $key => $line) {
1098
-		    $data = array();
1099
-		    // add support for ground vehicule with ~ in front of hex
1100
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1101
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1102
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1103
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1104
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1105
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1106
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1107
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1108
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1109
-		    //$data['emergency'] = ''; // emergency
1110
-		    //$data['registration'] = $line[2];
1111
-		    //$data['aircraft_icao'] = $line[0];
1112
-		    $data['datetime'] = date('Y-m-d H:i:s');
1113
-		    $data['format_source'] = 'aircraftjson';
1114
-		    $data['id_source'] = $id_source;
1115
-		    if (isset($value['name']) && $value['name'] != '') {
1116
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1117
-			    else $data['source_name'] = $value['name'];
1118
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1119
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
-		    $SI->add($data);
1121
-		    unset($data);
1098
+			$data = array();
1099
+			// add support for ground vehicule with ~ in front of hex
1100
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1101
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1102
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1103
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1104
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1105
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1106
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1107
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1108
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1109
+			//$data['emergency'] = ''; // emergency
1110
+			//$data['registration'] = $line[2];
1111
+			//$data['aircraft_icao'] = $line[0];
1112
+			$data['datetime'] = date('Y-m-d H:i:s');
1113
+			$data['format_source'] = 'aircraftjson';
1114
+			$data['id_source'] = $id_source;
1115
+			if (isset($value['name']) && $value['name'] != '') {
1116
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1117
+				else $data['source_name'] = $value['name'];
1118
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1119
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1120
+			$SI->add($data);
1121
+			unset($data);
1122 1122
 		}
1123
-	    }
1124
-	    //$last_exec['planeupdatefaa'] = time();
1125
-	    $last_exec[$id]['last'] = time();
1123
+		}
1124
+		//$last_exec['planeupdatefaa'] = time();
1125
+		$last_exec[$id]['last'] = time();
1126 1126
 	} elseif ($value['format'] === 'planefinderclient' && 
1127
-	    (
1127
+		(
1128 1128
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1129 1129
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1130
-	    )
1130
+		)
1131 1131
 	) {
1132
-	    $buffer = $Common->getData($value['host']);
1133
-	    $all_data = json_decode($buffer,true);
1134
-	    if (isset($all_data['aircraft'])) {
1132
+		$buffer = $Common->getData($value['host']);
1133
+		$all_data = json_decode($buffer,true);
1134
+		if (isset($all_data['aircraft'])) {
1135 1135
 		$reset = 0;
1136 1136
 		foreach ($all_data['aircraft'] as $key => $line) {
1137
-		    $data = array();
1138
-		    $data['hex'] = $key; // hex
1139
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1140
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1141
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1142
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1143
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1144
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1145
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1146
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1147
-		    //$data['emergency'] = ''; // emergency
1148
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1149
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1150
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1151
-		    $data['format_source'] = 'planefinderclient';
1152
-		    $data['id_source'] = $id_source;
1153
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1154
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1155
-		    $SI->add($data);
1156
-		    unset($data);
1137
+			$data = array();
1138
+			$data['hex'] = $key; // hex
1139
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1140
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1141
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1142
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1143
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1144
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1145
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1146
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1147
+			//$data['emergency'] = ''; // emergency
1148
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1149
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1150
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1151
+			$data['format_source'] = 'planefinderclient';
1152
+			$data['id_source'] = $id_source;
1153
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1154
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1155
+			$SI->add($data);
1156
+			unset($data);
1157
+		}
1157 1158
 		}
1158
-	    }
1159
-	    $last_exec[$id]['last'] = time();
1159
+		$last_exec[$id]['last'] = time();
1160 1160
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1161 1161
 	} elseif ($value['format'] === 'fr24json' && 
1162
-	    (
1162
+		(
1163 1163
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1164 1164
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1165
-	    )
1165
+		)
1166 1166
 	) {
1167
-	    //$buffer = $Common->getData($hosts[$id]);
1168
-	    $buffer = $Common->getData($value['host']);
1169
-	    $all_data = json_decode($buffer,true);
1170
-	    if (!empty($all_data)) $reset = 0;
1171
-	    foreach ($all_data as $key => $line) {
1167
+		//$buffer = $Common->getData($hosts[$id]);
1168
+		$buffer = $Common->getData($value['host']);
1169
+		$all_data = json_decode($buffer,true);
1170
+		if (!empty($all_data)) $reset = 0;
1171
+		foreach ($all_data as $key => $line) {
1172 1172
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1173
-		    $data = array();
1174
-		    $data['hex'] = $line[0];
1175
-		    $data['ident'] = $line[16]; //$line[13]
1176
-	    	    $data['altitude'] = $line[4]; // altitude
1177
-	    	    $data['speed'] = $line[5]; // speed
1178
-	    	    $data['heading'] = $line[3]; // heading
1179
-	    	    $data['latitude'] = $line[1]; // lat
1180
-	    	    $data['longitude'] = $line[2]; // long
1181
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1182
-	    	    $data['squawk'] = $line[6]; // squawk
1183
-	    	    $data['aircraft_icao'] = $line[8];
1184
-	    	    $data['registration'] = $line[9];
1185
-		    $data['departure_airport_iata'] = $line[11];
1186
-		    $data['arrival_airport_iata'] = $line[12];
1187
-	    	    $data['emergency'] = ''; // emergency
1188
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1189
-	    	    $data['format_source'] = 'fr24json';
1190
-    		    $data['id_source'] = $id_source;
1191
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1193
-		    $SI->add($data);
1194
-		    unset($data);
1173
+			$data = array();
1174
+			$data['hex'] = $line[0];
1175
+			$data['ident'] = $line[16]; //$line[13]
1176
+				$data['altitude'] = $line[4]; // altitude
1177
+				$data['speed'] = $line[5]; // speed
1178
+				$data['heading'] = $line[3]; // heading
1179
+				$data['latitude'] = $line[1]; // lat
1180
+				$data['longitude'] = $line[2]; // long
1181
+				$data['verticalrate'] = $line[15]; // verticale rate
1182
+				$data['squawk'] = $line[6]; // squawk
1183
+				$data['aircraft_icao'] = $line[8];
1184
+				$data['registration'] = $line[9];
1185
+			$data['departure_airport_iata'] = $line[11];
1186
+			$data['arrival_airport_iata'] = $line[12];
1187
+				$data['emergency'] = ''; // emergency
1188
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1189
+				$data['format_source'] = 'fr24json';
1190
+				$data['id_source'] = $id_source;
1191
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1193
+			$SI->add($data);
1194
+			unset($data);
1195 1195
 		}
1196
-	    }
1197
-	    //$last_exec['fr24json'] = time();
1198
-	    $last_exec[$id]['last'] = time();
1196
+		}
1197
+		//$last_exec['fr24json'] = time();
1198
+		$last_exec[$id]['last'] = time();
1199 1199
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1200 1200
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1201
-	    (
1201
+		(
1202 1202
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1203 1203
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1204
-	    )
1204
+		)
1205 1205
 	) {
1206
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1207
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1208
-	    //echo $buffer;
1209
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1210
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1211
-	    $all_data = json_decode($buffer,true);
1212
-	    if (json_last_error() != JSON_ERROR_NONE) {
1206
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1207
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1208
+		//echo $buffer;
1209
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1210
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1211
+		$all_data = json_decode($buffer,true);
1212
+		if (json_last_error() != JSON_ERROR_NONE) {
1213 1213
 		die(json_last_error_msg());
1214
-	    }
1215
-	    if (isset($all_data['mrkrs'])) {
1214
+		}
1215
+		if (isset($all_data['mrkrs'])) {
1216 1216
 		$reset = 0;
1217 1217
 		foreach ($all_data['mrkrs'] as $key => $line) {
1218
-		    if (isset($line['inf'])) {
1218
+			if (isset($line['inf'])) {
1219 1219
 			$data = array();
1220 1220
 			$data['hex'] = $line['inf']['ia'];
1221 1221
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1222
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1223
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1224
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1225
-	    		$data['latitude'] = $line['pt'][0]; // lat
1226
-	    		$data['longitude'] = $line['pt'][1]; // long
1227
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1228
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1229
-	    		//$data['aircraft_icao'] = $line[8];
1230
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1222
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1223
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1224
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1225
+				$data['latitude'] = $line['pt'][0]; // lat
1226
+				$data['longitude'] = $line['pt'][1]; // long
1227
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1228
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1229
+				//$data['aircraft_icao'] = $line[8];
1230
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1231 1231
 			//$data['departure_airport_iata'] = $line[11];
1232 1232
 			//$data['arrival_airport_iata'] = $line[12];
1233
-	    		//$data['emergency'] = ''; // emergency
1233
+				//$data['emergency'] = ''; // emergency
1234 1234
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1235
-	    		$data['format_source'] = 'radarvirtueljson';
1236
-    			$data['id_source'] = $id_source;
1235
+				$data['format_source'] = 'radarvirtueljson';
1236
+				$data['id_source'] = $id_source;
1237 1237
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1238 1238
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1239 1239
 			$SI->add($data);
1240 1240
 			unset($data);
1241
-		    }
1241
+			}
1242
+		}
1242 1243
 		}
1243
-	    }
1244
-	    //$last_exec['radarvirtueljson'] = time();
1245
-	    $last_exec[$id]['last'] = time();
1244
+		//$last_exec['radarvirtueljson'] = time();
1245
+		$last_exec[$id]['last'] = time();
1246 1246
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1247 1247
 	} elseif ($value['format'] === 'pirepsjson' && 
1248
-	    (
1248
+		(
1249 1249
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1250 1250
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1251
-	    )
1251
+		)
1252 1252
 	) {
1253
-	    //$buffer = $Common->getData($hosts[$id]);
1254
-	    $buffer = $Common->getData($value['host'].'?'.time());
1255
-	    $all_data = json_decode(utf8_encode($buffer),true);
1253
+		//$buffer = $Common->getData($hosts[$id]);
1254
+		$buffer = $Common->getData($value['host'].'?'.time());
1255
+		$all_data = json_decode(utf8_encode($buffer),true);
1256 1256
 	    
1257
-	    if (isset($all_data['pireps'])) {
1257
+		if (isset($all_data['pireps'])) {
1258 1258
 		$reset = 0;
1259
-	        foreach ($all_data['pireps'] as $line) {
1260
-		    $data = array();
1261
-		    $data['id'] = $line['id'];
1262
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1263
-		    $data['ident'] = $line['callsign']; // ident
1264
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1265
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1266
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1267
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1268
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1270
-		    $data['latitude'] = $line['lat']; // lat
1271
-		    $data['longitude'] = $line['lon']; // long
1272
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1273
-		    //$data['squawk'] = $line['squawk']; // squawk
1274
-		    //$data['emergency'] = ''; // emergency
1275
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1276
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1277
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1278
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1279
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1280
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1281
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1282
-		    else $data['info'] = '';
1283
-		    $data['format_source'] = 'pireps';
1284
-    		    $data['id_source'] = $id_source;
1285
-		    $data['datetime'] = date('Y-m-d H:i:s');
1286
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1287
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
-		    if ($line['icon'] === 'plane') {
1259
+			foreach ($all_data['pireps'] as $line) {
1260
+			$data = array();
1261
+			$data['id'] = $line['id'];
1262
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1263
+			$data['ident'] = $line['callsign']; // ident
1264
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1265
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1266
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1267
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1268
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1270
+			$data['latitude'] = $line['lat']; // lat
1271
+			$data['longitude'] = $line['lon']; // long
1272
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1273
+			//$data['squawk'] = $line['squawk']; // squawk
1274
+			//$data['emergency'] = ''; // emergency
1275
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1276
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1277
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1278
+			//$data['arrival_airport_time'] = $line['arrtime'];
1279
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1280
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1281
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1282
+			else $data['info'] = '';
1283
+			$data['format_source'] = 'pireps';
1284
+				$data['id_source'] = $id_source;
1285
+			$data['datetime'] = date('Y-m-d H:i:s');
1286
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1287
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1288
+			if ($line['icon'] === 'plane') {
1289 1289
 			$SI->add($data);
1290
-		    //    print_r($data);
1291
-    		    } elseif ($line['icon'] === 'ct') {
1290
+			//    print_r($data);
1291
+				} elseif ($line['icon'] === 'ct') {
1292 1292
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1293 1293
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1294 1294
 			$typec = substr($data['ident'],-3);
@@ -1303,209 +1303,209 @@  discard block
 block discarded – undo
1303 1303
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1304 1304
 			else $data['type'] = 'Observer';
1305 1305
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1306
-		    }
1307
-		    unset($data);
1306
+			}
1307
+			unset($data);
1308
+		}
1308 1309
 		}
1309
-	    }
1310
-	    //$last_exec['pirepsjson'] = time();
1311
-	    $last_exec[$id]['last'] = time();
1310
+		//$last_exec['pirepsjson'] = time();
1311
+		$last_exec[$id]['last'] = time();
1312 1312
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1313 1313
 	} elseif ($value['format'] === 'phpvmacars' && 
1314
-	    (
1314
+		(
1315 1315
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1316 1316
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1317
-	    )
1317
+		)
1318 1318
 	) {
1319
-	    //$buffer = $Common->getData($hosts[$id]);
1320
-	    if ($globalDebug) echo 'Get Data...'."\n";
1321
-	    $buffer = $Common->getData($value['host']);
1322
-	    $all_data = json_decode($buffer,true);
1323
-	    if ($buffer != '' && is_array($all_data)) {
1319
+		//$buffer = $Common->getData($hosts[$id]);
1320
+		if ($globalDebug) echo 'Get Data...'."\n";
1321
+		$buffer = $Common->getData($value['host']);
1322
+		$all_data = json_decode($buffer,true);
1323
+		if ($buffer != '' && is_array($all_data)) {
1324 1324
 		$reset = 0;
1325 1325
 		foreach ($all_data as $line) {
1326
-	    	    $data = array();
1327
-	    	    //$data['id'] = $line['id']; // id not usable
1328
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1329
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1330
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1331
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1332
-	    	    $data['ident'] = $line['flightnum']; // ident
1333
-	    	    $data['altitude'] = $line['alt']; // altitude
1334
-	    	    $data['speed'] = $line['gs']; // speed
1335
-	    	    $data['heading'] = $line['heading']; // heading
1336
-	    	    $data['latitude'] = $line['lat']; // lat
1337
-	    	    $data['longitude'] = $line['lng']; // long
1338
-	    	    $data['verticalrate'] = ''; // verticale rate
1339
-	    	    $data['squawk'] = ''; // squawk
1340
-	    	    $data['emergency'] = ''; // emergency
1341
-	    	    //$data['datetime'] = $line['lastupdate'];
1342
-	    	    //$data['last_update'] = $line['lastupdate'];
1343
-	    	    if (isset($value['timezone'])) {
1344
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1345
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1346
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1347
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1348
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1349
-	    	    $data['departure_airport_time'] = $line['deptime'];
1350
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1351
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1352
-    		    if (isset($line['registration'])) {
1353
-    			$data['registration'] = $line['registration'];
1354
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1355
-    		    } else $data['registration'] = $line['aircraft'];
1356
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1357
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1358
-		    if (isset($line['aircraftname'])) {
1326
+				$data = array();
1327
+				//$data['id'] = $line['id']; // id not usable
1328
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1329
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1330
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1331
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1332
+				$data['ident'] = $line['flightnum']; // ident
1333
+				$data['altitude'] = $line['alt']; // altitude
1334
+				$data['speed'] = $line['gs']; // speed
1335
+				$data['heading'] = $line['heading']; // heading
1336
+				$data['latitude'] = $line['lat']; // lat
1337
+				$data['longitude'] = $line['lng']; // long
1338
+				$data['verticalrate'] = ''; // verticale rate
1339
+				$data['squawk'] = ''; // squawk
1340
+				$data['emergency'] = ''; // emergency
1341
+				//$data['datetime'] = $line['lastupdate'];
1342
+				//$data['last_update'] = $line['lastupdate'];
1343
+				if (isset($value['timezone'])) {
1344
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1345
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1346
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1347
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1348
+				$data['departure_airport_icao'] = $line['depicao'];
1349
+				$data['departure_airport_time'] = $line['deptime'];
1350
+				$data['arrival_airport_icao'] = $line['arricao'];
1351
+				$data['arrival_airport_time'] = $line['arrtime'];
1352
+				if (isset($line['registration'])) {
1353
+				$data['registration'] = $line['registration'];
1354
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1355
+				} else $data['registration'] = $line['aircraft'];
1356
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1357
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1358
+			if (isset($line['aircraftname'])) {
1359 1359
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1360 1360
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1361
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1362
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1363
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1364
-	    		else {
1365
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1366
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1367
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1368
-	    		}
1369
-	    	    }
1370
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1371
-    		    $data['id_source'] = $id_source;
1372
-	    	    $data['format_source'] = 'phpvmacars';
1373
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1374
-		    $SI->add($data);
1375
-		    unset($data);
1361
+				$aircraft_data = explode('-',$line['aircraftname']);
1362
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1363
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1364
+				else {
1365
+					$aircraft_data = explode(' ',$line['aircraftname']);
1366
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1367
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1368
+				}
1369
+				}
1370
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1371
+				$data['id_source'] = $id_source;
1372
+				$data['format_source'] = 'phpvmacars';
1373
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1374
+			$SI->add($data);
1375
+			unset($data);
1376 1376
 		}
1377 1377
 		if ($globalDebug) echo 'No more data...'."\n";
1378 1378
 		unset($buffer);
1379 1379
 		unset($all_data);
1380
-	    }
1381
-	    //$last_exec['phpvmacars'] = time();
1382
-	    $last_exec[$id]['last'] = time();
1380
+		}
1381
+		//$last_exec['phpvmacars'] = time();
1382
+		$last_exec[$id]['last'] = time();
1383 1383
 	} elseif ($value['format'] === 'vaos' && 
1384
-	    (
1384
+		(
1385 1385
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1386 1386
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1387
-	    )
1387
+		)
1388 1388
 	) {
1389
-	    //$buffer = $Common->getData($hosts[$id]);
1390
-	    if ($globalDebug) echo 'Get Data...'."\n";
1391
-	    $buffer = $Common->getData($value['host']);
1392
-	    $all_data = json_decode($buffer,true);
1393
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1389
+		//$buffer = $Common->getData($hosts[$id]);
1390
+		if ($globalDebug) echo 'Get Data...'."\n";
1391
+		$buffer = $Common->getData($value['host']);
1392
+		$all_data = json_decode($buffer,true);
1393
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1394 1394
 		$reset = 0;
1395 1395
 		foreach ($all_data['ACARSData'] as $line) {
1396
-		    //print_r($line);
1397
-	    	    $data = array();
1398
-	    	    //$data['id'] = $line['id']; // id not usable
1399
-	    	    $data['id'] = $line['id'];
1400
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1401
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1402
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1403
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1404
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1405
-	    	    $data['altitude'] = $line['altitude']; // altitude
1406
-	    	    $data['speed'] = $line['groundspeed']; // speed
1407
-	    	    $data['heading'] = $line['heading']; // heading
1408
-	    	    $data['latitude'] = $line['lat']; // lat
1409
-	    	    $data['longitude'] = $line['lon']; // long
1410
-	    	    //$data['verticalrate'] = ''; // verticale rate
1411
-	    	    //$data['squawk'] = ''; // squawk
1412
-	    	    //$data['emergency'] = ''; // emergency
1413
-	    	    if (isset($value['timezone'])) {
1414
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1415
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1416
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1417
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1396
+			//print_r($line);
1397
+				$data = array();
1398
+				//$data['id'] = $line['id']; // id not usable
1399
+				$data['id'] = $line['id'];
1400
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1401
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1402
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1403
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1404
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1405
+				$data['altitude'] = $line['altitude']; // altitude
1406
+				$data['speed'] = $line['groundspeed']; // speed
1407
+				$data['heading'] = $line['heading']; // heading
1408
+				$data['latitude'] = $line['lat']; // lat
1409
+				$data['longitude'] = $line['lon']; // long
1410
+				//$data['verticalrate'] = ''; // verticale rate
1411
+				//$data['squawk'] = ''; // squawk
1412
+				//$data['emergency'] = ''; // emergency
1413
+				if (isset($value['timezone'])) {
1414
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1415
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1416
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1417
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1418 1418
 	    	    
1419
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1420
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1421
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1422
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1423
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1419
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1420
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1421
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1422
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1423
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1424 1424
 
1425
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1426
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1427
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1425
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1426
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1427
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1428 1428
 
1429
-    		    $data['id_source'] = $id_source;
1430
-	    	    $data['format_source'] = 'vaos';
1431
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1432
-		    $SI->add($data);
1433
-		    unset($data);
1429
+				$data['id_source'] = $id_source;
1430
+				$data['format_source'] = 'vaos';
1431
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1432
+			$SI->add($data);
1433
+			unset($data);
1434 1434
 		}
1435 1435
 		if ($globalDebug) echo 'No more data...'."\n";
1436 1436
 		unset($buffer);
1437 1437
 		unset($all_data);
1438
-	    }
1439
-	    //$last_exec['phpvmacars'] = time();
1440
-	    $last_exec[$id]['last'] = time();
1438
+		}
1439
+		//$last_exec['phpvmacars'] = time();
1440
+		$last_exec[$id]['last'] = time();
1441 1441
 	} elseif ($value['format'] === 'vam' && 
1442
-	    (
1442
+		(
1443 1443
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1444 1444
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1445
-	    )
1445
+		)
1446 1446
 	) {
1447
-	    //$buffer = $Common->getData($hosts[$id]);
1448
-	    if ($globalDebug) echo 'Get Data...'."\n";
1449
-	    $buffer = $Common->getData($value['host']);
1450
-	    $all_data = json_decode($buffer,true);
1451
-	    if ($buffer != '' && is_array($all_data)) {
1447
+		//$buffer = $Common->getData($hosts[$id]);
1448
+		if ($globalDebug) echo 'Get Data...'."\n";
1449
+		$buffer = $Common->getData($value['host']);
1450
+		$all_data = json_decode($buffer,true);
1451
+		if ($buffer != '' && is_array($all_data)) {
1452 1452
 		$reset = 0;
1453 1453
 		foreach ($all_data as $line) {
1454
-	    	    $data = array();
1455
-	    	    //$data['id'] = $line['id']; // id not usable
1456
-	    	    $data['id'] = trim($line['flight_id']);
1457
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1458
-	    	    $data['pilot_name'] = $line['pilot_name'];
1459
-	    	    $data['pilot_id'] = $line['pilot_id'];
1460
-	    	    $data['ident'] = trim($line['callsign']); // ident
1461
-	    	    $data['altitude'] = $line['altitude']; // altitude
1462
-	    	    $data['speed'] = $line['gs']; // speed
1463
-	    	    $data['heading'] = $line['heading']; // heading
1464
-	    	    $data['latitude'] = $line['latitude']; // lat
1465
-	    	    $data['longitude'] = $line['longitude']; // long
1466
-	    	    $data['verticalrate'] = ''; // verticale rate
1467
-	    	    $data['squawk'] = ''; // squawk
1468
-	    	    $data['emergency'] = ''; // emergency
1469
-	    	    //$data['datetime'] = $line['lastupdate'];
1470
-	    	    $data['last_update'] = $line['last_update'];
1471
-		    $data['datetime'] = date('Y-m-d H:i:s');
1472
-	    	    $data['departure_airport_icao'] = $line['departure'];
1473
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1474
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1475
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1476
-    		    //$data['registration'] = $line['aircraft'];
1477
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1478
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1479
-    		    $data['id_source'] = $id_source;
1480
-	    	    $data['format_source'] = 'vam';
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1483
-		    $SI->add($data);
1484
-		    unset($data);
1454
+				$data = array();
1455
+				//$data['id'] = $line['id']; // id not usable
1456
+				$data['id'] = trim($line['flight_id']);
1457
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1458
+				$data['pilot_name'] = $line['pilot_name'];
1459
+				$data['pilot_id'] = $line['pilot_id'];
1460
+				$data['ident'] = trim($line['callsign']); // ident
1461
+				$data['altitude'] = $line['altitude']; // altitude
1462
+				$data['speed'] = $line['gs']; // speed
1463
+				$data['heading'] = $line['heading']; // heading
1464
+				$data['latitude'] = $line['latitude']; // lat
1465
+				$data['longitude'] = $line['longitude']; // long
1466
+				$data['verticalrate'] = ''; // verticale rate
1467
+				$data['squawk'] = ''; // squawk
1468
+				$data['emergency'] = ''; // emergency
1469
+				//$data['datetime'] = $line['lastupdate'];
1470
+				$data['last_update'] = $line['last_update'];
1471
+			$data['datetime'] = date('Y-m-d H:i:s');
1472
+				$data['departure_airport_icao'] = $line['departure'];
1473
+				//$data['departure_airport_time'] = $line['departure_time'];
1474
+				$data['arrival_airport_icao'] = $line['arrival'];
1475
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1476
+				//$data['registration'] = $line['aircraft'];
1477
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1478
+				$data['aircraft_icao'] = $line['plane_type'];
1479
+				$data['id_source'] = $id_source;
1480
+				$data['format_source'] = 'vam';
1481
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1483
+			$SI->add($data);
1484
+			unset($data);
1485 1485
 		}
1486 1486
 		if ($globalDebug) echo 'No more data...'."\n";
1487 1487
 		unset($buffer);
1488 1488
 		unset($all_data);
1489
-	    }
1490
-	    //$last_exec['phpvmacars'] = time();
1491
-	    $last_exec[$id]['last'] = time();
1489
+		}
1490
+		//$last_exec['phpvmacars'] = time();
1491
+		$last_exec[$id]['last'] = time();
1492 1492
 	} elseif ($value['format'] === 'blitzortung' && 
1493
-	    (
1493
+		(
1494 1494
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1495 1495
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1496
-	    )
1496
+		)
1497 1497
 	) {
1498
-	    //$buffer = $Common->getData($hosts[$id]);
1499
-	    if ($globalDebug) echo 'Get Data...'."\n";
1500
-	    $buffer = $Common->getData($value['host']);
1501
-	    $all_data = json_decode($buffer,true);
1502
-	    if ($buffer != '') {
1498
+		//$buffer = $Common->getData($hosts[$id]);
1499
+		if ($globalDebug) echo 'Get Data...'."\n";
1500
+		$buffer = $Common->getData($value['host']);
1501
+		$all_data = json_decode($buffer,true);
1502
+		if ($buffer != '') {
1503 1503
 		$Source->deleteLocationBySource('blitzortung');
1504 1504
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1505 1505
 		$buffer = explode('\n',$buffer);
1506 1506
 		foreach ($buffer as $buffer_line) {
1507
-		    $line = json_decode($buffer_line,true);
1508
-		    if (isset($line['time'])) {
1507
+			$line = json_decode($buffer_line,true);
1508
+			if (isset($line['time'])) {
1509 1509
 			$data = array();
1510 1510
 			$data['altitude'] = $line['alt']; // altitude
1511 1511
 			$data['latitude'] = $line['lat']; // lat
@@ -1517,94 +1517,94 @@  discard block
 block discarded – undo
1517 1517
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1518 1518
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1519 1519
 			unset($data);
1520
-		    }
1520
+			}
1521 1521
 		}
1522 1522
 		if ($globalDebug) echo 'No more data...'."\n";
1523 1523
 		unset($buffer);
1524
-	    }
1525
-	    $last_exec[$id]['last'] = time();
1524
+		}
1525
+		$last_exec[$id]['last'] = time();
1526 1526
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1527 1527
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1528
-	    //$last_exec[$id]['last'] = time();
1529
-	    //$read = array( $sockets[$id] );
1530
-	    $read = $sockets;
1531
-	    $write = NULL;
1532
-	    $e = NULL;
1533
-	    $n = socket_select($read, $write, $e, $timeout);
1534
-	    if ($e != NULL) var_dump($e);
1535
-	    if ($n > 0) {
1528
+		//$last_exec[$id]['last'] = time();
1529
+		//$read = array( $sockets[$id] );
1530
+		$read = $sockets;
1531
+		$write = NULL;
1532
+		$e = NULL;
1533
+		$n = socket_select($read, $write, $e, $timeout);
1534
+		if ($e != NULL) var_dump($e);
1535
+		if ($n > 0) {
1536 1536
 		$reset = 0;
1537 1537
 		foreach ($read as $nb => $r) {
1538
-		    //$value = $formats[$nb];
1539
-		    $format = $globalSources[$nb]['format'];
1540
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1538
+			//$value = $formats[$nb];
1539
+			$format = $globalSources[$nb]['format'];
1540
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1541 1541
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1542
-		    } elseif ($format === 'vrstcp') {
1542
+			} elseif ($format === 'vrstcp') {
1543 1543
 			$buffer = @socket_read($r, 6000);
1544
-		    } else {
1544
+			} else {
1545 1545
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1546
-		    }
1547
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1548
-		    //echo $buffer."\n";
1549
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1550
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1551
-		    $error = false;
1552
-		    //$SI::del();
1553
-		    if ($buffer !== FALSE) {
1546
+			}
1547
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1548
+			//echo $buffer."\n";
1549
+			// lets play nice and handle signals such as ctrl-c/kill properly
1550
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1551
+			$error = false;
1552
+			//$SI::del();
1553
+			if ($buffer !== FALSE) {
1554 1554
 			if ($format === 'vrstcp') {
1555
-			    $buffer = explode('},{',$buffer);
1555
+				$buffer = explode('},{',$buffer);
1556 1556
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1557
-		    }
1558
-		    // SBS format is CSV format
1559
-		    if ($buffer !== FALSE && $buffer !== '') {
1557
+			}
1558
+			// SBS format is CSV format
1559
+			if ($buffer !== FALSE && $buffer !== '') {
1560 1560
 			$tt[$format] = 0;
1561 1561
 			if ($format === 'acarssbs3') {
1562
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1563
-			    $ACARS->add(trim($buffer));
1564
-			    $ACARS->deleteLiveAcarsData();
1562
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1563
+				$ACARS->add(trim($buffer));
1564
+				$ACARS->deleteLiveAcarsData();
1565 1565
 			} elseif ($format === 'raw') {
1566
-			    // AVR format
1567
-			    $data = $SBS->parse($buffer);
1568
-			    if (is_array($data)) {
1566
+				// AVR format
1567
+				$data = $SBS->parse($buffer);
1568
+				if (is_array($data)) {
1569 1569
 				$data['datetime'] = date('Y-m-d H:i:s');
1570 1570
 				$data['format_source'] = 'raw';
1571 1571
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1572 1572
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1573 1573
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1574 1574
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1575
-			    }
1575
+				}
1576 1576
 			} elseif ($format === 'ais') {
1577
-			    $ais_data = $AIS->parse_line(trim($buffer));
1578
-			    $data = array();
1579
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1580
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1581
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1582
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1583
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1584
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1585
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1586
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1587
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1588
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1589
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1590
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1591
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1592
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1593
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1577
+				$ais_data = $AIS->parse_line(trim($buffer));
1578
+				$data = array();
1579
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1580
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1581
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1582
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1583
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1584
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1585
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1586
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1587
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1588
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1589
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1590
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1591
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1592
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1593
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1595 1595
 
1596
-			    if (isset($ais_data['timestamp'])) {
1596
+				if (isset($ais_data['timestamp'])) {
1597 1597
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1598
-			    } else {
1598
+				} else {
1599 1599
 				$data['datetime'] = date('Y-m-d H:i:s');
1600
-			    }
1601
-			    $data['format_source'] = 'aisnmea';
1602
-    			    $data['id_source'] = $id_source;
1603
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1604
-			    unset($data);
1605
-                        } elseif ($format === 'flightgearsp') {
1606
-                    	    //echo $buffer."\n";
1607
-                    	    if (strlen($buffer) > 5) {
1600
+				}
1601
+				$data['format_source'] = 'aisnmea';
1602
+					$data['id_source'] = $id_source;
1603
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1604
+				unset($data);
1605
+						} elseif ($format === 'flightgearsp') {
1606
+							//echo $buffer."\n";
1607
+							if (strlen($buffer) > 5) {
1608 1608
 				$line = explode(',',$buffer);
1609 1609
 				$data = array();
1610 1610
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1621,38 +1621,38 @@  discard block
 block discarded – undo
1621 1621
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1622 1622
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1623 1623
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1624
-			    }
1625
-                        } elseif ($format === 'acars') {
1626
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1627
-			    $ACARS->add(trim($buffer));
1628
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1629
-			    $ACARS->deleteLiveAcarsData();
1624
+				}
1625
+						} elseif ($format === 'acars') {
1626
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1627
+				$ACARS->add(trim($buffer));
1628
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1629
+				$ACARS->deleteLiveAcarsData();
1630 1630
 			} elseif ($format === 'flightgearmp') {
1631
-			    if (substr($buffer,0,1) != '#') {
1631
+				if (substr($buffer,0,1) != '#') {
1632 1632
 				$data = array();
1633 1633
 				//echo $buffer."\n";
1634 1634
 				$line = explode(' ',$buffer);
1635 1635
 				if (count($line) === 11) {
1636
-				    $userserver = explode('@',$line[0]);
1637
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1638
-				    $data['ident'] = $userserver[0];
1639
-				    $data['registration'] = $userserver[0];
1640
-				    $data['latitude'] = $line[4];
1641
-				    $data['longitude'] = $line[5];
1642
-				    $data['altitude'] = $line[6];
1643
-				    $data['datetime'] = date('Y-m-d H:i:s');
1644
-				    $aircraft_type = $line[10];
1645
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1646
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1647
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1648
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1636
+					$userserver = explode('@',$line[0]);
1637
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1638
+					$data['ident'] = $userserver[0];
1639
+					$data['registration'] = $userserver[0];
1640
+					$data['latitude'] = $line[4];
1641
+					$data['longitude'] = $line[5];
1642
+					$data['altitude'] = $line[6];
1643
+					$data['datetime'] = date('Y-m-d H:i:s');
1644
+					$aircraft_type = $line[10];
1645
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1646
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1647
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1648
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1649
+				}
1649 1650
 				}
1650
-			    }
1651 1651
 			} elseif ($format === 'beast') {
1652
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1653
-			    die;
1652
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1653
+				die;
1654 1654
 			} elseif ($format === 'vrstcp') {
1655
-			    foreach($buffer as $all_data) {
1655
+				foreach($buffer as $all_data) {
1656 1656
 				$line = json_decode('{'.$all_data.'}',true);
1657 1657
 				$data = array();
1658 1658
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1672,158 +1672,158 @@  discard block
 block discarded – undo
1672 1672
 				*/
1673 1673
 				$data['datetime'] = date('Y-m-d H:i:s');
1674 1674
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1675
-		    		$data['format_source'] = 'vrstcp';
1675
+					$data['format_source'] = 'vrstcp';
1676 1676
 				$data['id_source'] = $id_source;
1677 1677
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678 1678
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1679 1679
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1680 1680
 				unset($data);
1681
-			    }
1681
+				}
1682 1682
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1683
-			    $line = explode("\t", $buffer);
1684
-			    for($k = 0; $k < count($line); $k=$k+2) {
1683
+				$line = explode("\t", $buffer);
1684
+				for($k = 0; $k < count($line); $k=$k+2) {
1685 1685
 				$key = $line[$k];
1686
-			        $lined[$key] = $line[$k+1];
1687
-			    }
1688
-    			    if (count($lined) > 3) {
1689
-    				$data['hex'] = $lined['hexid'];
1690
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1691
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1692
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1693
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1694
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1695
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1696
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1697
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1698
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1699
-    				$data['id_source'] = $id_source;
1700
-    				$data['format_source'] = 'tsv';
1701
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1702
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1686
+					$lined[$key] = $line[$k+1];
1687
+				}
1688
+					if (count($lined) > 3) {
1689
+					$data['hex'] = $lined['hexid'];
1690
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1691
+					$data['datetime'] = date('Y-m-d H:i:s');;
1692
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1693
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1694
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1695
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1696
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1697
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1698
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1699
+					$data['id_source'] = $id_source;
1700
+					$data['format_source'] = 'tsv';
1701
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1702
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1703 1703
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705
-    				unset($lined);
1706
-    				unset($data);
1707
-    			    } else $error = true;
1704
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1705
+					unset($lined);
1706
+					unset($data);
1707
+					} else $error = true;
1708 1708
 			} elseif ($format === 'aprs' && $use_aprs) {
1709
-			    if ($aprs_connect === 0) {
1709
+				if ($aprs_connect === 0) {
1710 1710
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1711 1711
 				$aprs_connect = 1;
1712
-			    }
1712
+				}
1713 1713
 			    
1714
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1714
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1715 1715
 				$aprs_last_tx = time();
1716 1716
 				$data_aprs = "# Keep alive";
1717 1717
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1718
-			    }
1718
+				}
1719 1719
 			    
1720
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1721
-			    //echo 'APRS data : '.$buffer."\n";
1722
-			    $buffer = str_replace('APRS <- ','',$buffer);
1723
-			    $buffer = str_replace('APRS -> ','',$buffer);
1724
-			    //echo $buffer."\n";
1725
-			    date_default_timezone_set('UTC');
1726
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1720
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1721
+				//echo 'APRS data : '.$buffer."\n";
1722
+				$buffer = str_replace('APRS <- ','',$buffer);
1723
+				$buffer = str_replace('APRS -> ','',$buffer);
1724
+				//echo $buffer."\n";
1725
+				date_default_timezone_set('UTC');
1726
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1727 1727
 				$line = $APRS->parse($buffer);
1728 1728
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1729 1729
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1730
-				    $aprs_last_tx = time();
1731
-				    $data = array();
1732
-				    //print_r($line);
1733
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1734
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1735
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1736
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1737
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1738
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1739
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1740
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1741
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1742
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1743
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1744
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1745
-				    $data['latitude'] = $line['latitude'];
1746
-				    $data['longitude'] = $line['longitude'];
1747
-				    //$data['verticalrate'] = $line[16];
1748
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1749
-				    //else $data['speed'] = 0;
1750
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1751
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1752
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1753
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1730
+					$aprs_last_tx = time();
1731
+					$data = array();
1732
+					//print_r($line);
1733
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1734
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1735
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1736
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1737
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1738
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1739
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1740
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1741
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1742
+					else $data['datetime'] = date('Y-m-d H:i:s');
1743
+					//$data['datetime'] = date('Y-m-d H:i:s');
1744
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1745
+					$data['latitude'] = $line['latitude'];
1746
+					$data['longitude'] = $line['longitude'];
1747
+					//$data['verticalrate'] = $line[16];
1748
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1749
+					//else $data['speed'] = 0;
1750
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1751
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1752
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1753
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1754 1754
 				    
1755
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1756
-				    //else echo 'No heading...'."\n";
1757
-				    //else $data['heading'] = 0;
1758
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1759
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1760
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1761
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1762
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1763
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1764
-    				    $data['id_source'] = $id_source;
1765
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1766
-				    else $data['format_source'] = 'aprs';
1767
-				    $data['source_name'] = $line['source'];
1768
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1769
-				    else $data['source_type'] = 'flarm';
1770
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1771
-				    $currentdate = date('Y-m-d H:i:s');
1772
-				    $aprsdate = strtotime($data['datetime']);
1773
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1774
-				    // Accept data if time <= system time + 20s
1775
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1776
-				    if (
1755
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1756
+					//else echo 'No heading...'."\n";
1757
+					//else $data['heading'] = 0;
1758
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1759
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1760
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1761
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1762
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1763
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1764
+						$data['id_source'] = $id_source;
1765
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1766
+					else $data['format_source'] = 'aprs';
1767
+					$data['source_name'] = $line['source'];
1768
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1769
+					else $data['source_type'] = 'flarm';
1770
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1771
+					$currentdate = date('Y-m-d H:i:s');
1772
+					$aprsdate = strtotime($data['datetime']);
1773
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1774
+					// Accept data if time <= system time + 20s
1775
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1776
+					if (
1777 1777
 					($data['source_type'] === 'modes') || 
1778 1778
 					isset($line['stealth']) && 
1779 1779
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1780 1780
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1781 1781
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1782 1782
 					$send = $SI->add($data);
1783
-				    } elseif ($data['source_type'] === 'ais') {
1783
+					} elseif ($data['source_type'] === 'ais') {
1784 1784
 					$data['type'] = '';
1785 1785
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1786
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1786
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1787 1787
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1788
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1789
-					    //$line['symbol'] === 'Balloon' ||
1790
-					    $line['symbol'] === 'Glider' || 
1791
-					    $line['symbol'] === 'No. Plane' || 
1792
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1793
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1794
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1795
-					    $send = $SI->add($data);
1796
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1797
-					    $line['symbol'] === 'Yacht (Sail)' || 
1798
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1799
-					    $send = $MI->add($data);
1800
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1801
-					    $line['symbol'] === 'Car' || 
1802
-					    $line['symbol'] === 'Ambulance' || 
1803
-					    $line['symbol'] === 'Van' || 
1804
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1805
-					    $line['symbol'] === 'Motorcycle' || 
1806
-					    $line['symbol'] === 'Tractor' || 
1807
-					    $line['symbol'] === 'Police' || 
1808
-					    $line['symbol'] === 'Bike' || 
1809
-					    $line['symbol'] === 'Jogger' || 
1810
-					    $line['symbol'] === 'Horse' || 
1811
-					    $line['symbol'] === 'Bus' || 
1812
-					    $line['symbol'] === 'Jeep' || 
1813
-					    $line['symbol'] === 'Recreational Vehicle' || 
1814
-					    $line['symbol'] === 'Yacht (Sail)' || 
1815
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1816
-					    $line['symbol'] === 'Firetruck' || 
1817
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1818
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1819
-					    $line['symbol'] === 'SUV' ||
1820
-					    $line['symbol'] === 'Snowmobile' ||
1821
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1822
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1788
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1789
+						//$line['symbol'] === 'Balloon' ||
1790
+						$line['symbol'] === 'Glider' || 
1791
+						$line['symbol'] === 'No. Plane' || 
1792
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1793
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1794
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1795
+						$send = $SI->add($data);
1796
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1797
+						$line['symbol'] === 'Yacht (Sail)' || 
1798
+						$line['symbol'] === 'Ship (Power Boat)')) {
1799
+						$send = $MI->add($data);
1800
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1801
+						$line['symbol'] === 'Car' || 
1802
+						$line['symbol'] === 'Ambulance' || 
1803
+						$line['symbol'] === 'Van' || 
1804
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1805
+						$line['symbol'] === 'Motorcycle' || 
1806
+						$line['symbol'] === 'Tractor' || 
1807
+						$line['symbol'] === 'Police' || 
1808
+						$line['symbol'] === 'Bike' || 
1809
+						$line['symbol'] === 'Jogger' || 
1810
+						$line['symbol'] === 'Horse' || 
1811
+						$line['symbol'] === 'Bus' || 
1812
+						$line['symbol'] === 'Jeep' || 
1813
+						$line['symbol'] === 'Recreational Vehicle' || 
1814
+						$line['symbol'] === 'Yacht (Sail)' || 
1815
+						$line['symbol'] === 'Ship (Power Boat)' || 
1816
+						$line['symbol'] === 'Firetruck' || 
1817
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1818
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1819
+						$line['symbol'] === 'SUV' ||
1820
+						$line['symbol'] === 'Snowmobile' ||
1821
+						$line['symbol'] === 'Mobile Satellite Station')) {
1822
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1823 1823
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1824 1824
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1825 1825
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1826
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1826
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1827 1827
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1828 1828
 					$Source->deleteOldLocationByType('gs');
1829 1829
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 					} else {
1832 1832
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1833 1833
 					}
1834
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1834
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1835 1835
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1836 1836
 					if ($globalDebug) echo '# Weather Station added'."\n";
1837 1837
 					$Source->deleteOldLocationByType('wx');
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 					} else {
1842 1842
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1843 1843
 					}
1844
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1844
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1845 1845
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1846 1846
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1847 1847
 					$Source->deleteOldLocationByType('lightning');
@@ -1850,11 +1850,11 @@  discard block
 block discarded – undo
1850 1850
 					} else {
1851 1851
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1852 1852
 					}
1853
-				    } elseif ($globalDebug) {
1854
-				    	echo '/!\ Not added: '.$buffer."\n";
1855
-				    	print_r($line);
1856
-				    }
1857
-				    unset($data);
1853
+					} elseif ($globalDebug) {
1854
+						echo '/!\ Not added: '.$buffer."\n";
1855
+						print_r($line);
1856
+					}
1857
+					unset($data);
1858 1858
 				}
1859 1859
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1860 1860
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1873,12 +1873,12 @@  discard block
 block discarded – undo
1873 1873
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1874 1874
 					$globalSources[$nb]['last_weather_clean'] = time();
1875 1875
 				}
1876
-			    }
1876
+				}
1877 1877
 			} else {
1878
-			    $line = explode(',', $buffer);
1879
-    			    if (count($line) > 20) {
1880
-    			    	$data['hex'] = $line[4];
1881
-    				/*
1878
+				$line = explode(',', $buffer);
1879
+					if (count($line) > 20) {
1880
+						$data['hex'] = $line[4];
1881
+					/*
1882 1882
     				$data['datetime'] = $line[6].' '.$line[7];
1883 1883
     					date_default_timezone_set($globalTimezone);
1884 1884
     					$datetime = new DateTime($data['datetime']);
@@ -1886,31 +1886,31 @@  discard block
 block discarded – undo
1886 1886
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1887 1887
     					date_default_timezone_set('UTC');
1888 1888
     				*/
1889
-    				// Force datetime to current UTC datetime
1890
-    				date_default_timezone_set('UTC');
1891
-    				$data['datetime'] = date('Y-m-d H:i:s');
1892
-    				$data['ident'] = trim($line[10]);
1893
-    				$data['latitude'] = $line[14];
1894
-    				$data['longitude'] = $line[15];
1895
-    				$data['verticalrate'] = $line[16];
1896
-    				$data['emergency'] = $line[20];
1897
-    				$data['speed'] = $line[12];
1898
-    				$data['squawk'] = $line[17];
1899
-    				$data['altitude'] = $line[11];
1900
-    				$data['heading'] = $line[13];
1901
-    				$data['ground'] = $line[21];
1902
-    				$data['emergency'] = $line[19];
1903
-    				$data['format_source'] = 'sbs';
1889
+					// Force datetime to current UTC datetime
1890
+					date_default_timezone_set('UTC');
1891
+					$data['datetime'] = date('Y-m-d H:i:s');
1892
+					$data['ident'] = trim($line[10]);
1893
+					$data['latitude'] = $line[14];
1894
+					$data['longitude'] = $line[15];
1895
+					$data['verticalrate'] = $line[16];
1896
+					$data['emergency'] = $line[20];
1897
+					$data['speed'] = $line[12];
1898
+					$data['squawk'] = $line[17];
1899
+					$data['altitude'] = $line[11];
1900
+					$data['heading'] = $line[13];
1901
+					$data['ground'] = $line[21];
1902
+					$data['emergency'] = $line[19];
1903
+					$data['format_source'] = 'sbs';
1904 1904
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1905 1905
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1906
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1906
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1907 1907
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1908
-    				$data['id_source'] = $id_source;
1909
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1910
-    				else $error = true;
1911
-    				unset($data);
1912
-    			    } else $error = true;
1913
-			    if ($error) {
1908
+					$data['id_source'] = $id_source;
1909
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1910
+					else $error = true;
1911
+					unset($data);
1912
+					} else $error = true;
1913
+				if ($error) {
1914 1914
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1915 1915
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1916 1916
 				} else {
@@ -1926,13 +1926,13 @@  discard block
 block discarded – undo
1926 1926
 					connect_all($sourceer);
1927 1927
 					$sourceer = array();
1928 1928
 				}
1929
-			    }
1929
+				}
1930 1930
 			}
1931 1931
 			// Sleep for xxx microseconds
1932 1932
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1933
-		    } else {
1933
+			} else {
1934 1934
 			if ($format === 'flightgearmp') {
1935
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1935
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1936 1936
 				//@socket_close($r);
1937 1937
 				sleep($globalMinFetch);
1938 1938
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1941,9 +1941,9 @@  discard block
 block discarded – undo
1941 1941
 				break;
1942 1942
 				
1943 1943
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1944
-			    if (isset($tt[$format])) $tt[$format]++;
1945
-			    else $tt[$format] = 0;
1946
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
1944
+				if (isset($tt[$format])) $tt[$format]++;
1945
+				else $tt[$format] = 0;
1946
+				if ($tt[$format] > 30 || $buffer === FALSE) {
1947 1947
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1948 1948
 				//@socket_close($r);
1949 1949
 				sleep(2);
@@ -1954,24 +1954,24 @@  discard block
 block discarded – undo
1954 1954
 				//connect_all($globalSources);
1955 1955
 				$tt[$format]=0;
1956 1956
 				break;
1957
-			    } 
1958
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1957
+				} 
1958
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
1959
+			}
1959 1960
 			}
1960
-		    }
1961 1961
 		}
1962
-	    } else {
1962
+		} else {
1963 1963
 		$error = socket_strerror(socket_last_error());
1964 1964
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1965 1965
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1966 1966
 			if (isset($globalDebug)) echo "Restarting...\n";
1967 1967
 			// Restart the script if possible
1968 1968
 			if (is_array($sockets)) {
1969
-			    if ($globalDebug) echo "Shutdown all sockets...";
1969
+				if ($globalDebug) echo "Shutdown all sockets...";
1970 1970
 			    
1971
-			    foreach ($sockets as $sock) {
1971
+				foreach ($sockets as $sock) {
1972 1972
 				@socket_shutdown($sock,2);
1973 1973
 				@socket_close($sock);
1974
-			    }
1974
+				}
1975 1975
 			    
1976 1976
 			}
1977 1977
 			if ($globalDebug) echo "Waiting...";
@@ -1986,15 +1986,15 @@  discard block
 block discarded – undo
1986 1986
 			if ($globalDebug) echo "Restart all connections...";
1987 1987
 			connect_all($globalSources);
1988 1988
 		}
1989
-	    }
1989
+		}
1990 1990
 	}
1991 1991
 	if ($globalDaemon === false) {
1992
-	    if ($globalDebug) echo 'Check all...'."\n";
1993
-	    if (isset($SI)) $SI->checkAll();
1994
-	    if (isset($TI)) $TI->checkAll();
1995
-	    if (isset($MI)) $MI->checkAll();
1992
+		if ($globalDebug) echo 'Check all...'."\n";
1993
+		if (isset($SI)) $SI->checkAll();
1994
+		if (isset($TI)) $TI->checkAll();
1995
+		if (isset($MI)) $MI->checkAll();
1996
+	}
1996 1997
 	}
1997
-    }
1998 1998
 }
1999 1999
 
2000 2000
 ?>
Please login to merge, or discard this patch.
Braces   +1207 added lines, -405 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -59,66 +63,107 @@  discard block
 block discarded – undo
59 63
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 64
 if (isset($options['s'])) {
61 65
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
64
-} elseif (isset($options['source'])) {
66
+    if (isset($options['format'])) {
67
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
68
+    } else {
69
+    	$globalSources[] = array('host' => $options['s']);
70
+    }
71
+    } elseif (isset($options['source'])) {
65 72
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
68
-}
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['source']);
77
+    }
78
+    }
69 79
 if (isset($options['aprsserverhost'])) {
70 80
 	$globalServerAPRS = TRUE;
71 81
 	$globalServerAPRShost = $options['aprsserverhost'];
72 82
 }
73
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
74
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
75
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
76
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
83
+if (isset($options['aprsserverport'])) {
84
+	$globalServerAPRSport = $options['aprsserverport'];
85
+}
86
+if (isset($options['aprsserverssid'])) {
87
+	$globalServerAPRSssid = $options['aprsserverssid'];
88
+}
89
+if (isset($options['aprsserverpass'])) {
90
+	$globalServerAPRSpass = $options['aprsserverpass'];
91
+}
92
+if (isset($options['noaprsserver'])) {
93
+	$globalServerAPRS = FALSE;
94
+}
77 95
 if (isset($options['enable-aircraft'])) {
78
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
96
+	if ($globalDebug) {
97
+		echo 'Enable Aircraft mode'."\n";
98
+	}
79 99
 	$globalAircraft = TRUE; 
80 100
 }
81 101
 if (isset($options['disable-aircraft'])) {
82
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
102
+	if ($globalDebug) {
103
+		echo 'Disable Aircraft mode'."\n";
104
+	}
83 105
 	$globalAircraft = FALSE;
84 106
 }
85 107
 if (isset($options['enable-tracker'])) {
86
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
108
+	if ($globalDebug) {
109
+		echo 'Enable Tracker mode'."\n";
110
+	}
87 111
 	$globalTracker = TRUE; 
88 112
 }
89 113
 if (isset($options['disable-tracker'])) {
90
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
114
+	if ($globalDebug) {
115
+		echo 'Disable Tracker mode'."\n";
116
+	}
91 117
 	$globalTracker = FALSE;
92 118
 }
93 119
 if (isset($options['enable-marine'])) {
94
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
120
+	if ($globalDebug) {
121
+		echo 'Enable Marine mode'."\n";
122
+	}
95 123
 	$globalMarine = TRUE;
96 124
 }
97 125
 if (isset($options['disable-marine'])) {
98
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
126
+	if ($globalDebug) {
127
+		echo 'Disable Marine mode'."\n";
128
+	}
99 129
 	$globalMarine = FALSE;
100 130
 }
101
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
102
-if (isset($options['server'])) $globalServer = TRUE;
103
-if (isset($options['idsource'])) $id_source = $options['idsource'];
104
-else $id_source = 1;
131
+if (isset($options['nodaemon'])) {
132
+	$globalDaemon = FALSE;
133
+}
134
+if (isset($options['server'])) {
135
+	$globalServer = TRUE;
136
+}
137
+if (isset($options['idsource'])) {
138
+	$id_source = $options['idsource'];
139
+} else {
140
+	$id_source = 1;
141
+}
105 142
 if (isset($globalServer) && $globalServer) {
106
-    if ($globalDebug) echo "Using Server Mode\n";
143
+    if ($globalDebug) {
144
+    	echo "Using Server Mode\n";
145
+    }
107 146
     $SI=new SpotterServer();
108 147
 /*
109 148
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
110 149
     $SI = new adsb2aprs();
111 150
     $SI->connect();
112 151
 */
113
-} else $SI=new SpotterImport($Connection->db);
152
+} else {
153
+	$SI=new SpotterImport($Connection->db);
154
+}
114 155
 
115
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
156
+if (isset($globalTracker) && $globalTracker) {
157
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
158
+}
116 159
 if (isset($globalMarine) && $globalMarine) {
117 160
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
118 161
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
119 162
 }
120 163
 
121
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
164
+if (isset($globalTracker) && $globalTracker) {
165
+	$TI = new TrackerImport($Connection->db);
166
+}
122 167
 if (isset($globalMarine) && $globalMarine) {
123 168
     $AIS = new AIS();
124 169
     $MI = new MarineImport($Connection->db);
@@ -143,7 +188,9 @@  discard block
 block discarded – undo
143 188
 }
144 189
 
145 190
 // let's try and connect
146
-if ($globalDebug) echo "Connecting...\n";
191
+if ($globalDebug) {
192
+	echo "Connecting...\n";
193
+}
147 194
 $use_aprs = false;
148 195
 $aprs_full = false;
149 196
 $reset = 0;
@@ -152,7 +199,9 @@  discard block
 block discarded – undo
152 199
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
153 200
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
154 201
     $reset++;
155
-    if ($globalDebug) echo 'Connect to all...'."\n";
202
+    if ($globalDebug) {
203
+    	echo 'Connect to all...'."\n";
204
+    }
156 205
     foreach ($hosts as $id => $value) {
157 206
 	$host = $value['host'];
158 207
 	$globalSources[$id]['last_exec'] = 0;
@@ -162,32 +211,44 @@  discard block
 block discarded – undo
162 211
         	//$formats[$id] = 'deltadbtxt';
163 212
         	$globalSources[$id]['format'] = 'deltadbtxt';
164 213
         	//$last_exec['deltadbtxt'] = 0;
165
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to deltadb source (".$host.")...\n";
216
+        	}
166 217
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
167 218
         	//$formats[$id] = 'vatsimtxt';
168 219
         	$globalSources[$id]['format'] = 'vatsimtxt';
169 220
         	//$last_exec['vatsimtxt'] = 0;
170
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
221
+        	if ($globalDebug) {
222
+        		echo "Connect to vatsim source (".$host.")...\n";
223
+        	}
171 224
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
172 225
         	//$formats[$id] = 'aircraftlistjson';
173 226
         	$globalSources[$id]['format'] = 'aircraftlistjson';
174 227
         	//$last_exec['aircraftlistjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
230
+        	}
176 231
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
177 232
         	//$formats[$id] = 'aircraftjson';
178 233
         	$globalSources[$id]['format'] = 'aircraftjson';
179 234
         	//$last_exec['aircraftlistjson'] = 0;
180
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
235
+        	if ($globalDebug) {
236
+        		echo "Connect to aircraft.json source (".$host.")...\n";
237
+        	}
181 238
     	    } else if (preg_match('/aircraft$/i',$host)) {
182 239
         	//$formats[$id] = 'planefinderclient';
183 240
         	$globalSources[$id]['format'] = 'planefinderclient';
184 241
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
242
+        	if ($globalDebug) {
243
+        		echo "Connect to planefinderclient source (".$host.")...\n";
244
+        	}
186 245
     	    } else if (preg_match('/opensky/i',$host)) {
187 246
         	//$formats[$id] = 'aircraftlistjson';
188 247
         	$globalSources[$id]['format'] = 'opensky';
189 248
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to opensky source (".$host.")...\n";
251
+        	}
191 252
     	    /*
192 253
     	    // Disabled for now, site change source format
193 254
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -204,7 +265,9 @@  discard block
 block discarded – undo
204 265
         	//$formats[$id] = 'planeupdatefaa';
205 266
         	$globalSources[$id]['format'] = 'planeupdatefaa';
206 267
         	//$last_exec['planeupdatefaa'] = 0;
207
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
268
+        	if ($globalDebug) {
269
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
270
+        	}
208 271
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209 272
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210 273
         	    exit(0);
@@ -213,37 +276,53 @@  discard block
 block discarded – undo
213 276
         	//$formats[$id] = 'phpvmacars';
214 277
         	$globalSources[$id]['format'] = 'phpvmacars';
215 278
         	//$last_exec['phpvmacars'] = 0;
216
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
279
+        	if ($globalDebug) {
280
+        		echo "Connect to phpvmacars source (".$host.")...\n";
281
+        	}
217 282
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
218 283
         	//$formats[$id] = 'phpvmacars';
219 284
         	$globalSources[$id]['format'] = 'vaos';
220 285
         	//$last_exec['phpvmacars'] = 0;
221
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
286
+        	if ($globalDebug) {
287
+        		echo "Connect to vaos source (".$host.")...\n";
288
+        	}
222 289
             } else if (preg_match('/VAM-json.php$/i',$host)) {
223 290
         	//$formats[$id] = 'phpvmacars';
224 291
         	$globalSources[$id]['format'] = 'vam';
225
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
292
+        	if ($globalDebug) {
293
+        		echo "Connect to Vam source (".$host.")...\n";
294
+        	}
226 295
             } else if (preg_match('/whazzup/i',$host)) {
227 296
         	//$formats[$id] = 'whazzup';
228 297
         	$globalSources[$id]['format'] = 'whazzup';
229 298
         	//$last_exec['whazzup'] = 0;
230
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
299
+        	if ($globalDebug) {
300
+        		echo "Connect to whazzup source (".$host.")...\n";
301
+        	}
231 302
             } else if (preg_match('/blitzortung/i',$host)) {
232 303
         	$globalSources[$id]['format'] = 'blitzortung';
233
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
304
+        	if ($globalDebug) {
305
+        		echo "Connect to blitzortung source (".$host.")...\n";
306
+        	}
234 307
             } else if (preg_match('/airwhere/i',$host)) {
235 308
         	$globalSources[$id]['format'] = 'airwhere';
236
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
309
+        	if ($globalDebug) {
310
+        		echo "Connect to airwhere source (".$host.")...\n";
311
+        	}
237 312
             } else if (preg_match('/recentpireps/i',$host)) {
238 313
         	//$formats[$id] = 'pirepsjson';
239 314
         	$globalSources[$id]['format'] = 'pirepsjson';
240 315
         	//$last_exec['pirepsjson'] = 0;
241
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
316
+        	if ($globalDebug) {
317
+        		echo "Connect to pirepsjson source (".$host.")...\n";
318
+        	}
242 319
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
243 320
         	//$formats[$id] = 'fr24json';
244 321
         	$globalSources[$id]['format'] = 'fr24json';
245 322
         	//$last_exec['fr24json'] = 0;
246
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
323
+        	if ($globalDebug) {
324
+        		echo "Connect to fr24 source (".$host.")...\n";
325
+        	}
247 326
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
248 327
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
249 328
         	    exit(0);
@@ -252,7 +331,9 @@  discard block
 block discarded – undo
252 331
         	//$formats[$id] = 'fr24json';
253 332
         	$globalSources[$id]['format'] = 'myshiptracking';
254 333
         	//$last_exec['fr24json'] = 0;
255
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
334
+        	if ($globalDebug) {
335
+        		echo "Connect to myshiptracking source (".$host.")...\n";
336
+        	}
256 337
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
257 338
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
258 339
         	    exit(0);
@@ -261,17 +342,26 @@  discard block
 block discarded – undo
261 342
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
262 343
         	//$formats[$id] = 'tsv';
263 344
         	$globalSources[$id]['format'] = 'tsv';
264
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
345
+        	if ($globalDebug) {
346
+        		echo "Connect to tsv source (".$host.")...\n";
347
+        	}
265 348
             }
266 349
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
267 350
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
268 351
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
269 352
     		    if ($idf !== false) {
270 353
     			$httpfeeds[$id] = $idf;
271
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
273
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
274
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
354
+        		if ($globalDebug) {
355
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
356
+        		}
357
+    		    } elseif ($globalDebug) {
358
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
359
+    		    }
360
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
361
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
362
+    		} elseif ($globalDebug) {
363
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+    		}
275 365
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
276 366
 	    $hostport = explode(':',$host);
277 367
 	    if (isset($hostport[1])) {
@@ -311,19 +401,27 @@  discard block
 block discarded – undo
311 401
         		//$formats[$id] = 'beast';
312 402
         		$globalSources[$id]['format'] = 'beast';
313 403
 		    //} else $formats[$id] = 'sbs';
314
-		    } else $globalSources[$id]['format'] = 'sbs';
404
+		    } else {
405
+		    	$globalSources[$id]['format'] = 'sbs';
406
+		    }
315 407
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
316 408
 		}
317
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
409
+		if ($globalDebug) {
410
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
411
+		}
318 412
             } else {
319
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
413
+		if ($globalDebug) {
414
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
415
+		}
320 416
 		sleep(10);
321 417
 		connect_all($hosts);
322 418
     	    }
323 419
         }
324 420
     }
325 421
 }
326
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
422
+if (!isset($globalMinFetch)) {
423
+	$globalMinFetch = 15;
424
+}
327 425
 
328 426
 // Initialize all
329 427
 $status = array();
@@ -332,13 +430,19 @@  discard block
 block discarded – undo
332 430
 $formats = array();
333 431
 $last_exec = array();
334 432
 $time = time();
335
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
336
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
337
-else $timeout = 20;
433
+if (isset($globalSourcesTimeout)) {
434
+	$timeout = $globalSourcesTimeOut;
435
+} else if (isset($globalSBS1TimeOut)) {
436
+	$timeout = $globalSBS1TimeOut;
437
+} else {
438
+	$timeout = 20;
439
+}
338 440
 $errno = '';
339 441
 $errstr='';
340 442
 
341
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
443
+if (!isset($globalDaemon)) {
444
+	$globalDaemon = TRUE;
445
+}
342 446
 /* Initiate connections to all the hosts simultaneously */
343 447
 //connect_all($hosts);
344 448
 //connect_all($globalSources);
@@ -367,7 +471,9 @@  discard block
 block discarded – undo
367 471
     if (isset($source['format']) && $source['format'] == 'aprs') {
368 472
 	$aprs_connect = 0;
369 473
 	$use_aprs = true;
370
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
474
+	if (isset($source['port']) && $source['port'] == '10152') {
475
+		$aprs_full = true;
476
+	}
371 477
 	break;
372 478
     }
373 479
 }
@@ -378,25 +484,46 @@  discard block
 block discarded – undo
378 484
 	$aprs_connect = 0;
379 485
 	$aprs_keep = 120;
380 486
 	$aprs_last_tx = time();
381
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
382
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
383
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
384
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
385
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
386
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
387
-	if ($aprs_full) $aprs_filter = '';
388
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
389
-	else $aprs_pass = '-1';
487
+	if (isset($globalAPRSversion)) {
488
+		$aprs_version = $globalAPRSversion;
489
+	} else {
490
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
491
+	}
492
+	if (isset($globalAPRSssid)) {
493
+		$aprs_ssid = $globalAPRSssid;
494
+	} else {
495
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
496
+	}
497
+	if (isset($globalAPRSfilter)) {
498
+		$aprs_filter = $globalAPRSfilter;
499
+	} else {
500
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
501
+	}
502
+	if ($aprs_full) {
503
+		$aprs_filter = '';
504
+	}
505
+	if (isset($globalAPRSpass)) {
506
+		$aprs_pass = $globalAPRSpass;
507
+	} else {
508
+		$aprs_pass = '-1';
509
+	}
390 510
 
391
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
392
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
393
-}
511
+	if ($aprs_filter != '') {
512
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
513
+	} else {
514
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
515
+	}
516
+	}
394 517
 
395 518
 // connected - lets do some work
396 519
 //if ($globalDebug) echo "Connected!\n";
397 520
 sleep(1);
398
-if ($globalDebug) echo "SCAN MODE \n\n";
399
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
521
+if ($globalDebug) {
522
+	echo "SCAN MODE \n\n";
523
+}
524
+if (!isset($globalCronEnd)) {
525
+	$globalCronEnd = 60;
526
+}
400 527
 $endtime = time()+$globalCronEnd;
401 528
 $i = 1;
402 529
 $tt = array();
@@ -410,22 +537,32 @@  discard block
 block discarded – undo
410 537
 
411 538
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
412 539
 while ($i > 0) {
413
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
540
+    if (function_exists('pcntl_fork')) {
541
+    	pcntl_signal_dispatch();
542
+    }
414 543
 
415
-    if (!$globalDaemon) $i = $endtime-time();
544
+    if (!$globalDaemon) {
545
+    	$i = $endtime-time();
546
+    }
416 547
     // Delete old ATC
417 548
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
418
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
549
+	if ($globalDebug) {
550
+		echo 'Delete old ATC...'."\n";
551
+	}
419 552
         $ATC->deleteOldATC();
420 553
     }
421 554
     
422 555
     if (count($last_exec) == count($globalSources)) {
423 556
 	$max = $globalMinFetch;
424 557
 	foreach ($last_exec as $last) {
425
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
558
+	    if ((time() - $last['last']) < $max) {
559
+	    	$max = time() - $last['last'];
560
+	    }
426 561
 	}
427 562
 	if ($max < $globalMinFetch) {
428
-	    if ($globalDebug) echo 'Sleeping...'."\n";
563
+	    if ($globalDebug) {
564
+	    	echo 'Sleeping...'."\n";
565
+	    }
429 566
 	    sleep($globalMinFetch-$max+2);
430 567
 	}
431 568
     }
@@ -435,7 +572,9 @@  discard block
 block discarded – undo
435 572
     foreach ($globalSources as $id => $value) {
436 573
 	date_default_timezone_set('UTC');
437 574
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
438
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
575
+	if (!isset($last_exec[$id]['last'])) {
576
+		$last_exec[$id]['last'] = 0;
577
+	}
439 578
 	if ($value['format'] === 'deltadbtxt' && 
440 579
 	    (
441 580
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -444,7 +583,9 @@  discard block
 block discarded – undo
444 583
 	) {
445 584
 	    //$buffer = $Common->getData($hosts[$id]);
446 585
 	    $buffer = $Common->getData($value['host']);
447
-	    if ($buffer != '') $reset = 0;
586
+	    if ($buffer != '') {
587
+	    	$reset = 0;
588
+	    }
448 589
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
449 590
 	    $buffer = explode('\n',$buffer);
450 591
 	    foreach ($buffer as $line) {
@@ -453,20 +594,41 @@  discard block
 block discarded – undo
453 594
 	            $data = array();
454 595
 	            $data['hex'] = $line[1]; // hex
455 596
 	            $data['ident'] = $line[2]; // ident
456
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
457
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
458
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
459
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
460
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
597
+	            if (isset($line[3])) {
598
+	            	$data['altitude'] = $line[3];
599
+	            }
600
+	            // altitude
601
+	            if (isset($line[4])) {
602
+	            	$data['speed'] = $line[4];
603
+	            }
604
+	            // speed
605
+	            if (isset($line[5])) {
606
+	            	$data['heading'] = $line[5];
607
+	            }
608
+	            // heading
609
+	            if (isset($line[6])) {
610
+	            	$data['latitude'] = $line[6];
611
+	            }
612
+	            // lat
613
+	            if (isset($line[7])) {
614
+	            	$data['longitude'] = $line[7];
615
+	            }
616
+	            // long
461 617
 	            $data['verticalrate'] = ''; // vertical rate
462 618
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
463 619
 	            $data['emergency'] = ''; // emergency
464 620
 		    $data['datetime'] = date('Y-m-d H:i:s');
465 621
 		    $data['format_source'] = 'deltadbtxt';
466 622
     		    $data['id_source'] = $id_source;
467
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
469
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
623
+		    if (isset($value['name']) && $value['name'] != '') {
624
+		    	$data['source_name'] = $value['name'];
625
+		    }
626
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
627
+		    	$data['noarchive'] = true;
628
+		    }
629
+		    if (isset($value['sourcestats'])) {
630
+		    	$data['sourcestats'] = $value['sourcestats'];
631
+		    }
470 632
     		    $SI->add($data);
471 633
 		    unset($data);
472 634
     		}
@@ -481,7 +643,9 @@  discard block
 block discarded – undo
481 643
 	    date_default_timezone_set('CET');
482 644
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
483 645
 	    date_default_timezone_set('UTC');
484
-	    if ($buffer != '') $reset = 0;
646
+	    if ($buffer != '') {
647
+	    	$reset = 0;
648
+	    }
485 649
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
486 650
 	    $buffer = explode('\n',$buffer);
487 651
 	    foreach ($buffer as $line) {
@@ -490,18 +654,42 @@  discard block
 block discarded – undo
490 654
 		    $add = false;
491 655
 		    $ais_data = $AIS->parse_line(trim($line));
492 656
 		    $data = array();
493
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
494
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
495
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
496
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
497
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
498
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
499
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
500
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
501
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
502
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
503
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
504
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
657
+		    if (isset($ais_data['ident'])) {
658
+		    	$data['ident'] = $ais_data['ident'];
659
+		    }
660
+		    if (isset($ais_data['mmsi'])) {
661
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
662
+		    }
663
+		    if (isset($ais_data['speed'])) {
664
+		    	$data['speed'] = $ais_data['speed'];
665
+		    }
666
+		    if (isset($ais_data['heading'])) {
667
+		    	$data['heading'] = $ais_data['heading'];
668
+		    }
669
+		    if (isset($ais_data['latitude'])) {
670
+		    	$data['latitude'] = $ais_data['latitude'];
671
+		    }
672
+		    if (isset($ais_data['longitude'])) {
673
+		    	$data['longitude'] = $ais_data['longitude'];
674
+		    }
675
+		    if (isset($ais_data['status'])) {
676
+		    	$data['status'] = $ais_data['status'];
677
+		    }
678
+		    if (isset($ais_data['statusid'])) {
679
+		    	$data['status_id'] = $ais_data['statusid'];
680
+		    }
681
+		    if (isset($ais_data['type'])) {
682
+		    	$data['type'] = $ais_data['type'];
683
+		    }
684
+		    if (isset($ais_data['typeid'])) {
685
+		    	$data['type_id'] = $ais_data['typeid'];
686
+		    }
687
+		    if (isset($ais_data['imo'])) {
688
+		    	$data['imo'] = $ais_data['imo'];
689
+		    }
690
+		    if (isset($ais_data['callsign'])) {
691
+		    	$data['callsign'] = $ais_data['callsign'];
692
+		    }
505 693
 		    if (isset($ais_data['timestamp'])) {
506 694
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
507 695
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -515,8 +703,12 @@  discard block
 block discarded – undo
515 703
 		    $data['format_source'] = 'aisnmeatxt';
516 704
     		    $data['id_source'] = $id_source;
517 705
 		    //print_r($data);
518
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
519
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
706
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
707
+		    	$data['noarchive'] = true;
708
+		    }
709
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
710
+		    	$MI->add($data);
711
+		    }
520 712
 		    unset($data);
521 713
 		}
522 714
     	    }
@@ -539,20 +731,48 @@  discard block
 block discarded – undo
539 731
 			    if ($line != '') {
540 732
 				$ais_data = $AIS->parse_line(trim($line));
541 733
 				$data = array();
542
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
543
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
544
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
545
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
546
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
547
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
548
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
549
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
550
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
551
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
552
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
553
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
555
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
734
+				if (isset($ais_data['ident'])) {
735
+					$data['ident'] = $ais_data['ident'];
736
+				}
737
+				if (isset($ais_data['mmsi'])) {
738
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
739
+				}
740
+				if (isset($ais_data['speed'])) {
741
+					$data['speed'] = $ais_data['speed'];
742
+				}
743
+				if (isset($ais_data['heading'])) {
744
+					$data['heading'] = $ais_data['heading'];
745
+				}
746
+				if (isset($ais_data['latitude'])) {
747
+					$data['latitude'] = $ais_data['latitude'];
748
+				}
749
+				if (isset($ais_data['longitude'])) {
750
+					$data['longitude'] = $ais_data['longitude'];
751
+				}
752
+				if (isset($ais_data['status'])) {
753
+					$data['status'] = $ais_data['status'];
754
+				}
755
+				if (isset($ais_data['statusid'])) {
756
+					$data['status_id'] = $ais_data['statusid'];
757
+				}
758
+				if (isset($ais_data['type'])) {
759
+					$data['type'] = $ais_data['type'];
760
+				}
761
+				if (isset($ais_data['typeid'])) {
762
+					$data['type_id'] = $ais_data['typeid'];
763
+				}
764
+				if (isset($ais_data['imo'])) {
765
+					$data['imo'] = $ais_data['imo'];
766
+				}
767
+				if (isset($ais_data['callsign'])) {
768
+					$data['callsign'] = $ais_data['callsign'];
769
+				}
770
+				if (isset($ais_data['destination'])) {
771
+					$data['arrival_code'] = $ais_data['destination'];
772
+				}
773
+				if (isset($ais_data['eta_ts'])) {
774
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
775
+				}
556 776
 				if (isset($ais_data['timestamp'])) {
557 777
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558 778
 				} else {
@@ -560,18 +780,27 @@  discard block
 block discarded – undo
560 780
 				}
561 781
 				$data['format_source'] = 'aisnmeahttp';
562 782
 				$data['id_source'] = $id_source;
563
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
564
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
783
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
784
+					$data['noarchive'] = true;
785
+				}
786
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
787
+					$MI->add($data);
788
+				}
565 789
 				unset($data);
566 790
 			    }
567 791
 			}
568 792
 		    }
569 793
 		} else {
570 794
 		    $format = $value['format'];
571
-		    if (isset($tt[$format])) $tt[$format]++;
572
-		    else $tt[$format] = 0;
795
+		    if (isset($tt[$format])) {
796
+		    	$tt[$format]++;
797
+		    } else {
798
+		    	$tt[$format] = 0;
799
+		    }
573 800
 		    if ($tt[$format] > 30) {
574
-			if ($globalDebug) echo 'Reconnect...'."\n";
801
+			if ($globalDebug) {
802
+				echo 'Reconnect...'."\n";
803
+			}
575 804
 			sleep(2);
576 805
 			//$sourceeen[] = $value;
577 806
 			//connect_all($sourceeen);
@@ -607,12 +836,18 @@  discard block
 block discarded – undo
607 836
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
608 837
 			    //$data['type_id'] = $line['TYPE'];
609 838
 			    $data['imo'] = $line['IMO'];
610
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
611
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
839
+			    if ($line['DEST'] != '') {
840
+			    	$data['arrival_code'] = $line['DEST'];
841
+			    }
842
+			    if ($line['ARV'] != '') {
843
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
844
+			    }
612 845
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
613 846
 			    $data['format_source'] = 'myshiptracking';
614 847
 			    $data['id_source'] = $id_source;
615
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
848
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
849
+			    	$data['noarchive'] = true;
850
+			    }
616 851
 			    $MI->add($data);
617 852
 			    unset($data);
618 853
 			}
@@ -637,7 +872,9 @@  discard block
 block discarded – undo
637 872
 			    $data['callsign'] = $line['callsign'];
638 873
 			    $data['mmsi'] = substr($line['mmsi'],-9);
639 874
 			    $data['speed'] = $line['sog'];
640
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
875
+			    if ($line['heading'] != '511') {
876
+			    	$data['heading'] = $line['heading'];
877
+			    }
641 878
 			    $data['latitude'] = $line['latitude'];
642 879
 			    $data['longitude'] = $line['longitude'];
643 880
 			    $data['type_id'] = $line['shiptype'];
@@ -645,7 +882,9 @@  discard block
 block discarded – undo
645 882
 			    $data['datetime'] = $line['time'];
646 883
 			    $data['format_source'] = 'boatbeaconapp';
647 884
 			    $data['id_source'] = $id_source;
648
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
885
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
886
+			    	$data['noarchive'] = true;
887
+			    }
649 888
 			    $MI->add($data);
650 889
 			    unset($data);
651 890
 			}
@@ -667,22 +906,44 @@  discard block
 block discarded – undo
667 906
 		    foreach ($all_data['features'] as $line) {
668 907
 			print_r($line);
669 908
 			$data = array();
670
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
671
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
672
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
673
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
674
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
675
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
909
+			if (isset($line['properties']['name'])) {
910
+				$data['ident'] = $line['properties']['name'];
911
+			}
912
+			if (isset($line['properties']['callsign'])) {
913
+				$data['callsign'] = $line['properties']['callsign'];
914
+			}
915
+			if (isset($line['properties']['mmsi'])) {
916
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
917
+			}
918
+			if (isset($line['properties']['imo'])) {
919
+				$data['imo'] = $line['properties']['imo'];
920
+			}
921
+			if (isset($line['properties']['speed'])) {
922
+				$data['speed'] = $line['properties']['speed'];
923
+			}
924
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
925
+				$data['heading'] = $line['properties']['heading'];
926
+			}
676 927
 			$data['latitude'] = $line['geometry']['coordinates'][1];
677 928
 			$data['longitude'] = $line['geometry']['coordinates'][0];
678
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
679
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
680
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
929
+			if (isset($line['properties']['vesselType'])) {
930
+				$data['type'] = $line['properties']['vesselType'];
931
+			}
932
+			if (isset($line['properties']['destination'])) {
933
+				$data['arrival_code'] = $line['properties']['destination'];
934
+			}
935
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
936
+				$data['arrival_date'] = $line['properties']['eta'];
937
+			}
681 938
 			$data['format_source'] = 'boatnerd';
682 939
 			$data['id_source'] = $id_source;
683 940
 			$data['datetime'] = date('Y-m-d H:i:s');
684
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
685
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
941
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
942
+				$data['noarchive'] = true;
943
+			}
944
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
945
+				$MI->add($data);
946
+			}
686 947
 			unset($data);
687 948
 		    }
688 949
 		}
@@ -695,11 +956,17 @@  discard block
 block discarded – undo
695 956
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
696 957
 	    )
697 958
 	) {
698
-	    if ($globalDebug) echo 'download...';
959
+	    if ($globalDebug) {
960
+	    	echo 'download...';
961
+	    }
699 962
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
700
-	    if ($globalDebug) echo 'done !'."\n";
963
+	    if ($globalDebug) {
964
+	    	echo 'done !'."\n";
965
+	    }
701 966
 	    // FIXME: Need more work
702
-	    if ($buffer != '') $reset = 0;
967
+	    if ($buffer != '') {
968
+	    	$reset = 0;
969
+	    }
703 970
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
704 971
 	    $buffer = explode('\n',$buffer);
705 972
 	    foreach ($buffer as $line) {
@@ -725,7 +992,9 @@  discard block
 block discarded – undo
725 992
 		    //$data['etaTime'] = substr($line,135,5);
726 993
 		    $data['format_source'] = 'shipplotter';
727 994
     		    $data['id_source'] = $id_source;
728
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
995
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
996
+		    	$data['noarchive'] = true;
997
+		    }
729 998
 		    //print_r($data);
730 999
 		    //echo 'Add...'."\n";
731 1000
 		    $MI->add($data);
@@ -739,10 +1008,14 @@  discard block
 block discarded – undo
739 1008
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
740 1009
 	    )
741 1010
 	) {
742
-	    if ($globalDebug) echo 'download...';
1011
+	    if ($globalDebug) {
1012
+	    	echo 'download...';
1013
+	    }
743 1014
 	    for ($i =0; $i <= 1; $i++) {
744 1015
 	    $buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
745
-	    if ($globalDebug) echo 'done'."\n";
1016
+	    if ($globalDebug) {
1017
+	    	echo 'done'."\n";
1018
+	    }
746 1019
 	    if ($buffer != '') {
747 1020
 		$all_data = json_decode($buffer,true);
748 1021
 		if (isset($all_data['missions'])) {
@@ -751,7 +1024,9 @@  discard block
 block discarded – undo
751 1024
 				$mission_name = $mission['mistitle'];
752 1025
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
753 1026
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
754
-				} else $bufferm = '';
1027
+				} else {
1028
+					$bufferm = '';
1029
+				}
755 1030
 				if ($bufferm != '') {
756 1031
 					$mission_data = json_decode($bufferm,true);
757 1032
 					if (isset($mission_data['leaderboard'][0]['results'])) {
@@ -779,7 +1054,9 @@  discard block
 block discarded – undo
779 1054
 								//$data['callsign'] = trim(substr($line,100,7);
780 1055
 								$data['format_source'] = 'sailaway';
781 1056
 								$data['id_source'] = $id_source;
782
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1057
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1058
+									$data['noarchive'] = true;
1059
+								}
783 1060
 								//print_r($data);
784 1061
 								//echo 'Add...'."\n";
785 1062
 								$MI->add($data);
@@ -820,16 +1097,28 @@  discard block
 block discarded – undo
820 1097
     		    $line = explode(':', $line);
821 1098
     		    if (count($line) > 30 && $line[0] != 'callsign') {
822 1099
 			$data = array();
823
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
824
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1100
+			if (isset($line[37]) && $line[37] != '') {
1101
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1102
+			} else {
1103
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1104
+			}
825 1105
 			$data['pilot_id'] = $line[1];
826 1106
 			$data['pilot_name'] = $line[2];
827 1107
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
828 1108
 			$data['ident'] = $line[0]; // ident
829
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1109
+			if ($line[7] != '' && $line[7] != 0) {
1110
+				$data['altitude'] = $line[7];
1111
+			}
1112
+			// altitude
830 1113
 			$data['speed'] = $line[8]; // speed
831
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
832
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1114
+			if (isset($line[45])) {
1115
+				$data['heading'] = $line[45];
1116
+			}
1117
+			// heading
1118
+			elseif (isset($line[38])) {
1119
+				$data['heading'] = $line[38];
1120
+			}
1121
+			// heading
833 1122
 			$data['latitude'] = $line[5]; // lat
834 1123
 	        	$data['longitude'] = $line[6]; // long
835 1124
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -845,7 +1134,9 @@  discard block
 block discarded – undo
845 1134
 			$data['frequency'] = $line[4];
846 1135
 			$data['type'] = $line[18];
847 1136
 			$data['range'] = $line[19];
848
-			if (isset($line[35])) $data['info'] = $line[35];
1137
+			if (isset($line[35])) {
1138
+				$data['info'] = $line[35];
1139
+			}
849 1140
     			$data['id_source'] = $id_source;
850 1141
 	    		//$data['arrival_airport_time'] = ;
851 1142
 	    		if ($line[9] != '') {
@@ -859,27 +1150,47 @@  discard block
 block discarded – undo
859 1150
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
860 1151
 	    		*/
861 1152
 	    		$data['format_source'] = $value['format'];
862
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
863
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
864
-    			if ($line[3] === 'PILOT') $SI->add($data);
865
-			elseif ($line[3] === 'ATC') {
1153
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1154
+				$data['noarchive'] = true;
1155
+			}
1156
+			if (isset($value['name']) && $value['name'] != '') {
1157
+				$data['source_name'] = $value['name'];
1158
+			}
1159
+    			if ($line[3] === 'PILOT') {
1160
+    				$SI->add($data);
1161
+    			} elseif ($line[3] === 'ATC') {
866 1162
 				//print_r($data);
867 1163
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
868 1164
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
869 1165
 				$typec = substr($data['ident'],-3);
870
-				if ($typec === 'APP') $data['type'] = 'Approach';
871
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
872
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
873
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
874
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
875
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
876
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
877
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
878
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
879
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1166
+				if ($typec === 'APP') {
1167
+					$data['type'] = 'Approach';
1168
+				} elseif ($typec === 'TWR') {
1169
+					$data['type'] = 'Tower';
1170
+				} elseif ($typec === 'OBS') {
1171
+					$data['type'] = 'Observer';
1172
+				} elseif ($typec === 'GND') {
1173
+					$data['type'] = 'Ground';
1174
+				} elseif ($typec === 'DEL') {
1175
+					$data['type'] = 'Delivery';
1176
+				} elseif ($typec === 'DEP') {
1177
+					$data['type'] = 'Departure';
1178
+				} elseif ($typec === 'FSS') {
1179
+					$data['type'] = 'Flight Service Station';
1180
+				} elseif ($typec === 'CTR') {
1181
+					$data['type'] = 'Control Radar or Centre';
1182
+				} elseif ($data['type'] === '') {
1183
+					$data['type'] = 'Observer';
1184
+				}
1185
+				if (!isset($data['source_name'])) {
1186
+					$data['source_name'] = '';
1187
+				}
880 1188
 				if (isset($ATC)) {
881
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
882
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1189
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1190
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1191
+					} else {
1192
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1193
+					}
883 1194
 				}
884 1195
 			}
885 1196
     			unset($data);
@@ -906,14 +1217,20 @@  discard block
 block discarded – undo
906 1217
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
907 1218
 			$data['latitude'] = (float)$line['pktLatitude'];
908 1219
 			$data['longitude'] = (float)$line['pktLongitude'];
909
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
910
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1220
+			if ((float)$line['pktTrack'] != 0) {
1221
+				$data['heading'] = (float)$line['pktTrack'];
1222
+			}
1223
+			if ((int)$line['pktSpeed'] != 0) {
1224
+				$data['speed'] = (int)$line['pktSpeed'];
1225
+			}
911 1226
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
912 1227
 			$data['altitude_relative'] = 'AMSL';
913 1228
 			$data['pilot_id'] = (int)$line['pktPilotID'];
914 1229
 			$data['aircraft_icao'] = 'PARAGLIDER';
915 1230
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
916
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1231
+			if (isset($pilot_data[4])) {
1232
+				$data['pilot_name'] = $pilot_data[4];
1233
+			}
917 1234
 			$data['format_source'] = $value['format'];
918 1235
 			$SI->add($data);
919 1236
 			unset($data);
@@ -961,25 +1278,59 @@  discard block
 block discarded – undo
961 1278
 		    foreach ($all_data['acList'] as $line) {
962 1279
 			$data = array();
963 1280
 			$data['hex'] = $line['Icao']; // hex
964
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
965
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
966
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
967
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
968
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
969
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1281
+			if (isset($line['Call'])) {
1282
+				$data['ident'] = $line['Call'];
1283
+			}
1284
+			// ident
1285
+			if (isset($line['Alt'])) {
1286
+				$data['altitude'] = $line['Alt'];
1287
+			}
1288
+			// altitude
1289
+			if (isset($line['Spd'])) {
1290
+				$data['speed'] = $line['Spd'];
1291
+			}
1292
+			// speed
1293
+			if (isset($line['Trak'])) {
1294
+				$data['heading'] = $line['Trak'];
1295
+			}
1296
+			// heading
1297
+			if (isset($line['Lat'])) {
1298
+				$data['latitude'] = $line['Lat'];
1299
+			}
1300
+			// lat
1301
+			if (isset($line['Long'])) {
1302
+				$data['longitude'] = $line['Long'];
1303
+			}
1304
+			// long
970 1305
 			//$data['verticalrate'] = $line['']; // verticale rate
971
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1306
+			if (isset($line['Sqk'])) {
1307
+				$data['squawk'] = $line['Sqk'];
1308
+			}
1309
+			// squawk
972 1310
 			$data['emergency'] = ''; // emergency
973
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
974
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
975
-			else $data['datetime'] = date('Y-m-d H:i:s');
1311
+			if (isset($line['Reg'])) {
1312
+				$data['registration'] = $line['Reg'];
1313
+			}
1314
+			if (isset($line['PosTime'])) {
1315
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1316
+			} else {
1317
+				$data['datetime'] = date('Y-m-d H:i:s');
1318
+			}
976 1319
 			//$data['datetime'] = date('Y-m-d H:i:s');
977
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1320
+			if (isset($line['Type'])) {
1321
+				$data['aircraft_icao'] = $line['Type'];
1322
+			}
978 1323
 			$data['format_source'] = 'aircraftlistjson';
979 1324
 			$data['id_source'] = $id_source;
980
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
981
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
982
-			if (isset($data['latitude'])) $SI->add($data);
1325
+			if (isset($value['name']) && $value['name'] != '') {
1326
+				$data['source_name'] = $value['name'];
1327
+			}
1328
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1329
+				$data['noarchive'] = true;
1330
+			}
1331
+			if (isset($data['latitude'])) {
1332
+				$SI->add($data);
1333
+			}
983 1334
 			unset($data);
984 1335
 		    }
985 1336
 		} elseif (is_array($all_data)) {
@@ -996,17 +1347,26 @@  discard block
 block discarded – undo
996 1347
 			$data['verticalrate'] = $line['vrt']; // verticale rate
997 1348
 			$data['squawk'] = $line['squawk']; // squawk
998 1349
 			$data['emergency'] = ''; // emergency
999
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1000
-			else $data['datetime'] = date('Y-m-d H:i:s');
1350
+			if (isset($line['PosTime'])) {
1351
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1352
+			} else {
1353
+				$data['datetime'] = date('Y-m-d H:i:s');
1354
+			}
1001 1355
 			$data['format_source'] = 'aircraftlistjson';
1002 1356
 			$data['id_source'] = $id_source;
1003
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1004
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1357
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1358
+				$data['noarchive'] = true;
1359
+			}
1360
+			if (isset($value['name']) && $value['name'] != '') {
1361
+				$data['source_name'] = $value['name'];
1362
+			}
1005 1363
 			$SI->add($data);
1006 1364
 			unset($data);
1007 1365
 		    }
1008 1366
 		}
1009
-	    } elseif ($globalDebug) echo 'No data'."\n";
1367
+	    } elseif ($globalDebug) {
1368
+	    	echo 'No data'."\n";
1369
+	    }
1010 1370
     	    //$last_exec['aircraftlistjson'] = time();
1011 1371
     	    $last_exec[$id]['last'] = time();
1012 1372
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1042,8 +1402,12 @@  discard block
 block discarded – undo
1042 1402
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1043 1403
 	    	    $data['format_source'] = 'planeupdatefaa';
1044 1404
     		    $data['id_source'] = $id_source;
1045
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1046
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1405
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1406
+		    	$data['noarchive'] = true;
1407
+		    }
1408
+		    if (isset($value['name']) && $value['name'] != '') {
1409
+		    	$data['source_name'] = $value['name'];
1410
+		    }
1047 1411
 		    $SI->add($data);
1048 1412
 		    unset($data);
1049 1413
 		}
@@ -1077,7 +1441,9 @@  discard block
 block discarded – undo
1077 1441
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1078 1442
 		    $data['format_source'] = 'opensky';
1079 1443
 		    $data['id_source'] = $id_source;
1080
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1444
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1445
+		    	$data['noarchive'] = true;
1446
+		    }
1081 1447
 		    $SI->add($data);
1082 1448
 		    unset($data);
1083 1449
 		}
@@ -1097,15 +1463,42 @@  discard block
 block discarded – undo
1097 1463
 		foreach ($all_data['aircraft'] as $key => $line) {
1098 1464
 		    $data = array();
1099 1465
 		    // add support for ground vehicule with ~ in front of hex
1100
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1101
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1102
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1103
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1104
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1105
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1106
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1107
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1108
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1466
+		    if (isset($line['hex'])) {
1467
+		    	$data['hex'] = $line['hex'];
1468
+		    }
1469
+		    // hex
1470
+		    if (isset($line['flight'])) {
1471
+		    	$data['ident'] = trim($line['flight']);
1472
+		    }
1473
+		    // ident
1474
+		    if (isset($line['altitude'])) {
1475
+		    	$data['altitude'] = $line['altitude'];
1476
+		    }
1477
+		    // altitude
1478
+		    if (isset($line['speed'])) {
1479
+		    	$data['speed'] = $line['speed'];
1480
+		    }
1481
+		    // speed
1482
+		    if (isset($line['track'])) {
1483
+		    	$data['heading'] = $line['track'];
1484
+		    }
1485
+		    // heading
1486
+		    if (isset($line['lat'])) {
1487
+		    	$data['latitude'] = $line['lat'];
1488
+		    }
1489
+		    // lat
1490
+		    if (isset($line['lon'])) {
1491
+		    	$data['longitude'] = $line['lon'];
1492
+		    }
1493
+		    // long
1494
+		    if (isset($line['vert_rate'])) {
1495
+		    	$data['verticalrate'] = $line['vert_rate'];
1496
+		    }
1497
+		    // verticale rate
1498
+		    if (isset($line['squawk'])) {
1499
+		    	$data['squawk'] = $line['squawk'];
1500
+		    }
1501
+		    // squawk
1109 1502
 		    //$data['emergency'] = ''; // emergency
1110 1503
 		    //$data['registration'] = $line[2];
1111 1504
 		    //$data['aircraft_icao'] = $line[0];
@@ -1113,10 +1506,17 @@  discard block
 block discarded – undo
1113 1506
 		    $data['format_source'] = 'aircraftjson';
1114 1507
 		    $data['id_source'] = $id_source;
1115 1508
 		    if (isset($value['name']) && $value['name'] != '') {
1116
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1117
-			    else $data['source_name'] = $value['name'];
1118
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1119
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1509
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1510
+			    	$data['source_name'] = $value['name'].'_MLAT';
1511
+			    } else {
1512
+			    	$data['source_name'] = $value['name'];
1513
+			    }
1514
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1515
+		    	$data['source_name'] = 'MLAT';
1516
+		    }
1517
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1518
+		    	$data['noarchive'] = true;
1519
+		    }
1120 1520
 		    $SI->add($data);
1121 1521
 		    unset($data);
1122 1522
 		}
@@ -1136,22 +1536,54 @@  discard block
 block discarded – undo
1136 1536
 		foreach ($all_data['aircraft'] as $key => $line) {
1137 1537
 		    $data = array();
1138 1538
 		    $data['hex'] = $key; // hex
1139
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1140
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1141
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1142
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1143
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1144
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1145
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1146
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1539
+		    if (isset($line['callsign'])) {
1540
+		    	$data['ident'] = trim($line['callsign']);
1541
+		    }
1542
+		    // ident
1543
+		    if (isset($line['altitude'])) {
1544
+		    	$data['altitude'] = $line['altitude'];
1545
+		    }
1546
+		    // altitude
1547
+		    if (isset($line['speed'])) {
1548
+		    	$data['speed'] = $line['speed'];
1549
+		    }
1550
+		    // speed
1551
+		    if (isset($line['heading'])) {
1552
+		    	$data['heading'] = $line['heading'];
1553
+		    }
1554
+		    // heading
1555
+		    if (isset($line['lat'])) {
1556
+		    	$data['latitude'] = $line['lat'];
1557
+		    }
1558
+		    // lat
1559
+		    if (isset($line['lon'])) {
1560
+		    	$data['longitude'] = $line['lon'];
1561
+		    }
1562
+		    // long
1563
+		    if (isset($line['vert_rate'])) {
1564
+		    	$data['verticalrate'] = $line['vert_rate'];
1565
+		    }
1566
+		    // verticale rate
1567
+		    if (isset($line['squawk'])) {
1568
+		    	$data['squawk'] = $line['squawk'];
1569
+		    }
1570
+		    // squawk
1147 1571
 		    //$data['emergency'] = ''; // emergency
1148
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1149
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1572
+		    if (isset($line['reg'])) {
1573
+		    	$data['registration'] = $line['reg'];
1574
+		    }
1575
+		    if (isset($line['type'])) {
1576
+		    	$data['aircraft_icao'] = $line['type'];
1577
+		    }
1150 1578
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1151 1579
 		    $data['format_source'] = 'planefinderclient';
1152 1580
 		    $data['id_source'] = $id_source;
1153
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1154
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1581
+		    if (isset($value['name']) && $value['name'] != '') {
1582
+		    	$data['source_name'] = $value['name'];
1583
+		    }
1584
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1585
+		    	$data['noarchive'] = true;
1586
+		    }
1155 1587
 		    $SI->add($data);
1156 1588
 		    unset($data);
1157 1589
 		}
@@ -1167,7 +1599,9 @@  discard block
 block discarded – undo
1167 1599
 	    //$buffer = $Common->getData($hosts[$id]);
1168 1600
 	    $buffer = $Common->getData($value['host']);
1169 1601
 	    $all_data = json_decode($buffer,true);
1170
-	    if (!empty($all_data)) $reset = 0;
1602
+	    if (!empty($all_data)) {
1603
+	    	$reset = 0;
1604
+	    }
1171 1605
 	    foreach ($all_data as $key => $line) {
1172 1606
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1173 1607
 		    $data = array();
@@ -1188,8 +1622,12 @@  discard block
 block discarded – undo
1188 1622
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1189 1623
 	    	    $data['format_source'] = 'fr24json';
1190 1624
     		    $data['id_source'] = $id_source;
1191
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1192
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1625
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1626
+		    	$data['noarchive'] = true;
1627
+		    }
1628
+		    if (isset($value['name']) && $value['name'] != '') {
1629
+		    	$data['source_name'] = $value['name'];
1630
+		    }
1193 1631
 		    $SI->add($data);
1194 1632
 		    unset($data);
1195 1633
 		}
@@ -1218,24 +1656,42 @@  discard block
 block discarded – undo
1218 1656
 		    if (isset($line['inf'])) {
1219 1657
 			$data = array();
1220 1658
 			$data['hex'] = $line['inf']['ia'];
1221
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1659
+			if (isset($line['inf']['cs'])) {
1660
+				$data['ident'] = $line['inf']['cs'];
1661
+			}
1662
+			//$line[13]
1222 1663
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1223
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1224
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1664
+	    		if (isset($line['inf']['gs'])) {
1665
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1666
+	    		}
1667
+	    		// speed
1668
+	    		if (isset($line['inf']['tr'])) {
1669
+	    			$data['heading'] = $line['inf']['tr'];
1670
+	    		}
1671
+	    		// heading
1225 1672
 	    		$data['latitude'] = $line['pt'][0]; // lat
1226 1673
 	    		$data['longitude'] = $line['pt'][1]; // long
1227 1674
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1228
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1675
+	    		if (isset($line['inf']['sq'])) {
1676
+	    			$data['squawk'] = $line['inf']['sq'];
1677
+	    		}
1678
+	    		// squawk
1229 1679
 	    		//$data['aircraft_icao'] = $line[8];
1230
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1680
+	    		if (isset($line['inf']['rc'])) {
1681
+	    			$data['registration'] = $line['inf']['rc'];
1682
+	    		}
1231 1683
 			//$data['departure_airport_iata'] = $line[11];
1232 1684
 			//$data['arrival_airport_iata'] = $line[12];
1233 1685
 	    		//$data['emergency'] = ''; // emergency
1234 1686
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1235 1687
 	    		$data['format_source'] = 'radarvirtueljson';
1236 1688
     			$data['id_source'] = $id_source;
1237
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1238
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1689
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1690
+				$data['noarchive'] = true;
1691
+			}
1692
+			if (isset($value['name']) && $value['name'] != '') {
1693
+				$data['source_name'] = $value['name'];
1694
+			}
1239 1695
 			$SI->add($data);
1240 1696
 			unset($data);
1241 1697
 		    }
@@ -1261,30 +1717,65 @@  discard block
 block discarded – undo
1261 1717
 		    $data['id'] = $line['id'];
1262 1718
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1263 1719
 		    $data['ident'] = $line['callsign']; // ident
1264
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1265
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1266
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1267
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1268
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1269
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1720
+		    if (isset($line['pilotid'])) {
1721
+		    	$data['pilot_id'] = $line['pilotid'];
1722
+		    }
1723
+		    // pilot id
1724
+		    if (isset($line['name'])) {
1725
+		    	$data['pilot_name'] = $line['name'];
1726
+		    }
1727
+		    // pilot name
1728
+		    if (isset($line['alt'])) {
1729
+		    	$data['altitude'] = $line['alt'];
1730
+		    }
1731
+		    // altitude
1732
+		    if (isset($line['gs'])) {
1733
+		    	$data['speed'] = $line['gs'];
1734
+		    }
1735
+		    // speed
1736
+		    if (isset($line['heading'])) {
1737
+		    	$data['heading'] = $line['heading'];
1738
+		    }
1739
+		    // heading
1740
+		    if (isset($line['route'])) {
1741
+		    	$data['waypoints'] = $line['route'];
1742
+		    }
1743
+		    // route
1270 1744
 		    $data['latitude'] = $line['lat']; // lat
1271 1745
 		    $data['longitude'] = $line['lon']; // long
1272 1746
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1273 1747
 		    //$data['squawk'] = $line['squawk']; // squawk
1274 1748
 		    //$data['emergency'] = ''; // emergency
1275
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1276
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1277
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1749
+		    if (isset($line['depicao'])) {
1750
+		    	$data['departure_airport_icao'] = $line['depicao'];
1751
+		    }
1752
+		    if (isset($line['deptime'])) {
1753
+		    	$data['departure_airport_time'] = $line['deptime'];
1754
+		    }
1755
+		    if (isset($line['arricao'])) {
1756
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1757
+		    }
1278 1758
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1279
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1280
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1281
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1282
-		    else $data['info'] = '';
1759
+		    if (isset($line['aircraft'])) {
1760
+		    	$data['aircraft_icao'] = $line['aircraft'];
1761
+		    }
1762
+		    if (isset($line['transponder'])) {
1763
+		    	$data['squawk'] = $line['transponder'];
1764
+		    }
1765
+		    if (isset($line['atis'])) {
1766
+		    	$data['info'] = $line['atis'];
1767
+		    } else {
1768
+		    	$data['info'] = '';
1769
+		    }
1283 1770
 		    $data['format_source'] = 'pireps';
1284 1771
     		    $data['id_source'] = $id_source;
1285 1772
 		    $data['datetime'] = date('Y-m-d H:i:s');
1286
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1287
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1773
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1774
+		    	$data['noarchive'] = true;
1775
+		    }
1776
+		    if (isset($value['name']) && $value['name'] != '') {
1777
+		    	$data['source_name'] = $value['name'];
1778
+		    }
1288 1779
 		    if ($line['icon'] === 'plane') {
1289 1780
 			$SI->add($data);
1290 1781
 		    //    print_r($data);
@@ -1293,16 +1784,28 @@  discard block
 block discarded – undo
1293 1784
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1294 1785
 			$typec = substr($data['ident'],-3);
1295 1786
 			$data['type'] = '';
1296
-			if ($typec === 'APP') $data['type'] = 'Approach';
1297
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1298
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1299
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1300
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1301
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1302
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1303
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1304
-			else $data['type'] = 'Observer';
1305
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1787
+			if ($typec === 'APP') {
1788
+				$data['type'] = 'Approach';
1789
+			} elseif ($typec === 'TWR') {
1790
+				$data['type'] = 'Tower';
1791
+			} elseif ($typec === 'OBS') {
1792
+				$data['type'] = 'Observer';
1793
+			} elseif ($typec === 'GND') {
1794
+				$data['type'] = 'Ground';
1795
+			} elseif ($typec === 'DEL') {
1796
+				$data['type'] = 'Delivery';
1797
+			} elseif ($typec === 'DEP') {
1798
+				$data['type'] = 'Departure';
1799
+			} elseif ($typec === 'FSS') {
1800
+				$data['type'] = 'Flight Service Station';
1801
+			} elseif ($typec === 'CTR') {
1802
+				$data['type'] = 'Control Radar or Centre';
1803
+			} else {
1804
+				$data['type'] = 'Observer';
1805
+			}
1806
+			if (isset($ATC)) {
1807
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1808
+			}
1306 1809
 		    }
1307 1810
 		    unset($data);
1308 1811
 		}
@@ -1317,7 +1820,9 @@  discard block
 block discarded – undo
1317 1820
 	    )
1318 1821
 	) {
1319 1822
 	    //$buffer = $Common->getData($hosts[$id]);
1320
-	    if ($globalDebug) echo 'Get Data...'."\n";
1823
+	    if ($globalDebug) {
1824
+	    	echo 'Get Data...'."\n";
1825
+	    }
1321 1826
 	    $buffer = $Common->getData($value['host']);
1322 1827
 	    $all_data = json_decode($buffer,true);
1323 1828
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1325,10 +1830,16 @@  discard block
 block discarded – undo
1325 1830
 		foreach ($all_data as $line) {
1326 1831
 	    	    $data = array();
1327 1832
 	    	    //$data['id'] = $line['id']; // id not usable
1328
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1833
+	    	    if (isset($line['pilotid'])) {
1834
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1835
+	    	    }
1329 1836
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1330
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1331
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1837
+	    	    if (isset($line['pilotname'])) {
1838
+	    	    	$data['pilot_name'] = $line['pilotname'];
1839
+	    	    }
1840
+	    	    if (isset($line['pilotid'])) {
1841
+	    	    	$data['pilot_id'] = $line['pilotid'];
1842
+	    	    }
1332 1843
 	    	    $data['ident'] = $line['flightnum']; // ident
1333 1844
 	    	    $data['altitude'] = $line['alt']; // altitude
1334 1845
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1344,7 +1855,9 @@  discard block
 block discarded – undo
1344 1855
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1345 1856
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1346 1857
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1347
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1858
+	    	    } else {
1859
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1860
+	    	    }
1348 1861
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1349 1862
 	    	    $data['departure_airport_time'] = $line['deptime'];
1350 1863
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1352,29 +1865,47 @@  discard block
 block discarded – undo
1352 1865
     		    if (isset($line['registration'])) {
1353 1866
     			$data['registration'] = $line['registration'];
1354 1867
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1355
-    		    } else $data['registration'] = $line['aircraft'];
1356
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1357
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1868
+    		    } else {
1869
+    		    	$data['registration'] = $line['aircraft'];
1870
+    		    }
1871
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1872
+		    	$data['noarchive'] = true;
1873
+		    }
1874
+		    if (isset($line['route'])) {
1875
+		    	$data['waypoints'] = $line['route'];
1876
+		    }
1877
+		    // route
1358 1878
 		    if (isset($line['aircraftname'])) {
1359 1879
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1360 1880
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1361 1881
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1362
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1363
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1364
-	    		else {
1882
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1883
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1884
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1885
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1886
+	    		} else {
1365 1887
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1366
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1367
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1888
+	    		    if (isset($aircraft_data[1])) {
1889
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1890
+	    		    } else {
1891
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1892
+	    		    }
1368 1893
 	    		}
1369 1894
 	    	    }
1370
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1895
+    		    if (isset($line['route'])) {
1896
+    		    	$data['waypoints'] = $line['route'];
1897
+    		    }
1371 1898
     		    $data['id_source'] = $id_source;
1372 1899
 	    	    $data['format_source'] = 'phpvmacars';
1373
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1900
+		    if (isset($value['name']) && $value['name'] != '') {
1901
+		    	$data['source_name'] = $value['name'];
1902
+		    }
1374 1903
 		    $SI->add($data);
1375 1904
 		    unset($data);
1376 1905
 		}
1377
-		if ($globalDebug) echo 'No more data...'."\n";
1906
+		if ($globalDebug) {
1907
+			echo 'No more data...'."\n";
1908
+		}
1378 1909
 		unset($buffer);
1379 1910
 		unset($all_data);
1380 1911
 	    }
@@ -1387,7 +1918,9 @@  discard block
 block discarded – undo
1387 1918
 	    )
1388 1919
 	) {
1389 1920
 	    //$buffer = $Common->getData($hosts[$id]);
1390
-	    if ($globalDebug) echo 'Get Data...'."\n";
1921
+	    if ($globalDebug) {
1922
+	    	echo 'Get Data...'."\n";
1923
+	    }
1391 1924
 	    $buffer = $Common->getData($value['host']);
1392 1925
 	    $all_data = json_decode($buffer,true);
1393 1926
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1398,10 +1931,16 @@  discard block
 block discarded – undo
1398 1931
 	    	    //$data['id'] = $line['id']; // id not usable
1399 1932
 	    	    $data['id'] = $line['id'];
1400 1933
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1401
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1402
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1934
+	    	    if (isset($line['user']['username'])) {
1935
+	    	    	$data['pilot_name'] = $line['user']['username'];
1936
+	    	    }
1937
+	    	    if (isset($line['user_id'])) {
1938
+	    	    	$data['pilot_id'] = $line['user_id'];
1939
+	    	    }
1403 1940
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1404
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1941
+	    	    if (is_numeric($data['ident'])) {
1942
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1943
+	    	    }
1405 1944
 	    	    $data['altitude'] = $line['altitude']; // altitude
1406 1945
 	    	    $data['speed'] = $line['groundspeed']; // speed
1407 1946
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1414,7 +1953,9 @@  discard block
 block discarded – undo
1414 1953
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1415 1954
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1416 1955
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1417
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1956
+	    	    } else {
1957
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1958
+	    	    }
1418 1959
 	    	    
1419 1960
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1420 1961
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1422,17 +1963,26 @@  discard block
 block discarded – undo
1422 1963
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1423 1964
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1424 1965
 
1425
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1426
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1966
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1967
+		    	$data['noarchive'] = true;
1968
+		    }
1969
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
1970
+		    	$data['waypoints'] = $line['bid']['route'];
1971
+		    }
1972
+		    // route
1427 1973
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1428 1974
 
1429 1975
     		    $data['id_source'] = $id_source;
1430 1976
 	    	    $data['format_source'] = 'vaos';
1431
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1977
+		    if (isset($value['name']) && $value['name'] != '') {
1978
+		    	$data['source_name'] = $value['name'];
1979
+		    }
1432 1980
 		    $SI->add($data);
1433 1981
 		    unset($data);
1434 1982
 		}
1435
-		if ($globalDebug) echo 'No more data...'."\n";
1983
+		if ($globalDebug) {
1984
+			echo 'No more data...'."\n";
1985
+		}
1436 1986
 		unset($buffer);
1437 1987
 		unset($all_data);
1438 1988
 	    }
@@ -1445,7 +1995,9 @@  discard block
 block discarded – undo
1445 1995
 	    )
1446 1996
 	) {
1447 1997
 	    //$buffer = $Common->getData($hosts[$id]);
1448
-	    if ($globalDebug) echo 'Get Data...'."\n";
1998
+	    if ($globalDebug) {
1999
+	    	echo 'Get Data...'."\n";
2000
+	    }
1449 2001
 	    $buffer = $Common->getData($value['host']);
1450 2002
 	    $all_data = json_decode($buffer,true);
1451 2003
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1474,16 +2026,25 @@  discard block
 block discarded – undo
1474 2026
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1475 2027
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1476 2028
     		    //$data['registration'] = $line['aircraft'];
1477
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2029
+		    if (isset($line['route'])) {
2030
+		    	$data['waypoints'] = $line['route'];
2031
+		    }
2032
+		    // route
1478 2033
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1479 2034
     		    $data['id_source'] = $id_source;
1480 2035
 	    	    $data['format_source'] = 'vam';
1481
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1482
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2036
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2037
+		    	$data['noarchive'] = true;
2038
+		    }
2039
+		    if (isset($value['name']) && $value['name'] != '') {
2040
+		    	$data['source_name'] = $value['name'];
2041
+		    }
1483 2042
 		    $SI->add($data);
1484 2043
 		    unset($data);
1485 2044
 		}
1486
-		if ($globalDebug) echo 'No more data...'."\n";
2045
+		if ($globalDebug) {
2046
+			echo 'No more data...'."\n";
2047
+		}
1487 2048
 		unset($buffer);
1488 2049
 		unset($all_data);
1489 2050
 	    }
@@ -1496,7 +2057,9 @@  discard block
 block discarded – undo
1496 2057
 	    )
1497 2058
 	) {
1498 2059
 	    //$buffer = $Common->getData($hosts[$id]);
1499
-	    if ($globalDebug) echo 'Get Data...'."\n";
2060
+	    if ($globalDebug) {
2061
+	    	echo 'Get Data...'."\n";
2062
+	    }
1500 2063
 	    $buffer = $Common->getData($value['host']);
1501 2064
 	    $all_data = json_decode($buffer,true);
1502 2065
 	    if ($buffer != '') {
@@ -1514,12 +2077,16 @@  discard block
 block discarded – undo
1514 2077
 			$data['id_source'] = $id_source;
1515 2078
 			$data['format_source'] = 'blitzortung';
1516 2079
 			$SI->add($data);
1517
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2080
+			if ($globalDebug) {
2081
+				echo '☈ Lightning added'."\n";
2082
+			}
1518 2083
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1519 2084
 			unset($data);
1520 2085
 		    }
1521 2086
 		}
1522
-		if ($globalDebug) echo 'No more data...'."\n";
2087
+		if ($globalDebug) {
2088
+			echo 'No more data...'."\n";
2089
+		}
1523 2090
 		unset($buffer);
1524 2091
 	    }
1525 2092
 	    $last_exec[$id]['last'] = time();
@@ -1531,7 +2098,9 @@  discard block
 block discarded – undo
1531 2098
 	    $write = NULL;
1532 2099
 	    $e = NULL;
1533 2100
 	    $n = socket_select($read, $write, $e, $timeout);
1534
-	    if ($e != NULL) var_dump($e);
2101
+	    if ($e != NULL) {
2102
+	    	var_dump($e);
2103
+	    }
1535 2104
 	    if ($n > 0) {
1536 2105
 		$reset = 0;
1537 2106
 		foreach ($read as $nb => $r) {
@@ -1553,13 +2122,17 @@  discard block
 block discarded – undo
1553 2122
 		    if ($buffer !== FALSE) {
1554 2123
 			if ($format === 'vrstcp') {
1555 2124
 			    $buffer = explode('},{',$buffer);
1556
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2125
+			} else {
2126
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2127
+			}
1557 2128
 		    }
1558 2129
 		    // SBS format is CSV format
1559 2130
 		    if ($buffer !== FALSE && $buffer !== '') {
1560 2131
 			$tt[$format] = 0;
1561 2132
 			if ($format === 'acarssbs3') {
1562
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2133
+			    if ($globalDebug) {
2134
+			    	echo 'ACARS : '.$buffer."\n";
2135
+			    }
1563 2136
 			    $ACARS->add(trim($buffer));
1564 2137
 			    $ACARS->deleteLiveAcarsData();
1565 2138
 			} elseif ($format === 'raw') {
@@ -1568,30 +2141,70 @@  discard block
 block discarded – undo
1568 2141
 			    if (is_array($data)) {
1569 2142
 				$data['datetime'] = date('Y-m-d H:i:s');
1570 2143
 				$data['format_source'] = 'raw';
1571
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1572
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1573
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1574
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2144
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2145
+					$data['source_name'] = $globalSources[$nb]['name'];
2146
+				}
2147
+				if (isset($globalSources[$nb]['sourcestats'])) {
2148
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2149
+				}
2150
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2151
+					$data['noarchive'] = true;
2152
+				}
2153
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2154
+					$SI->add($data);
2155
+				}
1575 2156
 			    }
1576 2157
 			} elseif ($format === 'ais') {
1577 2158
 			    $ais_data = $AIS->parse_line(trim($buffer));
1578 2159
 			    $data = array();
1579
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1580
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1581
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1582
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1583
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1584
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1585
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1586
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1587
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1588
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1589
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1590
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1591
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1592
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1593
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1594
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2160
+			    if (isset($ais_data['ident'])) {
2161
+			    	$data['ident'] = $ais_data['ident'];
2162
+			    }
2163
+			    if (isset($ais_data['mmsi'])) {
2164
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2165
+			    }
2166
+			    if (isset($ais_data['speed'])) {
2167
+			    	$data['speed'] = $ais_data['speed'];
2168
+			    }
2169
+			    if (isset($ais_data['heading'])) {
2170
+			    	$data['heading'] = $ais_data['heading'];
2171
+			    }
2172
+			    if (isset($ais_data['latitude'])) {
2173
+			    	$data['latitude'] = $ais_data['latitude'];
2174
+			    }
2175
+			    if (isset($ais_data['longitude'])) {
2176
+			    	$data['longitude'] = $ais_data['longitude'];
2177
+			    }
2178
+			    if (isset($ais_data['status'])) {
2179
+			    	$data['status'] = $ais_data['status'];
2180
+			    }
2181
+			    if (isset($ais_data['statusid'])) {
2182
+			    	$data['status_id'] = $ais_data['statusid'];
2183
+			    }
2184
+			    if (isset($ais_data['type'])) {
2185
+			    	$data['type'] = $ais_data['type'];
2186
+			    }
2187
+			    if (isset($ais_data['imo'])) {
2188
+			    	$data['imo'] = $ais_data['imo'];
2189
+			    }
2190
+			    if (isset($ais_data['callsign'])) {
2191
+			    	$data['callsign'] = $ais_data['callsign'];
2192
+			    }
2193
+			    if (isset($ais_data['destination'])) {
2194
+			    	$data['arrival_code'] = $ais_data['destination'];
2195
+			    }
2196
+			    if (isset($ais_data['eta_ts'])) {
2197
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2198
+			    }
2199
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2200
+			    	$data['noarchive'] = true;
2201
+			    }
2202
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2203
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2204
+			    }
2205
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2206
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2207
+			    }
1595 2208
 
1596 2209
 			    if (isset($ais_data['timestamp'])) {
1597 2210
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1600,7 +2213,9 @@  discard block
 block discarded – undo
1600 2213
 			    }
1601 2214
 			    $data['format_source'] = 'aisnmea';
1602 2215
     			    $data['id_source'] = $id_source;
1603
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2216
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2217
+			    	$MI->add($data);
2218
+			    }
1604 2219
 			    unset($data);
1605 2220
                         } elseif ($format === 'flightgearsp') {
1606 2221
                     	    //echo $buffer."\n";
@@ -1618,12 +2233,18 @@  discard block
 block discarded – undo
1618 2233
 				$data['speed'] = round($line[5]*1.94384);
1619 2234
 				$data['datetime'] = date('Y-m-d H:i:s');
1620 2235
 				$data['format_source'] = 'flightgearsp';
1621
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1622
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2236
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2237
+					$data['noarchive'] = true;
2238
+				}
2239
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2240
+					$SI->add($data);
2241
+				}
1623 2242
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1624 2243
 			    }
1625 2244
                         } elseif ($format === 'acars') {
1626
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2245
+                    	    if ($globalDebug) {
2246
+                    	    	echo 'ACARS : '.$buffer."\n";
2247
+                    	    }
1627 2248
 			    $ACARS->add(trim($buffer));
1628 2249
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1629 2250
 			    $ACARS->deleteLiveAcarsData();
@@ -1644,8 +2265,12 @@  discard block
 block discarded – undo
1644 2265
 				    $aircraft_type = $line[10];
1645 2266
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1646 2267
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1647
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1648
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2268
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2269
+				    	$data['noarchive'] = true;
2270
+				    }
2271
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2272
+				    	$SI->add($data);
2273
+				    }
1649 2274
 				}
1650 2275
 			    }
1651 2276
 			} elseif ($format === 'beast') {
@@ -1655,28 +2280,62 @@  discard block
 block discarded – undo
1655 2280
 			    foreach($buffer as $all_data) {
1656 2281
 				$line = json_decode('{'.$all_data.'}',true);
1657 2282
 				$data = array();
1658
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1659
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1660
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1661
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1662
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1663
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1664
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2283
+				if (isset($line['Icao'])) {
2284
+					$data['hex'] = $line['Icao'];
2285
+				}
2286
+				// hex
2287
+				if (isset($line['Call'])) {
2288
+					$data['ident'] = $line['Call'];
2289
+				}
2290
+				// ident
2291
+				if (isset($line['Alt'])) {
2292
+					$data['altitude'] = $line['Alt'];
2293
+				}
2294
+				// altitude
2295
+				if (isset($line['Spd'])) {
2296
+					$data['speed'] = $line['Spd'];
2297
+				}
2298
+				// speed
2299
+				if (isset($line['Trak'])) {
2300
+					$data['heading'] = $line['Trak'];
2301
+				}
2302
+				// heading
2303
+				if (isset($line['Lat'])) {
2304
+					$data['latitude'] = $line['Lat'];
2305
+				}
2306
+				// lat
2307
+				if (isset($line['Long'])) {
2308
+					$data['longitude'] = $line['Long'];
2309
+				}
2310
+				// long
1665 2311
 				//$data['verticalrate'] = $line['']; // verticale rate
1666
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2312
+				if (isset($line['Sqk'])) {
2313
+					$data['squawk'] = $line['Sqk'];
2314
+				}
2315
+				// squawk
1667 2316
 				$data['emergency'] = ''; // emergency
1668
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2317
+				if (isset($line['Reg'])) {
2318
+					$data['registration'] = $line['Reg'];
2319
+				}
1669 2320
 				/*
1670 2321
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1671 2322
 				else $data['datetime'] = date('Y-m-d H:i:s');
1672 2323
 				*/
1673 2324
 				$data['datetime'] = date('Y-m-d H:i:s');
1674
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2325
+				if (isset($line['Type'])) {
2326
+					$data['aircraft_icao'] = $line['Type'];
2327
+				}
1675 2328
 		    		$data['format_source'] = 'vrstcp';
1676 2329
 				$data['id_source'] = $id_source;
1677
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1678
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1679
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2330
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2331
+					$data['noarchive'] = true;
2332
+				}
2333
+				if (isset($value['name']) && $value['name'] != '') {
2334
+					$data['source_name'] = $value['name'];
2335
+				}
2336
+				if (isset($data['latitude']) && isset($data['hex'])) {
2337
+					$SI->add($data);
2338
+				}
1680 2339
 				unset($data);
1681 2340
 			    }
1682 2341
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1689,22 +2348,46 @@  discard block
 block discarded – undo
1689 2348
     				$data['hex'] = $lined['hexid'];
1690 2349
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1691 2350
     				$data['datetime'] = date('Y-m-d H:i:s');;
1692
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1693
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1694
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1695
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1696
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1697
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1698
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2351
+    				if (isset($lined['ident'])) {
2352
+    					$data['ident'] = $lined['ident'];
2353
+    				}
2354
+    				if (isset($lined['lat'])) {
2355
+    					$data['latitude'] = $lined['lat'];
2356
+    				}
2357
+    				if (isset($lined['lon'])) {
2358
+    					$data['longitude'] = $lined['lon'];
2359
+    				}
2360
+    				if (isset($lined['speed'])) {
2361
+    					$data['speed'] = $lined['speed'];
2362
+    				}
2363
+    				if (isset($lined['squawk'])) {
2364
+    					$data['squawk'] = $lined['squawk'];
2365
+    				}
2366
+    				if (isset($lined['alt'])) {
2367
+    					$data['altitude'] = $lined['alt'];
2368
+    				}
2369
+    				if (isset($lined['heading'])) {
2370
+    					$data['heading'] = $lined['heading'];
2371
+    				}
1699 2372
     				$data['id_source'] = $id_source;
1700 2373
     				$data['format_source'] = 'tsv';
1701
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1702
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1703
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1704
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2374
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2375
+    					$data['source_name'] = $globalSources[$nb]['name'];
2376
+    				}
2377
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2378
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2379
+    				}
2380
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2381
+					$data['noarchive'] = true;
2382
+				}
2383
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2384
+    					$SI->add($data);
2385
+    				}
1705 2386
     				unset($lined);
1706 2387
     				unset($data);
1707
-    			    } else $error = true;
2388
+    			    } else {
2389
+    			    	$error = true;
2390
+    			    }
1708 2391
 			} elseif ($format === 'aprs' && $use_aprs) {
1709 2392
 			    if ($aprs_connect === 0) {
1710 2393
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1730,47 +2413,96 @@  discard block
 block discarded – undo
1730 2413
 				    $aprs_last_tx = time();
1731 2414
 				    $data = array();
1732 2415
 				    //print_r($line);
1733
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1734
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1735
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1736
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1737
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1738
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1739
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1740
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1741
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1742
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2416
+				    if (isset($line['address'])) {
2417
+				    	$data['hex'] = $line['address'];
2418
+				    }
2419
+				    if (isset($line['mmsi'])) {
2420
+				    	$data['mmsi'] = $line['mmsi'];
2421
+				    }
2422
+				    if (isset($line['imo'])) {
2423
+				    	$data['imo'] = $line['imo'];
2424
+				    }
2425
+				    if (isset($line['squawk'])) {
2426
+				    	$data['squawk'] = $line['squawk'];
2427
+				    }
2428
+				    if (isset($line['arrival_code'])) {
2429
+				    	$data['arrival_code'] = $line['arrival_code'];
2430
+				    }
2431
+				    if (isset($line['arrival_date'])) {
2432
+				    	$data['arrival_date'] = $line['arrival_date'];
2433
+				    }
2434
+				    if (isset($line['typeid'])) {
2435
+				    	$data['type_id'] = $line['typeid'];
2436
+				    }
2437
+				    if (isset($line['statusid'])) {
2438
+				    	$data['status_id'] = $line['statusid'];
2439
+				    }
2440
+				    if (isset($line['timestamp'])) {
2441
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2442
+				    } else {
2443
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2444
+				    }
1743 2445
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1744
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2446
+				    if (isset($line['ident'])) {
2447
+				    	$data['ident'] = $line['ident'];
2448
+				    }
1745 2449
 				    $data['latitude'] = $line['latitude'];
1746 2450
 				    $data['longitude'] = $line['longitude'];
1747 2451
 				    //$data['verticalrate'] = $line[16];
1748
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2452
+				    if (isset($line['speed'])) {
2453
+				    	$data['speed'] = $line['speed'];
2454
+				    }
1749 2455
 				    //else $data['speed'] = 0;
1750
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1751
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1752
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2456
+				    if (isset($line['altitude'])) {
2457
+				    	$data['altitude'] = $line['altitude'];
2458
+				    }
2459
+				    if (isset($line['comment'])) {
2460
+				    	$data['comment'] = $line['comment'];
2461
+				    }
2462
+				    if (isset($line['symbol'])) {
2463
+				    	$data['type'] = $line['symbol'];
2464
+				    }
1753 2465
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1754 2466
 				    
1755
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2467
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2468
+				    	$data['heading'] = $line['heading'];
2469
+				    }
1756 2470
 				    //else echo 'No heading...'."\n";
1757 2471
 				    //else $data['heading'] = 0;
1758
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2472
+				    if (isset($line['stealth'])) {
2473
+				    	$data['aircraft_type'] = $line['stealth'];
2474
+				    }
1759 2475
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1760
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1761
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1762
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1763
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2476
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2477
+				    	$data['noarchive'] = true;
2478
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2479
+				    	$data['noarchive'] = false;
2480
+				    }
2481
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2482
+				    	$data['noarchive'] = true;
2483
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2484
+				    	$data['noarchive'] = false;
2485
+				    }
1764 2486
     				    $data['id_source'] = $id_source;
1765
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1766
-				    else $data['format_source'] = 'aprs';
2487
+    				    if (isset($line['format_source'])) {
2488
+    				    	$data['format_source'] = $line['format_source'];
2489
+    				    } else {
2490
+				    	$data['format_source'] = 'aprs';
2491
+				    }
1767 2492
 				    $data['source_name'] = $line['source'];
1768
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1769
-				    else $data['source_type'] = 'flarm';
1770
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2493
+				    if (isset($line['source_type'])) {
2494
+				    	$data['source_type'] = $line['source_type'];
2495
+				    } else {
2496
+				    	$data['source_type'] = 'flarm';
2497
+				    }
2498
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2499
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2500
+    				    }
1771 2501
 				    $currentdate = date('Y-m-d H:i:s');
1772 2502
 				    $aprsdate = strtotime($data['datetime']);
1773
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2503
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2504
+				    	$data['altitude_relative'] = 'AMSL';
2505
+				    }
1774 2506
 				    // Accept data if time <= system time + 20s
1775 2507
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1776 2508
 				    if (
@@ -1782,7 +2514,9 @@  discard block
 block discarded – undo
1782 2514
 					$send = $SI->add($data);
1783 2515
 				    } elseif ($data['source_type'] === 'ais') {
1784 2516
 					$data['type'] = '';
1785
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2517
+					if (isset($globalMarine) && $globalMarine) {
2518
+						$send = $MI->add($data);
2519
+					}
1786 2520
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1787 2521
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1788 2522
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1790,8 +2524,12 @@  discard block
 block discarded – undo
1790 2524
 					    $line['symbol'] === 'Glider' || 
1791 2525
 					    $line['symbol'] === 'No. Plane' || 
1792 2526
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1793
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1794
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2527
+					    if ($line['symbol'] === 'Ballon') {
2528
+					    	$data['aircraft_icao'] = 'BALL';
2529
+					    }
2530
+					    if ($line['symbol'] === 'Glider') {
2531
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2532
+					    }
1795 2533
 					    $send = $SI->add($data);
1796 2534
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1797 2535
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1822,9 +2560,13 @@  discard block
 block discarded – undo
1822 2560
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1823 2561
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1824 2562
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1825
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2563
+					if (isset($globalTracker) && $globalTracker) {
2564
+						$send = $TI->add($data);
2565
+					}
1826 2566
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1827
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2567
+					if (!isset($data['altitude'])) {
2568
+						$data['altitude'] = 0;
2569
+					}
1828 2570
 					$Source->deleteOldLocationByType('gs');
1829 2571
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1830 2572
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1833,7 +2575,9 @@  discard block
 block discarded – undo
1833 2575
 					}
1834 2576
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1835 2577
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1836
-					if ($globalDebug) echo '# Weather Station added'."\n";
2578
+					if ($globalDebug) {
2579
+						echo '# Weather Station added'."\n";
2580
+					}
1837 2581
 					$Source->deleteOldLocationByType('wx');
1838 2582
 					$weather_data = json_encode($line);
1839 2583
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1843,7 +2587,9 @@  discard block
 block discarded – undo
1843 2587
 					}
1844 2588
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1845 2589
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1846
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2590
+					if ($globalDebug) {
2591
+						echo '☈ Lightning added'."\n";
2592
+					}
1847 2593
 					$Source->deleteOldLocationByType('lightning');
1848 2594
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1849 2595
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1855,8 +2601,7 @@  discard block
 block discarded – undo
1855 2601
 				    	print_r($line);
1856 2602
 				    }
1857 2603
 				    unset($data);
1858
-				}
1859
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2604
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1860 2605
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1861 2606
 				}
1862 2607
 				/*
@@ -1865,7 +2610,9 @@  discard block
 block discarded – undo
1865 2610
 				}
1866 2611
 				*/
1867 2612
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1868
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2613
+				elseif ($line === true && $globalDebug) {
2614
+					echo '!! Failed : '.$buffer."!!\n";
2615
+				}
1869 2616
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1870 2617
 					$Source->deleteOldLocationByType('lightning');
1871 2618
 					$Source->deleteOldLocationByType('wx');
@@ -1901,27 +2648,47 @@  discard block
 block discarded – undo
1901 2648
     				$data['ground'] = $line[21];
1902 2649
     				$data['emergency'] = $line[19];
1903 2650
     				$data['format_source'] = 'sbs';
1904
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1905
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1906
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1907
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2651
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2652
+					$data['source_name'] = $globalSources[$nb]['name'];
2653
+				} elseif ($line[0] == 'MLAT') {
2654
+					$data['source_name'] = 'MLAT';
2655
+				}
2656
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2657
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2658
+    				}
2659
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2660
+					$data['noarchive'] = true;
2661
+				}
1908 2662
     				$data['id_source'] = $id_source;
1909
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1910
-    				else $error = true;
2663
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2664
+    					$send = $SI->add($data);
2665
+    				} else {
2666
+    					$error = true;
2667
+    				}
1911 2668
     				unset($data);
1912
-    			    } else $error = true;
2669
+    			    } else {
2670
+    			    	$error = true;
2671
+    			    }
1913 2672
 			    if ($error) {
1914 2673
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1915
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2674
+					if ($globalDebug) {
2675
+						echo "Not a message. Ignoring... \n";
2676
+					}
1916 2677
 				} else {
1917
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2678
+					if ($globalDebug) {
2679
+						echo "Wrong line format. Ignoring... \n";
2680
+					}
1918 2681
 					if ($globalDebug) {
1919 2682
 						echo $buffer;
1920 2683
 						//print_r($line);
1921 2684
 					}
1922 2685
 					//socket_close($r);
1923
-					if ($globalDebug) echo "Reconnect after an error...\n";
1924
-					if ($format === 'aprs') $aprs_connect = 0;
2686
+					if ($globalDebug) {
2687
+						echo "Reconnect after an error...\n";
2688
+					}
2689
+					if ($format === 'aprs') {
2690
+						$aprs_connect = 0;
2691
+					}
1925 2692
 					$sourceer[$nb] = $globalSources[$nb];
1926 2693
 					connect_all($sourceer);
1927 2694
 					$sourceer = array();
@@ -1929,10 +2696,14 @@  discard block
 block discarded – undo
1929 2696
 			    }
1930 2697
 			}
1931 2698
 			// Sleep for xxx microseconds
1932
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2699
+			if (isset($globalSBSSleep)) {
2700
+				usleep($globalSBSSleep);
2701
+			}
1933 2702
 		    } else {
1934 2703
 			if ($format === 'flightgearmp') {
1935
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2704
+			    	if ($globalDebug) {
2705
+			    		echo "Reconnect FlightGear MP...";
2706
+			    	}
1936 2707
 				//@socket_close($r);
1937 2708
 				sleep($globalMinFetch);
1938 2709
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1941,10 +2712,15 @@  discard block
 block discarded – undo
1941 2712
 				break;
1942 2713
 				
1943 2714
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1944
-			    if (isset($tt[$format])) $tt[$format]++;
1945
-			    else $tt[$format] = 0;
2715
+			    if (isset($tt[$format])) {
2716
+			    	$tt[$format]++;
2717
+			    } else {
2718
+			    	$tt[$format] = 0;
2719
+			    }
1946 2720
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
1947
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2721
+				if ($globalDebug) {
2722
+					echo "ERROR : Reconnect ".$format."...";
2723
+				}
1948 2724
 				//@socket_close($r);
1949 2725
 				sleep(2);
1950 2726
 				$aprs_connect = 0;
@@ -1962,11 +2738,17 @@  discard block
 block discarded – undo
1962 2738
 	    } else {
1963 2739
 		$error = socket_strerror(socket_last_error());
1964 2740
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1965
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1966
-			if (isset($globalDebug)) echo "Restarting...\n";
2741
+			if ($globalDebug) {
2742
+				echo "ERROR : socket_select give this error ".$error . "\n";
2743
+			}
2744
+			if (isset($globalDebug)) {
2745
+				echo "Restarting...\n";
2746
+			}
1967 2747
 			// Restart the script if possible
1968 2748
 			if (is_array($sockets)) {
1969
-			    if ($globalDebug) echo "Shutdown all sockets...";
2749
+			    if ($globalDebug) {
2750
+			    	echo "Shutdown all sockets...";
2751
+			    }
1970 2752
 			    
1971 2753
 			    foreach ($sockets as $sock) {
1972 2754
 				@socket_shutdown($sock,2);
@@ -1974,25 +2756,45 @@  discard block
 block discarded – undo
1974 2756
 			    }
1975 2757
 			    
1976 2758
 			}
1977
-			if ($globalDebug) echo "Waiting...";
2759
+			if ($globalDebug) {
2760
+				echo "Waiting...";
2761
+			}
1978 2762
 			sleep(2);
1979 2763
 			$time = time();
1980 2764
 			//connect_all($hosts);
1981 2765
 			$aprs_connect = 0;
1982
-			if ($reset%5 === 0) sleep(20);
1983
-			if ($reset%10 === 0) sleep(100);
1984
-			if ($reset%20 === 0) sleep(200);
1985
-			if ($reset > 100) exit('Too many attempts...');
1986
-			if ($globalDebug) echo "Restart all connections...";
2766
+			if ($reset%5 === 0) {
2767
+				sleep(20);
2768
+			}
2769
+			if ($reset%10 === 0) {
2770
+				sleep(100);
2771
+			}
2772
+			if ($reset%20 === 0) {
2773
+				sleep(200);
2774
+			}
2775
+			if ($reset > 100) {
2776
+				exit('Too many attempts...');
2777
+			}
2778
+			if ($globalDebug) {
2779
+				echo "Restart all connections...";
2780
+			}
1987 2781
 			connect_all($globalSources);
1988 2782
 		}
1989 2783
 	    }
1990 2784
 	}
1991 2785
 	if ($globalDaemon === false) {
1992
-	    if ($globalDebug) echo 'Check all...'."\n";
1993
-	    if (isset($SI)) $SI->checkAll();
1994
-	    if (isset($TI)) $TI->checkAll();
1995
-	    if (isset($MI)) $MI->checkAll();
2786
+	    if ($globalDebug) {
2787
+	    	echo 'Check all...'."\n";
2788
+	    }
2789
+	    if (isset($SI)) {
2790
+	    	$SI->checkAll();
2791
+	    }
2792
+	    if (isset($TI)) {
2793
+	    	$TI->checkAll();
2794
+	    }
2795
+	    if (isset($MI)) {
2796
+	    	$MI->checkAll();
2797
+	    }
1996 2798
 	}
1997 2799
     }
1998 2800
 }
Please login to merge, or discard this patch.
require/class.MarineImport.php 2 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,57 +46,57 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
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";
58
-	    foreach ($this->all_tracked as $key => $flight) {
57
+		if ($globalDebug) echo "Update last seen tracked data...\n";
58
+		foreach ($this->all_tracked as $key => $flight) {
59 59
 		if (isset($this->all_tracked[$key]['id'])) {
60
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
-    		    $Marine = new Marine($this->db);
62
-    		    $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']);
60
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
+				$Marine = new Marine($this->db);
62
+				$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']);
63
+		}
63 64
 		}
64
-	    }
65 65
 	}
66
-    }
66
+	}
67 67
 
68
-    public function del() {
68
+	public function del() {
69 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 70
 	// Delete old infos
71 71
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
72 72
 	foreach ($this->all_tracked as $key => $flight) {
73
-    	    if (isset($flight['lastupdate'])) {
74
-        	if ($flight['lastupdate'] < (time()-3000)) {
75
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
-            		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
-			    /*
73
+			if (isset($flight['lastupdate'])) {
74
+			if ($flight['lastupdate'] < (time()-3000)) {
75
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
+					if (isset($this->all_tracked[$key]['id'])) {
77
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
+				/*
79 79
 			    $MarineLive = new MarineLive();
80 80
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
81 81
 			    $MarineLive->db = null;
82 82
 			    */
83
-            		    //$real_arrival = $this->arrival($key);
84
-            		    $Marine = new Marine($this->db);
85
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83
+						//$real_arrival = $this->arrival($key);
84
+						$Marine = new Marine($this->db);
85
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 86
 				$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 87
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
88
-			    }
89
-			    // Put in archive
88
+				}
89
+				// Put in archive
90 90
 //				$Marine->db = null;
91 91
 			}
92
-            	    }
93
-            	    unset($this->all_tracked[$key]);
94
-    	        }
95
-	    }
96
-        }
97
-    }
92
+					}
93
+					unset($this->all_tracked[$key]);
94
+				}
95
+		}
96
+		}
97
+	}
98 98
 
99
-    public function add($line) {
99
+	public function add($line) {
100 100
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
101 101
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
102 102
 	date_default_timezone_set('UTC');
@@ -105,104 +105,104 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	// SBS format is CSV format
107 107
 	if(is_array($line) && (isset($line['mmsi']) || isset($line['id']))) {
108
-	    //print_r($line);
109
-  	    if (isset($line['mmsi']) || isset($line['id'])) {
108
+		//print_r($line);
109
+  		if (isset($line['mmsi']) || isset($line['id'])) {
110 110
 
111 111
 		
112 112
 		// Increment message number
113 113
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114
-		    $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'];
118
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
114
+			$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'];
118
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
119
+				$this->stats[$current_date][$source]['msg']['date'] = time();
120
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
122 122
 		}
123 123
 		
124 124
 		
125 125
 		$Common = new Common();
126 126
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
127
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
128
+			else $id = trim($line['id']);
129 129
 		
130 130
 		if (!isset($this->all_tracked[$id])) {
131
-		    $this->all_tracked[$id] = array();
132
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => ''));
134
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
-		    if (!isset($line['id'])) {
131
+			$this->all_tracked[$id] = array();
132
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => ''));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
+			if (!isset($line['id'])) {
136 136
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
137 137
 			$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;
138
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
+			if ($globalAllTracked !== FALSE) $dataFound = true;
140 140
 		}
141 141
 		
142 142
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
145 145
 			$Marine = new Marine($this->db);
146 146
 			$identity = $Marine->getIdentity($line['mmsi']);
147 147
 			if (!empty($identity)) {
148
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
-			    $this->all_tracked[$id]['type'] = $identity['type'];
150
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
148
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
+				$this->all_tracked[$id]['type'] = $identity['type'];
150
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
151 151
 			}
152 152
 			//print_r($identity);
153 153
 			unset($Marine);
154 154
 			//$dataFound = true;
155
-		    }
155
+			}
156 156
 		}
157 157
 		if (isset($line['type_id'])) {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
160 160
 		}
161 161
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
164 164
 		}
165 165
 		if (isset($line['status']) && $line['status'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
167 167
 		}
168 168
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
169
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
171 171
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
172
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
173 173
 				$Marine = new Marine($this->db);
174 174
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
175 175
 				unset($Marine);
176
-			    }
176
+				}
177
+			}
177 178
 			}
178
-		    }
179 179
 		}
180 180
 
181 181
 
182 182
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
183
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
183
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
184 184
 		}
185 185
 		if (isset($line['imo']) && $line['imo'] != '') {
186
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
186
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
187 187
 		}
188 188
 		if (isset($line['callsign']) && $line['callsign'] != '') {
189
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
189
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
190 190
 		}
191 191
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
192
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
192
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
193 193
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
194 194
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
195 195
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
196
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
197 197
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
198
-				    $Marine = new Marine($this->db);
199
-				    $fromsource = NULL;
200
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
-				    $Marine->db = null;
198
+					$Marine = new Marine($this->db);
199
+					$fromsource = NULL;
200
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
+					$Marine->db = null;
202
+				}
202 203
 				}
203
-			    }
204 204
 			}
205
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
205
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
206 206
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
207 207
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
208 208
 			if (!isset($line['id'])) {
@@ -210,38 +210,38 @@  discard block
 block discarded – undo
210 210
 				$this->all_tracked[$id]['forcenew'] = 1;
211 211
 				$this->all_tracked[$id]['addedMarine'] = 0;
212 212
 			}
213
-		    }
213
+			}
214 214
 		}
215 215
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
216
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
216
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
217 217
 		}
218 218
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
219
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
219
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
220 220
 		}
221 221
 		if (isset($line['captain_name']) && $line['captain_name'] != '') {
222
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
222
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_name' => $line['captain_name']));
223 223
 		}
224 224
 		if (isset($line['race_id']) && $line['race_id'] != '') {
225
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
225
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_id' => $line['race_id']));
226 226
 		}
227 227
 		if (isset($line['race_name']) && $line['race_name'] != '') {
228
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
228
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('race_name' => $line['race_name']));
229 229
 		}
230 230
 
231 231
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
232 232
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
233
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
233
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
234 234
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
235
-			    $timeelapsed = microtime(true);
236
-			    $Marine = new Marine($this->db);
237
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
238
-			    $Marine->db = null;
235
+				$timeelapsed = microtime(true);
236
+				$Marine = new Marine($this->db);
237
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
238
+				$Marine->db = null;
239
+			}
239 240
 			}
240
-		    }
241
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
242
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
241
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
242
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
243 243
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
244
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
244
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
245 245
 				$timeelapsed = microtime(true);
246 246
 				$Marine = new Marine($this->db);
247 247
 				$fromsource = NULL;
@@ -249,20 +249,20 @@  discard block
 block discarded – undo
249 249
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
250 250
 				$Marine->db = null;
251 251
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
252
-			    }
252
+				}
253
+			}
253 254
 			}
254
-		    }
255
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
255
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
256 256
 		}
257 257
 
258 258
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
259
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
259
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
260 260
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
261
-		    } else {
261
+			} else {
262 262
 				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";
263 263
 				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";
264 264
 				return '';
265
-		    }
265
+			}
266 266
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
267 267
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
268 268
 			return '';
@@ -279,24 +279,24 @@  discard block
 block discarded – undo
279 279
 
280 280
 
281 281
 		if (isset($line['speed'])) {
282
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
283
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
282
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
283
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
284 284
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
285
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
286
-		    if ($distance > 1000 && $distance < 10000) {
285
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
286
+			if ($distance > 1000 && $distance < 10000) {
287 287
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
288 288
 			$speed = $speed*3.6;
289 289
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
290 290
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
291
-		    }
291
+			}
292 292
 		}
293 293
 
294
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
295
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
296
-	    	    else unset($timediff);
297
-	    	    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')))) {
294
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
295
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
296
+				else unset($timediff);
297
+				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')))) {
298 298
 			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'])) {
299
-			    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'])) {
299
+				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'])) {
300 300
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
301 301
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
302 302
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -304,192 +304,192 @@  discard block
 block discarded – undo
304 304
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
305 305
 				$timeelapsed = microtime(true);
306 306
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
307
-				    $Marine = new Marine($this->db);
308
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
309
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
310
-				    $Marine->db = null;
311
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
307
+					$Marine = new Marine($this->db);
308
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
309
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
310
+					$Marine->db = null;
311
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
312 312
 				}
313 313
 				$this->tmd = 0;
314 314
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
315
-			    }
315
+				}
316 316
 			}
317 317
 
318 318
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
319 319
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
320 320
 				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') {
321
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
322
-				    $dataFound = true;
323
-				    $this->all_tracked[$id]['time_last_coord'] = time();
321
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
322
+					$dataFound = true;
323
+					$this->all_tracked[$id]['time_last_coord'] = time();
324 324
 				}
325 325
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
326 326
 			}
327 327
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
328
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
328
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
329 329
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
330 330
 				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') {
331
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
332
-				    $dataFound = true;
333
-				    $this->all_tracked[$id]['time_last_coord'] = time();
331
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
332
+					$dataFound = true;
333
+					$this->all_tracked[$id]['time_last_coord'] = time();
334 334
 				}
335 335
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
336 336
 			}
337 337
 
338
-		    } else if ($globalDebug && $timediff > 20) {
338
+			} else if ($globalDebug && $timediff > 20) {
339 339
 			$this->tmd = $this->tmd + 1;
340 340
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
341 341
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
342 342
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
343 343
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
344
-		    }
344
+			}
345 345
 		}
346 346
 		if (isset($line['last_update']) && $line['last_update'] != '') {
347
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
348
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
347
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
348
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
349 349
 		}
350 350
 		if (isset($line['format_source']) && $line['format_source'] != '') {
351
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
351
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
352 352
 		}
353 353
 		if (isset($line['source_name']) && $line['source_name'] != '') {
354
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
354
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
355 355
 		}
356 356
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
357
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
357
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
358 358
 		}
359 359
 		
360 360
 		if (isset($line['heading']) && $line['heading'] != '') {
361
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
362
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
363
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
364
-		    //$dataFound = true;
361
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
362
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
363
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
364
+			//$dataFound = true;
365 365
   		} 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']) {
366
-  		    $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']);
367
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
368
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
369
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
366
+  			$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']);
367
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
368
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
369
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
370 370
   		}
371 371
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
372 372
 
373 373
 
374 374
 
375 375
 		if ($dataFound === true && (isset($this->all_tracked[$id]['mmsi']) || isset($this->all_tracked[$id]['id']))) {
376
-		    $this->all_tracked[$id]['lastupdate'] = time();
377
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
378
-		        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'])) {
379
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
376
+			$this->all_tracked[$id]['lastupdate'] = time();
377
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
378
+				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'])) {
379
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
380 380
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
381
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
382
-				    $timeelapsed = microtime(true);
383
-				    $MarineLive = new MarineLive($this->db);
384
-				    if (isset($line['id'])) {
381
+					if ($globalDebug) echo "Check if vessel is already in DB...";
382
+					$timeelapsed = microtime(true);
383
+					$MarineLive = new MarineLive($this->db);
384
+					if (isset($line['id'])) {
385 385
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
386 386
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
387
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
387
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
388 388
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
389 389
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
390
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
390
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
391 391
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
392 392
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
393
-				    } else $recent_ident = '';
394
-				    $MarineLive->db=null;
395
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
396
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
393
+					} else $recent_ident = '';
394
+					$MarineLive->db=null;
395
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
396
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
397 397
 				} else $recent_ident = '';
398
-			    } else {
398
+				} else {
399 399
 				$recent_ident = '';
400 400
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
401
-			    }
402
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
403
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
404
-			    {
401
+				}
402
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
403
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
404
+				{
405 405
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
406 406
 				//adds the spotter data for the archive
407
-				    $highlight = '';
408
-				    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')));
409
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
407
+					$highlight = '';
408
+					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')));
409
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
410 410
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
411
-					    $timeelapsed = microtime(true);
412
-					    $Marine = new Marine($this->db);
413
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
414
-					    $Marine->db = null;
415
-					    if ($globalDebug && isset($result)) echo $result."\n";
416
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
411
+						$timeelapsed = microtime(true);
412
+						$Marine = new Marine($this->db);
413
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
414
+						$Marine->db = null;
415
+						if ($globalDebug && isset($result)) echo $result."\n";
416
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
417
+					}
417 418
 					}
418
-				    }
419
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
419
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
420 420
 					// Add source stat in DB
421 421
 					$Stats = new Stats($this->db);
422 422
 					if (!empty($this->stats)) {
423
-					    if ($globalDebug) echo 'Add source stats : ';
424
-				    	    foreach($this->stats as $date => $data) {
423
+						if ($globalDebug) echo 'Add source stats : ';
424
+							foreach($this->stats as $date => $data) {
425 425
 						foreach($data as $source => $sourced) {
426
-					    	    //print_r($sourced);
427
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
428
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
429
-				    		    if (isset($sourced['msg'])) {
430
-				    			if (time() - $sourced['msg']['date'] > 10) {
431
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
432
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
433
-			    			    	    unset($this->stats[$date][$source]['msg']);
434
-			    				}
435
-			    			    }
436
-			    			}
437
-			    			if ($date != date('Y-m-d')) {
438
-			    			    unset($this->stats[$date]);
439
-			    			}
440
-				    	    }
441
-				    	    if ($globalDebug) echo 'Done'."\n";
426
+								//print_r($sourced);
427
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
428
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
429
+								if (isset($sourced['msg'])) {
430
+								if (time() - $sourced['msg']['date'] > 10) {
431
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
432
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
433
+										unset($this->stats[$date][$source]['msg']);
434
+								}
435
+								}
436
+							}
437
+							if ($date != date('Y-m-d')) {
438
+								unset($this->stats[$date]);
439
+							}
440
+							}
441
+							if ($globalDebug) echo 'Done'."\n";
442 442
 					}
443 443
 					$Stats->db = null;
444
-				    }
444
+					}
445 445
 				    
446
-				    $this->del();
446
+					$this->del();
447 447
 				//$ignoreImport = false;
448 448
 				$this->all_tracked[$id]['addedMarine'] = 1;
449 449
 				//print_r($this->all_tracked[$id]);
450 450
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
451
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
452
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
453
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
451
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
452
+					//MarineLive->deleteLiveMarineDataNotUpdated();
453
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
454 454
 					$MarineLive = new MarineLive($this->db);
455 455
 					$MarineLive->deleteLiveMarineData();
456 456
 					$MarineLive->db=null;
457 457
 					if ($globalDebug) echo " Done\n";
458
-				    }
459
-				    $this->last_delete = time();
458
+					}
459
+					$this->last_delete = time();
460 460
 				}
461
-			    } elseif ($recent_ident != '') {
461
+				} elseif ($recent_ident != '') {
462 462
 				$this->all_tracked[$id]['id'] = $recent_ident;
463 463
 				$this->all_tracked[$id]['addedMarine'] = 1;
464 464
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
465
-				    if (isset($globalDaemon) && !$globalDaemon) {
465
+					if (isset($globalDaemon) && !$globalDaemon) {
466 466
 					$Marine = new Marine($this->db);
467 467
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
468 468
 					$Marine->db = null;
469
-				    }
469
+					}
470 470
 				}
471 471
 				
472
-			    }
472
+				}
473 473
 			}
474
-		    }
475
-		    //adds the spotter LIVE data
476
-		    if ($globalDebug) {
474
+			}
475
+			//adds the spotter LIVE data
476
+			if ($globalDebug) {
477 477
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
478
-		    }
479
-		    $ignoreImport = false;
478
+			}
479
+			$ignoreImport = false;
480 480
 
481
-		    if (!$ignoreImport) {
481
+			if (!$ignoreImport) {
482 482
 			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'])) {
483 483
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
484 484
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
485
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
485
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
486 486
 					$timeelapsed = microtime(true);
487 487
 					$MarineLive = new MarineLive($this->db);
488 488
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
489 489
 					$MarineLive->db = null;
490 490
 					if ($globalDebug) echo $result."\n";
491 491
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
492
-				    }
492
+					}
493 493
 				}
494 494
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
495 495
 					$APRSMarine->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']);
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 					if ($stats_heading == 16) $stats_heading = 0;
525 525
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
526 526
 						for ($i=0;$i<=15;$i++) {
527
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
527
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
528 528
 						}
529 529
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
530 530
 					} else {
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
 					//var_dump($this->stats);
538 538
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
539 539
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
540
-						    end($this->stats[$current_date][$source]['hist']);
541
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
540
+							end($this->stats[$current_date][$source]['hist']);
541
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
542 542
 						} else $mini = 0;
543 543
 						for ($i=$mini;$i<=$distance;$i+=10) {
544
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
544
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
545 545
 						}
546 546
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
547 547
 					} else {
@@ -557,24 +557,24 @@  discard block
 block discarded – undo
557 557
 			
558 558
 			
559 559
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
560
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
560
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
561 561
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
562 562
 				$MarineLive = new MarineLive($this->db);
563 563
 				$MarineLive->deleteLiveMarineDataNotUpdated();
564 564
 				$MarineLive->db = null;
565 565
 				//MarineLive->deleteLiveMarineData();
566 566
 				if ($globalDebug) echo " Done\n";
567
-			    }
568
-			    $this->last_delete_hourly = time();
567
+				}
568
+				$this->last_delete_hourly = time();
569 569
 			}
570 570
 			
571
-		    }
572
-		    //$ignoreImport = false;
571
+			}
572
+			//$ignoreImport = false;
573 573
 		}
574 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
575 575
 		if ($send) return $this->all_tracked[$id];
576
-	    }
576
+		}
577
+	}
577 578
 	}
578
-    }
579 579
 }
580 580
 ?>
Please login to merge, or discard this patch.
Braces   +202 added lines, -69 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' => '','captain_id' => '','captain_name' => '','race_id' => '','race_name' => ''));
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']) {
@@ -191,7 +217,9 @@  discard block
 block discarded – undo
191 217
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
192 218
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
193 219
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
194
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
220
+			if ($globalDebug) {
221
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
222
+			}
195 223
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
196 224
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
197 225
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -204,7 +232,9 @@  discard block
 block discarded – undo
204 232
 			}
205 233
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
206 234
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
207
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
235
+			if ($globalDebug) {
236
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
237
+			}
208 238
 			if (!isset($line['id'])) {
209 239
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
210 240
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -213,7 +243,9 @@  discard block
 block discarded – undo
213 243
 		    }
214 244
 		}
215 245
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
216
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
246
+		    if (strtotime($line['arrival_date']) > time()) {
247
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
248
+		    }
217 249
 		}
218 250
 		if (isset($line['captain_id']) && $line['captain_id'] != '') {
219 251
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('captain_id' => $line['captain_id']));
@@ -246,34 +278,49 @@  discard block
 block discarded – undo
246 278
 				$Marine = new Marine($this->db);
247 279
 				$fromsource = NULL;
248 280
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
249
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
281
+				if ($globalDebug && $result != 'success') {
282
+					echo '!!! ERROR : '.$result."\n";
283
+				}
250 284
 				$Marine->db = null;
251
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+				if ($globalDebugTimeElapsed) {
286
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
+				}
252 288
 			    }
253 289
 			}
254 290
 		    }
255
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
291
+		    if (!isset($this->all_tracked[$id]['id'])) {
292
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
293
+		    }
256 294
 		}
257 295
 
258 296
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
259 297
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
260 298
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
261 299
 		    } else {
262
-				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";
263
-				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";
300
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
301
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
302
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
303
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
304
+				}
264 305
 				return '';
265 306
 		    }
266 307
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
267
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
308
+			if ($globalDebug) {
309
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
310
+			}
268 311
 			return '';
269 312
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
270
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
313
+			if ($globalDebug) {
314
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
315
+			}
271 316
 			return '';
272 317
 		} elseif (!isset($line['datetime'])) {
273 318
 			date_default_timezone_set('UTC');
274 319
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
275 320
 		} else {
276
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
321
+			if ($globalDebug) {
322
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
323
+			}
277 324
 			return '';
278 325
 		}
279 326
 
@@ -286,14 +333,21 @@  discard block
 block discarded – undo
286 333
 		    if ($distance > 1000 && $distance < 10000) {
287 334
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
288 335
 			$speed = $speed*3.6;
289
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
290
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
336
+			if ($speed < 1000) {
337
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
338
+			}
339
+  			if ($globalDebug) {
340
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
341
+  			}
291 342
 		    }
292 343
 		}
293 344
 
294 345
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
295
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
296
-	    	    else unset($timediff);
346
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
347
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
348
+	    	    } else {
349
+	    	    	unset($timediff);
350
+	    	    }
297 351
 	    	    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')))) {
298 352
 			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'])) {
299 353
 			    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'])) {
@@ -301,22 +355,32 @@  discard block
 block discarded – undo
301 355
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
302 356
 				$this->all_tracked[$id]['putinarchive'] = true;
303 357
 				
304
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
358
+				if ($globalDebug) {
359
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
360
+				}
305 361
 				$timeelapsed = microtime(true);
306 362
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
307 363
 				    $Marine = new Marine($this->db);
308 364
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
309
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
365
+				    if (!empty($all_country)) {
366
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
367
+				    }
310 368
 				    $Marine->db = null;
311
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+				    if ($globalDebugTimeElapsed) {
370
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
371
+				    }
312 372
 				}
313 373
 				$this->tmd = 0;
314
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
374
+				if ($globalDebug) {
375
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
376
+				}
315 377
 			    }
316 378
 			}
317 379
 
318 380
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
319
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
381
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
382
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
383
+				}
320 384
 				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') {
321 385
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
322 386
 				    $dataFound = true;
@@ -325,8 +389,12 @@  discard block
 block discarded – undo
325 389
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
326 390
 			}
327 391
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
328
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
329
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
392
+			    if ($line['longitude'] > 180) {
393
+			    	$line['longitude'] = $line['longitude'] - 360;
394
+			    }
395
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
396
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
397
+				}
330 398
 				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') {
331 399
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
332 400
 				    $dataFound = true;
@@ -344,7 +412,9 @@  discard block
 block discarded – undo
344 412
 		    }
345 413
 		}
346 414
 		if (isset($line['last_update']) && $line['last_update'] != '') {
347
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
415
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
416
+		    	$dataFound = true;
417
+		    }
348 418
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
349 419
 		}
350 420
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -358,15 +428,21 @@  discard block
 block discarded – undo
358 428
 		}
359 429
 		
360 430
 		if (isset($line['heading']) && $line['heading'] != '') {
361
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
431
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
432
+		    	$this->all_tracked[$id]['putinarchive'] = true;
433
+		    }
362 434
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
363 435
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
364 436
 		    //$dataFound = true;
365 437
   		} 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']) {
366 438
   		    $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']);
367 439
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
368
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
369
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
440
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
441
+		    	$this->all_tracked[$id]['putinarchive'] = true;
442
+		    }
443
+  		    if ($globalDebug) {
444
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
445
+  		    }
370 446
   		}
371 447
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
372 448
 
@@ -378,23 +454,38 @@  discard block
 block discarded – undo
378 454
 		        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'])) {
379 455
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
380 456
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
381
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
457
+				    if ($globalDebug) {
458
+				    	echo "Check if vessel is already in DB...";
459
+				    }
382 460
 				    $timeelapsed = microtime(true);
383 461
 				    $MarineLive = new MarineLive($this->db);
384 462
 				    if (isset($line['id'])) {
385 463
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
386
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
464
+					if ($globalDebugTimeElapsed) {
465
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
466
+					}
387 467
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
388 468
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
389
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
469
+					if ($globalDebugTimeElapsed) {
470
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
471
+					}
390 472
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
391 473
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
392
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
393
-				    } else $recent_ident = '';
474
+					if ($globalDebugTimeElapsed) {
475
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
476
+					}
477
+				    } else {
478
+				    	$recent_ident = '';
479
+				    }
394 480
 				    $MarineLive->db=null;
395
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
396
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
397
-				} else $recent_ident = '';
481
+				    if ($globalDebug && $recent_ident == '') {
482
+				    	echo " Not in DB.\n";
483
+				    } elseif ($globalDebug && $recent_ident != '') {
484
+				    	echo " Already in DB.\n";
485
+				    }
486
+				} else {
487
+					$recent_ident = '';
488
+				}
398 489
 			    } else {
399 490
 				$recent_ident = '';
400 491
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -402,30 +493,44 @@  discard block
 block discarded – undo
402 493
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
403 494
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
404 495
 			    {
405
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
496
+				if ($globalDebug) {
497
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
498
+				}
406 499
 				//adds the spotter data for the archive
407 500
 				    $highlight = '';
408
-				    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')));
501
+				    if (!isset($this->all_tracked[$id]['id'])) {
502
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
503
+				    }
409 504
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
410 505
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
411 506
 					    $timeelapsed = microtime(true);
412 507
 					    $Marine = new Marine($this->db);
413 508
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
414 509
 					    $Marine->db = null;
415
-					    if ($globalDebug && isset($result)) echo $result."\n";
416
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
510
+					    if ($globalDebug && isset($result)) {
511
+					    	echo $result."\n";
512
+					    }
513
+					    if ($globalDebugTimeElapsed) {
514
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
515
+					    }
417 516
 					}
418 517
 				    }
419 518
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
420 519
 					// Add source stat in DB
421 520
 					$Stats = new Stats($this->db);
422 521
 					if (!empty($this->stats)) {
423
-					    if ($globalDebug) echo 'Add source stats : ';
522
+					    if ($globalDebug) {
523
+					    	echo 'Add source stats : ';
524
+					    }
424 525
 				    	    foreach($this->stats as $date => $data) {
425 526
 						foreach($data as $source => $sourced) {
426 527
 					    	    //print_r($sourced);
427
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
428
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
528
+				    	    	    if (isset($sourced['polar'])) {
529
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
530
+				    	    	    }
531
+				    	    	    if (isset($sourced['hist'])) {
532
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
533
+				    	    	    }
429 534
 				    		    if (isset($sourced['msg'])) {
430 535
 				    			if (time() - $sourced['msg']['date'] > 10) {
431 536
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -438,7 +543,9 @@  discard block
 block discarded – undo
438 543
 			    			    unset($this->stats[$date]);
439 544
 			    			}
440 545
 				    	    }
441
-				    	    if ($globalDebug) echo 'Done'."\n";
546
+				    	    if ($globalDebug) {
547
+				    	    	echo 'Done'."\n";
548
+				    	    }
442 549
 					}
443 550
 					$Stats->db = null;
444 551
 				    }
@@ -448,13 +555,17 @@  discard block
 block discarded – undo
448 555
 				$this->all_tracked[$id]['addedMarine'] = 1;
449 556
 				//print_r($this->all_tracked[$id]);
450 557
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
451
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
558
+				    if ($globalDebug) {
559
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
560
+				    }
452 561
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
453 562
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
454 563
 					$MarineLive = new MarineLive($this->db);
455 564
 					$MarineLive->deleteLiveMarineData();
456 565
 					$MarineLive->db=null;
457
-					if ($globalDebug) echo " Done\n";
566
+					if ($globalDebug) {
567
+						echo " Done\n";
568
+					}
458 569
 				    }
459 570
 				    $this->last_delete = time();
460 571
 				}
@@ -480,15 +591,21 @@  discard block
 block discarded – undo
480 591
 
481 592
 		    if (!$ignoreImport) {
482 593
 			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'])) {
483
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
594
+				if ($globalDebug) {
595
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
596
+				}
484 597
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
485 598
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
486 599
 					$timeelapsed = microtime(true);
487 600
 					$MarineLive = new MarineLive($this->db);
488 601
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country'],$this->all_tracked[$id]['captain_id'],$this->all_tracked[$id]['captain_name'],$this->all_tracked[$id]['race_id'],$this->all_tracked[$id]['race_name']);
489 602
 					$MarineLive->db = null;
490
-					if ($globalDebug) echo $result."\n";
491
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
603
+					if ($globalDebug) {
604
+						echo $result."\n";
605
+					}
606
+					if ($globalDebugTimeElapsed) {
607
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
608
+					}
492 609
 				    }
493 610
 				}
494 611
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -500,7 +617,9 @@  discard block
 block discarded – undo
500 617
 				
501 618
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
502 619
 					$source = $this->all_tracked[$id]['source_name'];
503
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
620
+					if ($source == '') {
621
+						$source = $this->all_tracked[$id]['format_source'];
622
+					}
504 623
 					if (!isset($this->source_location[$source])) {
505 624
 						$Location = new Source($this->db);
506 625
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -521,7 +640,9 @@  discard block
 block discarded – undo
521 640
 					$stats_heading = round($stats_heading/22.5);
522 641
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
523 642
 					$current_date = date('Y-m-d');
524
-					if ($stats_heading == 16) $stats_heading = 0;
643
+					if ($stats_heading == 16) {
644
+						$stats_heading = 0;
645
+					}
525 646
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
526 647
 						for ($i=0;$i<=15;$i++) {
527 648
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -539,7 +660,9 @@  discard block
 block discarded – undo
539 660
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
540 661
 						    end($this->stats[$current_date][$source]['hist']);
541 662
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
542
-						} else $mini = 0;
663
+						} else {
664
+							$mini = 0;
665
+						}
543 666
 						for ($i=$mini;$i<=$distance;$i+=10) {
544 667
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
545 668
 						}
@@ -551,19 +674,27 @@  discard block
 block discarded – undo
551 674
 				
552 675
 
553 676
 				$this->all_tracked[$id]['lastupdate'] = time();
554
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
555
-			} 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";
677
+				if ($this->all_tracked[$id]['putinarchive']) {
678
+					$send = true;
679
+				}
680
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
681
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
682
+			}
556 683
 			//$this->del();
557 684
 			
558 685
 			
559 686
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
560 687
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
561
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
688
+				if ($globalDebug) {
689
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
690
+				}
562 691
 				$MarineLive = new MarineLive($this->db);
563 692
 				$MarineLive->deleteLiveMarineDataNotUpdated();
564 693
 				$MarineLive->db = null;
565 694
 				//MarineLive->deleteLiveMarineData();
566
-				if ($globalDebug) echo " Done\n";
695
+				if ($globalDebug) {
696
+					echo " Done\n";
697
+				}
567 698
 			    }
568 699
 			    $this->last_delete_hourly = time();
569 700
 			}
@@ -572,7 +703,9 @@  discard block
 block discarded – undo
572 703
 		    //$ignoreImport = false;
573 704
 		}
574 705
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
575
-		if ($send) return $this->all_tracked[$id];
706
+		if ($send) {
707
+			return $this->all_tracked[$id];
708
+		}
576 709
 	    }
577 710
 	}
578 711
     }
Please login to merge, or discard this patch.
require/class.MarineLive.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	* Gets all the spotter information based on the latest data entry
100
-	*
101
-	* @return Array the spotter information
102
-	*
103
-	*/
99
+	 * Gets all the spotter information based on the latest data entry
100
+	 *
101
+	 * @return Array the spotter information
102
+	 *
103
+	 */
104 104
 	public function getLiveMarineData($limit = '', $sort = '', $filter = array())
105 105
 	{
106 106
 		global $globalDBdriver, $globalLiveInterval;
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 	}
144 144
 
145 145
 	/**
146
-	* Gets Minimal Live Spotter data
147
-	*
148
-	* @return Array the spotter information
149
-	*
150
-	*/
146
+	 * Gets Minimal Live Spotter data
147
+	 *
148
+	 * @return Array the spotter information
149
+	 *
150
+	 */
151 151
 	public function getMinLiveMarineData($filter = array())
152 152
 	{
153 153
 		global $globalDBdriver, $globalLiveInterval;
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	}
178 178
 
179 179
 	/**
180
-	* Gets Minimal Live Spotter data since xx seconds
181
-	*
182
-	* @return Array the spotter information
183
-	*
184
-	*/
180
+	 * Gets Minimal Live Spotter data since xx seconds
181
+	 *
182
+	 * @return Array the spotter information
183
+	 *
184
+	 */
185 185
 	public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false)
186 186
 	{
187 187
 		global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive;
@@ -252,11 +252,11 @@  discard block
 block discarded – undo
252 252
 	}
253 253
 
254 254
 	/**
255
-	* Gets number of latest data entry
256
-	*
257
-	* @return String number of entry
258
-	*
259
-	*/
255
+	 * Gets number of latest data entry
256
+	 *
257
+	 * @return String number of entry
258
+	 *
259
+	 */
260 260
 	public function getLiveMarineCount($filter = array())
261 261
 	{
262 262
 		global $globalDBdriver, $globalLiveInterval;
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 	}
282 282
 
283 283
 	/**
284
-	* Gets all the spotter information based on the latest data entry and coord
285
-	*
286
-	* @return Array the spotter information
287
-	*
288
-	*/
284
+	 * Gets all the spotter information based on the latest data entry and coord
285
+	 *
286
+	 * @return Array the spotter information
287
+	 *
288
+	 */
289 289
 	public function getLiveMarineDatabyCoord($coord, $filter = array())
290 290
 	{
291 291
 		global $globalDBdriver, $globalLiveInterval;
@@ -309,11 +309,11 @@  discard block
 block discarded – undo
309 309
 	}
310 310
 
311 311
 	/**
312
-	* Gets all the spotter information based on the latest data entry and coord
313
-	*
314
-	* @return Array the spotter information
315
-	*
316
-	*/
312
+	 * Gets all the spotter information based on the latest data entry and coord
313
+	 *
314
+	 * @return Array the spotter information
315
+	 *
316
+	 */
317 317
 	public function getMinLiveMarineDatabyCoord($coord, $filter = array())
318 318
 	{
319 319
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 	}
383 383
 
384 384
 	/**
385
-	* Gets all the spotter information based on a user's latitude and longitude
386
-	*
387
-	* @return Array the spotter information
388
-	*
389
-	*/
385
+	 * Gets all the spotter information based on a user's latitude and longitude
386
+	 *
387
+	 * @return Array the spotter information
388
+	 *
389
+	 */
390 390
 	public function getLatestMarineForLayar($lat, $lng, $radius, $interval)
391 391
 	{
392 392
 		$Marine = new Marine($this->db);
@@ -399,75 +399,75 @@  discard block
 block discarded – undo
399 399
 		if ($lng != '')
400 400
 		{
401 401
 			if (!is_numeric($lng))
402
-                        {
403
-                                return false;
404
-                        }
405
-                }
406
-
407
-                if ($radius != '')
408
-                {
409
-                        if (!is_numeric($radius))
410
-                        {
411
-                                return false;
412
-                        }
413
-                }
402
+						{
403
+								return false;
404
+						}
405
+				}
406
+
407
+				if ($radius != '')
408
+				{
409
+						if (!is_numeric($radius))
410
+						{
411
+								return false;
412
+						}
413
+				}
414 414
 		$additional_query = '';
415 415
 		if ($interval != '')
416
-                {
417
-                        if (!is_string($interval))
418
-                        {
419
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
420
-			        return false;
421
-                        } else {
422
-                if ($interval == '1m')
423
-                {
424
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
425
-                } else if ($interval == '15m'){
426
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
427
-                } 
428
-            }
429
-                } else {
430
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
431
-        }
432
-
433
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
416
+				{
417
+						if (!is_string($interval))
418
+						{
419
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
420
+					return false;
421
+						} else {
422
+				if ($interval == '1m')
423
+				{
424
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
425
+				} else if ($interval == '15m'){
426
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
427
+				} 
428
+			}
429
+				} else {
430
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
431
+		}
432
+
433
+				$query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
434 434
                    WHERE marine_live.latitude <> '' 
435 435
                                    AND marine_live.longitude <> '' 
436 436
                    ".$additional_query."
437 437
                    HAVING distance < :radius  
438 438
                                    ORDER BY distance";
439 439
 
440
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
440
+				$spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
441 441
 
442
-                return $spotter_array;
443
-        }
442
+				return $spotter_array;
443
+		}
444 444
 
445 445
     
446
-        /**
447
-	* Gets all the spotter information based on a particular callsign
448
-	*
449
-	* @return Array the spotter information
450
-	*
451
-	*/
446
+		/**
447
+		 * Gets all the spotter information based on a particular callsign
448
+		 *
449
+		 * @return Array the spotter information
450
+		 *
451
+		 */
452 452
 	public function getLastLiveMarineDataByIdent($ident)
453 453
 	{
454 454
 		$Marine = new Marine($this->db);
455 455
 		date_default_timezone_set('UTC');
456 456
 
457 457
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
458
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
458
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
459 459
 
460 460
 		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
461 461
 
462 462
 		return $spotter_array;
463 463
 	}
464 464
 
465
-        /**
466
-	* Gets all the spotter information based on a particular callsign
467
-	*
468
-	* @return Array the spotter information
469
-	*
470
-	*/
465
+		/**
466
+		 * Gets all the spotter information based on a particular callsign
467
+		 *
468
+		 * @return Array the spotter information
469
+		 *
470
+		 */
471 471
 	public function getDateLiveMarineDataByIdent($ident,$date)
472 472
 	{
473 473
 		$Marine = new Marine($this->db);
@@ -480,11 +480,11 @@  discard block
 block discarded – undo
480 480
 	}
481 481
 
482 482
 	/**
483
-	* Gets all the spotter information based on a particular MMSI
484
-	*
485
-	* @return Array the spotter information
486
-	*
487
-	*/
483
+	 * Gets all the spotter information based on a particular MMSI
484
+	 *
485
+	 * @return Array the spotter information
486
+	 *
487
+	 */
488 488
 	public function getDateLiveMarineDataByMMSI($mmsi,$date)
489 489
 	{
490 490
 		$Marine = new Marine($this->db);
@@ -496,51 +496,51 @@  discard block
 block discarded – undo
496 496
 		return $spotter_array;
497 497
 	}
498 498
 
499
-        /**
500
-	* Gets last spotter information based on a particular callsign
501
-	*
502
-	* @return Array the spotter information
503
-	*
504
-	*/
499
+		/**
500
+		 * Gets last spotter information based on a particular callsign
501
+		 *
502
+		 * @return Array the spotter information
503
+		 *
504
+		 */
505 505
 	public function getLastLiveMarineDataById($id)
506 506
 	{
507 507
 		$Marine = new Marine($this->db);
508 508
 		date_default_timezone_set('UTC');
509 509
 
510 510
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
511
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
511
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
512 512
 
513 513
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
514 514
 
515 515
 		return $spotter_array;
516 516
 	}
517 517
 
518
-        /**
519
-	* Gets last spotter information based on a particular callsign
520
-	*
521
-	* @return Array the spotter information
522
-	*
523
-	*/
518
+		/**
519
+		 * Gets last spotter information based on a particular callsign
520
+		 *
521
+		 * @return Array the spotter information
522
+		 *
523
+		 */
524 524
 	public function getDateLiveMarineDataById($id,$date)
525 525
 	{
526 526
 		$Marine = new Marine($this->db);
527 527
 		date_default_timezone_set('UTC');
528 528
 
529 529
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
530
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
531
-                $date = date('c',$date);
530
+				$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
531
+				$date = date('c',$date);
532 532
 		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
533 533
 
534 534
 		return $spotter_array;
535 535
 	}
536 536
 
537 537
 
538
-        /**
539
-	* Gets all the spotter information based on a particular id
540
-	*
541
-	* @return Array the spotter information
542
-	*
543
-	*/
538
+		/**
539
+		 * Gets all the spotter information based on a particular id
540
+		 *
541
+		 * @return Array the spotter information
542
+		 *
543
+		 */
544 544
 	public function getAllLiveMarineDataById($id,$liveinterval = false)
545 545
 	{
546 546
 		global $globalDBdriver, $globalLiveInterval;
@@ -568,18 +568,18 @@  discard block
 block discarded – undo
568 568
 		return $spotter_array;
569 569
 	}
570 570
 
571
-        /**
572
-	* Gets all the spotter information based on a particular ident
573
-	*
574
-	* @return Array the spotter information
575
-	*
576
-	*/
571
+		/**
572
+		 * Gets all the spotter information based on a particular ident
573
+		 *
574
+		 * @return Array the spotter information
575
+		 *
576
+		 */
577 577
 	public function getAllLiveMarineDataByIdent($ident)
578 578
 	{
579 579
 		date_default_timezone_set('UTC');
580 580
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
581 581
 		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
582
-    		try {
582
+			try {
583 583
 			
584 584
 			$sth = $this->db->prepare($query);
585 585
 			$sth->execute(array(':ident' => $ident));
@@ -593,23 +593,23 @@  discard block
 block discarded – undo
593 593
 
594 594
 
595 595
 	/**
596
-	* Deletes all info in the table
597
-	*
598
-	* @return String success or false
599
-	*
600
-	*/
596
+	 * Deletes all info in the table
597
+	 *
598
+	 * @return String success or false
599
+	 *
600
+	 */
601 601
 	public function deleteLiveMarineData()
602 602
 	{
603 603
 		global $globalDBdriver;
604 604
 		if ($globalDBdriver == 'mysql') {
605 605
 			//$query  = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date";
606 606
 			$query  = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date';
607
-            		//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
607
+					//$query  = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)";
608 608
 		} else {
609 609
 			$query  = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date";
610 610
 		}
611 611
         
612
-    		try {
612
+			try {
613 613
 			
614 614
 			$sth = $this->db->prepare($query);
615 615
 			$sth->execute();
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 	}
622 622
 
623 623
 	/**
624
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
625
-	*
626
-	* @return String success or false
627
-	*
628
-	*/
624
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
625
+	 *
626
+	 * @return String success or false
627
+	 *
628
+	 */
629 629
 	public function deleteLiveMarineDataNotUpdated()
630 630
 	{
631 631
 		global $globalDBdriver, $globalDebug;
632 632
 		if ($globalDBdriver == 'mysql') {
633 633
 			//$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0';
634
-    			$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
635
-    			try {
634
+				$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0";
635
+				try {
636 636
 				
637 637
 				$sth = $this->db->prepare($query);
638 638
 				$sth->execute();
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 				return "error";
641 641
 			}
642 642
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
643
-                        $i = 0;
644
-                        $j =0;
643
+						$i = 0;
644
+						$j =0;
645 645
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
646 646
 			foreach($all as $row)
647 647
 			{
@@ -649,20 +649,20 @@  discard block
 block discarded – undo
649 649
 				$j++;
650 650
 				if ($j == 30) {
651 651
 					if ($globalDebug) echo ".";
652
-				    	try {
652
+						try {
653 653
 						
654 654
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
655 655
 						$sth->execute();
656 656
 					} catch(PDOException $e) {
657 657
 						return "error";
658 658
 					}
659
-                                	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
660
-                                	$j = 0;
659
+									$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
660
+									$j = 0;
661 661
 				}
662 662
 				$query_delete .= "'".$row['fammarine_id']."',";
663 663
 			}
664 664
 			if ($i > 0) {
665
-    				try {
665
+					try {
666 666
 					
667 667
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
668 668
 					$sth->execute();
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 			return "success";
674 674
 		} elseif ($globalDBdriver == 'pgsql') {
675 675
 			//$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0";
676
-    			//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
677
-    			$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
678
-    			try {
676
+				//$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
677
+				$query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)";
678
+				try {
679 679
 				
680 680
 				$sth = $this->db->prepare($query);
681 681
 				$sth->execute();
@@ -719,17 +719,17 @@  discard block
 block discarded – undo
719 719
 	}
720 720
 
721 721
 	/**
722
-	* Deletes all info in the table for an ident
723
-	*
724
-	* @return String success or false
725
-	*
726
-	*/
722
+	 * Deletes all info in the table for an ident
723
+	 *
724
+	 * @return String success or false
725
+	 *
726
+	 */
727 727
 	public function deleteLiveMarineDataByIdent($ident)
728 728
 	{
729 729
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
730 730
 		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
731 731
         
732
-    		try {
732
+			try {
733 733
 			
734 734
 			$sth = $this->db->prepare($query);
735 735
 			$sth->execute(array(':ident' => $ident));
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
 	}
742 742
 
743 743
 	/**
744
-	* Deletes all info in the table for an id
745
-	*
746
-	* @return String success or false
747
-	*
748
-	*/
744
+	 * Deletes all info in the table for an id
745
+	 *
746
+	 * @return String success or false
747
+	 *
748
+	 */
749 749
 	public function deleteLiveMarineDataById($id)
750 750
 	{
751 751
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
752 752
 		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
753 753
         
754
-    		try {
754
+			try {
755 755
 			
756 756
 			$sth = $this->db->prepare($query);
757 757
 			$sth->execute(array(':id' => $id));
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
 
765 765
 
766 766
 	/**
767
-	* Gets the marine race
768
-	*
769
-	* @return String the ident
770
-	*
771
-	*/
767
+	 * Gets the marine race
768
+	 *
769
+	 * @return String the ident
770
+	 *
771
+	 */
772 772
 	public function getAllRaces()
773 773
 	{
774 774
 		$query  = 'SELECT DISTINCT marine_live.race_id, marine_live.race_name FROM marine_live ORDER BY marine_live.race_name';
@@ -779,11 +779,11 @@  discard block
 block discarded – undo
779 779
 	}
780 780
 
781 781
 	/**
782
-	* Gets the aircraft ident within the last hour
783
-	*
784
-	* @return String the ident
785
-	*
786
-	*/
782
+	 * Gets the aircraft ident within the last hour
783
+	 *
784
+	 * @return String the ident
785
+	 *
786
+	 */
787 787
 	public function getIdentFromLastHour($ident)
788 788
 	{
789 789
 		global $globalDBdriver, $globalTimezone;
@@ -809,14 +809,14 @@  discard block
 block discarded – undo
809 809
 			$ident_result = $row['ident'];
810 810
 		}
811 811
 		return $ident_result;
812
-        }
812
+		}
813 813
 
814 814
 	/**
815
-	* Check recent aircraft
816
-	*
817
-	* @return String the ident
818
-	*
819
-	*/
815
+	 * Check recent aircraft
816
+	 *
817
+	 * @return String the ident
818
+	 *
819
+	 */
820 820
 	public function checkIdentRecent($ident)
821 821
 	{
822 822
 		global $globalDBdriver, $globalTimezone;
@@ -842,14 +842,14 @@  discard block
 block discarded – undo
842 842
 			$ident_result = $row['fammarine_id'];
843 843
 		}
844 844
 		return $ident_result;
845
-        }
845
+		}
846 846
 
847 847
 	/**
848
-	* Check recent aircraft by id
849
-	*
850
-	* @return String the ident
851
-	*
852
-	*/
848
+	 * Check recent aircraft by id
849
+	 *
850
+	 * @return String the ident
851
+	 *
852
+	 */
853 853
 	public function checkIdRecent($id)
854 854
 	{
855 855
 		global $globalDBdriver, $globalTimezone;
@@ -875,14 +875,14 @@  discard block
 block discarded – undo
875 875
 			$ident_result = $row['fammarine_id'];
876 876
 		}
877 877
 		return $ident_result;
878
-        }
878
+		}
879 879
 
880 880
 	/**
881
-	* Check recent aircraft by mmsi
882
-	*
883
-	* @return String the ident
884
-	*
885
-	*/
881
+	 * Check recent aircraft by mmsi
882
+	 *
883
+	 * @return String the ident
884
+	 *
885
+	 */
886 886
 	public function checkMMSIRecent($mmsi)
887 887
 	{
888 888
 		global $globalDBdriver, $globalTimezone;
@@ -908,19 +908,19 @@  discard block
 block discarded – undo
908 908
 			$ident_result = $row['fammarine_id'];
909 909
 		}
910 910
 		return $ident_result;
911
-        }
911
+		}
912 912
 
913 913
 	/**
914
-	* Adds a new spotter data
915
-	*
916
-	* @param String $fammarine_id the ID from flightaware
917
-	* @param String $ident the flight ident
918
-	* @param String $aircraft_icao the aircraft type
919
-	* @param String $departure_airport_icao the departure airport
920
-	* @param String $arrival_airport_icao the arrival airport
921
-	* @return String success or false
922
-	*
923
-	*/
914
+	 * Adds a new spotter data
915
+	 *
916
+	 * @param String $fammarine_id the ID from flightaware
917
+	 * @param String $ident the flight ident
918
+	 * @param String $aircraft_icao the aircraft type
919
+	 * @param String $departure_airport_icao the departure airport
920
+	 * @param String $arrival_airport_icao the arrival airport
921
+	 * @return String success or false
922
+	 *
923
+	 */
924 924
 	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '',$captain_id = '',$captain_name = '',$race_id = '', $race_name = '')
925 925
 	{
926 926
 		global $globalURL, $globalArchive, $globalDebug;
@@ -998,10 +998,10 @@  discard block
 block discarded – undo
998 998
 		if ($typeid == '') $typeid = NULL;
999 999
 		if ($statusid == '') $statusid = NULL;
1000 1000
 
1001
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1002
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1003
-            	if ($arrival_date == '') $arrival_date = NULL;
1004
-            	$query = '';
1001
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1002
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1003
+				if ($arrival_date == '') $arrival_date = NULL;
1004
+				$query = '';
1005 1005
 		if ($globalArchive) {
1006 1006
 			if ($globalDebug) echo '-- Delete previous data -- ';
1007 1007
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
Please login to merge, or discard this patch.
Braces   +119 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (MarineLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (MarineLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -86,8 +90,11 @@  discard block
 block discarded – undo
86 90
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
87 91
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88 92
 		}
89
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
93
+		if ($filter_query_where == '' && $where) {
94
+			$filter_query_where = ' WHERE';
95
+		} elseif ($filter_query_where != '' && $and) {
96
+			$filter_query_where .= ' AND';
97
+		}
91 98
 		if ($filter_query_where != '') {
92 99
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
93 100
 		}
@@ -128,9 +135,13 @@  discard block
 block discarded – undo
128 135
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
129 136
 			}
130 137
 		}
131
-		if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC';
138
+		if ($orderby_query == '') {
139
+			$orderby_query= ' ORDER BY date DESC';
140
+		}
132 141
 
133
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
142
+		if (!isset($globalLiveInterval)) {
143
+			$globalLiveInterval = '200';
144
+		}
134 145
 		if ($globalDBdriver == 'mysql') {
135 146
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
136 147
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -155,7 +166,9 @@  discard block
 block discarded – undo
155 166
 
156 167
 		$filter_query = $this->getFilter($filter,true,true);
157 168
 
158
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
159 172
 		if ($globalDBdriver == 'mysql') {
160 173
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source, marine_live.captain_name 
161 174
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -196,48 +209,72 @@  discard block
 block discarded – undo
196 209
 		}
197 210
 		$filter_query = $this->getFilter($filter,true,true);
198 211
 
199
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
200
-		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300';
212
+		if (!isset($globalLiveInterval)) {
213
+			$globalLiveInterval = '200';
214
+		}
215
+		if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') {
216
+			$globalMap3DMarinesLimit = '300';
217
+		}
201 218
 		if ($globalDBdriver == 'mysql') {
202 219
 			if (isset($globalArchive) && $globalArchive === TRUE) {
203 220
 				$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, marine_live.captain_name 
204 221
 				    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 ";
205
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
222
+				if ($usecoord) {
223
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
224
+				}
206 225
 				$query .= "UNION
207 226
 				    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, marine_live.captain_name 
208 227
 				    FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date";
209
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
228
+				if ($usecoord) {
229
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
230
+				}
210 231
 				$query .= ") AS marine 
211 232
 				    WHERE latitude <> '0' AND longitude <> '0' 
212 233
 				    ORDER BY fammarine_id, date";
213
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
234
+				if ($limit) {
235
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
236
+				}
214 237
 			} else {
215 238
 				$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, marine_live.captain_name 
216 239
 				    FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date ";
217
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
240
+				if ($usecoord) {
241
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
242
+				}
218 243
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
219 244
 				ORDER BY marine_live.fammarine_id, marine_live.date";
220
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
245
+				if ($limit) {
246
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
247
+				}
221 248
 			}
222 249
 		} else {
223 250
 			if (isset($globalArchive) && $globalArchive === TRUE) {
224 251
 				$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, marine_live.captain_name 
225 252
 				    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 ";
226
-				if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
253
+				if ($usecoord) {
254
+					$query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
255
+				}
227 256
 				$query .= "UNION
228 257
 				    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, marine_live.captain_name 
229 258
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date";
230
-				if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
259
+				if ($usecoord) {
260
+					$query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong;
261
+				}
231 262
 				$query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' ";
232 263
 				$query .= "ORDER BY fammarine_id, date";
233
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
264
+				if ($limit) {
265
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
266
+				}
234 267
 			} else {
235 268
 				$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, marine_live.captain_name 
236 269
 				    FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date ";
237
-				if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
270
+				if ($usecoord) {
271
+					$query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." ";
272
+				}
238 273
 				$query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
239 274
 				ORDER BY marine_live.fammarine_id, marine_live.date";
240
-				if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit;
275
+				if ($limit) {
276
+					$query .= " LIMIT ".$globalMap3DMarinesLimit;
277
+				}
241 278
 			}
242 279
 		}
243 280
 		try {
@@ -262,7 +299,9 @@  discard block
 block discarded – undo
262 299
 		global $globalDBdriver, $globalLiveInterval;
263 300
 		$filter_query = $this->getFilter($filter,true,true);
264 301
 
265
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
302
+		if (!isset($globalLiveInterval)) {
303
+			$globalLiveInterval = '200';
304
+		}
266 305
 		if ($globalDBdriver == 'mysql') {
267 306
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
268 307
 		} else {
@@ -290,7 +329,9 @@  discard block
 block discarded – undo
290 329
 	{
291 330
 		global $globalDBdriver, $globalLiveInterval;
292 331
 		$Marine = new Marine($this->db);
293
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
332
+		if (!isset($globalLiveInterval)) {
333
+			$globalLiveInterval = '200';
334
+		}
294 335
 		$filter_query = $this->getFilter($filter);
295 336
 
296 337
 		if (is_array($coord)) {
@@ -298,7 +339,9 @@  discard block
 block discarded – undo
298 339
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
299 340
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
300 341
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
301
-		} else return array();
342
+		} else {
343
+			return array();
344
+		}
302 345
 		if ($globalDBdriver == 'mysql') {
303 346
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id ORDER BY date DESC'.$filter_query;
304 347
 		} else {
@@ -318,7 +361,9 @@  discard block
 block discarded – undo
318 361
 	{
319 362
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
320 363
 		$Marine = new Marine($this->db);
321
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
364
+		if (!isset($globalLiveInterval)) {
365
+			$globalLiveInterval = '200';
366
+		}
322 367
 		$filter_query = $this->getFilter($filter,true,true);
323 368
 
324 369
 		if (is_array($coord)) {
@@ -326,7 +371,9 @@  discard block
 block discarded – undo
326 371
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327 372
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
328 373
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
329
-		} else return array();
374
+		} else {
375
+			return array();
376
+		}
330 377
 		/*
331 378
 		if ($globalDBdriver == 'mysql') {
332 379
 			$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 
@@ -549,11 +596,15 @@  discard block
 block discarded – undo
549 596
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
550 597
 		if ($globalDBdriver == 'mysql') {
551 598
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
552
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
599
+			if ($liveinterval) {
600
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
601
+			}
553 602
 			$query .= ' ORDER BY date';
554 603
 		} else {
555 604
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
556
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
605
+			if ($liveinterval) {
606
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
607
+			}
557 608
 			$query .= ' ORDER BY date';
558 609
 		}
559 610
 
@@ -648,7 +699,9 @@  discard block
 block discarded – undo
648 699
 				$i++;
649 700
 				$j++;
650 701
 				if ($j == 30) {
651
-					if ($globalDebug) echo ".";
702
+					if ($globalDebug) {
703
+						echo ".";
704
+					}
652 705
 				    	try {
653 706
 						
654 707
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -943,7 +996,9 @@  discard block
 block discarded – undo
943 996
 			{
944 997
 				return false;
945 998
 			}
946
-		} else return '';
999
+		} else {
1000
+			return '';
1001
+		}
947 1002
 
948 1003
 		if ($longitude != '')
949 1004
 		{
@@ -951,7 +1006,9 @@  discard block
 block discarded – undo
951 1006
 			{
952 1007
 				return false;
953 1008
 			}
954
-		} else return '';
1009
+		} else {
1010
+			return '';
1011
+		}
955 1012
 
956 1013
 
957 1014
 		if ($heading != '')
@@ -960,7 +1017,9 @@  discard block
 block discarded – undo
960 1017
 			{
961 1018
 				return false;
962 1019
 			}
963
-		} else $heading = 0;
1020
+		} else {
1021
+			$heading = 0;
1022
+		}
964 1023
 
965 1024
 		if ($groundspeed != '')
966 1025
 		{
@@ -968,9 +1027,13 @@  discard block
 block discarded – undo
968 1027
 			{
969 1028
 				return false;
970 1029
 			}
971
-		} else $groundspeed = 0;
1030
+		} else {
1031
+			$groundspeed = 0;
1032
+		}
972 1033
 		date_default_timezone_set('UTC');
973
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1034
+		if ($date == '') {
1035
+			$date = date("Y-m-d H:i:s", time());
1036
+		}
974 1037
 
975 1038
         
976 1039
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -995,15 +1058,27 @@  discard block
 block discarded – undo
995 1058
 		$captain_name = filter_var($captain_name,FILTER_SANITIZE_STRING);
996 1059
 		$race_id = filter_var($race_id,FILTER_SANITIZE_STRING);
997 1060
 		$race_name = filter_var($race_name,FILTER_SANITIZE_STRING);
998
-		if ($typeid == '') $typeid = NULL;
999
-		if ($statusid == '') $statusid = NULL;
1061
+		if ($typeid == '') {
1062
+			$typeid = NULL;
1063
+		}
1064
+		if ($statusid == '') {
1065
+			$statusid = NULL;
1066
+		}
1000 1067
 
1001
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1002
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1003
-            	if ($arrival_date == '') $arrival_date = NULL;
1068
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1069
+            		$groundspeed = 0;
1070
+            	}
1071
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1072
+            		$heading = 0;
1073
+            	}
1074
+            	if ($arrival_date == '') {
1075
+            		$arrival_date = NULL;
1076
+            	}
1004 1077
             	$query = '';
1005 1078
 		if ($globalArchive) {
1006
-			if ($globalDebug) echo '-- Delete previous data -- ';
1079
+			if ($globalDebug) {
1080
+				echo '-- Delete previous data -- ';
1081
+			}
1007 1082
 			$query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;';
1008 1083
 		}
1009 1084
 		$query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,type_id,status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) 
@@ -1018,10 +1093,14 @@  discard block
 block discarded – undo
1018 1093
 		}
1019 1094
 		
1020 1095
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1021
-			if ($globalDebug) echo '(Add to Marine archive : ';
1096
+			if ($globalDebug) {
1097
+				echo '(Add to Marine archive : ';
1098
+			}
1022 1099
 			$MarineArchive = new MarineArchive($this->db);
1023 1100
 			$result =  $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source, $source_name, $over_country,$captain_id,$captain_name,$race_id,$race_name);
1024
-			if ($globalDebug) echo $result.')';
1101
+			if ($globalDebug) {
1102
+				echo $result.')';
1103
+			}
1025 1104
 		}
1026 1105
 		return "success";
1027 1106
 	}
Please login to merge, or discard this patch.
require/class.Marine.php 2 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	}
89 89
 
90 90
 	/**
91
-	* Executes the SQL statements to get the spotter information
92
-	*
93
-	* @param String $query the SQL query
94
-	* @param Array $params parameter of the query
95
-	* @param String $limitQuery the limit query
96
-	* @return Array the spotter information
97
-	*
98
-	*/
91
+	 * Executes the SQL statements to get the spotter information
92
+	 *
93
+	 * @param String $query the SQL query
94
+	 * @param Array $params parameter of the query
95
+	 * @param String $limitQuery the limit query
96
+	 * @return Array the spotter information
97
+	 *
98
+	 */
99 99
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
100 100
 	{
101 101
 		date_default_timezone_set('UTC');
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 	
231 231
 	
232 232
 	/**
233
-	* Gets all the spotter information based on the latest data entry
234
-	*
235
-	* @return Array the spotter information
236
-	*
237
-	*/
233
+	 * Gets all the spotter information based on the latest data entry
234
+	 *
235
+	 * @return Array the spotter information
236
+	 *
237
+	 */
238 238
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
239 239
 	{
240 240
 		global $global_query;
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	}
284 284
 
285 285
 	/**
286
-	* Gets all the spotter information based on the callsign
287
-	*
288
-	* @return Array the spotter information
289
-	*
290
-	*/
286
+	 * Gets all the spotter information based on the callsign
287
+	 *
288
+	 * @return Array the spotter information
289
+	 *
290
+	 */
291 291
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
292 292
 	{
293 293
 		global $global_query;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	/**
342
-	* Gets all the marine information based on the type
343
-	*
344
-	* @return Array the marine information
345
-	*
346
-	*/
342
+	 * Gets all the marine information based on the type
343
+	 *
344
+	 * @return Array the marine information
345
+	 *
346
+	 */
347 347
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
348 348
 	{
349 349
 		global $global_query;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 
452 452
 
453 453
 	/**
454
-	* Gets all source name
455
-	*
456
-	* @param String type format of source
457
-	* @return Array list of source name
458
-	*
459
-	*/
454
+	 * Gets all source name
455
+	 *
456
+	 * @param String type format of source
457
+	 * @return Array list of source name
458
+	 *
459
+	 */
460 460
 	public function getAllSourceName($type = '',$filters = array())
461 461
 	{
462 462
 		$filter_query = $this->getFilter($filters,true,true);
@@ -486,11 +486,11 @@  discard block
 block discarded – undo
486 486
 
487 487
 
488 488
 	/**
489
-	* Gets a list of all idents/callsigns
490
-	*
491
-	* @return Array list of ident/callsign names
492
-	*
493
-	*/
489
+	 * Gets a list of all idents/callsigns
490
+	 *
491
+	 * @return Array list of ident/callsign names
492
+	 *
493
+	 */
494 494
 	public function getAllIdents($filters = array())
495 495
 	{
496 496
 		$filter_query = $this->getFilter($filters,true,true);
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 	}
515 515
 
516 516
 	/**
517
-	* Gets all info from a mmsi
518
-	*
519
-	* @return Array ident
520
-	*
521
-	*/
517
+	 * Gets all info from a mmsi
518
+	 *
519
+	 * @return Array ident
520
+	 *
521
+	 */
522 522
 	public function getIdentity($mmsi)
523 523
 	{
524 524
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -531,9 +531,9 @@  discard block
 block discarded – undo
531 531
 	}
532 532
 
533 533
 	/**
534
-	* Add identity
535
-	*
536
-	*/
534
+	 * Add identity
535
+	 *
536
+	 */
537 537
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
538 538
 	{
539 539
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 	}
600 600
 
601 601
 	/**
602
-	* Update ident tracker data
603
-	*
604
-	* @param String $fammarine_id the ID
605
-	* @param String $ident the marine ident
606
-	* @return String success or false
607
-	*
608
-	*/
602
+	 * Update ident tracker data
603
+	 *
604
+	 * @param String $fammarine_id the ID
605
+	 * @param String $ident the marine ident
606
+	 * @return String success or false
607
+	 *
608
+	 */
609 609
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
610 610
 	{
611 611
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 	}
621 621
 
622 622
 	/**
623
-	* Update arrival marine data
624
-	*
625
-	* @param String $fammarine_id the ID
626
-	* @param String $arrival_code the marine ident
627
-	* @return String success or false
628
-	*
629
-	*/
623
+	 * Update arrival marine data
624
+	 *
625
+	 * @param String $fammarine_id the ID
626
+	 * @param String $arrival_code the marine ident
627
+	 * @return String success or false
628
+	 *
629
+	 */
630 630
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
631 631
 	{
632 632
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -641,19 +641,19 @@  discard block
 block discarded – undo
641 641
 	}
642 642
 
643 643
 	/**
644
-	* Update Status data
645
-	*
646
-	* @param String $fammarine_id the ID
647
-	* @param String $status_id the marine status id
648
-	* @param String $status the marine status
649
-	* @return String success or false
650
-	*
651
-	*/
644
+	 * Update Status data
645
+	 *
646
+	 * @param String $fammarine_id the ID
647
+	 * @param String $status_id the marine status id
648
+	 * @param String $status the marine status
649
+	 * @return String success or false
650
+	 *
651
+	 */
652 652
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
653 653
 	{
654 654
 
655 655
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
656
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
656
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
657 657
 
658 658
 		try {
659 659
 			$sth = $this->db->prepare($query);
@@ -666,17 +666,17 @@  discard block
 block discarded – undo
666 666
 
667 667
 	}
668 668
 	/**
669
-	* Update latest marine data
670
-	*
671
-	* @param String $fammarine_id the ID
672
-	* @param String $ident the marine ident
673
-	* @return String success or false
674
-	*
675
-	*/	
669
+	 * Update latest marine data
670
+	 *
671
+	 * @param String $fammarine_id the ID
672
+	 * @param String $ident the marine ident
673
+	 * @return String success or false
674
+	 *
675
+	 */	
676 676
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
677 677
 	{
678 678
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
679
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
679
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
680 680
 
681 681
 		try {
682 682
 			$sth = $this->db->prepare($query);
@@ -690,30 +690,30 @@  discard block
 block discarded – undo
690 690
 	}
691 691
 
692 692
 	/**
693
-	* Adds a new spotter data
694
-	*
695
-	* @param String $fammarine_id the ID
696
-	* @param String $ident the marine ident
697
-	* @param String $departure_airport_icao the departure airport
698
-	* @param String $arrival_airport_icao the arrival airport
699
-	* @param String $latitude latitude of flight
700
-	* @param String $longitude latitude of flight
701
-	* @param String $waypoints waypoints of flight
702
-	* @param String $heading heading of flight
703
-	* @param String $groundspeed speed of flight
704
-	* @param String $date date of flight
705
-	* @param String $departure_airport_time departure time of flight
706
-	* @param String $arrival_airport_time arrival time of flight
707
-	* @param String $squawk squawk code of flight
708
-	* @param String $route_stop route stop of flight
709
-	* @param String $highlight highlight or not
710
-	* @param String $ModeS ModesS code of flight
711
-	* @param String $registration registration code of flight
712
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
713
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
714
-	* @param String $verticalrate vertival rate of flight
715
-	* @return String success or false
716
-	*/
693
+	 * Adds a new spotter data
694
+	 *
695
+	 * @param String $fammarine_id the ID
696
+	 * @param String $ident the marine ident
697
+	 * @param String $departure_airport_icao the departure airport
698
+	 * @param String $arrival_airport_icao the arrival airport
699
+	 * @param String $latitude latitude of flight
700
+	 * @param String $longitude latitude of flight
701
+	 * @param String $waypoints waypoints of flight
702
+	 * @param String $heading heading of flight
703
+	 * @param String $groundspeed speed of flight
704
+	 * @param String $date date of flight
705
+	 * @param String $departure_airport_time departure time of flight
706
+	 * @param String $arrival_airport_time arrival time of flight
707
+	 * @param String $squawk squawk code of flight
708
+	 * @param String $route_stop route stop of flight
709
+	 * @param String $highlight highlight or not
710
+	 * @param String $ModeS ModesS code of flight
711
+	 * @param String $registration registration code of flight
712
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
713
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
714
+	 * @param String $verticalrate vertival rate of flight
715
+	 * @return String success or false
716
+	 */
717 717
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '', $captain_id = '',$captain_name = '',$race_id = '', $race_name = '')
718 718
 	{
719 719
 		global $globalURL, $globalMarineImageFetch;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 			$sth->execute($query_values);
833 833
 			$this->db = null;
834 834
 		} catch (PDOException $e) {
835
-		    return "error : ".$e->getMessage();
835
+			return "error : ".$e->getMessage();
836 836
 		}
837 837
 		
838 838
 		return "success";
@@ -841,11 +841,11 @@  discard block
 block discarded – undo
841 841
 	
842 842
   
843 843
 	/**
844
-	* Gets the aircraft ident within the last hour
845
-	*
846
-	* @return String the ident
847
-	*
848
-	*/
844
+	 * Gets the aircraft ident within the last hour
845
+	 *
846
+	 * @return String the ident
847
+	 *
848
+	 */
849 849
 	public function getIdentFromLastHour($ident)
850 850
 	{
851 851
 		global $globalDBdriver, $globalTimezone;
@@ -861,11 +861,11 @@  discard block
 block discarded – undo
861 861
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
862 862
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
863 863
 			$query_data = array(':ident' => $ident);
864
-    		}
864
+			}
865 865
 		
866 866
 		$sth = $this->db->prepare($query);
867 867
 		$sth->execute($query_data);
868
-    		$ident_result='';
868
+			$ident_result='';
869 869
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
870 870
 		{
871 871
 			$ident_result = $row['ident'];
@@ -876,11 +876,11 @@  discard block
 block discarded – undo
876 876
 	
877 877
 	
878 878
 	/**
879
-	* Gets the aircraft data from the last 20 seconds
880
-	*
881
-	* @return Array the spotter data
882
-	*
883
-	*/
879
+	 * Gets the aircraft data from the last 20 seconds
880
+	 *
881
+	 * @return Array the spotter data
882
+	 *
883
+	 */
884 884
 	public function getRealTimeData($q = '')
885 885
 	{
886 886
 		global $globalDBdriver;
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 	
919 919
 
920 920
 	/**
921
-	* Gets all number of flight over countries
922
-	*
923
-	* @return Array the airline country list
924
-	*
925
-	*/
921
+	 * Gets all number of flight over countries
922
+	 *
923
+	 * @return Array the airline country list
924
+	 *
925
+	 */
926 926
 
927 927
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
928 928
 	{
@@ -995,11 +995,11 @@  discard block
 block discarded – undo
995 995
 	
996 996
 	
997 997
 	/**
998
-	* Gets all callsigns that have flown over
999
-	*
1000
-	* @return Array the callsign list
1001
-	*
1002
-	*/
998
+	 * Gets all callsigns that have flown over
999
+	 *
1000
+	 * @return Array the callsign list
1001
+	 *
1002
+	 */
1003 1003
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
1004 1004
 	{
1005 1005
 		global $globalDBdriver;
@@ -1066,11 +1066,11 @@  discard block
 block discarded – undo
1066 1066
 
1067 1067
 
1068 1068
 	/**
1069
-	* Counts all dates
1070
-	*
1071
-	* @return Array the date list
1072
-	*
1073
-	*/
1069
+	 * Counts all dates
1070
+	 *
1071
+	 * @return Array the date list
1072
+	 *
1073
+	 */
1074 1074
 	public function countAllDates($filters = array())
1075 1075
 	{
1076 1076
 		global $globalTimezone, $globalDBdriver;
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
 	
1117 1117
 	
1118 1118
 	/**
1119
-	* Counts all dates during the last 7 days
1120
-	*
1121
-	* @return Array the date list
1122
-	*
1123
-	*/
1119
+	 * Counts all dates during the last 7 days
1120
+	 *
1121
+	 * @return Array the date list
1122
+	 *
1123
+	 */
1124 1124
 	public function countAllDatesLast7Days($filters = array())
1125 1125
 	{
1126 1126
 		global $globalTimezone, $globalDBdriver;
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 			$query .= " GROUP BY date_name 
1143 1143
 								ORDER BY date_name ASC";
1144 1144
 			$query_data = array(':offset' => $offset);
1145
-    		}
1145
+			}
1146 1146
 		
1147 1147
 		$sth = $this->db->prepare($query);
1148 1148
 		$sth->execute($query_data);
@@ -1162,11 +1162,11 @@  discard block
 block discarded – undo
1162 1162
 	}
1163 1163
 
1164 1164
 	/**
1165
-	* Counts all dates during the last month
1166
-	*
1167
-	* @return Array the date list
1168
-	*
1169
-	*/
1165
+	 * Counts all dates during the last month
1166
+	 *
1167
+	 * @return Array the date list
1168
+	 *
1169
+	 */
1170 1170
 	public function countAllDatesLastMonth($filters = array())
1171 1171
 	{
1172 1172
 		global $globalTimezone, $globalDBdriver;
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 			$query .= " GROUP BY date_name 
1189 1189
 								ORDER BY date_name ASC";
1190 1190
 			$query_data = array(':offset' => $offset);
1191
-    		}
1191
+			}
1192 1192
 		
1193 1193
 		$sth = $this->db->prepare($query);
1194 1194
 		$sth->execute($query_data);
@@ -1210,11 +1210,11 @@  discard block
 block discarded – undo
1210 1210
 
1211 1211
 
1212 1212
 	/**
1213
-	* Counts all month
1214
-	*
1215
-	* @return Array the month list
1216
-	*
1217
-	*/
1213
+	 * Counts all month
1214
+	 *
1215
+	 * @return Array the month list
1216
+	 *
1217
+	 */
1218 1218
 	public function countAllMonths($filters = array())
1219 1219
 	{
1220 1220
 		global $globalTimezone, $globalDBdriver;
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
 	
1260 1260
 
1261 1261
 	/**
1262
-	* Counts all dates during the last year
1263
-	*
1264
-	* @return Array the date list
1265
-	*
1266
-	*/
1262
+	 * Counts all dates during the last year
1263
+	 *
1264
+	 * @return Array the date list
1265
+	 *
1266
+	 */
1267 1267
 	public function countAllMonthsLastYear($filters)
1268 1268
 	{
1269 1269
 		global $globalTimezone, $globalDBdriver;
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 			$query .= " GROUP BY year_name, month_name
1286 1286
 								ORDER BY year_name, month_name ASC";
1287 1287
 			$query_data = array(':offset' => $offset);
1288
-    		}
1288
+			}
1289 1289
 		
1290 1290
 		$sth = $this->db->prepare($query);
1291 1291
 		$sth->execute($query_data);
@@ -1308,11 +1308,11 @@  discard block
 block discarded – undo
1308 1308
 	
1309 1309
 	
1310 1310
 	/**
1311
-	* Counts all hours
1312
-	*
1313
-	* @return Array the hour list
1314
-	*
1315
-	*/
1311
+	 * Counts all hours
1312
+	 *
1313
+	 * @return Array the hour list
1314
+	 *
1315
+	 */
1316 1316
 	public function countAllHours($orderby,$filters = array())
1317 1317
 	{
1318 1318
 		global $globalTimezone, $globalDBdriver;
@@ -1375,11 +1375,11 @@  discard block
 block discarded – undo
1375 1375
 	
1376 1376
 	
1377 1377
 	/**
1378
-	* Counts all hours by date
1379
-	*
1380
-	* @return Array the hour list
1381
-	*
1382
-	*/
1378
+	 * Counts all hours by date
1379
+	 *
1380
+	 * @return Array the hour list
1381
+	 *
1382
+	 */
1383 1383
 	public function countAllHoursByDate($date, $filters = array())
1384 1384
 	{
1385 1385
 		global $globalTimezone, $globalDBdriver;
@@ -1423,11 +1423,11 @@  discard block
 block discarded – undo
1423 1423
 	
1424 1424
 	
1425 1425
 	/**
1426
-	* Counts all hours by a ident/callsign
1427
-	*
1428
-	* @return Array the hour list
1429
-	*
1430
-	*/
1426
+	 * Counts all hours by a ident/callsign
1427
+	 *
1428
+	 * @return Array the hour list
1429
+	 *
1430
+	 */
1431 1431
 	public function countAllHoursByIdent($ident, $filters = array())
1432 1432
 	{
1433 1433
 		global $globalTimezone, $globalDBdriver;
@@ -1472,11 +1472,11 @@  discard block
 block discarded – undo
1472 1472
 	
1473 1473
 	
1474 1474
 	/**
1475
-	* Counts all vessels
1476
-	*
1477
-	* @return Integer the number of vessels
1478
-	*
1479
-	*/
1475
+	 * Counts all vessels
1476
+	 *
1477
+	 * @return Integer the number of vessels
1478
+	 *
1479
+	 */
1480 1480
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1481 1481
 	{
1482 1482
 		global $globalDBdriver;
@@ -1511,11 +1511,11 @@  discard block
 block discarded – undo
1511 1511
 	}
1512 1512
 	
1513 1513
 	/**
1514
-	* Counts all vessel type
1515
-	*
1516
-	* @return Integer the number of vessels
1517
-	*
1518
-	*/
1514
+	 * Counts all vessel type
1515
+	 *
1516
+	 * @return Integer the number of vessels
1517
+	 *
1518
+	 */
1519 1519
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1520 1520
 	{
1521 1521
 		global $globalDBdriver;
@@ -1550,11 +1550,11 @@  discard block
 block discarded – undo
1550 1550
 	
1551 1551
   
1552 1552
 	/**
1553
-	* Counts all hours of today
1554
-	*
1555
-	* @return Array the hour list
1556
-	*
1557
-	*/
1553
+	 * Counts all hours of today
1554
+	 *
1555
+	 * @return Array the hour list
1556
+	 *
1557
+	 */
1558 1558
 	public function countAllHoursFromToday($filters = array())
1559 1559
 	{
1560 1560
 		global $globalTimezone, $globalDBdriver;
@@ -1594,12 +1594,12 @@  discard block
 block discarded – undo
1594 1594
 	}
1595 1595
     
1596 1596
     
1597
-     /**
1598
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1599
-	*
1600
-	* @return Integer the Barrie Spotter ID
1597
+	 /**
1598
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1599
+	  *
1600
+	  * @return Integer the Barrie Spotter ID
1601 1601
 q	*
1602
-	*/
1602
+	  */
1603 1603
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1604 1604
 	{
1605 1605
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1620,13 +1620,13 @@  discard block
 block discarded – undo
1620 1620
   
1621 1621
  
1622 1622
 	/**
1623
-	* Parses a date string
1624
-	*
1625
-	* @param String $dateString the date string
1626
-	* @param String $timezone the timezone of a user
1627
-	* @return Array the time information
1628
-	*
1629
-	*/
1623
+	 * Parses a date string
1624
+	 *
1625
+	 * @param String $dateString the date string
1626
+	 * @param String $timezone the timezone of a user
1627
+	 * @return Array the time information
1628
+	 *
1629
+	 */
1630 1630
 	public function parseDateString($dateString, $timezone = '')
1631 1631
 	{
1632 1632
 		$time_array = array();
@@ -1659,12 +1659,12 @@  discard block
 block discarded – undo
1659 1659
 	}
1660 1660
 	
1661 1661
 	/**
1662
-	* Parses the direction degrees to working
1663
-	*
1664
-	* @param Float $direction the direction in degrees
1665
-	* @return Array the direction information
1666
-	*
1667
-	*/
1662
+	 * Parses the direction degrees to working
1663
+	 *
1664
+	 * @param Float $direction the direction in degrees
1665
+	 * @return Array the direction information
1666
+	 *
1667
+	 */
1668 1668
 	public function parseDirection($direction = 0)
1669 1669
 	{
1670 1670
 		if ($direction == '') $direction = 0;
@@ -1743,12 +1743,12 @@  discard block
 block discarded – undo
1743 1743
 	
1744 1744
 	
1745 1745
 	/**
1746
-	* Gets Country from latitude/longitude
1747
-	*
1748
-	* @param Float $latitude latitute of the flight
1749
-	* @param Float $longitude longitute of the flight
1750
-	* @return String the countrie
1751
-	*/
1746
+	 * Gets Country from latitude/longitude
1747
+	 *
1748
+	 * @param Float $latitude latitute of the flight
1749
+	 * @param Float $longitude longitute of the flight
1750
+	 * @return String the countrie
1751
+	 */
1752 1752
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1753 1753
 	{
1754 1754
 		global $globalDBdriver, $globalDebug;
@@ -1785,11 +1785,11 @@  discard block
 block discarded – undo
1785 1785
 	}
1786 1786
 
1787 1787
 	/**
1788
-	* Gets Country from iso2
1789
-	*
1790
-	* @param String $iso2 ISO2 country code
1791
-	* @return String the countrie
1792
-	*/
1788
+	 * Gets Country from iso2
1789
+	 *
1790
+	 * @param String $iso2 ISO2 country code
1791
+	 * @return String the countrie
1792
+	 */
1793 1793
 	public function getCountryFromISO2($iso2)
1794 1794
 	{
1795 1795
 		global $globalDBdriver, $globalDebug;
@@ -1818,12 +1818,12 @@  discard block
 block discarded – undo
1818 1818
 
1819 1819
 	
1820 1820
 	/**
1821
-	* Gets the short url from bit.ly
1822
-	*
1823
-	* @param String $url the full url
1824
-	* @return String the bit.ly url
1825
-	*
1826
-	*/
1821
+	 * Gets the short url from bit.ly
1822
+	 *
1823
+	 * @param String $url the full url
1824
+	 * @return String the bit.ly url
1825
+	 *
1826
+	 */
1827 1827
 	public function getBitlyURL($url)
1828 1828
 	{
1829 1829
 		global $globalBitlyAccessToken;
@@ -1850,11 +1850,11 @@  discard block
 block discarded – undo
1850 1850
 
1851 1851
 	
1852 1852
 	/**
1853
-	* Gets all vessels types that have flown over
1854
-	*
1855
-	* @return Array the vessel type list
1856
-	*
1857
-	*/
1853
+	 * Gets all vessels types that have flown over
1854
+	 *
1855
+	 * @return Array the vessel type list
1856
+	 *
1857
+	 */
1858 1858
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1859 1859
 	{
1860 1860
 		global $globalDBdriver;
@@ -1920,11 +1920,11 @@  discard block
 block discarded – undo
1920 1920
 	}
1921 1921
 
1922 1922
 	/**
1923
-	* Gets all the tracker information
1924
-	*
1925
-	* @return Array the tracker information
1926
-	*
1927
-	*/
1923
+	 * Gets all the tracker information
1924
+	 *
1925
+	 * @return Array the tracker information
1926
+	 *
1927
+	 */
1928 1928
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1929 1929
 	{
1930 1930
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
Braces   +218 added lines, -77 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -78,8 +82,11 @@  discard block
 block discarded – undo
78 82
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
79 83
 			}
80 84
 		}
81
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
82
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
85
+		if ($filter_query_where == '' && $where) {
86
+			$filter_query_where = ' WHERE';
87
+		} elseif ($filter_query_where != '' && $and) {
88
+			$filter_query_where .= ' AND';
89
+		}
83 90
 		if ($filter_query_where != '') {
84 91
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
85 92
 		}
@@ -133,39 +140,75 @@  discard block
 block discarded – undo
133 140
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
134 141
 			} elseif (isset($row['spotter_archive_output_id'])) {
135 142
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
136
-			*/} 
137
-			elseif (isset($row['marineid'])) {
143
+			*/} elseif (isset($row['marineid'])) {
138 144
 				$temp_array['marine_id'] = $row['marineid'];
139 145
 			} else {
140 146
 				$temp_array['marine_id'] = '';
141 147
 			}
142
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
143
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
144
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
145
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
146
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
147
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
148
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
149
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
150
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
151
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
152
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
153
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
154
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
155
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
156
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
148
+			if (isset($row['fammarine_id'])) {
149
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
150
+			}
151
+			if (isset($row['mmsi'])) {
152
+				$temp_array['mmsi'] = $row['mmsi'];
153
+			}
154
+			if (isset($row['type'])) {
155
+				$temp_array['type'] = $row['type'];
156
+			}
157
+			if (isset($row['type_id'])) {
158
+				$temp_array['type_id'] = $row['type_id'];
159
+			}
160
+			if (isset($row['status'])) {
161
+				$temp_array['status'] = $row['status'];
162
+			}
163
+			if (isset($row['status_id'])) {
164
+				$temp_array['status_id'] = $row['status_id'];
165
+			}
166
+			if (isset($row['captain_id'])) {
167
+				$temp_array['captain_id'] = $row['captain_id'];
168
+			}
169
+			if (isset($row['captain_name'])) {
170
+				$temp_array['captain_name'] = $row['captain_name'];
171
+			}
172
+			if (isset($row['race_id'])) {
173
+				$temp_array['race_id'] = $row['race_id'];
174
+			}
175
+			if (isset($row['race_name'])) {
176
+				$temp_array['race_name'] = $row['race_name'];
177
+			}
178
+			if (isset($row['ident'])) {
179
+				$temp_array['ident'] = $row['ident'];
180
+			}
181
+			if (isset($row['arrival_port_name'])) {
182
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
183
+			}
184
+			if (isset($row['latitude'])) {
185
+				$temp_array['latitude'] = $row['latitude'];
186
+			}
187
+			if (isset($row['longitude'])) {
188
+				$temp_array['longitude'] = $row['longitude'];
189
+			}
190
+			if (isset($row['format_source'])) {
191
+				$temp_array['format_source'] = $row['format_source'];
192
+			}
157 193
 			if (isset($row['heading'])) {
158 194
 				$temp_array['heading'] = $row['heading'];
159 195
 				$heading_direction = $this->parseDirection($row['heading']);
160
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
196
+				if (isset($heading_direction[0]['direction_fullname'])) {
197
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
198
+				}
199
+			}
200
+			if (isset($row['ground_speed'])) {
201
+				$temp_array['ground_speed'] = $row['ground_speed'];
161 202
 			}
162
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
163 203
 
164 204
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
165 205
 			{
166 206
 				$Image = new Image($this->db);
167
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
168
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
207
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
208
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
209
+				} else {
210
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
211
+				}
169 212
 				unset($Image);
170 213
 				if (count($image_array) > 0) {
171 214
 					$temp_array['image'] = $image_array[0]['image'];
@@ -217,13 +260,21 @@  discard block
 block discarded – undo
217 260
 			}
218 261
 			
219 262
 			$fromsource = NULL;
220
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
221
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
222
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
263
+			if (isset($row['source_name']) && $row['source_name'] != '') {
264
+				$temp_array['source_name'] = $row['source_name'];
265
+			}
266
+			if (isset($row['over_country']) && $row['over_country'] != '') {
267
+				$temp_array['over_country'] = $row['over_country'];
268
+			}
269
+			if (isset($row['distance']) && $row['distance'] != '') {
270
+				$temp_array['distance'] = $row['distance'];
271
+			}
223 272
 			$temp_array['query_number_rows'] = $num_rows;
224 273
 			$spotter_array[] = $temp_array;
225 274
 		}
226
-		if ($num_rows == 0) return array();
275
+		if ($num_rows == 0) {
276
+			return array();
277
+		}
227 278
 		$spotter_array[0]['query_number_rows'] = $num_rows;
228 279
 		return $spotter_array;
229 280
 	}	
@@ -249,8 +300,12 @@  discard block
 block discarded – undo
249 300
 			{
250 301
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
251 302
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
252
-			} else $limit_query = "";
253
-		} else $limit_query = "";
303
+			} else {
304
+				$limit_query = "";
305
+			}
306
+		} else {
307
+			$limit_query = "";
308
+		}
254 309
 		if ($sort != "")
255 310
 		{
256 311
 			$search_orderby_array = $this->getOrderBy();
@@ -274,7 +329,9 @@  discard block
 block discarded – undo
274 329
 		global $global_query;
275 330
 		
276 331
 		date_default_timezone_set('UTC');
277
-		if ($id == '') return array();
332
+		if ($id == '') {
333
+			return array();
334
+		}
278 335
 		$additional_query = "marine_output.fammarine_id = :id";
279 336
 		$query_values = array(':id' => $id);
280 337
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -470,8 +527,11 @@  discard block
 block discarded – undo
470 527
 		$query .= " ORDER BY marine_output.source_name ASC";
471 528
 
472 529
 		$sth = $this->db->prepare($query);
473
-		if (!empty($query_values)) $sth->execute($query_values);
474
-		else $sth->execute();
530
+		if (!empty($query_values)) {
531
+			$sth->execute($query_values);
532
+		} else {
533
+			$sth->execute();
534
+		}
475 535
 
476 536
 		$source_array = array();
477 537
 		$temp_array = array();
@@ -526,8 +586,11 @@  discard block
 block discarded – undo
526 586
 		$sth = $this->db->prepare($query);
527 587
 		$sth->execute(array(':mmsi' => $mmsi));
528 588
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
529
-		if (isset($result[0])) return $result[0];
530
-		else return array();
589
+		if (isset($result[0])) {
590
+			return $result[0];
591
+		} else {
592
+			return array();
593
+		}
531 594
 	}
532 595
 
533 596
 	/**
@@ -568,7 +631,9 @@  discard block
 block discarded – undo
568 631
 			date_default_timezone_set($globalTimezone);
569 632
 			$datetime = new DateTime();
570 633
 			$offset = $datetime->format('P');
571
-		} else $offset = '+00:00';
634
+		} else {
635
+			$offset = '+00:00';
636
+		}
572 637
 
573 638
 		if ($globalDBdriver == 'mysql') {
574 639
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -818,11 +883,21 @@  discard block
 block discarded – undo
818 883
 			$latitude = 0;
819 884
 			$longitude = 0;
820 885
 		}
821
-		if ($type_id == '') $type_id = NULL;
822
-		if ($status_id == '') $status_id = NULL;
823
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
824
-		if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
825
-		if ($arrival_date == '') $arrival_date = NULL;
886
+		if ($type_id == '') {
887
+			$type_id = NULL;
888
+		}
889
+		if ($status_id == '') {
890
+			$status_id = NULL;
891
+		}
892
+		if ($heading == '' || $Common->isInteger($heading) === false) {
893
+			$heading = 0;
894
+		}
895
+		if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
896
+			$groundspeed = 0;
897
+		}
898
+		if ($arrival_date == '') {
899
+			$arrival_date = NULL;
900
+		}
826 901
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name) 
827 902
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name)";
828 903
 
@@ -929,7 +1004,9 @@  discard block
 block discarded – undo
929 1004
 		global $globalDBdriver, $globalArchive;
930 1005
 		//$filter_query = $this->getFilter($filters,true,true);
931 1006
 		$Connection= new Connection($this->db);
932
-		if (!$Connection->tableExists('countries')) return array();
1007
+		if (!$Connection->tableExists('countries')) {
1008
+			return array();
1009
+		}
933 1010
 		require_once('class.SpotterLive.php');
934 1011
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
935 1012
 			$MarineLive = new MarineLive($this->db);
@@ -973,7 +1050,9 @@  discard block
 block discarded – undo
973 1050
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
974 1051
 		}
975 1052
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
976
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1053
+		if ($limit) {
1054
+			$query .= " LIMIT 10 OFFSET 0";
1055
+		}
977 1056
 
978 1057
 		$sth = $this->db->prepare($query);
979 1058
 		$sth->execute();
@@ -1007,12 +1086,18 @@  discard block
 block discarded – undo
1007 1086
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1008 1087
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1009 1088
 		 if ($olderthanmonths > 0) {
1010
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1011
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1089
+			if ($globalDBdriver == 'mysql') {
1090
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1091
+			} else {
1092
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1093
+			}
1012 1094
 		}
1013 1095
 		if ($sincedate != '') {
1014
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1015
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1096
+			if ($globalDBdriver == 'mysql') {
1097
+				$query .= " AND marine_output.date > '".$sincedate."'";
1098
+			} else {
1099
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1100
+			}
1016 1101
 		}
1017 1102
 		$query_values = array();
1018 1103
 		if ($year != '') {
@@ -1043,7 +1128,9 @@  discard block
 block discarded – undo
1043 1128
 			}
1044 1129
 		}
1045 1130
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1046
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1131
+		if ($limit) {
1132
+			$query .= " LIMIT 10 OFFSET 0";
1133
+		}
1047 1134
       		
1048 1135
 		$sth = $this->db->prepare($query);
1049 1136
 		$sth->execute($query_values);
@@ -1078,7 +1165,9 @@  discard block
 block discarded – undo
1078 1165
 			date_default_timezone_set($globalTimezone);
1079 1166
 			$datetime = new DateTime();
1080 1167
 			$offset = $datetime->format('P');
1081
-		} else $offset = '+00:00';
1168
+		} else {
1169
+			$offset = '+00:00';
1170
+		}
1082 1171
 
1083 1172
 		if ($globalDBdriver == 'mysql') {
1084 1173
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1128,7 +1217,9 @@  discard block
 block discarded – undo
1128 1217
 			date_default_timezone_set($globalTimezone);
1129 1218
 			$datetime = new DateTime();
1130 1219
 			$offset = $datetime->format('P');
1131
-		} else $offset = '+00:00';
1220
+		} else {
1221
+			$offset = '+00:00';
1222
+		}
1132 1223
 		$filter_query = $this->getFilter($filters,true,true);
1133 1224
 		if ($globalDBdriver == 'mysql') {
1134 1225
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1174,7 +1265,9 @@  discard block
 block discarded – undo
1174 1265
 			date_default_timezone_set($globalTimezone);
1175 1266
 			$datetime = new DateTime();
1176 1267
 			$offset = $datetime->format('P');
1177
-		} else $offset = '+00:00';
1268
+		} else {
1269
+			$offset = '+00:00';
1270
+		}
1178 1271
 		$filter_query = $this->getFilter($filters,true,true);
1179 1272
 		if ($globalDBdriver == 'mysql') {
1180 1273
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1222,7 +1315,9 @@  discard block
 block discarded – undo
1222 1315
 			date_default_timezone_set($globalTimezone);
1223 1316
 			$datetime = new DateTime();
1224 1317
 			$offset = $datetime->format('P');
1225
-		} else $offset = '+00:00';
1318
+		} else {
1319
+			$offset = '+00:00';
1320
+		}
1226 1321
 
1227 1322
 		if ($globalDBdriver == 'mysql') {
1228 1323
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1271,7 +1366,9 @@  discard block
 block discarded – undo
1271 1366
 			date_default_timezone_set($globalTimezone);
1272 1367
 			$datetime = new DateTime();
1273 1368
 			$offset = $datetime->format('P');
1274
-		} else $offset = '+00:00';
1369
+		} else {
1370
+			$offset = '+00:00';
1371
+		}
1275 1372
 		$filter_query = $this->getFilter($filters,true,true);
1276 1373
 		if ($globalDBdriver == 'mysql') {
1277 1374
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1320,7 +1417,9 @@  discard block
 block discarded – undo
1320 1417
 			date_default_timezone_set($globalTimezone);
1321 1418
 			$datetime = new DateTime();
1322 1419
 			$offset = $datetime->format('P');
1323
-		} else $offset = '+00:00';
1420
+		} else {
1421
+			$offset = '+00:00';
1422
+		}
1324 1423
 
1325 1424
 		$orderby_sql = '';
1326 1425
 		if ($orderby == "hour")
@@ -1389,7 +1488,9 @@  discard block
 block discarded – undo
1389 1488
 			date_default_timezone_set($globalTimezone);
1390 1489
 			$datetime = new DateTime($date);
1391 1490
 			$offset = $datetime->format('P');
1392
-		} else $offset = '+00:00';
1491
+		} else {
1492
+			$offset = '+00:00';
1493
+		}
1393 1494
 
1394 1495
 		if ($globalDBdriver == 'mysql') {
1395 1496
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1437,7 +1538,9 @@  discard block
 block discarded – undo
1437 1538
 			date_default_timezone_set($globalTimezone);
1438 1539
 			$datetime = new DateTime();
1439 1540
 			$offset = $datetime->format('P');
1440
-		} else $offset = '+00:00';
1541
+		} else {
1542
+			$offset = '+00:00';
1543
+		}
1441 1544
 
1442 1545
 		if ($globalDBdriver == 'mysql') {
1443 1546
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1502,8 +1605,11 @@  discard block
 block discarded – undo
1502 1605
 				$query_values = array_merge($query_values,array(':month' => $month));
1503 1606
 			}
1504 1607
 		}
1505
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1506
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1608
+		if (empty($query_values)) {
1609
+			$queryi .= $this->getFilter($filters);
1610
+		} else {
1611
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1612
+		}
1507 1613
 		
1508 1614
 		$sth = $this->db->prepare($queryi);
1509 1615
 		$sth->execute($query_values);
@@ -1540,8 +1646,11 @@  discard block
 block discarded – undo
1540 1646
 				$query_values = array_merge($query_values,array(':month' => $month));
1541 1647
 			}
1542 1648
 		}
1543
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1544
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1649
+		if (empty($query_values)) {
1650
+			$queryi .= $this->getFilter($filters);
1651
+		} else {
1652
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1653
+		}
1545 1654
 		
1546 1655
 		$sth = $this->db->prepare($queryi);
1547 1656
 		$sth->execute($query_values);
@@ -1563,7 +1672,9 @@  discard block
 block discarded – undo
1563 1672
 			date_default_timezone_set($globalTimezone);
1564 1673
 			$datetime = new DateTime();
1565 1674
 			$offset = $datetime->format('P');
1566
-		} else $offset = '+00:00';
1675
+		} else {
1676
+			$offset = '+00:00';
1677
+		}
1567 1678
 
1568 1679
 		if ($globalDBdriver == 'mysql') {
1569 1680
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1667,7 +1778,9 @@  discard block
 block discarded – undo
1667 1778
 	*/
1668 1779
 	public function parseDirection($direction = 0)
1669 1780
 	{
1670
-		if ($direction == '') $direction = 0;
1781
+		if ($direction == '') {
1782
+			$direction = 0;
1783
+		}
1671 1784
 		$direction_array = array();
1672 1785
 		$temp_array = array();
1673 1786
 
@@ -1756,7 +1869,9 @@  discard block
 block discarded – undo
1756 1869
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1757 1870
 	
1758 1871
 		$Connection = new Connection($this->db);
1759
-		if (!$Connection->tableExists('countries')) return '';
1872
+		if (!$Connection->tableExists('countries')) {
1873
+			return '';
1874
+		}
1760 1875
 	
1761 1876
 		try {
1762 1877
 			/*
@@ -1776,9 +1891,13 @@  discard block
 block discarded – undo
1776 1891
 			$sth->closeCursor();
1777 1892
 			if (count($row) > 0) {
1778 1893
 				return $row;
1779
-			} else return '';
1894
+			} else {
1895
+				return '';
1896
+			}
1780 1897
 		} catch (PDOException $e) {
1781
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1898
+			if (isset($globalDebug) && $globalDebug) {
1899
+				echo 'Error : '.$e->getMessage()."\n";
1900
+			}
1782 1901
 			return '';
1783 1902
 		}
1784 1903
 	
@@ -1796,7 +1915,9 @@  discard block
 block discarded – undo
1796 1915
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1797 1916
 	
1798 1917
 		$Connection = new Connection($this->db);
1799
-		if (!$Connection->tableExists('countries')) return '';
1918
+		if (!$Connection->tableExists('countries')) {
1919
+			return '';
1920
+		}
1800 1921
 	
1801 1922
 		try {
1802 1923
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1808,9 +1929,13 @@  discard block
 block discarded – undo
1808 1929
 			$sth->closeCursor();
1809 1930
 			if (count($row) > 0) {
1810 1931
 				return $row;
1811
-			} else return '';
1932
+			} else {
1933
+				return '';
1934
+			}
1812 1935
 		} catch (PDOException $e) {
1813
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1936
+			if (isset($globalDebug) && $globalDebug) {
1937
+				echo 'Error : '.$e->getMessage()."\n";
1938
+			}
1814 1939
 			return '';
1815 1940
 		}
1816 1941
 	
@@ -1828,7 +1953,9 @@  discard block
 block discarded – undo
1828 1953
 	{
1829 1954
 		global $globalBitlyAccessToken;
1830 1955
 		
1831
-		if ($globalBitlyAccessToken == '') return $url;
1956
+		if ($globalBitlyAccessToken == '') {
1957
+			return $url;
1958
+		}
1832 1959
         
1833 1960
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1834 1961
 		
@@ -1904,7 +2031,9 @@  discard block
 block discarded – undo
1904 2031
 			}
1905 2032
 		}
1906 2033
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
1907
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2034
+		if ($limit) {
2035
+			$query .= " LIMIT 10 OFFSET 0";
2036
+		}
1908 2037
 		$sth = $this->db->prepare($query);
1909 2038
 		$sth->execute($query_values);
1910 2039
 		$marine_array = array();
@@ -1942,9 +2071,15 @@  discard block
 block discarded – undo
1942 2071
 				foreach ($q_array as $q_item){
1943 2072
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1944 2073
 					$additional_query .= " AND (";
1945
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1946
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1947
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2074
+					if (is_int($q_item)) {
2075
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2076
+					}
2077
+					if (is_int($q_item)) {
2078
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2079
+					}
2080
+					if (is_int($q_item)) {
2081
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2082
+					}
1948 2083
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
1949 2084
 					$additional_query .= ")";
1950 2085
 				}
@@ -1992,7 +2127,9 @@  discard block
 block discarded – undo
1992 2127
 				date_default_timezone_set($globalTimezone);
1993 2128
 				$datetime = new DateTime();
1994 2129
 				$offset = $datetime->format('P');
1995
-			} else $offset = '+00:00';
2130
+			} else {
2131
+				$offset = '+00:00';
2132
+			}
1996 2133
 			if ($date_array[1] != "")
1997 2134
 			{
1998 2135
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2019,8 +2156,12 @@  discard block
 block discarded – undo
2019 2156
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2020 2157
 			{
2021 2158
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2022
-			} else $limit_query = "";
2023
-		} else $limit_query = "";
2159
+			} else {
2160
+				$limit_query = "";
2161
+			}
2162
+		} else {
2163
+			$limit_query = "";
2164
+		}
2024 2165
 		if ($sort != "")
2025 2166
 		{
2026 2167
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     <?php }; if (isset($globalSatellite) && $globalSatellite) { ?><td><div id="ibxsatellite"><h4><?php echo _("Satellites Displayed"); ?></h4><br /><i class="fa fa-spinner fa-pulse fa-fw"></i></div></td><?php } ?>
51 51
 </tr></table></div>
52 52
 <?php
53
-    if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
53
+	if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
54 54
 ?>
55 55
 <script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
56 56
 <?php
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 <script src="<?php echo $globalURL; ?>/js/map-marine.3d.js.php"></script>
75 75
 <?php
76 76
 	}
77
-    }
77
+	}
78 78
 ?>
79 79
 
80 80
 <div id="sidebar" class="sidebar collapsed">
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 	<li><a href="" onclick="getUserLocation(); return false;" title="<?php echo _("Plot your Location"); ?>"><i class="fa fa-map-marker"></i></a></li>
86 86
 	<li><a href="" onclick="getCompassDirection(); return false;" title="<?php echo _("Compass Mode"); ?>"><i class="fa fa-compass"></i></a></li>
87 87
 <?php
88
-    //if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
88
+	//if ((isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') || (isset($globalBeta) && $globalBeta === TRUE)) {
89 89
 	if (isset($globalArchive) && $globalArchive == TRUE && (!isset($globalAircraft) || $globalAircraft === TRUE)) {
90 90
 ?>
91 91
 	<li><a href="#archive" role="tab" title="<?php echo _("Archive"); ?>"><i class="fa fa-archive"></i></a></li>
92 92
 <?php
93 93
 	}
94
-    //}
94
+	//}
95 95
 ?>
96 96
 	<li><a href="#home" role="tab" title="<?php echo _("Layers"); ?>"><i class="fa fa-map"></i></a></li>
97 97
 	<li><a href="#filters" role="tab" title="<?php echo _("Filters"); ?>"><i class="fa fa-filter"></i></a></li>
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 ?>
106 106
 
107 107
 <?php
108
-    if (isset($globalMap3D) && $globalMap3D) {
108
+	if (isset($globalMap3D) && $globalMap3D) {
109 109
 	if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
110 110
 ?>
111 111
 	<li><a href="" onclick="show3D(); return false;" role="tab" title="3D"><b>3D</b></a></li>
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	<li><a href="" onclick="show2D(); return false;" role="tab" title="2D"><b>2D</b></a></li>
116 116
 <?php
117 117
 	}
118
-    }
118
+	}
119 119
 ?>
120 120
     </ul>
121 121
 
@@ -264,15 +264,15 @@  discard block
 block discarded – undo
264 264
 		    </div>
265 265
 		</li>
266 266
 		<?php
267
-		    if (isset($globalDemo) && $globalDemo) {
267
+			if (isset($globalDemo) && $globalDemo) {
268 268
 		?>
269 269
 		<li><button type="button" class="btn btn-primary disabled"><?php echo _("Show archive"); ?></button> Disabled in Demo mode</li>
270 270
 		<?php
271
-		    } else {
271
+			} else {
272 272
 		?>
273 273
 		<li><button type="button" onclick="addarchive(begindate,enddate);" class="btn btn-primary"><?php echo _("Show archive"); ?></button></li>
274 274
 		<?php
275
-		    }
275
+			}
276 276
 		?>
277 277
 	    </ul>
278 278
 	    <ul>
@@ -291,83 +291,83 @@  discard block
 block discarded – undo
291 291
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
292 292
 					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
293 293
 					else $MapType = $_COOKIE['MapType'];
294
-			    ?>
294
+				?>
295 295
 			<select  class="selectpicker" onchange="mapType(this);">
296 296
 			    <?php
297 297
 				} else {
298 298
 					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
299 299
 					else $MapType = $_COOKIE['MapType3D'];
300
-			    ?>
300
+				?>
301 301
 			<select  class="selectpicker" onchange="mapType3D(this);">
302 302
 			    <?php
303 303
 				}
304
-			    ?>
304
+				?>
305 305
 			    <?php
306 306
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
307
-			    ?>
307
+				?>
308 308
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
309 309
 			    <?php
310 310
 				} else {
311
-				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
312
-			    ?>
311
+					if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
312
+				?>
313 313
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
314 314
 			    <?php
315
-				    }
316
-			    ?>
315
+					}
316
+				?>
317 317
 			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
318 318
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
319 319
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option>
320 320
 			    <?php
321
-				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
322
-			    ?>
321
+					if (isset($globalBingMapKey) && $globalBingMapKey != '') {
322
+				?>
323 323
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
324 324
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
325 325
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
326 326
 			    <?php
327
-				    }
328
-			    ?>
327
+					}
328
+				?>
329 329
 			    <?php
330
-				    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
331
-			    ?>
330
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
331
+				?>
332 332
 			    <?php
333 333
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
334
-			    ?>
334
+				?>
335 335
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
336 336
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
337 337
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
338 338
 			    <?php
339 339
 					}
340
-			    ?>
340
+				?>
341 341
 			    <?php
342 342
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
343
-			    ?>
343
+				?>
344 344
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
345 345
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
346 346
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
347 347
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
348 348
 			    <?php
349 349
 					}
350
-			    ?>
350
+				?>
351 351
 			    <?php
352 352
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
353
-			    ?>
353
+				?>
354 354
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
355 355
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
356 356
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
357 357
 			    <?php
358 358
 					}
359
-			    ?>
359
+				?>
360 360
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
361 361
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
362 362
 			    <?php
363
-				    }
364
-			    ?>
363
+					}
364
+				?>
365 365
 			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
366 366
 			    <?php
367
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
367
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
368 368
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
369 369
 					else $MapBoxId = $_COOKIE['MapTypeId'];
370
-			    ?>
370
+				?>
371 371
 			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
372 372
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
373 373
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
@@ -382,17 +382,17 @@  discard block
 block discarded – undo
382 382
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
383 383
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
384 384
 			    <?php
385
-				    }
386
-			    ?>
385
+					}
386
+				?>
387 387
 			    <!--<option value="OpenSeaMap"<?php if ($MapType == 'OpenSeaMap') print ' selected'; ?>>OpenSeaMap</option>-->
388 388
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
389 389
 			    <?php
390 390
 				}
391
-			    ?>
391
+				?>
392 392
 			</select>
393 393
 		    </li>
394 394
 <?php
395
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
395
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
396 396
 ?>
397 397
 		    <li><?php echo _("Type of Terrain:"); ?>
398 398
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -403,18 +403,18 @@  discard block
 block discarded – undo
403 403
 			</select>
404 404
 		    </li>
405 405
 <?php
406
-    }
406
+	}
407 407
 ?>
408 408
 
409 409
 <?php
410
-    if (isset($globalMap3D) && $globalMap3D) {
410
+	if (isset($globalMap3D) && $globalMap3D) {
411 411
 ?>
412 412
 		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
413 413
 <?php
414
-    }
414
+	}
415 415
 ?>
416 416
 <?php
417
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
417
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
418 418
 ?>
419 419
 		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
420 420
 
@@ -437,17 +437,17 @@  discard block
 block discarded – undo
437 437
 		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
438 438
 <?php
439 439
 	}
440
-    }
440
+	}
441 441
 ?>
442 442
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
443 443
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
444 444
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
445 445
 <?php
446
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
446
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
447 447
 ?>
448 448
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) print 'checked'; ?> ><?php echo _("Display weather on 3D map"); ?></label></div></li>
449 449
 <?php
450
-    }
450
+	}
451 451
 ?>
452 452
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
453 453
 <?php
@@ -463,82 +463,82 @@  discard block
 block discarded – undo
463 463
 	}
464 464
 ?>
465 465
 <?php
466
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
466
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
467 467
 ?>
468 468
 		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
469 469
 		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li>
470 470
 		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
471 471
 		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
472 472
 <?php
473
-    }
474
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
473
+	}
474
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
475 475
 ?>
476 476
 		    <li><div class="checkbox"><label><input type="checkbox" name="displaysanta" value="1" onclick="clickSanta(this)"><i class="fa fa-snowflake-o" aria-hidden="true"></i> <?php echo _("Show Santa Claus now"); ?> <i class="fa fa-snowflake-o" aria-hidden="true"></i></label></div></li>
477 477
 <?php
478
-    }
478
+	}
479 479
 ?>
480 480
 		    <?php
481 481
 			if (function_exists('array_column')) {
482
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
483
-		    ?>
482
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
483
+			?>
484 484
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
485 485
 		    <?php
486
-			    }
486
+				}
487 487
 			} elseif (isset($globalSources)) {
488
-			    $dispolar = false;
489
-			    foreach ($globalSources as $testsource) {
490
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
491
-			    }
492
-			    if ($dispolar) {
493
-		    ?>
488
+				$dispolar = false;
489
+				foreach ($globalSources as $testsource) {
490
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
491
+				}
492
+				if ($dispolar) {
493
+			?>
494 494
 		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
495 495
 		    <?php
496
-			    }
497
-		        }
498
-		    ?>
496
+				}
497
+				}
498
+			?>
499 499
 <?php
500
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
500
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
501 501
 ?>
502 502
 
503 503
 		    <?php
504 504
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
505
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
506
-		    ?>
505
+					if (extension_loaded('gd') && function_exists('gd_info')) {
506
+			?>
507 507
 		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
508 508
 		    <?php 
509 509
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
510
-		    ?>
510
+			?>
511 511
 			<li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li>
512 512
 		    <?php
513 513
 				}
514
-			    }
515
-		        }
516
-		    ?>
514
+				}
515
+				}
516
+			?>
517 517
 		    <?php
518 518
 			if (isset($globalMarine) && $globalMarine === TRUE) {
519
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
520
-		    ?>
519
+				if (extension_loaded('gd') && function_exists('gd_info')) {
520
+			?>
521 521
 		    <li><?php echo _("Marine icon color:"); ?>
522 522
 			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
523 523
 		    </li>
524 524
 		    <?php
525
-			    }
526
-		        }
527
-		    ?>
525
+				}
526
+				}
527
+			?>
528 528
 		    <?php
529 529
 			if (isset($globalTracker) && $globalTracker === TRUE) {
530
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
531
-		    ?>
530
+				if (extension_loaded('gd') && function_exists('gd_info')) {
531
+			?>
532 532
 		    <li><?php echo _("Tracker icon color:"); ?>
533 533
 			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
534 534
 		    </li>
535 535
 		    <?php
536
-			    }
537
-		        }
538
-		    ?>
536
+				}
537
+				}
538
+			?>
539 539
 		    <?php
540 540
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
541
-		    ?>
541
+			?>
542 542
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
543 543
 			<div class="range">
544 544
 			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
@@ -547,9 +547,9 @@  discard block
 block discarded – undo
547 547
 		    </li>
548 548
 		    <?php
549 549
 			}
550
-		    ?>
550
+			?>
551 551
 <?php
552
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
552
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
553 553
 ?>
554 554
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
555 555
 			<div class="range">
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		    </li>
588 588
 <?php
589 589
 	}
590
-    }
590
+	}
591 591
 ?>
592 592
 		    <li><?php echo _("Distance unit:"); ?>
593 593
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -620,19 +620,19 @@  discard block
 block discarded – undo
620 620
 		    <ul>
621 621
 		    <?php
622 622
 			if (!isset($globalAircraft) || $globalAircraft) {
623
-		    ?>
623
+			?>
624 624
 		    <?php
625 625
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
626
-		    ?>
626
+			?>
627 627
 			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
628 628
 			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
629 629
 			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
630 630
 		    <?php
631 631
 			}
632
-		    ?>
632
+			?>
633 633
 		    <?php
634 634
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
635
-		    ?>
635
+			?>
636 636
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
637 637
 			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
638 638
 			<?php } ?>
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 			<?php } ?>
642 642
 		    <?php
643 643
 			}
644
-		    ?>
644
+			?>
645 645
 		    <li><?php echo _("Display airlines:"); ?>
646 646
 		    <br/>
647 647
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -661,14 +661,14 @@  discard block
 block discarded – undo
661 661
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
662 662
 					}
663 663
 				}
664
-			    ?>
664
+				?>
665 665
 			</select>
666 666
 		    </li>
667 667
 		    <?php
668 668
 			$Spotter = new Spotter();
669 669
 			$allalliancenames = $Spotter->getAllAllianceNames();
670 670
 			if (!empty($allalliancenames)) {
671
-		    ?>
671
+			?>
672 672
 		    <li><?php echo _("Display alliance:"); ?>
673 673
 		    <br/>
674 674
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -682,18 +682,18 @@  discard block
 block discarded – undo
682 682
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
683 683
 					}
684 684
 				}
685
-			    ?>
685
+				?>
686 686
 			</select>
687 687
 		    </li>
688 688
 		    <?php
689 689
 			}
690
-		    ?>
690
+			?>
691 691
 		    <?php
692 692
 			}
693
-		    ?>
693
+			?>
694 694
 		    <?php
695 695
 			if (isset($globalAPRS) && $globalAPRS) {
696
-		    ?>
696
+			?>
697 697
 		    <li><?php echo _("Display APRS sources name:"); ?>
698 698
 			<select class="selectpicker" multiple onchange="sources(this);">
699 699
 			    <?php
@@ -717,18 +717,18 @@  discard block
 block discarded – undo
717 717
 						echo '<option value="'.$src['name'].'">'.$src['name'].'</option>';
718 718
 					}
719 719
 				}
720
-			    ?>
720
+				?>
721 721
 			</select>
722 722
 		    </li>
723 723
 		    <?php
724 724
 			}
725
-		    ?>
725
+			?>
726 726
 		    <?php
727 727
 			if (!isset($globalAircraft) || $globalAircraft) {
728
-		    ?>
728
+			?>
729 729
 		    <?php
730
-			    if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
731
-		    ?>
730
+				if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
731
+			?>
732 732
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
733 733
 			<select class="selectpicker" onchange="airlinestype(this);">
734 734
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -738,14 +738,14 @@  discard block
 block discarded – undo
738 738
 			</select>
739 739
 		    </li>
740 740
 		    <?php
741
-			    }
742
-		    ?>
741
+				}
742
+			?>
743 743
 		    <?php
744 744
 			}
745
-		    ?>
745
+			?>
746 746
 		    <?php
747 747
 			if (isset($globalMarine) && $globalMarine) {
748
-		    ?>
748
+			?>
749 749
 		    <li>
750 750
 			<?php echo _("Display vessels with MMSI:"); ?>
751 751
 			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 						foreach ($races as $race) {
765 765
 							print '<option value="'.$race['race_id'].'">'.$race['race_name'].'</option>';
766 766
 						}
767
-			    ?>
767
+				?>
768 768
 			</select>
769 769
 		    </li>
770 770
 
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
 					}
773 773
 				}
774 774
 			}
775
-		    ?>
775
+			?>
776 776
 		    <li>
777 777
 			<?php echo _("Display with ident:"); ?>
778 778
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	    </form>
786 786
     	</div>
787 787
 <?php
788
-    if (isset($globalSatellite) && $globalSatellite) {
788
+	if (isset($globalSatellite) && $globalSatellite) {
789 789
 ?>
790 790
         <div class="sidebar-pane" id="satellites">
791 791
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -825,14 +825,14 @@  discard block
 block discarded – undo
825 825
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
826 826
 					}
827 827
 				}
828
-			    ?>
828
+				?>
829 829
 			</select>
830 830
 		    </li>
831 831
 		</ul>
832 832
 	    </form>
833 833
 	</div>
834 834
 <?php
835
-    }
835
+	}
836 836
 ?>
837 837
     </div>
838 838
 </div>
Please login to merge, or discard this patch.
Braces   +558 added lines, -141 removed lines patch added patch discarded remove patch
@@ -52,7 +52,10 @@  discard block
 block discarded – undo
52 52
 <?php
53 53
     if ((!isset($_COOKIE['MapFormat']) && isset($globalMap3Ddefault) && $globalMap3Ddefault) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d')) {
54 54
 ?>
55
-<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) print '?tsk='.$tsk; ?>"></script>
55
+<script src="<?php echo $globalURL; ?>/js/map.3d.js.php<?php if (isset($tsk)) {
56
+	print '?tsk='.$tsk;
57
+}
58
+?>"></script>
56 59
 <?php
57 60
 	if (!isset($globalAircraft) || $globalAircraft) {
58 61
 ?>
@@ -148,13 +151,22 @@  discard block
 block discarded – undo
148 151
 <?php
149 152
 		if (!isset($globalAircraft) || $globalAircraft) {
150 153
 ?>
151
-				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') print 'checked'; ?> /><?php echo _("Display waypoints"); ?></label></div></li>
152
-				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') print 'checked'; ?> /><?php echo _("Display airspace"); ?></label></div></li>
154
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
155
+	print 'checked';
156
+}
157
+?> /><?php echo _("Display waypoints"); ?></label></div></li>
158
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
159
+	print 'checked';
160
+}
161
+?> /><?php echo _("Display airspace"); ?></label></div></li>
153 162
 <?php
154 163
 		}
155 164
 		if (isset($globalMarine) && $globalMarine) {
156 165
 ?>
157
-				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="loadOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') print 'checked'; ?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
166
+				<li><div class="checkbox"><label><input type="checkbox" name="openseamap" value="1" onclick="loadOpenSeaMap(this);" <?php if (isset($_COOKIE['openseamap']) && $_COOKIE['openseamap'] == 'true') {
167
+	print 'checked';
168
+}
169
+?> /><?php echo _("Display OpenSeaMap"); ?></label></div></li>
158 170
 <?php
159 171
 		}
160 172
 ?>
@@ -168,8 +180,14 @@  discard block
 block discarded – undo
168 180
 <?php
169 181
 		if (!isset($globalAircraft) || $globalAircraft) {
170 182
 ?>
171
-				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') print 'checked'; ?> /><?php echo _("Display waypoints"); ?> Beta</label></div></li>
172
-				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') print 'checked'; ?> /><?php echo _("Display airspace"); ?> Beta</label></div></li>
183
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
184
+	print 'checked';
185
+}
186
+?> /><?php echo _("Display waypoints"); ?> Beta</label></div></li>
187
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
188
+	print 'checked';
189
+}
190
+?> /><?php echo _("Display airspace"); ?> Beta</label></div></li>
173 191
 <?php
174 192
 		}
175 193
 ?>
@@ -183,14 +201,32 @@  discard block
 block discarded – undo
183 201
 		<h1>NOTAM</h1>
184 202
 		<form>
185 203
 			<ul>
186
-				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam(this);" <?php if (isset($_COOKIE['notam']) && $_COOKIE['notam'] == 'true') print 'checked'; ?> /><?php echo _("Display NOTAM"); ?></label></div></li>
204
+				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam(this);" <?php if (isset($_COOKIE['notam']) && $_COOKIE['notam'] == 'true') {
205
+	print 'checked';
206
+}
207
+?> /><?php echo _("Display NOTAM"); ?></label></div></li>
187 208
 				<li><?php echo _("NOTAM scope:"); ?>
188 209
 					<select class="selectpicker" onchange="notamscope(this);">
189
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
190
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
191
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
192
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
193
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
210
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
211
+	print ' selected';
212
+}
213
+?>>All</option>
214
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
215
+	print ' selected';
216
+}
217
+?>>Airport/Enroute warning</option>
218
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
219
+	print ' selected';
220
+}
221
+?>>Airport warning</option>
222
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
223
+	print ' selected';
224
+}
225
+?>>Navigation warning</option>
226
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
227
+	print ' selected';
228
+}
229
+?>>Enroute warning</option>
194 230
 					</select
195 231
 				</li>
196 232
 			</ul>
@@ -218,7 +254,10 @@  discard block
 block discarded – undo
218 254
 		    <div class="form-group">
219 255
 			<label><?php echo _("From:"); ?></label>
220 256
 			<div class='input-group date' id='datetimepicker1'>
221
-			    <input type='text' id="start_date" name="start_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') print date("Y-m-d H:i",$_COOKIE['archive_begin']).' UTC'; ?>" required />
257
+			    <input type='text' id="start_date" name="start_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') {
258
+	print date("Y-m-d H:i",$_COOKIE['archive_begin']).' UTC';
259
+}
260
+?>" required />
222 261
 			    <span class="input-group-addon">
223 262
 				<span class="glyphicon glyphicon-calendar"></span>
224 263
 			    </span>
@@ -227,7 +266,10 @@  discard block
 block discarded – undo
227 266
 		    <div class="form-group">
228 267
 			<label><?php echo _("To:"); ?></label>
229 268
 			<div class='input-group date' id='datetimepicker2'>
230
-			    <input type='text' id="end_date" name="end_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_end']) && $_COOKIE['archive_end'] != '') print date("Y-m-d H:i",$_COOKIE['archive_end']).' UTC'; ?>" />
269
+			    <input type='text' id="end_date" name="end_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_end']) && $_COOKIE['archive_end'] != '') {
270
+	print date("Y-m-d H:i",$_COOKIE['archive_end']).' UTC';
271
+}
272
+?>" />
231 273
 			    <span class="input-group-addon">
232 274
 				<span class="glyphicon glyphicon-calendar"></span>
233 275
 			    </span>
@@ -259,8 +301,20 @@  discard block
 block discarded – undo
259 301
 		    </script>
260 302
 		<li><?php echo _("Playback speed:"); ?>
261 303
 		    <div class="range">
262
-			<input type="range" min="0" max="50" step="1" id="archivespeed" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
263
-			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
304
+			<input type="range" min="0" max="50" step="1" id="archivespeed" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
305
+	print $_POST['archivespeed'];
306
+} elseif (isset($_COOKIE['archive_speed'])) {
307
+	print $_COOKIE['archive_speed'];
308
+} else {
309
+	print '1';
310
+}
311
+?>">
312
+			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
313
+	print $_COOKIE['archive_speed'];
314
+} else {
315
+	print '1';
316
+}
317
+?></output>
264 318
 		    </div>
265 319
 		</li>
266 320
 		<?php
@@ -289,14 +343,20 @@  discard block
 block discarded – undo
289 343
 		    <li><?php echo _("Type of Map:"); ?>
290 344
 			    <?php
291 345
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
292
-					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
293
-					else $MapType = $_COOKIE['MapType'];
346
+					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
347
+						$MapType = $globalMapProvider;
348
+					} else {
349
+						$MapType = $_COOKIE['MapType'];
350
+					}
294 351
 			    ?>
295 352
 			<select  class="selectpicker" onchange="mapType(this);">
296 353
 			    <?php
297 354
 				} else {
298
-					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
299
-					else $MapType = $_COOKIE['MapType3D'];
355
+					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') {
356
+						$MapType = $globalMapProvider;
357
+					} else {
358
+						$MapType = $_COOKIE['MapType3D'];
359
+					}
300 360
 			    ?>
301 361
 			<select  class="selectpicker" onchange="mapType3D(this);">
302 362
 			    <?php
@@ -305,24 +365,48 @@  discard block
 block discarded – undo
305 365
 			    <?php
306 366
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
307 367
 			    ?>
308
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
368
+			    <option value="offline"<?php if ($MapType == 'offline') {
369
+	print ' selected';
370
+}
371
+?>>Natural Earth (local)</option>
309 372
 			    <?php
310 373
 				} else {
311 374
 				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
312 375
 			    ?>
313
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
376
+			    <option value="offline"<?php if ($MapType == 'offline') {
377
+	print ' selected';
378
+}
379
+?>>Natural Earth (local)</option>
314 380
 			    <?php
315 381
 				    }
316 382
 			    ?>
317
-			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
318
-			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
319
-			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') print ' selected'; ?>>ArcGIS Ocean</option>
383
+			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') {
384
+	print ' selected';
385
+}
386
+?>>ArcGIS Streetmap</option>
387
+			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') {
388
+	print ' selected';
389
+}
390
+?>>ArcGIS Satellite</option>
391
+			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Ocean') {
392
+	print ' selected';
393
+}
394
+?>>ArcGIS Ocean</option>
320 395
 			    <?php
321 396
 				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
322 397
 			    ?>
323
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
324
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
325
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
398
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
399
+	print ' selected';
400
+}
401
+?>>Bing-Aerial</option>
402
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
403
+	print ' selected';
404
+}
405
+?>>Bing-Hybrid</option>
406
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
407
+	print ' selected';
408
+}
409
+?>>Bing-Road</option>
326 410
 			    <?php
327 411
 				    }
328 412
 			    ?>
@@ -332,60 +416,147 @@  discard block
 block discarded – undo
332 416
 			    <?php
333 417
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
334 418
 			    ?>
335
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
336
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
337
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
419
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
420
+	print ' selected';
421
+}
422
+?>>Here-Aerial</option>
423
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
424
+	print ' selected';
425
+}
426
+?>>Here-Hybrid</option>
427
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
428
+	print ' selected';
429
+}
430
+?>>Here-Road</option>
338 431
 			    <?php
339 432
 					}
340 433
 			    ?>
341 434
 			    <?php
342 435
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
343 436
 			    ?>
344
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
345
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
346
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
347
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
437
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
438
+	print ' selected';
439
+}
440
+?>>Google Roadmap</option>
441
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
442
+	print ' selected';
443
+}
444
+?>>Google Satellite</option>
445
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
446
+	print ' selected';
447
+}
448
+?>>Google Hybrid</option>
449
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
450
+	print ' selected';
451
+}
452
+?>>Google Terrain</option>
348 453
 			    <?php
349 454
 					}
350 455
 			    ?>
351 456
 			    <?php
352 457
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
353 458
 			    ?>
354
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
355
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
356
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
459
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
460
+	print ' selected';
461
+}
462
+?>>MapQuest-OSM</option>
463
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
464
+	print ' selected';
465
+}
466
+?>>MapQuest-Aerial</option>
467
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
468
+	print ' selected';
469
+}
470
+?>>MapQuest-Hybrid</option>
357 471
 			    <?php
358 472
 					}
359 473
 			    ?>
360
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
361
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
474
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
475
+	print ' selected';
476
+}
477
+?>>Yandex</option>
478
+			    <option value="offline"<?php if ($MapType == 'offline') {
479
+	print ' selected';
480
+}
481
+?>>Natural Earth</option>
362 482
 			    <?php
363 483
 				    }
364 484
 			    ?>
365
-			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
485
+			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') {
486
+	print ' selected';
487
+}
488
+?>>National Geographic Street</option>
366 489
 			    <?php
367 490
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
368
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
369
-					else $MapBoxId = $_COOKIE['MapTypeId'];
491
+					if (!isset($_COOKIE['MapTypeId'])) {
492
+						$MapBoxId = 'default';
493
+					} else {
494
+						$MapBoxId = $_COOKIE['MapTypeId'];
495
+					}
370 496
 			    ?>
371
-			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
372
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
373
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
374
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
375
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
376
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
377
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
378
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
379
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
380
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
381
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
382
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
383
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
497
+			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') {
498
+	print ' selected';
499
+}
500
+?>>Mapbox GL</option>
501
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
502
+	print ' selected';
503
+}
504
+?>>Mapbox default</option>
505
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
506
+	print ' selected';
507
+}
508
+?>>Mapbox streets</option>
509
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
510
+	print ' selected';
511
+}
512
+?>>Mapbox light</option>
513
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
514
+	print ' selected';
515
+}
516
+?>>Mapbox dark</option>
517
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
518
+	print ' selected';
519
+}
520
+?>>Mapbox satellite</option>
521
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
522
+	print ' selected';
523
+}
524
+?>>Mapbox streets-satellite</option>
525
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
526
+	print ' selected';
527
+}
528
+?>>Mapbox streets-basic</option>
529
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
530
+	print ' selected';
531
+}
532
+?>>Mapbox comic</option>
533
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
534
+	print ' selected';
535
+}
536
+?>>Mapbox outdoors</option>
537
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
538
+	print ' selected';
539
+}
540
+?>>Mapbox pencil</option>
541
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
542
+	print ' selected';
543
+}
544
+?>>Mapbox pirates</option>
545
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
546
+	print ' selected';
547
+}
548
+?>>Mapbox emerald</option>
384 549
 			    <?php
385 550
 				    }
386 551
 			    ?>
387
-			    <!--<option value="OpenSeaMap"<?php if ($MapType == 'OpenSeaMap') print ' selected'; ?>>OpenSeaMap</option>-->
388
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
552
+			    <!--<option value="OpenSeaMap"<?php if ($MapType == 'OpenSeaMap') {
553
+	print ' selected';
554
+}
555
+?>>OpenSeaMap</option>-->
556
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
557
+	print ' selected';
558
+}
559
+?>>OpenStreetMap</option>
389 560
 			    <?php
390 561
 				}
391 562
 			    ?>
@@ -396,10 +567,22 @@  discard block
 block discarded – undo
396 567
 ?>
397 568
 		    <li><?php echo _("Type of Terrain:"); ?>
398 569
 			<select  class="selectpicker" onchange="terrainType(this);">
399
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
400
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
401
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
402
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
570
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
571
+	print ' selected';
572
+}
573
+?>>stk terrain</option>
574
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
575
+	print ' selected';
576
+}
577
+?>>ellipsoid</option>
578
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
579
+	print ' selected';
580
+}
581
+?>>vr terrain</option>
582
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
583
+	print ' selected';
584
+}
585
+?>>ArticDEM</option>
403 586
 			</select>
404 587
 		    </li>
405 588
 <?php
@@ -409,66 +592,126 @@  discard block
 block discarded – undo
409 592
 <?php
410 593
     if (isset($globalMap3D) && $globalMap3D) {
411 594
 ?>
412
-		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') print 'checked'; ?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
595
+		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') {
596
+	print 'checked';
597
+}
598
+?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
413 599
 <?php
414 600
     }
415 601
 ?>
416 602
 <?php
417 603
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
418 604
 ?>
419
-		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') print 'checked'; ?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
605
+		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') {
606
+	print 'checked';
607
+}
608
+?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
420 609
 
421 610
 <?php
422 611
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
423 612
 ?>
424
-		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') print 'checked'; ?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
425
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) print 'checked'; ?> ><?php echo _("Display flight path"); ?></label></div></li>
426
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
427
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) print 'checked'; ?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
428
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
613
+		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
617
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
618
+	print 'checked';
619
+}
620
+?> ><?php echo _("Display flight path"); ?></label></div></li>
621
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)) {
622
+	print 'checked';
623
+}
624
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
625
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightremainingroute" value="1" onclick="clickFlightRemainingRoute(this)" <?php if ((isset($_COOKIE['MapRemainingRoute']) && $_COOKIE['MapRemainingRoute'] == 'true') || (!isset($_COOKIE['MapRemainingRoute']) && isset($globalMapRemainingRoute) && $globalMapRemainingRoute)) {
626
+	print 'checked';
627
+}
628
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
629
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightestimation" value="1" onclick="clickFlightEstimation(this)" <?php if ((isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'true') || (!isset($_COOKIE['flightestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
630
+	print 'checked';
631
+}
632
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
429 633
 <?php
430 634
 	} elseif (!isset($globalTracker) || $globalTracker === TRUE) {
431 635
 ?>
432
-		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) print 'checked'; ?> ><?php echo _("Enable map matching"); ?></label></div></li>
636
+		    <li><div class="checkbox"><label><input type="checkbox" name="mapmatching" value="1" onclick="clickMapMatching(this)" <?php if ((isset($_COOKIE['mapmatching']) && $_COOKIE['mapmatching'] == 'true') || (!isset($_COOKIE['mapmatching']) && isset($globalMapMatching) && $globalMapMatching)) {
637
+	print 'checked';
638
+}
639
+?> ><?php echo _("Enable map matching"); ?></label></div></li>
433 640
 <?php
434 641
 	}
435 642
 	if (isset($globalSatellite) && $globalSatellite === TRUE) {
436 643
 ?>
437
-		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) print 'checked'; ?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
644
+		    <li><div class="checkbox"><label><input type="checkbox" name="satelliteestimation" value="1" onclick="clickSatelliteEstimation(this)" <?php if ((isset($_COOKIE['satelliteestimation']) && $_COOKIE['satelliteestimation'] == 'true') || (!isset($_COOKIE['satelliteestimation']) && !isset($globalMapEstimation)) || (!isset($_COOKIE['satelliteestimation']) && isset($globalMapEstimation) && $globalMapEstimation)) {
645
+	print 'checked';
646
+}
647
+?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
438 648
 <?php
439 649
 	}
440 650
     }
441 651
 ?>
442
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
443
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) print 'checked'; ?> ><?php echo _("Display ground station on map"); ?></label></div></li>
444
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) print 'checked'; ?> ><?php echo _("Display weather station on map"); ?></label></div></li>
652
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true' || !isset($_COOKIE['displayairports'])) {
653
+	print 'checked';
654
+}
655
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
656
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaygroundstation" value="1" onclick="clickDisplayGroundStation(this)" <?php if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') || (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
657
+	print 'checked';
658
+}
659
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
660
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayweatherstation" value="1" onclick="clickDisplayWeatherStation(this)" <?php if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') || (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
661
+	print 'checked';
662
+}
663
+?> ><?php echo _("Display weather station on map"); ?></label></div></li>
445 664
 <?php
446 665
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && isset($globalMETAR) && isset($globalMETARcycle) && $globalMETAR && $globalMETARcycle) {
447 666
 ?>
448
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) print 'checked'; ?> ><?php echo _("Display weather on 3D map"); ?></label></div></li>
667
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayweather" value="1" onclick="clickDisplayWeather(this)" <?php if ((isset($_COOKIE['show_Weather']) && $_COOKIE['show_Weather'] == 'true') || (!isset($_COOKIE['show_Weather']) && (isset($globalMapWeather) && $globalMapWeather === TRUE))) {
668
+	print 'checked';
669
+}
670
+?> ><?php echo _("Display weather on 3D map"); ?></label></div></li>
449 671
 <?php
450 672
     }
451 673
 ?>
452
-		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) print 'checked'; ?> ><?php echo _("Display lightning on map"); ?></label></div></li>
674
+		    <li><div class="checkbox"><label><input type="checkbox" name="displaylightning" value="1" onclick="clickDisplayLightning(this)" <?php if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') || (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
675
+	print 'checked';
676
+}
677
+?> ><?php echo _("Display lightning on map"); ?></label></div></li>
453 678
 <?php
454 679
 	if (isset($globalFires)) {
455 680
 ?>
456
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) print 'checked'; ?> ><?php echo _("Display fires on map"); ?></label></div></li>
681
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayfires" value="1" onclick="clickDisplayFires(this)" <?php if ((isset($_COOKIE['show_Fires']) && $_COOKIE['show_Fires'] == 'true') || (!isset($_COOKIE['show_Fires']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
682
+	print 'checked';
683
+}
684
+?> ><?php echo _("Display fires on map"); ?></label></div></li>
457 685
 <?php
458 686
 	}
459 687
 	if (isset($globalMap3D) && $globalMap3D) {
460 688
 ?>
461
-		    <li><div class="checkbox"><label><input type="checkbox" name="singlemodel" value="1" onclick="clickSingleModel(this)" <?php if (isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') print 'checked'; ?> ><?php echo _("Only display selected flight on 3D mode"); ?></label></div></li>
689
+		    <li><div class="checkbox"><label><input type="checkbox" name="singlemodel" value="1" onclick="clickSingleModel(this)" <?php if (isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') {
690
+	print 'checked';
691
+}
692
+?> ><?php echo _("Only display selected flight on 3D mode"); ?></label></div></li>
462 693
 <?php
463 694
 	}
464 695
 ?>
465 696
 <?php
466 697
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
467 698
 ?>
468
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) print 'checked'; ?> ><?php echo _("Show mini-map"); ?></label></div></li>
469
-		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) print 'checked'; ?> ><?php echo _("Use shadows"); ?></label></div></li>
470
-		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) print 'checked'; ?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
471
-		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) print 'checked'; ?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
699
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayminimap" value="1" onclick="clickDisplayMinimap(this)" <?php if (!isset($_COOKIE['displayminimap']) || (isset($_COOKIE['displayminimap']) && $_COOKIE['displayminimap'] == 'true')) {
700
+	print 'checked';
701
+}
702
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
703
+		    <li><div class="checkbox"><label><input type="checkbox" name="shadows" value="1" onclick="clickShadows(this)" <?php if ((!isset($_COOKIE['map3dnoshadows']) && (!isset($globalMap3DShadows) || $globalMap3DShadows)) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'false')) {
704
+	print 'checked';
705
+}
706
+?> ><?php echo _("Use shadows"); ?></label></div></li>
707
+		    <li><div class="checkbox"><label><input type="checkbox" name="one3dmodel" value="1" onclick="useOne3Dmodel(this)" <?php if ((isset($_COOKIE['one3dmodel']) && $_COOKIE['one3dmodel'] == 'true') || (!isset($_COOKIE['one3dmodel']) && isset($globalMap3DOneModel) && $globalMap3DOneModel)) {
708
+	print 'checked';
709
+}
710
+?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
711
+		    <li><div class="checkbox"><label><input type="checkbox" name="updaterealtime" value="1" onclick="clickUpdateRealtime(this)" <?php if ((isset($_COOKIE['updaterealtime']) && $_COOKIE['updaterealtime'] == 'true') || !isset($_COOKIE['updaterealtime'])) {
712
+	print 'checked';
713
+}
714
+?> ><?php echo _("Display realtime data in infobox"); ?></label></div></li>
472 715
 <?php
473 716
     }
474 717
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -481,17 +724,25 @@  discard block
 block discarded – undo
481 724
 			if (function_exists('array_column')) {
482 725
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
483 726
 		    ?>
484
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
727
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
728
+	print 'checked';
729
+}
730
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
485 731
 		    <?php
486 732
 			    }
487 733
 			} elseif (isset($globalSources)) {
488 734
 			    $dispolar = false;
489 735
 			    foreach ($globalSources as $testsource) {
490
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
736
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
737
+			        	$dispolar = true;
738
+			        }
491 739
 			    }
492 740
 			    if ($dispolar) {
493 741
 		    ?>
494
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) print 'checked'; ?> ><?php echo _("Display polar on map"); ?></label></div></li>
742
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
743
+	print 'checked';
744
+}
745
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
495 746
 		    <?php
496 747
 			    }
497 748
 		        }
@@ -504,11 +755,21 @@  discard block
 block discarded – undo
504 755
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
505 756
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
506 757
 		    ?>
507
-		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') print 'checked'; ?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
758
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
759
+	print 'checked';
760
+}
761
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
508 762
 		    <?php 
509 763
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
510 764
 		    ?>
511
-			<li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print '1a3151'; ?>"></li>
765
+			<li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
766
+	print $_COOKIE['IconColor'];
767
+} elseif (isset($globalAircraftIconColor)) {
768
+	print $globalAircraftIconColor;
769
+} else {
770
+	print '1a3151';
771
+}
772
+?>"></li>
512 773
 		    <?php
513 774
 				}
514 775
 			    }
@@ -519,7 +780,14 @@  discard block
 block discarded – undo
519 780
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
520 781
 		    ?>
521 782
 		    <li><?php echo _("Marine icon color:"); ?>
522
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
783
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
784
+	print $_COOKIE['MarineIconColor'];
785
+} elseif (isset($globalMarineIconColor)) {
786
+	print $globalMarineIconColor;
787
+} else {
788
+	print '1a3151';
789
+}
790
+?>">
523 791
 		    </li>
524 792
 		    <?php
525 793
 			    }
@@ -530,7 +798,14 @@  discard block
 block discarded – undo
530 798
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
531 799
 		    ?>
532 800
 		    <li><?php echo _("Tracker icon color:"); ?>
533
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print '1a3151'; ?>">
801
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
802
+	print $_COOKIE['TrackerIconColor'];
803
+} elseif (isset($globalTrackerIconColor)) {
804
+	print $globalTrackerIconColor;
805
+} else {
806
+	print '1a3151';
807
+}
808
+?>">
534 809
 		    </li>
535 810
 		    <?php
536 811
 			    }
@@ -541,8 +816,22 @@  discard block
 block discarded – undo
541 816
 		    ?>
542 817
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
543 818
 			<div class="range">
544
-			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?>">
545
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
819
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
820
+	print $_COOKIE['AirportZoom'];
821
+} elseif (isset($globalAirportZoom)) {
822
+	print $globalAirportZoom;
823
+} else {
824
+	print '7';
825
+}
826
+?>">
827
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
828
+	print $_COOKIE['AirportZoom'];
829
+} elseif (isset($globalAirportZoom)) {
830
+	print $globalAirportZoom;
831
+} else {
832
+	print '7';
833
+}
834
+?></output>
546 835
 			</div>
547 836
 		    </li>
548 837
 		    <?php
@@ -553,17 +842,40 @@  discard block
 block discarded – undo
553 842
 ?>
554 843
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
555 844
 			<div class="range">
556
-			    <input type="range" min="0.5" max="2" step="0.5" name="resolutionscale" onchange="scale.value=value;resolutionScale(resolutionscale.value);" value="<?php if (isset($_COOKIE['resolutionScale'])) print $_COOKIE['resolutionScale']; else print '1'; ?>">
557
-			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) print $_COOKIE['resolutionScale']; else print '1'; ?></output>
845
+			    <input type="range" min="0.5" max="2" step="0.5" name="resolutionscale" onchange="scale.value=value;resolutionScale(resolutionscale.value);" value="<?php if (isset($_COOKIE['resolutionScale'])) {
846
+	print $_COOKIE['resolutionScale'];
847
+} else {
848
+	print '1';
849
+}
850
+?>">
851
+			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) {
852
+	print $_COOKIE['resolutionScale'];
853
+} else {
854
+	print '1';
855
+}
856
+?></output>
558 857
 			</div>
559 858
 		    </li>
560 859
 <?php
561 860
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
562 861
 ?>
563
-		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') print 'checked'; ?> > <?php echo _("Use airlines liveries"); ?></li>
564
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> > <?php echo _("Force Aircraft color"); ?>&nbsp;
862
+		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') {
863
+	print 'checked';
864
+}
865
+?> > <?php echo _("Use airlines liveries"); ?></li>
866
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
867
+	print 'checked';
868
+}
869
+?> > <?php echo _("Force Aircraft color"); ?>&nbsp;
565 870
 		    <!--<li><?php echo _("Aircraft icon color:"); ?>-->
566
-			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) print $_COOKIE['IconColor']; elseif (isset($globalAircraftIconColor)) print $globalAircraftIconColor; else print 'ff0000'; ?>">
871
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
872
+	print $_COOKIE['IconColor'];
873
+} elseif (isset($globalAircraftIconColor)) {
874
+	print $globalAircraftIconColor;
875
+} else {
876
+	print 'ff0000';
877
+}
878
+?>">
567 879
 		    </li>
568 880
 <?php
569 881
 	}
@@ -571,9 +883,19 @@  discard block
 block discarded – undo
571 883
 <?php
572 884
 	if (isset($globalMarine) && $globalMarine === TRUE) {
573 885
 ?>
574
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?>&nbsp;
886
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
887
+	print 'checked';
888
+}
889
+?> ><?php echo _("Force Marine color"); ?>&nbsp;
575 890
 		    <!--<li><?php echo _("Marine icon color:"); ?>-->
576
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
891
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
892
+	print $_COOKIE['MarineIconColor'];
893
+} elseif (isset($globalMarineIconColor)) {
894
+	print $globalMarineIconColor;
895
+} else {
896
+	print 'ff0000';
897
+}
898
+?>">
577 899
 		    </li>
578 900
 <?php
579 901
 	}
@@ -581,9 +903,19 @@  discard block
 block discarded – undo
581 903
 <?php
582 904
 	if (isset($globalTracker) && $globalTracker === TRUE) {
583 905
 ?>
584
-		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Tracker color"); ?>&nbsp;
906
+		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') {
907
+	print 'checked';
908
+}
909
+?> ><?php echo _("Force Tracker color"); ?>&nbsp;
585 910
 		    <!--<li><?php echo _("Tracker icon color:"); ?>-->
586
-			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) print $_COOKIE['TrackerIconColor']; elseif (isset($globalTrackerIconColor)) print $globalTrackerIconColor; else print 'ff0000'; ?>">
911
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
912
+	print $_COOKIE['TrackerIconColor'];
913
+} elseif (isset($globalTrackerIconColor)) {
914
+	print $globalTrackerIconColor;
915
+} else {
916
+	print 'ff0000';
917
+}
918
+?>">
587 919
 		    </li>
588 920
 <?php
589 921
 	}
@@ -591,22 +923,46 @@  discard block
 block discarded – undo
591 923
 ?>
592 924
 		    <li><?php echo _("Distance unit:"); ?>
593 925
 			<select class="selectpicker" onchange="unitdistance(this);">
594
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
595
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
596
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
926
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
927
+	echo ' selected';
928
+}
929
+?>>km</option>
930
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
931
+	echo ' selected';
932
+}
933
+?>>nm</option>
934
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
935
+	echo ' selected';
936
+}
937
+?>>mi</option>
597 938
 		        </select>
598 939
 		    </li>
599 940
 		    <li><?php echo _("Altitude unit:"); ?>
600 941
 			<select class="selectpicker" onchange="unitaltitude(this);">
601
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
602
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
942
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
943
+	echo ' selected';
944
+}
945
+?>>m</option>
946
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
947
+	echo ' selected';
948
+}
949
+?>>feet</option>
603 950
 		        </select>
604 951
 		    </li>
605 952
 		    <li><?php echo _("Speed unit:"); ?>
606 953
 			<select class="selectpicker" onchange="unitspeed(this);">
607
-			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) echo ' selected'; ?>>km/h</option>
608
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
609
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
954
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
955
+	echo ' selected';
956
+}
957
+?>>km/h</option>
958
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
959
+	echo ' selected';
960
+}
961
+?>>mph</option>
962
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
963
+	echo ' selected';
964
+}
965
+?>>knots</option>
610 966
 		        </select>
611 967
 		    </li>
612 968
 
@@ -624,9 +980,18 @@  discard block
 block discarded – undo
624 980
 		    <?php
625 981
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
626 982
 		    ?>
627
-			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) print 'checked'; ?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
628
-			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) print 'checked'; ?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
629
-			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) print 'checked'; ?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
983
+			<?php if (isset($globalVATSIM) && $globalVATSIM) { ?><li><input type="checkbox" name="vatsim" value="1" onclick="clickVATSIM(this)" <?php if ((isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') || !isset($_COOKIE['ShowVATSIM'])) {
984
+	print 'checked';
985
+}
986
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
987
+			<?php if (isset($globalIVAO) && $globalIVAO) { ?><li><input type="checkbox" name="ivao" value="1" onclick="clickIVAO(this)" <?php if ((isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') || !isset($_COOKIE['ShowIVAO'])) {
988
+	print 'checked';
989
+}
990
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
991
+			<?php if (isset($globalphpVMS) && $globalphpVMS) { ?><li><input type="checkbox" name="phpvms" value="1" onclick="clickphpVMS(this)" <?php if ((isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') || !isset($_COOKIE['ShowVMS'])) {
992
+	print 'checked';
993
+}
994
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
630 995
 		    <?php
631 996
 			}
632 997
 		    ?>
@@ -634,10 +999,16 @@  discard block
 block discarded – undo
634 999
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
635 1000
 		    ?>
636 1001
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
637
-			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) print 'checked'; ?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
1002
+			    <li><div class="checkbox"><label><input type="checkbox" name="sbs" value="1" onclick="clickSBS1(this)" <?php if ((isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') || !isset($_COOKIE['ShowSBS1'])) {
1003
+	print 'checked';
1004
+}
1005
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
638 1006
 			<?php } ?>
639 1007
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
640
-			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) print 'checked'; ?> ><?php echo _("Display APRS data"); ?></label></div></li>
1008
+			    <li><div class="checkbox"><label><input type="checkbox" name="aprs" value="1" onclick="clickAPRS(this)" <?php if ((isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') || !isset($_COOKIE['ShowAPRS'])) {
1009
+	print 'checked';
1010
+}
1011
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
641 1012
 			<?php } ?>
642 1013
 		    <?php
643 1014
 			}
@@ -654,7 +1025,9 @@  discard block
 block discarded – undo
654 1025
 				}
655 1026
 				foreach($allairlinenames as $airline) {
656 1027
 					$airline_name = $airline['airline_name'];
657
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
1028
+					if (strlen($airline_name) > 30) {
1029
+						$airline_name = substr($airline_name,0,30).'...';
1030
+					}
658 1031
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
659 1032
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
660 1033
 					} else {
@@ -672,7 +1045,10 @@  discard block
 block discarded – undo
672 1045
 		    <li><?php echo _("Display alliance:"); ?>
673 1046
 		    <br/>
674 1047
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
675
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
1048
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
1049
+	echo ' selected';
1050
+}
1051
+?>><?php echo _("All"); ?></option>
676 1052
 			    <?php
677 1053
 				foreach($allalliancenames as $alliance) {
678 1054
 					$alliance_name = $alliance['alliance'];
@@ -731,10 +1107,22 @@  discard block
 block discarded – undo
731 1107
 		    ?>
732 1108
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
733 1109
 			<select class="selectpicker" onchange="airlinestype(this);">
734
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
735
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
736
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
737
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
1110
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
1111
+	echo ' selected';
1112
+}
1113
+?>><?php echo _("All"); ?></option>
1114
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
1115
+	echo ' selected';
1116
+}
1117
+?>><?php echo _("Passenger"); ?></option>
1118
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
1119
+	echo ' selected';
1120
+}
1121
+?>><?php echo _("Cargo"); ?></option>
1122
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
1123
+	echo ' selected';
1124
+}
1125
+?>><?php echo _("Military"); ?></option>
738 1126
 			</select>
739 1127
 		    </li>
740 1128
 		    <?php
@@ -748,7 +1136,10 @@  discard block
 block discarded – undo
748 1136
 		    ?>
749 1137
 		    <li>
750 1138
 			<?php echo _("Display vessels with MMSI:"); ?>
751
-			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
1139
+			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) {
1140
+	print $_COOKIE['filter_mmsi'];
1141
+}
1142
+?>" />
752 1143
 		    </li>
753 1144
 			<?php
754 1145
 				if (isset($globalVM) && $globalVM) {
@@ -775,7 +1166,10 @@  discard block
 block discarded – undo
775 1166
 		    ?>
776 1167
 		    <li>
777 1168
 			<?php echo _("Display with ident:"); ?>
778
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
1169
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
1170
+	print $_COOKIE['filter_ident'];
1171
+}
1172
+?>" />
779 1173
 		    </li>
780 1174
 		</ul>
781 1175
 	    </form>
@@ -791,7 +1185,10 @@  discard block
 block discarded – undo
791 1185
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
792 1186
 	    <form>
793 1187
 		<ul>
794
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
1188
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') || !isset($_COOKIE['displayiss'])) {
1189
+	print 'checked';
1190
+}
1191
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
795 1192
 		    <li><?php echo _("Type:"); ?>
796 1193
 			<select class="selectpicker" multiple onchange="sattypes(this);">
797 1194
 			    <?php
@@ -799,25 +1196,45 @@  discard block
 block discarded – undo
799 1196
 				$types = $Satellite->get_tle_types();
800 1197
 				foreach ($types as $type) {
801 1198
 					$type_name = $type['tle_type'];
802
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
803
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
804
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
805
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
806
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
807
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
808
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
809
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
810
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
811
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
812
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
813
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
814
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
815
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
816
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
817
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
818
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
819
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
820
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
1199
+					if ($type_name == 'musson') {
1200
+						$type_name = 'Russian LEO Navigation';
1201
+					} else if ($type_name == 'nnss') {
1202
+						$type_name = 'Navi Navigation Satellite System';
1203
+					} else if ($type_name == 'sbas') {
1204
+						$type_name = 'Satellite-Based Augmentation System';
1205
+					} else if ($type_name == 'glo-ops') {
1206
+						$type_name = 'Glonass Operational';
1207
+					} else if ($type_name == 'gps-ops') {
1208
+						$type_name = 'GPS Operational';
1209
+					} else if ($type_name == 'argos') {
1210
+						$type_name = 'ARGOS Data Collection System';
1211
+					} else if ($type_name == 'tdrss') {
1212
+						$type_name = 'Tracking and Data Relay Satellite System';
1213
+					} else if ($type_name == 'sarsat') {
1214
+						$type_name = 'Search & Rescue';
1215
+					} else if ($type_name == 'dmc') {
1216
+						$type_name = 'Disaster Monitoring';
1217
+					} else if ($type_name == 'resource') {
1218
+						$type_name = 'Earth Resources';
1219
+					} else if ($type_name == 'stations') {
1220
+						$type_name = 'Space Stations';
1221
+					} else if ($type_name == 'geo') {
1222
+						$type_name = 'Geostationary';
1223
+					} else if ($type_name == 'amateur') {
1224
+						$type_name = 'Amateur Radio';
1225
+					} else if ($type_name == 'x-comm') {
1226
+						$type_name = 'Experimental';
1227
+					} else if ($type_name == 'other-comm') {
1228
+						$type_name = 'Other Comm';
1229
+					} else if ($type_name == 'science') {
1230
+						$type_name = 'Space & Earth Science';
1231
+					} else if ($type_name == 'military') {
1232
+						$type_name = 'Miscellaneous Military';
1233
+					} else if ($type_name == 'radar') {
1234
+						$type_name = 'Radar Calibration';
1235
+					} else if ($type_name == 'tle-new') {
1236
+						$type_name = 'Last 30 days launches';
1237
+					}
821 1238
 					
822 1239
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
823 1240
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
live-geojson.php 1 patch
Braces   +336 added lines, -136 removed lines patch added patch discarded remove patch
@@ -12,7 +12,9 @@  discard block
 block discarded – undo
12 12
 $tracker = false;
13 13
 $marine = false;
14 14
 $usecoord = false;
15
-if (isset($_GET['test'])) exit();
15
+if (isset($_GET['test'])) {
16
+	exit();
17
+}
16 18
 if (isset($_GET['tracker'])) {
17 19
     $tracker = true;
18 20
 }
@@ -57,29 +59,58 @@  discard block
 block discarded – undo
57 59
 }
58 60
 header('Content-Type: text/javascript');
59 61
 
60
-if (!isset($globalJsonCompress)) $compress = true;
61
-else $compress = $globalJsonCompress;
62
+if (!isset($globalJsonCompress)) {
63
+	$compress = true;
64
+} else {
65
+	$compress = $globalJsonCompress;
66
+}
62 67
 
63 68
 $from_archive = false;
64 69
 $min = true;
65 70
 $allhistory = false;
66 71
 $filter['source'] = array();
67
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
68
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
69
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
70
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
71
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
72
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
73
-if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') $filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
74
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
75
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
76
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
77
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
78
-if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') $filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_STRING);
72
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') {
73
+	$filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
74
+}
75
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') {
76
+	$filter['source'] = array_merge($filter['source'],array('whazzup'));
77
+}
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') {
79
+	$filter['source'] = array_merge($filter['source'],array('phpvmacars'));
80
+}
81
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') {
82
+	$filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
83
+}
84
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') {
85
+	$filter['source'] = array_merge($filter['source'],array('aprs'));
86
+}
87
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') {
88
+	$filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
89
+}
90
+if (isset($_COOKIE['filter_mmsi']) && $_COOKIE['filter_mmsi'] != '') {
91
+	$filter['mmsi'] = filter_var($_COOKIE['filter_mmsi'],FILTER_SANITIZE_STRING);
92
+}
93
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') {
94
+	$filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
95
+}
96
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') {
97
+	$filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
98
+}
99
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') {
100
+	$filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
101
+}
102
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') {
103
+	$filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
104
+}
105
+if (isset($_COOKIE['filter_race']) && $_COOKIE['filter_race'] != 'all') {
106
+	$filter['race'] = filter_var($_COOKIE['filter_race'],FILTER_SANITIZE_STRING);
107
+}
79 108
 
80 109
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
81 110
 	$min = true;
82
-} else $min = false;
111
+} else {
112
+	$min = false;
113
+}
83 114
 
84 115
 $spotter_array = array();
85 116
 
@@ -190,24 +221,38 @@  discard block
 block discarded – undo
190 221
 			$flightcnt = $SpotterLive->getLiveSpotterCount($filter);
191 222
 		}
192 223
 	}
193
-	if ($flightcnt == '') $flightcnt = 0;
194
-} else $flightcnt = 0;
224
+	if ($flightcnt == '') {
225
+		$flightcnt = 0;
226
+	}
227
+	} else {
228
+	$flightcnt = 0;
229
+}
195 230
 
196 231
 $sqltime = round(microtime(true)-$begintime,2);
197 232
 
198 233
 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
199
-if ($currenttime != '') $currenttime = round($currenttime/1000);
234
+if ($currenttime != '') {
235
+	$currenttime = round($currenttime/1000);
236
+}
200 237
 
201
-if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) $usenextlatlon = false;
202
-else $usenextlatlon = true;
203
-if ($usenextlatlon === false) $currenttime = '';
238
+if ((!isset($_COOKIE['flightestimation']) && isset($globalMapEstimation) && $globalMapEstimation == FALSE) || (isset($_COOKIE['flightestimation']) && $_COOKIE['flightestimation'] == 'false')) {
239
+	$usenextlatlon = false;
240
+} else {
241
+	$usenextlatlon = true;
242
+}
243
+if ($usenextlatlon === false) {
244
+	$currenttime = '';
245
+}
204 246
 $j = 0;
205 247
 $prev_flightaware_id = '';
206 248
 $aircrafts_shadow = array();
207 249
 $output = '{';
208 250
 	$output .= '"type": "FeatureCollection",';
209
-		if ($min) $output .= '"minimal": "true",';
210
-		else $output .= '"minimal": "false",';
251
+		if ($min) {
252
+			$output .= '"minimal": "true",';
253
+		} else {
254
+			$output .= '"minimal": "false",';
255
+		}
211 256
 		//$output .= '"fc": "'.$flightcnt.'",';
212 257
 		$output .= '"sqt": "'.$sqltime.'",';
213 258
 
@@ -252,18 +297,29 @@  discard block
 block discarded – undo
252 297
 						}
253 298
 						$output .= '"properties": {';
254 299
 						if (isset($spotter_item['flightaware_id'])) {
255
-							if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
256
-							else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
300
+							if ($compress) {
301
+								$output .= '"fi": "'.$spotter_item['flightaware_id'].'",';
302
+							} else {
303
+								$output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",';
304
+							}
257 305
 						} elseif (isset($spotter_item['famtrackid'])) {
258
-							if ($compress) $output .= '"fti": "'.$spotter_item['famtrackid'].'",';
259
-							else $output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
306
+							if ($compress) {
307
+								$output .= '"fti": "'.$spotter_item['famtrackid'].'",';
308
+							} else {
309
+								$output .= '"famtrackid": "'.$spotter_item['famtrackid'].'",';
310
+							}
260 311
 						} elseif (isset($spotter_item['fammarine_id'])) {
261
-							if ($compress) $output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
262
-							else $output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
312
+							if ($compress) {
313
+								$output .= '"fmi": "'.$spotter_item['fammarine_id'].'",';
314
+							} else {
315
+								$output .= '"fammarineid": "'.$spotter_item['fammarine_id'].'",';
316
+							}
263 317
 						}
264 318
 						$output .= '"fc": "'.$flightcnt.'",';
265 319
 						$output .= '"sqt": "'.$sqltime.'",';
266
-						if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
320
+						if (isset($begindate)) {
321
+							$output .= '"archive_date": "'.$begindate.'",';
322
+						}
267 323
 
268 324
 /*
269 325
 							if ($min) $output .= '"minimal": "true",';
@@ -271,16 +327,25 @@  discard block
 block discarded – undo
271 327
 */
272 328
 							//$output .= '"fc": "'.$spotter_item['nb'].'",';
273 329
 						if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') {
274
-							if ($compress) $output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
275
-							else $output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
330
+							if ($compress) {
331
+								$output .= '"c": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
332
+							} else {
333
+								$output .= '"callsign": '.json_encode(str_replace('\\','',$spotter_item['ident'])).',';
334
+							}
276 335
 							//'
277 336
 						} else {
278
-							if ($compress) $output .= '"c": "NA",';
279
-							else $output .= '"callsign": "NA",';
337
+							if ($compress) {
338
+								$output .= '"c": "NA",';
339
+							} else {
340
+								$output .= '"callsign": "NA",';
341
+							}
280 342
 						}
281 343
 						if (isset($spotter_item['registration'])) {
282
-							if ($compress) $output .= '"reg": '.json_encode($spotter_item['registration']).',';
283
-							else $output .= '"registration": '.json_encode($spotter_item['registration']).',';
344
+							if ($compress) {
345
+								$output .= '"reg": '.json_encode($spotter_item['registration']).',';
346
+							} else {
347
+								$output .= '"registration": '.json_encode($spotter_item['registration']).',';
348
+							}
284 349
 						}
285 350
 						if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) {
286 351
 							$output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",';
@@ -291,20 +356,30 @@  discard block
 block discarded – undo
291 356
 							$output .= '"aircraft_name": "NA",';
292 357
 						}
293 358
 						if (isset($spotter_item['aircraft_icao'])) {
294
-							if ($compress) $output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
295
-							else $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
359
+							if ($compress) {
360
+								$output .= '"ai": "'.$spotter_item['aircraft_icao'].'",';
361
+							} else {
362
+								$output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",';
363
+							}
296 364
 						}
297 365
 						if (!isset($spotter_item['aircraft_shadow']) && !$tracker && !$marine) {
298
-							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = '';
299
-							else {
366
+							if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') {
367
+								$spotter_item['aircraft_shadow'] = '';
368
+							} else {
300 369
 								$aircraft_icao = $spotter_item['aircraft_icao'];
301
-								if (isset($aircrafts_shadow[$aircraft_icao])) $spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
302
-								else {
370
+								if (isset($aircrafts_shadow[$aircraft_icao])) {
371
+									$spotter_item['aircraft_shadow'] = $aircrafts_shadow[$aircraft_icao];
372
+								} else {
303 373
 									$aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']);
304
-									if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
305
-									elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png';
306
-									elseif ($aircraft_icao == 'PARAGLIDER') $spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
307
-									else $spotter_item['aircraft_shadow'] = '';
374
+									if (count($aircraft_info) > 0) {
375
+										$spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow'];
376
+									} elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') {
377
+										$spotter_item['aircraft_shadow'] = 'PA18.png';
378
+									} elseif ($aircraft_icao == 'PARAGLIDER') {
379
+										$spotter_item['aircraft_shadow'] = 'PARAGLIDER.png';
380
+									} else {
381
+										$spotter_item['aircraft_shadow'] = '';
382
+									}
308 383
 									$aircrafts_shadow[$aircraft_icao] = $spotter_item['aircraft_shadow'];
309 384
 								}
310 385
 							}
@@ -312,73 +387,139 @@  discard block
 block discarded – undo
312 387
 						if (!isset($spotter_item['aircraft_shadow']) || $spotter_item['aircraft_shadow'] == '') {
313 388
 							if ($tracker) {
314 389
 								if (isset($spotter_item['type']) && $spotter_item['type'] == 'Ambulance') {
315
-									if ($compress) $output .= '"as": "ambulance.png",';
316
-									else $output .= '"aircraft_shadow": "ambulance.png",';
390
+									if ($compress) {
391
+										$output .= '"as": "ambulance.png",';
392
+									} else {
393
+										$output .= '"aircraft_shadow": "ambulance.png",';
394
+									}
317 395
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Police') {
318
-									if ($compress) $output .= '"as": "police.png",';
319
-									else $output .= '"aircraft_shadow": "police.png",';
396
+									if ($compress) {
397
+										$output .= '"as": "police.png",';
398
+									} else {
399
+										$output .= '"aircraft_shadow": "police.png",';
400
+									}
320 401
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Yacht (Sail)') {
321
-									if ($compress) $output .= '"as": "ship.png",';
322
-									else $output .= '"aircraft_shadow": "ship.png",';
402
+									if ($compress) {
403
+										$output .= '"as": "ship.png",';
404
+									} else {
405
+										$output .= '"aircraft_shadow": "ship.png",';
406
+									}
323 407
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Ship (Power Boat)') {
324
-									if ($compress) $output .= '"as": "ship.png",';
325
-									else $output .= '"aircraft_shadow": "ship.png",';
408
+									if ($compress) {
409
+										$output .= '"as": "ship.png",';
410
+									} else {
411
+										$output .= '"aircraft_shadow": "ship.png",';
412
+									}
326 413
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Shuttle') {
327
-									if ($compress) $output .= '"as": "ship.png",';
328
-									else $output .= '"aircraft_shadow": "ship.png",';
414
+									if ($compress) {
415
+										$output .= '"as": "ship.png",';
416
+									} else {
417
+										$output .= '"aircraft_shadow": "ship.png",';
418
+									}
329 419
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck') {
330
-									if ($compress) $output .= '"as": "truck.png",';
331
-									else $output .= '"aircraft_shadow": "truck.png",';
420
+									if ($compress) {
421
+										$output .= '"as": "truck.png",';
422
+									} else {
423
+										$output .= '"aircraft_shadow": "truck.png",';
424
+									}
332 425
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Truck (18 Wheeler)') {
333
-									if ($compress) $output .= '"as": "truck.png",';
334
-									else $output .= '"aircraft_shadow": "truck.png",';
426
+									if ($compress) {
427
+										$output .= '"as": "truck.png",';
428
+									} else {
429
+										$output .= '"aircraft_shadow": "truck.png",';
430
+									}
335 431
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Aircraft (small)') {
336
-									if ($compress) $output .= '"as": "aircraft.png",';
337
-									else $output .= '"aircraft_shadow": "aircraft.png",';
432
+									if ($compress) {
433
+										$output .= '"as": "aircraft.png",';
434
+									} else {
435
+										$output .= '"aircraft_shadow": "aircraft.png",';
436
+									}
338 437
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Large Aircraft') {
339
-									if ($compress) $output .= '"as": "aircraft.png",';
340
-									else $output .= '"aircraft_shadow": "aircraft.png",';
438
+									if ($compress) {
439
+										$output .= '"as": "aircraft.png",';
440
+									} else {
441
+										$output .= '"aircraft_shadow": "aircraft.png",';
442
+									}
341 443
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Helicopter') {
342
-									if ($compress) $output .= '"as": "helico.png",';
343
-									else $output .= '"aircraft_shadow": "helico.png",';
444
+									if ($compress) {
445
+										$output .= '"as": "helico.png",';
446
+									} else {
447
+										$output .= '"aircraft_shadow": "helico.png",';
448
+									}
344 449
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Railroad Engine') {
345
-									if ($compress) $output .= '"as": "rail.png",';
346
-									else $output .= '"aircraft_shadow": "rail.png",';
450
+									if ($compress) {
451
+										$output .= '"as": "rail.png",';
452
+									} else {
453
+										$output .= '"aircraft_shadow": "rail.png",';
454
+									}
347 455
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Firetruck') {
348
-									if ($compress) $output .= '"as": "firetruck.png",';
349
-									else $output .= '"aircraft_shadow": "firetruck.png",';
456
+									if ($compress) {
457
+										$output .= '"as": "firetruck.png",';
458
+									} else {
459
+										$output .= '"aircraft_shadow": "firetruck.png",';
460
+									}
350 461
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bus') {
351
-									if ($compress) $output .= '"as": "bus.png",';
352
-									else $output .= '"aircraft_shadow": "bus.png",';
462
+									if ($compress) {
463
+										$output .= '"as": "bus.png",';
464
+									} else {
465
+										$output .= '"aircraft_shadow": "bus.png",';
466
+									}
353 467
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Phone') {
354
-									if ($compress) $output .= '"as": "phone.png",';
355
-									else $output .= '"aircraft_shadow": "phone.png",';
468
+									if ($compress) {
469
+										$output .= '"as": "phone.png",';
470
+									} else {
471
+										$output .= '"aircraft_shadow": "phone.png",';
472
+									}
356 473
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Jogger') {
357
-									if ($compress) $output .= '"as": "jogger.png",';
358
-									else $output .= '"aircraft_shadow": "jogger.png",';
474
+									if ($compress) {
475
+										$output .= '"as": "jogger.png",';
476
+									} else {
477
+										$output .= '"aircraft_shadow": "jogger.png",';
478
+									}
359 479
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Bike') {
360
-									if ($compress) $output .= '"as": "bike.png",';
361
-									else $output .= '"aircraft_shadow": "bike.png",';
480
+									if ($compress) {
481
+										$output .= '"as": "bike.png",';
482
+									} else {
483
+										$output .= '"aircraft_shadow": "bike.png",';
484
+									}
362 485
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Motorcycle') {
363
-									if ($compress) $output .= '"as": "motorcycle.png",';
364
-									else $output .= '"aircraft_shadow": "motorcycle.png",';
486
+									if ($compress) {
487
+										$output .= '"as": "motorcycle.png",';
488
+									} else {
489
+										$output .= '"aircraft_shadow": "motorcycle.png",';
490
+									}
365 491
 								} elseif (isset($spotter_item['type']) && $spotter_item['type'] == 'Balloon') {
366
-									if ($compress) $output .= '"as": "balloon.png",';
367
-									else $output .= '"aircraft_shadow": "balloon.png",';
492
+									if ($compress) {
493
+										$output .= '"as": "balloon.png",';
494
+									} else {
495
+										$output .= '"aircraft_shadow": "balloon.png",';
496
+									}
368 497
 								} else {
369
-									if ($compress) $output .= '"as": "car.png",';
370
-									else $output .= '"aircraft_shadow": "car.png",';
498
+									if ($compress) {
499
+										$output .= '"as": "car.png",';
500
+									} else {
501
+										$output .= '"aircraft_shadow": "car.png",';
502
+									}
371 503
 								}
372 504
 							} elseif ($marine) {
373
-								if ($compress) $output .= '"as": "ship.png",';
374
-								else $output .= '"aircraft_shadow": "ship.png",';
505
+								if ($compress) {
506
+									$output .= '"as": "ship.png",';
507
+								} else {
508
+									$output .= '"aircraft_shadow": "ship.png",';
509
+								}
375 510
 							} else {
376
-								if ($compress) $output .= '"as": "default.png",';
377
-								else $output .= '"aircraft_shadow": "default.png",';
511
+								if ($compress) {
512
+									$output .= '"as": "default.png",';
513
+								} else {
514
+									$output .= '"aircraft_shadow": "default.png",';
515
+								}
378 516
 							}
379 517
 						} else {
380
-							if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
381
-							else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
518
+							if ($compress) {
519
+								$output .= '"as": "'.$spotter_item['aircraft_shadow'].'",';
520
+							} else {
521
+								$output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",';
522
+							}
382 523
 						}
383 524
 						if (isset($spotter_item['airline_name'])) {
384 525
 							$output .= '"airline_name": "'.$spotter_item['airline_name'].'",';
@@ -386,8 +527,11 @@  discard block
 block discarded – undo
386 527
 							$output .= '"airline_name": "NA",';
387 528
 						}
388 529
 						if (isset($spotter_item['departure_airport'])) {
389
-							if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",';
390
-							else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
530
+							if ($compress) {
531
+								$output .= '"dac": "'.$spotter_item['departure_airport'].'",';
532
+							} else {
533
+								$output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",';
534
+							}
391 535
 						}
392 536
 						if (isset($spotter_item['departure_airport_city'])) {
393 537
 							$output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",';
@@ -399,8 +543,11 @@  discard block
 block discarded – undo
399 543
 							$output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",';
400 544
 						}
401 545
 						if (isset($spotter_item['arrival_airport'])) {
402
-							if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
403
-							else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
546
+							if ($compress) {
547
+								$output .= '"aac": "'.$spotter_item['arrival_airport'].'",';
548
+							} else {
549
+								$output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",';
550
+							}
404 551
 						}
405 552
 						if (isset($spotter_item['arrival_airport_city'])) {
406 553
 							$output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",';
@@ -419,11 +566,17 @@  discard block
 block discarded – undo
419 566
 						}
420 567
 						
421 568
 						if (isset($spotter_item['real_altitude'])) {
422
-							if ($compress) $output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
423
-							else $output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
569
+							if ($compress) {
570
+								$output .= '"a": "'.($spotter_item['real_altitude']/100).'",';
571
+							} else {
572
+								$output .= '"altitude": "'.($spotter_item['real_altitude']/100).'",';
573
+							}
424 574
 						} elseif (isset($spotter_item['altitude'])) {
425
-							if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",';
426
-							else $output .= '"altitude": "'.$spotter_item['altitude'].'",';
575
+							if ($compress) {
576
+								$output .= '"a": "'.$spotter_item['altitude'].'",';
577
+							} else {
578
+								$output .= '"altitude": "'.$spotter_item['altitude'].'",';
579
+							}
427 580
 						}
428 581
 						
429 582
 						$heading = $spotter_item['heading'];
@@ -447,19 +600,24 @@  discard block
 block discarded – undo
447 600
 							}
448 601
 						}
449 602
 						
450
-						if ($compress)$output .= '"h": "'.$heading.'",';
451
-						else $output .= '"heading": "'.$heading.'",';
603
+						if ($compress) {
604
+							$output .= '"h": "'.$heading.'",';
605
+						} else {
606
+							$output .= '"heading": "'.$heading.'",';
607
+						}
452 608
 						if ($currenttime != '') {
453 609
 							if (strtotime($spotter_item['date']) < $currenttime) {
454 610
 								if (isset($archivespeed)) {
455 611
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
456 612
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
457
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
458
-									else {
613
+									if (!isset($idistance) || $fdistance < $idistance) {
614
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
615
+									} else {
459 616
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
460 617
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
461
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
462
-										else {
618
+										if (!isset($idistance) || $fdistance < $idistance) {
619
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
620
+										} else {
463 621
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed);
464 622
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
465 623
 										}
@@ -467,12 +625,14 @@  discard block
 block discarded – undo
467 625
 								} elseif ($usenextlatlon) {
468 626
 									$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
469 627
 									$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
470
-									if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
471
-									else {
628
+									if (!isset($idistance) || $fdistance < $idistance) {
629
+										$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
630
+									} else {
472 631
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,1,($currenttime-strtotime($spotter_item['date'])+$globalMapRefresh));
473 632
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
474
-										if (!isset($idistance) || $fdistance < $idistance) $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
475
-										else {
633
+										if (!isset($idistance) || $fdistance < $idistance) {
634
+											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
635
+										} else {
476 636
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading);
477 637
 											$output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],';
478 638
 										}
@@ -511,7 +671,9 @@  discard block
 block discarded – undo
511 671
 							}
512 672
 						}
513 673
 
514
-						if (!$min) $output .= '"image": "'.$image.'",';
674
+						if (!$min) {
675
+							$output .= '"image": "'.$image.'",';
676
+						}
515 677
 						if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') {
516 678
 							$output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",';
517 679
 						}
@@ -519,8 +681,11 @@  discard block
 block discarded – undo
519 681
 							$output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",';
520 682
 						}
521 683
 						if (isset($spotter_item['squawk'])) {
522
-							if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",';
523
-							else $output .= '"squawk": "'.$spotter_item['squawk'].'",';
684
+							if ($compress) {
685
+								$output .= '"sq": "'.$spotter_item['squawk'].'",';
686
+							} else {
687
+								$output .= '"squawk": "'.$spotter_item['squawk'].'",';
688
+							}
524 689
 						}
525 690
 						if (isset($spotter_item['squawk_usage'])) {
526 691
 							$output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",';
@@ -542,14 +707,23 @@  discard block
 block discarded – undo
542 707
 						}
543 708
 						// type when not aircraft ?
544 709
 						if (isset($spotter_item['type'])) {
545
-							if ($compress) $output .= '"t": "'.$spotter_item['type'].'"';
546
-							else $output .= '"type": "'.$spotter_item['type'].'"';
710
+							if ($compress) {
711
+								$output .= '"t": "'.$spotter_item['type'].'"';
712
+							} else {
713
+								$output .= '"type": "'.$spotter_item['type'].'"';
714
+							}
547 715
 						} elseif ($marine) {
548
-							if ($compress) $output .= '"t": "ship"';
549
-							else $output .= '"type": "ship"';
716
+							if ($compress) {
717
+								$output .= '"t": "ship"';
718
+							} else {
719
+								$output .= '"type": "ship"';
720
+							}
550 721
 						} else {
551
-							if ($compress) $output .= '"t": "aircraft"';
552
-							else $output .= '"type": "aircraft"';
722
+							if ($compress) {
723
+								$output .= '"t": "aircraft"';
724
+							} else {
725
+								$output .= '"type": "aircraft"';
726
+							}
553 727
 						}
554 728
 						$output .= '},';
555 729
 						$output .= '"geometry": {';
@@ -557,15 +731,19 @@  discard block
 block discarded – undo
557 731
 								$output .= '"coordinates": [';
558 732
 								if ($currenttime != '') {
559 733
 									if (strtotime($spotter_item['date']) < $currenttime) {
560
-										if (!isset($archivespeed)) $archivespeed = 1;
734
+										if (!isset($archivespeed)) {
735
+											$archivespeed = 1;
736
+										}
561 737
 										$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$heading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
562 738
 										$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
563
-										if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
564
-										else {
739
+										if (!isset($idistance) || $fdistance < $idistance) {
740
+											$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
741
+										} else {
565 742
 											$nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$cheading,$archivespeed,($currenttime-strtotime($spotter_item['date'])));
566 743
 											$fdistance = $Common->distance($spotter_item['latitude'],$spotter_item['longitude'],$nextcoord['latitude'],$nextcoord['longitude']);
567
-											if (!isset($idistance) || $fdistance < $idistance) $output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
568
-											else {
744
+											if (!isset($idistance) || $fdistance < $idistance) {
745
+												$output .= $nextcoord['longitude'].','.$nextcoord['latitude'];
746
+											} else {
569 747
 												$output .= $spotter_item['longitude'].', ';
570 748
 												$output .= $spotter_item['latitude'];
571 749
 											}
@@ -643,7 +821,9 @@  discard block
 block discarded – undo
643 821
 			}
644 822
 */
645 823
 				$history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING);
646
-				if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history'];
824
+				if ($history == '' && isset($_COOKIE['history'])) {
825
+					$history = $_COOKIE['history'];
826
+				}
647 827
 				
648 828
 				if (
649 829
 				    (isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') 
@@ -713,8 +893,11 @@  discard block
 block discarded – undo
713 893
 									$output_history .= ']}},';
714 894
 									$output .= $output_history;
715 895
 								}
716
-								if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
717
-								else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
896
+								if ($compress) {
897
+									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
898
+								} else {
899
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": [';
900
+								}
718 901
 							}
719 902
 							$output_history .= '[';
720 903
 							$output_history .=  $spotter_history['longitude'].', ';
@@ -735,10 +918,15 @@  discard block
 block discarded – undo
735 918
 							if ($d == false) {
736 919
 								if ($compress) {
737 920
 									$output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'",';
738
-									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') $output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
739
-									elseif (isset($spotter_history_array[0]['mapmatching_engine'])) $output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
921
+									if (isset($spotter_history_array[0]['mapmatching_engine']) && $spotter_history_array[0]['mapmatching_engine'] == 'graphhopper') {
922
+										$output_history .= '"atr": "Powered by <a href=\"https://www.graphhopper.com/\">GraphHopper API</a>", Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
923
+									} elseif (isset($spotter_history_array[0]['mapmatching_engine'])) {
924
+										$output_history .= '"atr": "Map matching engine use data from © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>",';
925
+									}
740 926
 									$output_history .= '"t": "history"},"geometry": {"type": "LineString","coordinates": [';
741
-								} else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
927
+								} else {
928
+									$output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
929
+								}
742 930
 								$d = true;
743 931
 							}
744 932
 							$output_history .= '[';
@@ -761,7 +949,9 @@  discard block
 block discarded – undo
761 949
 							$output_historyd = '[';
762 950
 							$output_historyd .=  $spotter_item['longitude'].', ';
763 951
 							$output_historyd .=  $spotter_item['latitude'];
764
-							if (isset($spotter_history['altitude'])) $output_historyd .=  ','.$spotter_item['altitude']*30.48;
952
+							if (isset($spotter_history['altitude'])) {
953
+								$output_historyd .=  ','.$spotter_item['altitude']*30.48;
954
+							}
765 955
 							$output_historyd .= '],';
766 956
 							//$output_history = $output_historyd.$output_history;
767 957
 							$output_history = $output_history.$output_historyd;
@@ -788,8 +978,11 @@  discard block
 block discarded – undo
788 978
 				        && $spotter_item['arrival_airport'] != 'NA' 
789 979
 				        && ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == "true") 
790 980
 				    	    || (!isset($_COOKIE['MapRoute']) && isset($globalMapRoute) && $globalMapRoute)))) {
791
-				    if ($compress) $output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
792
-				    else $output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
981
+				    if ($compress) {
982
+				    	$output_air = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "route"},"geometry": {"type": "LineString","coordinates": [';
983
+				    } else {
984
+				    	$output_air = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "route"},"geometry": {"type": "LineString","coordinates": [';
985
+				    }
793 986
 				    if (isset($spotter_item['departure_airport_latitude'])) {
794 987
 					$output_air .= '['.$spotter_item['departure_airport_longitude'].','.$spotter_item['departure_airport_latitude'].'],';
795 988
 				    } elseif (isset($spotter_item['departure_airport']) && $spotter_item['departure_airport'] != 'NA') {
@@ -822,8 +1015,11 @@  discard block
 block discarded – undo
822 1015
 				    	    || (!isset($_COOKIE['MapRemainingRoute']) && (!isset($globalMapRemainingRoute) 
823 1016
 				    	    || (isset($globalMapRemainingRoute) && $globalMapRemainingRoute)))))) {
824 1017
 				    $havedata = false;
825
-				    if ($compress) $output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
826
-				    else $output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1018
+				    if ($compress) {
1019
+				    	$output_dest = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1020
+				    } else {
1021
+				    	$output_dest = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "routedest"},"geometry": {"type": "LineString","coordinates": [';
1022
+				    }
827 1023
 				    
828 1024
 				    //$output_dest .= '['.$spotter_item['longitude'].','.$spotter_item['latitude'].'],';
829 1025
 				    if (isset($spotter_item['arrival_airport_latitude'])) {
@@ -848,7 +1044,9 @@  discard block
 block discarded – undo
848 1044
 					$output_dest  = substr($output_dest, 0, -1);
849 1045
 				    }
850 1046
 				    $output_dest .= ']}},';
851
-				    if ($havedata) $output .= $output_dest;
1047
+				    if ($havedata) {
1048
+				    	$output .= $output_dest;
1049
+				    }
852 1050
 				    unset($output_dest);
853 1051
 				}
854 1052
 			}
@@ -856,7 +1054,9 @@  discard block
 block discarded – undo
856 1054
 			$output .= ']';
857 1055
 			$output .= ',"initial_sqltime": "'.$sqltime.'",';
858 1056
 			$output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",';
859
-			if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",';
1057
+			if (isset($begindate)) {
1058
+				$output .= '"archive_date": "'.$begindate.'",';
1059
+			}
860 1060
 			$output .= '"fc": "'.$j.'"';
861 1061
 		} else {
862 1062
 			$output .= '"features": ';
Please login to merge, or discard this patch.
install/class.update_schema.php 1 patch
Braces   +512 added lines, -188 removed lines patch added patch discarded remove patch
@@ -258,7 +258,9 @@  discard block
 block discarded – undo
258 258
     		// Update table countries
259 259
     		if ($Connection->tableExists('airspace')) {
260 260
     		    $error .= update_db::update_countries();
261
-		    if ($error != '') return $error;
261
+		    if ($error != '') {
262
+		    	return $error;
263
+		    }
262 264
 		}
263 265
 		// Update schema_version to 7
264 266
 		$query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'";
@@ -314,7 +316,9 @@  discard block
 block discarded – undo
314 316
     		$error = '';
315 317
     		// Update table aircraft
316 318
 		$error .= create_db::import_file('../db/source_location.sql');
317
-		if ($error != '') return $error;
319
+		if ($error != '') {
320
+			return $error;
321
+		}
318 322
 		// Update schema_version to 6
319 323
 		$query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'";
320 324
         	try {
@@ -331,7 +335,9 @@  discard block
 block discarded – undo
331 335
     		$error = '';
332 336
     		// Update table aircraft
333 337
 		$error .= create_db::import_file('../db/notam.sql');
334
-		if ($error != '') return $error;
338
+		if ($error != '') {
339
+			return $error;
340
+		}
335 341
 		$query = "DELETE FROM config WHERE name = 'last_update_db';
336 342
                         INSERT INTO config (name,value) VALUES ('last_update_db',NOW());
337 343
                         DELETE FROM config WHERE name = 'last_update_notam_db';
@@ -365,7 +371,9 @@  discard block
 block discarded – undo
365 371
 		$error = '';
366 372
     		// Update table atc
367 373
 		$error .= create_db::import_file('../db/atc.sql');
368
-		if ($error != '') return $error;
374
+		if ($error != '') {
375
+			return $error;
376
+		}
369 377
 		
370 378
 		$query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'";
371 379
         	try {
@@ -389,13 +397,21 @@  discard block
 block discarded – undo
389 397
 		$error = '';
390 398
     		// Add tables
391 399
 		$error .= create_db::import_file('../db/aircraft_owner.sql');
392
-		if ($error != '') return $error;
400
+		if ($error != '') {
401
+			return $error;
402
+		}
393 403
 		$error .= create_db::import_file('../db/metar.sql');
394
-		if ($error != '') return $error;
404
+		if ($error != '') {
405
+			return $error;
406
+		}
395 407
 		$error .= create_db::import_file('../db/taf.sql');
396
-		if ($error != '') return $error;
408
+		if ($error != '') {
409
+			return $error;
410
+		}
397 411
 		$error .= create_db::import_file('../db/airport.sql');
398
-		if ($error != '') return $error;
412
+		if ($error != '') {
413
+			return $error;
414
+		}
399 415
 		
400 416
 		$query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'";
401 417
         	try {
@@ -469,19 +485,33 @@  discard block
 block discarded – undo
469 485
 		$error = '';
470 486
     		// Add tables
471 487
 		$error .= create_db::import_file('../db/stats.sql');
472
-		if ($error != '') return $error;
488
+		if ($error != '') {
489
+			return $error;
490
+		}
473 491
 		$error .= create_db::import_file('../db/stats_aircraft.sql');
474
-		if ($error != '') return $error;
492
+		if ($error != '') {
493
+			return $error;
494
+		}
475 495
 		$error .= create_db::import_file('../db/stats_airline.sql');
476
-		if ($error != '') return $error;
496
+		if ($error != '') {
497
+			return $error;
498
+		}
477 499
 		$error .= create_db::import_file('../db/stats_airport.sql');
478
-		if ($error != '') return $error;
500
+		if ($error != '') {
501
+			return $error;
502
+		}
479 503
 		$error .= create_db::import_file('../db/stats_owner.sql');
480
-		if ($error != '') return $error;
504
+		if ($error != '') {
505
+			return $error;
506
+		}
481 507
 		$error .= create_db::import_file('../db/stats_pilot.sql');
482
-		if ($error != '') return $error;
508
+		if ($error != '') {
509
+			return $error;
510
+		}
483 511
 		$error .= create_db::import_file('../db/spotter_archive_output.sql');
484
-		if ($error != '') return $error;
512
+		if ($error != '') {
513
+			return $error;
514
+		}
485 515
 		
486 516
 		$query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'";
487 517
         	try {
@@ -521,7 +551,9 @@  discard block
 block discarded – undo
521 551
     		// Add tables
522 552
     		if (!$Connection->tableExists('stats_flight')) {
523 553
 			$error .= create_db::import_file('../db/stats_flight.sql');
524
-			if ($error != '') return $error;
554
+			if ($error != '') {
555
+				return $error;
556
+			}
525 557
 		}
526 558
 		$query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'";
527 559
         	try {
@@ -545,7 +577,9 @@  discard block
 block discarded – undo
545 577
     		} catch(PDOException $e) {
546 578
 		    return "error (update stats) : ".$e->getMessage()."\n";
547 579
     		}
548
-		if ($error != '') return $error;
580
+		if ($error != '') {
581
+			return $error;
582
+		}
549 583
 		$query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'";
550 584
         	try {
551 585
             	    $sth = $Connection->db->prepare($query);
@@ -566,7 +600,9 @@  discard block
 block discarded – undo
566 600
     		if (!$Connection->tableExists('stats_callsign')) {
567 601
 			$error .= create_db::import_file('../db/stats_callsign.sql');
568 602
 		}
569
-		if ($error != '') return $error;
603
+		if ($error != '') {
604
+			return $error;
605
+		}
570 606
 		$query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'";
571 607
         	try {
572 608
             	    $sth = $Connection->db->prepare($query);
@@ -584,7 +620,9 @@  discard block
 block discarded – undo
584 620
     		if (!$Connection->tableExists('stats_country')) {
585 621
 			$error .= create_db::import_file('../db/stats_country.sql');
586 622
 		}
587
-		if ($error != '') return $error;
623
+		if ($error != '') {
624
+			return $error;
625
+		}
588 626
 		$query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'";
589 627
         	try {
590 628
             	    $sth = $Connection->db->prepare($query);
@@ -607,7 +645,9 @@  discard block
 block discarded – undo
607 645
 			    return "error (update stats) : ".$e->getMessage()."\n";
608 646
     			}
609 647
     		}
610
-		if ($error != '') return $error;
648
+		if ($error != '') {
649
+			return $error;
650
+		}
611 651
 		$query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'";
612 652
         	try {
613 653
             	    $sth = $Connection->db->prepare($query);
@@ -623,7 +663,9 @@  discard block
 block discarded – undo
623 663
 		$error = '';
624 664
     		// Update airport table
625 665
 		$error .= create_db::import_file('../db/airport.sql');
626
-		if ($error != '') return 'Import airport.sql : '.$error;
666
+		if ($error != '') {
667
+			return 'Import airport.sql : '.$error;
668
+		}
627 669
 		// Remove primary key on Spotter_Archive
628 670
 		$query = "alter table spotter_archive drop spotter_archive_id";
629 671
         	try {
@@ -699,7 +741,9 @@  discard block
 block discarded – undo
699 741
 				return "error (add source_name column) : ".$e->getMessage()."\n";
700 742
     			}
701 743
     		}
702
-		if ($error != '') return $error;
744
+		if ($error != '') {
745
+			return $error;
746
+		}
703 747
 		$query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'";
704 748
         	try {
705 749
             	    $sth = $Connection->db->prepare($query);
@@ -717,7 +761,9 @@  discard block
 block discarded – undo
717 761
     		// Update airline table
718 762
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
719 763
 			$error .= create_db::import_file('../db/airlines.sql');
720
-			if ($error != '') return 'Import airlines.sql : '.$error;
764
+			if ($error != '') {
765
+				return 'Import airlines.sql : '.$error;
766
+			}
721 767
 		}
722 768
 		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) {
723 769
 			// Add column over_country
@@ -729,7 +775,9 @@  discard block
 block discarded – undo
729 775
 				return "error (add over_country) : ".$e->getMessage()."\n";
730 776
     			}
731 777
     		}
732
-		if ($error != '') return $error;
778
+		if ($error != '') {
779
+			return $error;
780
+		}
733 781
 		/*
734 782
     		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) {
735 783
 			// Force update ModeS (this will put type_flight data
@@ -759,7 +807,9 @@  discard block
 block discarded – undo
759 807
 			} catch(PDOException $e) {
760 808
 				return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n";
761 809
 			}
762
-			if ($error != '') return $error;
810
+			if ($error != '') {
811
+				return $error;
812
+			}
763 813
 		}
764 814
 		$query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'";
765 815
         	try {
@@ -782,7 +832,9 @@  discard block
 block discarded – undo
782 832
 			} else {
783 833
 				$error .= create_db::import_file('../db/pgsql/stats_source.sql');
784 834
 			}
785
-			if ($error != '') return $error;
835
+			if ($error != '') {
836
+				return $error;
837
+			}
786 838
 		}
787 839
 		$query = "UPDATE config SET value = '23' WHERE name = 'schema_version'";
788 840
         	try {
@@ -803,12 +855,16 @@  discard block
 block discarded – undo
803 855
 		if ($globalDBdriver == 'mysql') {
804 856
 			if (!$Connection->tableExists('tle')) {
805 857
 				$error .= create_db::import_file('../db/tle.sql');
806
-				if ($error != '') return $error;
858
+				if ($error != '') {
859
+					return $error;
860
+				}
807 861
 			}
808 862
 		} else {
809 863
 			if (!$Connection->tableExists('tle')) {
810 864
 				$error .= create_db::import_file('../db/pgsql/tle.sql');
811
-				if ($error != '') return $error;
865
+				if ($error != '') {
866
+					return $error;
867
+				}
812 868
 			}
813 869
 			$query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)";
814 870
 			try {
@@ -848,7 +904,9 @@  discard block
 block discarded – undo
848 904
 		} else {
849 905
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
850 906
 		}
851
-		if ($error != '') return 'Import airlines.sql : '.$error;
907
+		if ($error != '') {
908
+			return 'Import airlines.sql : '.$error;
909
+		}
852 910
 		if (!$Connection->checkColumnName('airlines','forsource')) {
853 911
 			// Add forsource to airlines
854 912
 			$query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL";
@@ -1331,20 +1389,28 @@  discard block
 block discarded – undo
1331 1389
 		}
1332 1390
 		if ($globalDBdriver == 'mysql') {
1333 1391
 			$error .= create_db::import_file('../db/airlines.sql');
1334
-			if ($error != '') return $error;
1392
+			if ($error != '') {
1393
+				return $error;
1394
+			}
1335 1395
 		} else {
1336 1396
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
1337
-			if ($error != '') return $error;
1397
+			if ($error != '') {
1398
+				return $error;
1399
+			}
1338 1400
 		}
1339 1401
 		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) {
1340 1402
 			include_once(dirname(__FILE__).'/class.update_db.php');
1341 1403
 			if (isset($globalVATSIM) && $globalVATSIM) {
1342 1404
 				$error .= update_db::update_vatsim();
1343
-				if ($error != '') return $error;
1405
+				if ($error != '') {
1406
+					return $error;
1407
+				}
1344 1408
 			}
1345 1409
 			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) {
1346 1410
 				$error .= update_db::update_IVAO();
1347
-				if ($error != '') return $error;
1411
+				if ($error != '') {
1412
+					return $error;
1413
+				}
1348 1414
 			}
1349 1415
 		}
1350 1416
 
@@ -1607,41 +1673,65 @@  discard block
 block discarded – undo
1607 1673
 		if ($globalDBdriver == 'mysql') {
1608 1674
 			if (!$Connection->tableExists('tracker_output')) {
1609 1675
 				$error .= create_db::import_file('../db/tracker_output.sql');
1610
-				if ($error != '') return $error;
1676
+				if ($error != '') {
1677
+					return $error;
1678
+				}
1611 1679
 			}
1612 1680
 			if (!$Connection->tableExists('tracker_live')) {
1613 1681
 				$error .= create_db::import_file('../db/tracker_live.sql');
1614
-				if ($error != '') return $error;
1682
+				if ($error != '') {
1683
+					return $error;
1684
+				}
1615 1685
 			}
1616 1686
 			if (!$Connection->tableExists('marine_output')) {
1617 1687
 				$error .= create_db::import_file('../db/marine_output.sql');
1618
-				if ($error != '') return $error;
1688
+				if ($error != '') {
1689
+					return $error;
1690
+				}
1619 1691
 			}
1620 1692
 			if (!$Connection->tableExists('marine_live')) {
1621 1693
 				$error .= create_db::import_file('../db/marine_live.sql');
1622
-				if ($error != '') return $error;
1694
+				if ($error != '') {
1695
+					return $error;
1696
+				}
1623 1697
 			}
1624 1698
 			if (!$Connection->tableExists('marine_identity')) {
1625 1699
 				$error .= create_db::import_file('../db/marine_identity.sql');
1626
-				if ($error != '') return $error;
1700
+				if ($error != '') {
1701
+					return $error;
1702
+				}
1627 1703
 			}
1628 1704
 			if (!$Connection->tableExists('marine_mid')) {
1629 1705
 				$error .= create_db::import_file('../db/marine_mid.sql');
1630
-				if ($error != '') return $error;
1706
+				if ($error != '') {
1707
+					return $error;
1708
+				}
1631 1709
 			}
1632 1710
 		} else {
1633 1711
 			$error .= create_db::import_file('../db/pgsql/tracker_output.sql');
1634
-			if ($error != '') return $error;
1712
+			if ($error != '') {
1713
+				return $error;
1714
+			}
1635 1715
 			$error .= create_db::import_file('../db/pgsql/tracker_live.sql');
1636
-			if ($error != '') return $error;
1716
+			if ($error != '') {
1717
+				return $error;
1718
+			}
1637 1719
 			$error .= create_db::import_file('../db/pgsql/marine_output.sql');
1638
-			if ($error != '') return $error;
1720
+			if ($error != '') {
1721
+				return $error;
1722
+			}
1639 1723
 			$error .= create_db::import_file('../db/pgsql/marine_live.sql');
1640
-			if ($error != '') return $error;
1724
+			if ($error != '') {
1725
+				return $error;
1726
+			}
1641 1727
 			$error .= create_db::import_file('../db/pgsql/marine_identity.sql');
1642
-			if ($error != '') return $error;
1728
+			if ($error != '') {
1729
+				return $error;
1730
+			}
1643 1731
 			$error .= create_db::import_file('../db/pgsql/marine_mid.sql');
1644
-			if ($error != '') return $error;
1732
+			if ($error != '') {
1733
+				return $error;
1734
+			}
1645 1735
 		}
1646 1736
 		$query = "UPDATE config SET value = '37' WHERE name = 'schema_version'";
1647 1737
 		try {
@@ -1660,39 +1750,61 @@  discard block
 block discarded – undo
1660 1750
 		if ($globalDBdriver == 'mysql') {
1661 1751
 			if (!$Connection->tableExists('marine_image')) {
1662 1752
 				$error .= create_db::import_file('../db/marine_image.sql');
1663
-				if ($error != '') return $error;
1753
+				if ($error != '') {
1754
+					return $error;
1755
+				}
1664 1756
 			}
1665 1757
 			if (!$Connection->tableExists('marine_archive')) {
1666 1758
 				$error .= create_db::import_file('../db/marine_archive.sql');
1667
-				if ($error != '') return $error;
1759
+				if ($error != '') {
1760
+					return $error;
1761
+				}
1668 1762
 			}
1669 1763
 			if (!$Connection->tableExists('marine_archive_output')) {
1670 1764
 				$error .= create_db::import_file('../db/marine_archive_output.sql');
1671
-				if ($error != '') return $error;
1765
+				if ($error != '') {
1766
+					return $error;
1767
+				}
1672 1768
 			}
1673 1769
 			if (!$Connection->tableExists('tracker_archive')) {
1674 1770
 				$error .= create_db::import_file('../db/tracker_archive.sql');
1675
-				if ($error != '') return $error;
1771
+				if ($error != '') {
1772
+					return $error;
1773
+				}
1676 1774
 			}
1677 1775
 			if (!$Connection->tableExists('tracker_archive_output')) {
1678 1776
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1679
-				if ($error != '') return $error;
1777
+				if ($error != '') {
1778
+					return $error;
1779
+				}
1680 1780
 			}
1681 1781
 			if (!$Connection->tableExists('marine_archive_output')) {
1682 1782
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
1683
-				if ($error != '') return $error;
1783
+				if ($error != '') {
1784
+					return $error;
1785
+				}
1684 1786
 			}
1685 1787
 		} else {
1686 1788
 			$error .= create_db::import_file('../db/pgsql/marine_image.sql');
1687
-			if ($error != '') return $error;
1789
+			if ($error != '') {
1790
+				return $error;
1791
+			}
1688 1792
 			$error .= create_db::import_file('../db/pgsql/marine_archive.sql');
1689
-			if ($error != '') return $error;
1793
+			if ($error != '') {
1794
+				return $error;
1795
+			}
1690 1796
 			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql');
1691
-			if ($error != '') return $error;
1797
+			if ($error != '') {
1798
+				return $error;
1799
+			}
1692 1800
 			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql');
1693
-			if ($error != '') return $error;
1801
+			if ($error != '') {
1802
+				return $error;
1803
+			}
1694 1804
 			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql');
1695
-			if ($error != '') return $error;
1805
+			if ($error != '') {
1806
+				return $error;
1807
+			}
1696 1808
 		}
1697 1809
 		if ($globalDBdriver == 'mysql') {
1698 1810
 			$query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'";
@@ -2063,7 +2175,9 @@  discard block
 block discarded – undo
2063 2175
 		if ($globalDBdriver == 'mysql') {
2064 2176
 			if (!$Connection->tableExists('tracker_archive_output')) {
2065 2177
 				$error .= create_db::import_file('../db/tracker_archive_output.sql');
2066
-				if ($error != '') return $error;
2178
+				if ($error != '') {
2179
+					return $error;
2180
+				}
2067 2181
 			}
2068 2182
 			$query = "ALTER TABLE tracker_live MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive MODIFY COLUMN altitude float DEFAULT NULL;ALTER TABLE tracker_archive_output MODIFY COLUMN last_altitude float DEFAULT NULL;ALTER TABLE tracker_output MODIFY COLUMN altitude float DEFAULT NULL;";
2069 2183
 		} else {
@@ -2091,14 +2205,22 @@  discard block
 block discarded – undo
2091 2205
 		$error = '';
2092 2206
 		if ($globalDBdriver == 'mysql') {
2093 2207
 			$error .= create_db::import_file('../db/airport.sql');
2094
-			if ($error != '') return $error;
2208
+			if ($error != '') {
2209
+				return $error;
2210
+			}
2095 2211
 			$error .= create_db::import_file('../db/airlines.sql');
2096
-			if ($error != '') return $error;
2212
+			if ($error != '') {
2213
+				return $error;
2214
+			}
2097 2215
 		} else {
2098 2216
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2099
-			if ($error != '') return $error;
2217
+			if ($error != '') {
2218
+				return $error;
2219
+			}
2100 2220
 			$error .= create_db::import_file('../db/pgsql/airlines.sql');
2101
-			if ($error != '') return $error;
2221
+			if ($error != '') {
2222
+				return $error;
2223
+			}
2102 2224
 		}
2103 2225
 		if ((isset($globalVATSIM) && $globalVATSIM) && (isset($globalIVAO) && $globalIVAO)) {
2104 2226
 			if (file_exists('tmp/ivae_feb2013.zip')) {
@@ -2115,7 +2237,9 @@  discard block
 block discarded – undo
2115 2237
 				$error .= update_db::update_vatsim();
2116 2238
 			}
2117 2239
 		}
2118
-		if ($error != '') return $error;
2240
+		if ($error != '') {
2241
+			return $error;
2242
+		}
2119 2243
 		$query = "UPDATE config SET value = '45' WHERE name = 'schema_version'";
2120 2244
 		try {
2121 2245
 			$sth = $Connection->db->prepare($query);
@@ -2133,10 +2257,14 @@  discard block
 block discarded – undo
2133 2257
 		if (!$Connection->tableExists('satellite')) {
2134 2258
 			if ($globalDBdriver == 'mysql') {
2135 2259
 				$error .= create_db::import_file('../db/satellite.sql');
2136
-				if ($error != '') return $error;
2260
+				if ($error != '') {
2261
+					return $error;
2262
+				}
2137 2263
 			} else {
2138 2264
 				$error .= create_db::import_file('../db/pgsql/satellite.sql');
2139
-				if ($error != '') return $error;
2265
+				if ($error != '') {
2266
+					return $error;
2267
+				}
2140 2268
 			}
2141 2269
 		}
2142 2270
 		$query = "UPDATE config SET value = '46' WHERE name = 'schema_version'";
@@ -2156,37 +2284,53 @@  discard block
 block discarded – undo
2156 2284
 		if (!$Connection->tableExists('stats_marine')) {
2157 2285
 			if ($globalDBdriver == 'mysql') {
2158 2286
 				$error .= create_db::import_file('../db/stats_marine.sql');
2159
-				if ($error != '') return $error;
2287
+				if ($error != '') {
2288
+					return $error;
2289
+				}
2160 2290
 			} else {
2161 2291
 				$error .= create_db::import_file('../db/pgsql/stats_marine.sql');
2162
-				if ($error != '') return $error;
2292
+				if ($error != '') {
2293
+					return $error;
2294
+				}
2163 2295
 			}
2164 2296
 		}
2165 2297
 		if (!$Connection->tableExists('stats_marine_country')) {
2166 2298
 			if ($globalDBdriver == 'mysql') {
2167 2299
 				$error .= create_db::import_file('../db/stats_marine_country.sql');
2168
-				if ($error != '') return $error;
2300
+				if ($error != '') {
2301
+					return $error;
2302
+				}
2169 2303
 			} else {
2170 2304
 				$error .= create_db::import_file('../db/pgsql/stats_marine_country.sql');
2171
-				if ($error != '') return $error;
2305
+				if ($error != '') {
2306
+					return $error;
2307
+				}
2172 2308
 			}
2173 2309
 		}
2174 2310
 		if (!$Connection->tableExists('stats_tracker')) {
2175 2311
 			if ($globalDBdriver == 'mysql') {
2176 2312
 				$error .= create_db::import_file('../db/stats_tracker.sql');
2177
-				if ($error != '') return $error;
2313
+				if ($error != '') {
2314
+					return $error;
2315
+				}
2178 2316
 			} else {
2179 2317
 				$error .= create_db::import_file('../db/pgsql/stats_tracker.sql');
2180
-				if ($error != '') return $error;
2318
+				if ($error != '') {
2319
+					return $error;
2320
+				}
2181 2321
 			}
2182 2322
 		}
2183 2323
 		if (!$Connection->tableExists('stats_tracker_country')) {
2184 2324
 			if ($globalDBdriver == 'mysql') {
2185 2325
 				$error .= create_db::import_file('../db/stats_tracker_country.sql');
2186
-				if ($error != '') return $error;
2326
+				if ($error != '') {
2327
+					return $error;
2328
+				}
2187 2329
 			} else {
2188 2330
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_country.sql');
2189
-				if ($error != '') return $error;
2331
+				if ($error != '') {
2332
+					return $error;
2333
+				}
2190 2334
 			}
2191 2335
 		}
2192 2336
 		$query = "UPDATE config SET value = '47' WHERE name = 'schema_version'";
@@ -2206,10 +2350,14 @@  discard block
 block discarded – undo
2206 2350
 		if (!$Connection->tableExists('stats_marine_type')) {
2207 2351
 			if ($globalDBdriver == 'mysql') {
2208 2352
 				$error .= create_db::import_file('../db/stats_marine_type.sql');
2209
-				if ($error != '') return $error;
2353
+				if ($error != '') {
2354
+					return $error;
2355
+				}
2210 2356
 			} else {
2211 2357
 				$error .= create_db::import_file('../db/pgsql/stats_marine_type.sql');
2212
-				if ($error != '') return $error;
2358
+				if ($error != '') {
2359
+					return $error;
2360
+				}
2213 2361
 			}
2214 2362
 		}
2215 2363
 		$query = "UPDATE config SET value = '48' WHERE name = 'schema_version'";
@@ -2229,10 +2377,14 @@  discard block
 block discarded – undo
2229 2377
 		if (!$Connection->tableExists('stats_tracker_type')) {
2230 2378
 			if ($globalDBdriver == 'mysql') {
2231 2379
 				$error .= create_db::import_file('../db/stats_tracker_type.sql');
2232
-				if ($error != '') return $error;
2380
+				if ($error != '') {
2381
+					return $error;
2382
+				}
2233 2383
 			} else {
2234 2384
 				$error .= create_db::import_file('../db/pgsql/stats_tracker_type.sql');
2235
-				if ($error != '') return $error;
2385
+				if ($error != '') {
2386
+					return $error;
2387
+				}
2236 2388
 			}
2237 2389
 		}
2238 2390
 		$query = "UPDATE config SET value = '49' WHERE name = 'schema_version'";
@@ -2251,10 +2403,14 @@  discard block
 block discarded – undo
2251 2403
 		$error = '';
2252 2404
 		if ($globalDBdriver == 'mysql') {
2253 2405
 			$error .= create_db::import_file('../db/airport.sql');
2254
-			if ($error != '') return $error;
2406
+			if ($error != '') {
2407
+				return $error;
2408
+			}
2255 2409
 		} else {
2256 2410
 			$error .= create_db::import_file('../db/pgsql/airport.sql');
2257
-			if ($error != '') return $error;
2411
+			if ($error != '') {
2412
+				return $error;
2413
+			}
2258 2414
 		}
2259 2415
 		$query = "UPDATE config SET value = '50' WHERE name = 'schema_version'";
2260 2416
 		try {
@@ -2272,14 +2428,22 @@  discard block
 block discarded – undo
2272 2428
 		$error = '';
2273 2429
 		if ($globalDBdriver == 'mysql') {
2274 2430
 			$error .= create_db::import_file('../db/aircraft.sql');
2275
-			if ($error != '') return $error;
2431
+			if ($error != '') {
2432
+				return $error;
2433
+			}
2276 2434
 			$error .= create_db::import_file('../db/aircraft_block.sql');
2277
-			if ($error != '') return $error;
2435
+			if ($error != '') {
2436
+				return $error;
2437
+			}
2278 2438
 		} else {
2279 2439
 			$error .= create_db::import_file('../db/pgsql/aircraft.sql');
2280
-			if ($error != '') return $error;
2440
+			if ($error != '') {
2441
+				return $error;
2442
+			}
2281 2443
 			$error .= create_db::import_file('../db/pgsql/aircraft_block.sql');
2282
-			if ($error != '') return $error;
2444
+			if ($error != '') {
2445
+				return $error;
2446
+			}
2283 2447
 		}
2284 2448
 		$query = "UPDATE config SET value = '51' WHERE name = 'schema_version'";
2285 2449
 		try {
@@ -2353,8 +2517,11 @@  discard block
 block discarded – undo
2353 2517
 			if ($Connection->tableExists('aircraft')) {
2354 2518
 				if (!$Connection->tableExists('config')) {
2355 2519
 					$version = '1';
2356
-					if ($update) return self::update_from_1();
2357
-					else return $version;
2520
+					if ($update) {
2521
+						return self::update_from_1();
2522
+					} else {
2523
+						return $version;
2524
+					}
2358 2525
 				} else {
2359 2526
 					$query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1";
2360 2527
 					try {
@@ -2367,211 +2534,368 @@  discard block
 block discarded – undo
2367 2534
 					if ($update) {
2368 2535
 						if ($result['value'] == '2') {
2369 2536
 							$error = self::update_from_2();
2370
-							if ($error != '') return $error;
2371
-							else return self::check_version(true);
2537
+							if ($error != '') {
2538
+								return $error;
2539
+							} else {
2540
+								return self::check_version(true);
2541
+							}
2372 2542
 						} elseif ($result['value'] == '3') {
2373 2543
 							$error = self::update_from_3();
2374
-							if ($error != '') return $error;
2375
-							else return self::check_version(true);
2544
+							if ($error != '') {
2545
+								return $error;
2546
+							} else {
2547
+								return self::check_version(true);
2548
+							}
2376 2549
 						} elseif ($result['value'] == '4') {
2377 2550
 							$error = self::update_from_4();
2378
-							if ($error != '') return $error;
2379
-							else return self::check_version(true);
2551
+							if ($error != '') {
2552
+								return $error;
2553
+							} else {
2554
+								return self::check_version(true);
2555
+							}
2380 2556
 						} elseif ($result['value'] == '5') {
2381 2557
 							$error = self::update_from_5();
2382
-							if ($error != '') return $error;
2383
-							else return self::check_version(true);
2558
+							if ($error != '') {
2559
+								return $error;
2560
+							} else {
2561
+								return self::check_version(true);
2562
+							}
2384 2563
 						} elseif ($result['value'] == '6') {
2385 2564
 							$error = self::update_from_6();
2386
-							if ($error != '') return $error;
2387
-							else return self::check_version(true);
2565
+							if ($error != '') {
2566
+								return $error;
2567
+							} else {
2568
+								return self::check_version(true);
2569
+							}
2388 2570
 						} elseif ($result['value'] == '7') {
2389 2571
 							$error = self::update_from_7();
2390
-							if ($error != '') return $error;
2391
-							else return self::check_version(true);
2572
+							if ($error != '') {
2573
+								return $error;
2574
+							} else {
2575
+								return self::check_version(true);
2576
+							}
2392 2577
 						} elseif ($result['value'] == '8') {
2393 2578
 							$error = self::update_from_8();
2394
-							if ($error != '') return $error;
2395
-							else return self::check_version(true);
2579
+							if ($error != '') {
2580
+								return $error;
2581
+							} else {
2582
+								return self::check_version(true);
2583
+							}
2396 2584
 						} elseif ($result['value'] == '9') {
2397 2585
 							$error = self::update_from_9();
2398
-							if ($error != '') return $error;
2399
-							else return self::check_version(true);
2586
+							if ($error != '') {
2587
+								return $error;
2588
+							} else {
2589
+								return self::check_version(true);
2590
+							}
2400 2591
 						} elseif ($result['value'] == '10') {
2401 2592
 							$error = self::update_from_10();
2402
-							if ($error != '') return $error;
2403
-							else return self::check_version(true);
2593
+							if ($error != '') {
2594
+								return $error;
2595
+							} else {
2596
+								return self::check_version(true);
2597
+							}
2404 2598
 						} elseif ($result['value'] == '11') {
2405 2599
 							$error = self::update_from_11();
2406
-							if ($error != '') return $error;
2407
-							else return self::check_version(true);
2600
+							if ($error != '') {
2601
+								return $error;
2602
+							} else {
2603
+								return self::check_version(true);
2604
+							}
2408 2605
 						} elseif ($result['value'] == '12') {
2409 2606
 							$error = self::update_from_12();
2410
-							if ($error != '') return $error;
2411
-							else return self::check_version(true);
2607
+							if ($error != '') {
2608
+								return $error;
2609
+							} else {
2610
+								return self::check_version(true);
2611
+							}
2412 2612
 						} elseif ($result['value'] == '13') {
2413 2613
 							$error = self::update_from_13();
2414
-							if ($error != '') return $error;
2415
-							else return self::check_version(true);
2614
+							if ($error != '') {
2615
+								return $error;
2616
+							} else {
2617
+								return self::check_version(true);
2618
+							}
2416 2619
 						} elseif ($result['value'] == '14') {
2417 2620
 							$error = self::update_from_14();
2418
-							if ($error != '') return $error;
2419
-							else return self::check_version(true);
2621
+							if ($error != '') {
2622
+								return $error;
2623
+							} else {
2624
+								return self::check_version(true);
2625
+							}
2420 2626
 						} elseif ($result['value'] == '15') {
2421 2627
 							$error = self::update_from_15();
2422
-							if ($error != '') return $error;
2423
-							else return self::check_version(true);
2628
+							if ($error != '') {
2629
+								return $error;
2630
+							} else {
2631
+								return self::check_version(true);
2632
+							}
2424 2633
 						} elseif ($result['value'] == '16') {
2425 2634
 							$error = self::update_from_16();
2426
-							if ($error != '') return $error;
2427
-							else return self::check_version(true);
2635
+							if ($error != '') {
2636
+								return $error;
2637
+							} else {
2638
+								return self::check_version(true);
2639
+							}
2428 2640
 						} elseif ($result['value'] == '17') {
2429 2641
 							$error = self::update_from_17();
2430
-							if ($error != '') return $error;
2431
-							else return self::check_version(true);
2642
+							if ($error != '') {
2643
+								return $error;
2644
+							} else {
2645
+								return self::check_version(true);
2646
+							}
2432 2647
 						} elseif ($result['value'] == '18') {
2433 2648
 							$error = self::update_from_18();
2434
-							if ($error != '') return $error;
2435
-							else return self::check_version(true);
2649
+							if ($error != '') {
2650
+								return $error;
2651
+							} else {
2652
+								return self::check_version(true);
2653
+							}
2436 2654
 						} elseif ($result['value'] == '19') {
2437 2655
 							$error = self::update_from_19();
2438
-							if ($error != '') return $error;
2439
-							else return self::check_version(true);
2656
+							if ($error != '') {
2657
+								return $error;
2658
+							} else {
2659
+								return self::check_version(true);
2660
+							}
2440 2661
 						} elseif ($result['value'] == '20') {
2441 2662
 							$error = self::update_from_20();
2442
-							if ($error != '') return $error;
2443
-							else return self::check_version(true);
2663
+							if ($error != '') {
2664
+								return $error;
2665
+							} else {
2666
+								return self::check_version(true);
2667
+							}
2444 2668
 						} elseif ($result['value'] == '21') {
2445 2669
 							$error = self::update_from_21();
2446
-							if ($error != '') return $error;
2447
-							else return self::check_version(true);
2670
+							if ($error != '') {
2671
+								return $error;
2672
+							} else {
2673
+								return self::check_version(true);
2674
+							}
2448 2675
 						} elseif ($result['value'] == '22') {
2449 2676
 							$error = self::update_from_22();
2450
-							if ($error != '') return $error;
2451
-							else return self::check_version(true);
2677
+							if ($error != '') {
2678
+								return $error;
2679
+							} else {
2680
+								return self::check_version(true);
2681
+							}
2452 2682
 						} elseif ($result['value'] == '23') {
2453 2683
 							$error = self::update_from_23();
2454
-							if ($error != '') return $error;
2455
-							else return self::check_version(true);
2684
+							if ($error != '') {
2685
+								return $error;
2686
+							} else {
2687
+								return self::check_version(true);
2688
+							}
2456 2689
 						} elseif ($result['value'] == '24') {
2457 2690
 							$error = self::update_from_24();
2458
-							if ($error != '') return $error;
2459
-							else return self::check_version(true);
2691
+							if ($error != '') {
2692
+								return $error;
2693
+							} else {
2694
+								return self::check_version(true);
2695
+							}
2460 2696
 						} elseif ($result['value'] == '25') {
2461 2697
 							$error = self::update_from_25();
2462
-							if ($error != '') return $error;
2463
-							else return self::check_version(true);
2698
+							if ($error != '') {
2699
+								return $error;
2700
+							} else {
2701
+								return self::check_version(true);
2702
+							}
2464 2703
 						} elseif ($result['value'] == '26') {
2465 2704
 							$error = self::update_from_26();
2466
-							if ($error != '') return $error;
2467
-							else return self::check_version(true);
2705
+							if ($error != '') {
2706
+								return $error;
2707
+							} else {
2708
+								return self::check_version(true);
2709
+							}
2468 2710
 						} elseif ($result['value'] == '27') {
2469 2711
 							$error = self::update_from_27();
2470
-							if ($error != '') return $error;
2471
-							else return self::check_version(true);
2712
+							if ($error != '') {
2713
+								return $error;
2714
+							} else {
2715
+								return self::check_version(true);
2716
+							}
2472 2717
 						} elseif ($result['value'] == '28') {
2473 2718
 							$error = self::update_from_28();
2474
-							if ($error != '') return $error;
2475
-							else return self::check_version(true);
2719
+							if ($error != '') {
2720
+								return $error;
2721
+							} else {
2722
+								return self::check_version(true);
2723
+							}
2476 2724
 						} elseif ($result['value'] == '29') {
2477 2725
 							$error = self::update_from_29();
2478
-							if ($error != '') return $error;
2479
-							else return self::check_version(true);
2726
+							if ($error != '') {
2727
+								return $error;
2728
+							} else {
2729
+								return self::check_version(true);
2730
+							}
2480 2731
 						} elseif ($result['value'] == '30') {
2481 2732
 							$error = self::update_from_30();
2482
-							if ($error != '') return $error;
2483
-							else return self::check_version(true);
2733
+							if ($error != '') {
2734
+								return $error;
2735
+							} else {
2736
+								return self::check_version(true);
2737
+							}
2484 2738
 						} elseif ($result['value'] == '31') {
2485 2739
 							$error = self::update_from_31();
2486
-							if ($error != '') return $error;
2487
-							else return self::check_version(true);
2740
+							if ($error != '') {
2741
+								return $error;
2742
+							} else {
2743
+								return self::check_version(true);
2744
+							}
2488 2745
 						} elseif ($result['value'] == '32') {
2489 2746
 							$error = self::update_from_32();
2490
-							if ($error != '') return $error;
2491
-							else return self::check_version(true);
2747
+							if ($error != '') {
2748
+								return $error;
2749
+							} else {
2750
+								return self::check_version(true);
2751
+							}
2492 2752
 						} elseif ($result['value'] == '33') {
2493 2753
 							$error = self::update_from_33();
2494
-							if ($error != '') return $error;
2495
-							else return self::check_version(true);
2754
+							if ($error != '') {
2755
+								return $error;
2756
+							} else {
2757
+								return self::check_version(true);
2758
+							}
2496 2759
 						} elseif ($result['value'] == '34') {
2497 2760
 							$error = self::update_from_34();
2498
-							if ($error != '') return $error;
2499
-							else return self::check_version(true);
2761
+							if ($error != '') {
2762
+								return $error;
2763
+							} else {
2764
+								return self::check_version(true);
2765
+							}
2500 2766
 						} elseif ($result['value'] == '35') {
2501 2767
 							$error = self::update_from_35();
2502
-							if ($error != '') return $error;
2503
-							else return self::check_version(true);
2768
+							if ($error != '') {
2769
+								return $error;
2770
+							} else {
2771
+								return self::check_version(true);
2772
+							}
2504 2773
 						} elseif ($result['value'] == '36') {
2505 2774
 							$error = self::update_from_36();
2506
-							if ($error != '') return $error;
2507
-							else return self::check_version(true);
2775
+							if ($error != '') {
2776
+								return $error;
2777
+							} else {
2778
+								return self::check_version(true);
2779
+							}
2508 2780
 						} elseif ($result['value'] == '37') {
2509 2781
 							$error = self::update_from_37();
2510
-							if ($error != '') return $error;
2511
-							else return self::check_version(true);
2782
+							if ($error != '') {
2783
+								return $error;
2784
+							} else {
2785
+								return self::check_version(true);
2786
+							}
2512 2787
 						} elseif ($result['value'] == '38') {
2513 2788
 							$error = self::update_from_38();
2514
-							if ($error != '') return $error;
2515
-							else return self::check_version(true);
2789
+							if ($error != '') {
2790
+								return $error;
2791
+							} else {
2792
+								return self::check_version(true);
2793
+							}
2516 2794
 						} elseif ($result['value'] == '39') {
2517 2795
 							$error = self::update_from_39();
2518
-							if ($error != '') return $error;
2519
-							else return self::check_version(true);
2796
+							if ($error != '') {
2797
+								return $error;
2798
+							} else {
2799
+								return self::check_version(true);
2800
+							}
2520 2801
 						} elseif ($result['value'] == '40') {
2521 2802
 							$error = self::update_from_40();
2522
-							if ($error != '') return $error;
2523
-							else return self::check_version(true);
2803
+							if ($error != '') {
2804
+								return $error;
2805
+							} else {
2806
+								return self::check_version(true);
2807
+							}
2524 2808
 						} elseif ($result['value'] == '41') {
2525 2809
 							$error = self::update_from_41();
2526
-							if ($error != '') return $error;
2527
-							else return self::check_version(true);
2810
+							if ($error != '') {
2811
+								return $error;
2812
+							} else {
2813
+								return self::check_version(true);
2814
+							}
2528 2815
 						} elseif ($result['value'] == '42') {
2529 2816
 							$error = self::update_from_42();
2530
-							if ($error != '') return $error;
2531
-							else return self::check_version(true);
2817
+							if ($error != '') {
2818
+								return $error;
2819
+							} else {
2820
+								return self::check_version(true);
2821
+							}
2532 2822
 						} elseif ($result['value'] == '43') {
2533 2823
 							$error = self::update_from_43();
2534
-							if ($error != '') return $error;
2535
-							else return self::check_version(true);
2824
+							if ($error != '') {
2825
+								return $error;
2826
+							} else {
2827
+								return self::check_version(true);
2828
+							}
2536 2829
 						} elseif ($result['value'] == '44') {
2537 2830
 							$error = self::update_from_44();
2538
-							if ($error != '') return $error;
2539
-							else return self::check_version(true);
2831
+							if ($error != '') {
2832
+								return $error;
2833
+							} else {
2834
+								return self::check_version(true);
2835
+							}
2540 2836
 						} elseif ($result['value'] == '45') {
2541 2837
 							$error = self::update_from_45();
2542
-							if ($error != '') return $error;
2543
-							else return self::check_version(true);
2838
+							if ($error != '') {
2839
+								return $error;
2840
+							} else {
2841
+								return self::check_version(true);
2842
+							}
2544 2843
 						} elseif ($result['value'] == '46') {
2545 2844
 							$error = self::update_from_46();
2546
-							if ($error != '') return $error;
2547
-							else return self::check_version(true);
2845
+							if ($error != '') {
2846
+								return $error;
2847
+							} else {
2848
+								return self::check_version(true);
2849
+							}
2548 2850
 						} elseif ($result['value'] == '47') {
2549 2851
 							$error = self::update_from_47();
2550
-							if ($error != '') return $error;
2551
-							else return self::check_version(true);
2852
+							if ($error != '') {
2853
+								return $error;
2854
+							} else {
2855
+								return self::check_version(true);
2856
+							}
2552 2857
 						} elseif ($result['value'] == '48') {
2553 2858
 							$error = self::update_from_48();
2554
-							if ($error != '') return $error;
2555
-							else return self::check_version(true);
2859
+							if ($error != '') {
2860
+								return $error;
2861
+							} else {
2862
+								return self::check_version(true);
2863
+							}
2556 2864
 						} elseif ($result['value'] == '49') {
2557 2865
 							$error = self::update_from_49();
2558
-							if ($error != '') return $error;
2559
-							else return self::check_version(true);
2866
+							if ($error != '') {
2867
+								return $error;
2868
+							} else {
2869
+								return self::check_version(true);
2870
+							}
2560 2871
 						} elseif ($result['value'] == '50') {
2561 2872
 							$error = self::update_from_50();
2562
-							if ($error != '') return $error;
2563
-							else return self::check_version(true);
2873
+							if ($error != '') {
2874
+								return $error;
2875
+							} else {
2876
+								return self::check_version(true);
2877
+							}
2564 2878
 						} elseif ($result['value'] == '51') {
2565 2879
 							$error = self::update_from_51();
2566
-							if ($error != '') return $error;
2567
-							else return self::check_version(true);
2568
-						} else return '';
2880
+							if ($error != '') {
2881
+								return $error;
2882
+							} else {
2883
+								return self::check_version(true);
2884
+							}
2885
+						} else {
2886
+							return '';
2887
+						}
2569 2888
 					} else {
2570
-						if (isset($result['value']) && $result['value'] != '') return $result['value'];
2571
-						else return 0;
2889
+						if (isset($result['value']) && $result['value'] != '') {
2890
+							return $result['value'];
2891
+						} else {
2892
+							return 0;
2893
+						}
2572 2894
 					}
2573 2895
 				}
2574
-			} else return $version;
2896
+			} else {
2897
+				return $version;
2898
+			}
2575 2899
 		}
2576 2900
 	}
2577 2901
 }
Please login to merge, or discard this patch.