Completed
Push — master ( 6543b3...ee7c1e )
by Yannick
33:38
created
js/map.3d.js.php 1 patch
Braces   +47 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,21 +27,30 @@  discard block
 block discarded – undo
27 27
 
28 28
 document.cookie =  'MapFormat=3d; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
29 29
 <?php
30
-	if (isset($_COOKIE['MapType3D'])) $MapType = $_COOKIE['MapType3D'];
31
-	else $MapType = $globalMapProvider;
32
-//	unset($_COOKIE['MapType']);
30
+	if (isset($_COOKIE['MapType3D'])) {
31
+		$MapType = $_COOKIE['MapType3D'];
32
+	} else {
33
+		$MapType = $globalMapProvider;
34
+	}
35
+	//	unset($_COOKIE['MapType']);
33 36
 
34 37
 	if ($MapType != 'Mapbox' && $MapType != 'OpenStreetMap' && $MapType != 'Bing-Aerial' && $MapType != 'Bing-Hybrid' && $MapType != 'Bing-Road' && $MapType != 'offline' && $MapType != 'ArcGIS-Streetmap' && $MapType != 'ArcGIS-Satellite' && $MapType != 'NatGeo-Street') {
35
-		if (isset($globalBingMapKey) && $globalBingMapKey != '') $MapType = 'Bing-Aerial';
36
-		else $MapType = 'OpenStreetMap';
38
+		if (isset($globalBingMapKey) && $globalBingMapKey != '') {
39
+			$MapType = 'Bing-Aerial';
40
+		} else {
41
+			$MapType = 'OpenStreetMap';
42
+		}
37 43
 	}
38 44
 	if (($MapType == 'Bing-Aerial' || $MapType == 'Bing-Hybrid' || $MapType == 'Bing-Road') && (!isset($globalBingMapKey) || $globalBingMapKey == '')) {
39 45
 		$MapType = 'OpenStreetMap';
40 46
 	}
41 47
 	if ($MapType == 'Mapbox') {
42
-		if ($_COOKIE['MapTypeId'] == 'default') $MapBoxId = $globalMapboxId;
43
-		else $MapBoxId = $_COOKIE['MapType3DId'];
44
-?>
48
+		if ($_COOKIE['MapTypeId'] == 'default') {
49
+			$MapBoxId = $globalMapboxId;
50
+		} else {
51
+			$MapBoxId = $_COOKIE['MapType3DId'];
52
+		}
53
+		?>
45 54
 	var imProv = Cesium.MapboxImageryProvider({
46 55
 		credit: 'Map data © OpenStreetMap contributors, ' +
47 56
 	      'CC-BY-SA, ' +
@@ -108,13 +117,23 @@  discard block
 block discarded – undo
108 117
 		credit : 'Imagery courtesy Natural Earth'
109 118
 	});
110 119
 <?php
111
-	}  elseif (isset($globalMapCustomLayer[$MapType])) {
120
+	} elseif (isset($globalMapCustomLayer[$MapType])) {
112 121
 		$customid = $MapType;
113 122
 ?>
114 123
 	var imProv = Cesium.createOpenStreetMapImageryProvider({
115 124
 		url : '<?php print $globalMapCustomLayer[$customid]['url']; ?>',
116
-		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) print $globalMapCustomLayer[$customid]['maxZoom']; else print '99'; ?>,
117
-		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) print $globalMapCustomLayer[$customid]['minZoom']; else print '0'; ?>,
125
+		maximumLevel: <?php if (isset($globalMapCustomLayer[$customid]['maxZoom'])) {
126
+	print $globalMapCustomLayer[$customid]['maxZoom'];
127
+} else {
128
+	print '99';
129
+}
130
+?>,
131
+		minimumLevel: <?php if (isset($globalMapCustomLayer[$customid]['minZoom'])) {
132
+	print $globalMapCustomLayer[$customid]['minZoom'];
133
+} else {
134
+	print '0';
135
+}
136
+?>,
118 137
 		credit: '<?php print $globalMapCustomLayer[$customid]['attribution']; ?>'
119 138
 	});
120 139
 <?php
@@ -403,7 +422,12 @@  discard block
 block discarded – undo
403 422
 	imageryProvider : imProv,
404 423
 	timeline : archive,
405 424
 	animation : false,
406
-	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) print 'false'; else print 'true'; ?>,
425
+	shadows : <?php if ((isset($globalMap3DShadows) && $globalMap3DShadows === FALSE) || (isset($_COOKIE['map3dnoshadows']) && $_COOKIE['map3dnoshadows'] == 'true')) {
426
+	print 'false';
427
+} else {
428
+	print 'true';
429
+}
430
+?>,
407 431
 	infoBox : false,
408 432
 	navigationHelpButton : false,
409 433
 	geocoder : false,
@@ -416,8 +440,11 @@  discard block
 block discarded – undo
416 440
 	if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) {
417 441
 		if (isset($_COOKIE['lastcentercoord'])) {
418 442
 			$lastcentercoord = explode(',',$_COOKIE['lastcentercoord']);
419
-			if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0;
420
-			else $zoom = $lastcentercoord[3];
443
+			if (!isset($lastcentercoord[3])) {
444
+				$zoom = $lastcentercoord[2]*1000000.0;
445
+			} else {
446
+				$zoom = $lastcentercoord[3];
447
+			}
421 448
 			$viewcenterlatitude = $lastcentercoord[0];
422 449
 			$viewcenterlongitude = $lastcentercoord[1];
423 450
 		} else {
@@ -534,7 +561,12 @@  discard block
 block discarded – undo
534 561
 ?>
535 562
 
536 563
 update_locationsLayer();
537
-setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
564
+setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) {
565
+	print $globalMapRefresh*1000*2;
566
+} else {
567
+	print '60000';
568
+}
569
+?>);
538 570
 viewer.camera.moveEnd.addEventListener(function() { 
539 571
 <?php
540 572
 	if (isset($globalMapUseBbox) && $globalMapUseBbox) {
Please login to merge, or discard this patch.
index.php 2 patches
Indentation   +103 added lines, -103 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
 
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 		    </div>
248 248
 		</li>
249 249
 		<?php
250
-		    if (isset($globalDemo) && $globalDemo) {
250
+			if (isset($globalDemo) && $globalDemo) {
251 251
 		?>
252 252
 		<li><button type="button" class="btn btn-primary disabled"><?php echo _("Show archive"); ?></button> Disabled in Demo mode</li>
253 253
 		<?php
254
-		    } else {
254
+			} else {
255 255
 		?>
256 256
 		<li><button type="button" onclick="addarchive(begindate,enddate);" class="btn btn-primary"><?php echo _("Show archive"); ?></button></li>
257 257
 		<?php
258
-		    }
258
+			}
259 259
 		?>
260 260
 	    </ul>
261 261
 	    <ul>
@@ -274,82 +274,82 @@  discard block
 block discarded – undo
274 274
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
275 275
 					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
276 276
 					else $MapType = $_COOKIE['MapType'];
277
-			    ?>
277
+				?>
278 278
 			<select  class="selectpicker" onchange="mapType(this);">
279 279
 			    <?php
280 280
 				} else {
281 281
 					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
282 282
 					else $MapType = $_COOKIE['MapType3D'];
283
-			    ?>
283
+				?>
284 284
 			<select  class="selectpicker" onchange="mapType3D(this);">
285 285
 			    <?php
286 286
 				}
287
-			    ?>
287
+				?>
288 288
 			    <?php
289 289
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
290
-			    ?>
290
+				?>
291 291
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
292 292
 			    <?php
293 293
 				} else {
294
-				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
295
-			    ?>
294
+					if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
295
+				?>
296 296
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
297 297
 			    <?php
298
-				    }
299
-			    ?>
298
+					}
299
+				?>
300 300
 			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
301 301
 			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
302 302
 			    <?php
303
-				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
304
-			    ?>
303
+					if (isset($globalBingMapKey) && $globalBingMapKey != '') {
304
+				?>
305 305
 			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
306 306
 			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
307 307
 			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
308 308
 			    <?php
309
-				    }
310
-			    ?>
309
+					}
310
+				?>
311 311
 			    <?php
312
-				    if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
313
-			    ?>
312
+					if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
313
+				?>
314 314
 			    <?php
315 315
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
316
-			    ?>
316
+				?>
317 317
 			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
318 318
 			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
319 319
 			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
320 320
 			    <?php
321 321
 					}
322
-			    ?>
322
+				?>
323 323
 			    <?php
324 324
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
325
-			    ?>
325
+				?>
326 326
 			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
327 327
 			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
328 328
 			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
329 329
 			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
330 330
 			    <?php
331 331
 					}
332
-			    ?>
332
+				?>
333 333
 			    <?php
334 334
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
335
-			    ?>
335
+				?>
336 336
 			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
337 337
 			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
338 338
 			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
339 339
 			    <?php
340 340
 					}
341
-			    ?>
341
+				?>
342 342
 			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
343 343
 			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
344 344
 			    <?php
345
-				    }
346
-			    ?>
345
+					}
346
+				?>
347 347
 			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
348 348
 			    <?php
349
-				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
349
+					if (isset($globalMapboxToken) && $globalMapboxToken != '') {
350 350
 					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
351 351
 					else $MapBoxId = $_COOKIE['MapTypeId'];
352
-			    ?>
352
+				?>
353 353
 			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
354 354
 			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
355 355
 			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
365 365
 			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
366 366
 			    <?php
367
-				    }
368
-			    ?>
367
+					}
368
+				?>
369 369
 			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
370 370
 			    <?php
371 371
 				}
372
-			    ?>
372
+				?>
373 373
 			</select>
374 374
 		    </li>
375 375
 <?php
376
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
376
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d' && (!isset($globalMapOffline) || $globalMapOffline === FALSE)) {
377 377
 ?>
378 378
 		    <li><?php echo _("Type of Terrain:"); ?>
379 379
 			<select  class="selectpicker" onchange="terrainType(this);">
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 			</select>
385 385
 		    </li>
386 386
 <?php
387
-    }
387
+	}
388 388
 ?>
389 389
 
390 390
 <?php
391
-    if (isset($globalMap3D) && $globalMap3D) {
391
+	if (isset($globalMap3D) && $globalMap3D) {
392 392
 ?>
393 393
 		    <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>
394 394
 <?php
395
-    }
395
+	}
396 396
 ?>
397 397
 <?php
398
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
398
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
399 399
 ?>
400 400
 		    <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>
401 401
 
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 		    <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>
419 419
 <?php
420 420
 	}
421
-    }
421
+	}
422 422
 ?>
423 423
 		    <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>
424 424
 		    <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>
@@ -437,80 +437,80 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 ?>
439 439
 <?php
440
-    if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
440
+	if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
441 441
 ?>
442 442
 		    <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>
443 443
 		    <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>
444 444
 <?php
445
-    }
446
-    if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
445
+	}
446
+	if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
447 447
 ?>
448 448
 		    <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>
449 449
 <?php
450
-    }
450
+	}
451 451
 ?>
452 452
 		    <?php
453 453
 			if (function_exists('array_column')) {
454
-			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
455
-		    ?>
454
+				if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
455
+			?>
456 456
 		    <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>
457 457
 		    <?php
458
-			    }
458
+				}
459 459
 			} elseif (isset($globalSources)) {
460
-			    $dispolar = false;
461
-			    foreach ($globalSources as $testsource) {
462
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
463
-			    }
464
-			    if ($dispolar) {
465
-		    ?>
460
+				$dispolar = false;
461
+				foreach ($globalSources as $testsource) {
462
+					if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
463
+				}
464
+				if ($dispolar) {
465
+			?>
466 466
 		    <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>
467 467
 		    <?php
468
-			    }
469
-		        }
470
-		    ?>
468
+				}
469
+				}
470
+			?>
471 471
 <?php
472
-    if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
472
+	if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
473 473
 ?>
474 474
 
475 475
 		    <?php
476 476
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
477
-		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
478
-		    ?>
477
+					if (extension_loaded('gd') && function_exists('gd_info')) {
478
+			?>
479 479
 		    <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>
480 480
 		    <?php 
481 481
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
482
-		    ?>
482
+			?>
483 483
 			<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>
484 484
 		    <?php
485 485
 				}
486
-			    }
487
-		        }
488
-		    ?>
486
+				}
487
+				}
488
+			?>
489 489
 		    <?php
490 490
 			if (isset($globalMarine) && $globalMarine === TRUE) {
491
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
492
-		    ?>
491
+				if (extension_loaded('gd') && function_exists('gd_info')) {
492
+			?>
493 493
 		    <li><?php echo _("Marine icon color:"); ?>
494 494
 			<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'; ?>">
495 495
 		    </li>
496 496
 		    <?php
497
-			    }
498
-		        }
499
-		    ?>
497
+				}
498
+				}
499
+			?>
500 500
 		    <?php
501 501
 			if (isset($globalTracker) && $globalTracker === TRUE) {
502
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
503
-		    ?>
502
+				if (extension_loaded('gd') && function_exists('gd_info')) {
503
+			?>
504 504
 		    <li><?php echo _("Tracker icon color:"); ?>
505 505
 			<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'; ?>">
506 506
 		    </li>
507 507
 		    <?php
508
-			    }
509
-		        }
510
-		    ?>
508
+				}
509
+				}
510
+			?>
511 511
 		    <?php
512 512
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
513
-		    ?>
513
+			?>
514 514
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
515 515
 			<div class="range">
516 516
 			    <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'; ?>">
@@ -519,9 +519,9 @@  discard block
 block discarded – undo
519 519
 		    </li>
520 520
 		    <?php
521 521
 			}
522
-		    ?>
522
+			?>
523 523
 <?php
524
-    } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
524
+	} elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
525 525
 ?>
526 526
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
527 527
 			<div class="range">
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 		    </li>
560 560
 <?php
561 561
 	}
562
-    }
562
+	}
563 563
 ?>
564 564
 		    <li><?php echo _("Distance unit:"); ?>
565 565
 			<select class="selectpicker" onchange="unitdistance(this);">
@@ -592,19 +592,19 @@  discard block
 block discarded – undo
592 592
 		    <ul>
593 593
 		    <?php
594 594
 			if (!isset($globalAircraft) || $globalAircraft) {
595
-		    ?>
595
+			?>
596 596
 		    <?php
597 597
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
598
-		    ?>
598
+			?>
599 599
 			<?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 } ?>
600 600
 			<?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 } ?>
601 601
 			<?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 } ?>
602 602
 		    <?php
603 603
 			}
604
-		    ?>
604
+			?>
605 605
 		    <?php
606 606
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
607
-		    ?>
607
+			?>
608 608
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
609 609
 			    <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>
610 610
 			<?php } ?>
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 			<?php } ?>
614 614
 		    <?php
615 615
 			}
616
-		    ?>
616
+			?>
617 617
 		    <li><?php echo _("Display airlines:"); ?>
618 618
 		    <br/>
619 619
 			<select class="selectpicker" multiple onchange="airlines(this);" id="display_airlines">
@@ -633,14 +633,14 @@  discard block
 block discarded – undo
633 633
 						echo '<option value="'.$airline['airline_icao'].'">'.$airline_name.'</option>';
634 634
 					}
635 635
 				}
636
-			    ?>
636
+				?>
637 637
 			</select>
638 638
 		    </li>
639 639
 		    <?php
640 640
 			$Spotter = new Spotter();
641 641
 			$allalliancenames = $Spotter->getAllAllianceNames();
642 642
 			if (!empty($allalliancenames)) {
643
-		    ?>
643
+			?>
644 644
 		    <li><?php echo _("Display alliance:"); ?>
645 645
 		    <br/>
646 646
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
@@ -654,18 +654,18 @@  discard block
 block discarded – undo
654 654
 						echo '<option value="'.$alliance_name.'">'.$alliance_name.'</option>';
655 655
 					}
656 656
 				}
657
-			    ?>
657
+				?>
658 658
 			</select>
659 659
 		    </li>
660 660
 		    <?php
661 661
 			}
662
-		    ?>
662
+			?>
663 663
 		    <?php
664 664
 			}
665
-		    ?>
665
+			?>
666 666
 		    <?php
667 667
 			if (isset($globalAPRS) && $globalAPRS) {
668
-		    ?>
668
+			?>
669 669
 		    <li><?php echo _("Display APRS sources name:"); ?>
670 670
 			<select class="selectpicker" multiple onchange="sources(this);">
671 671
 			    <?php
@@ -689,18 +689,18 @@  discard block
 block discarded – undo
689 689
 						echo '<option value="'.$src['name'].'">'.$src['name'].'</option>';
690 690
 					}
691 691
 				}
692
-			    ?>
692
+				?>
693 693
 			</select>
694 694
 		    </li>
695 695
 		    <?php
696 696
 			}
697
-		    ?>
697
+			?>
698 698
 		    <?php
699 699
 			if (!isset($globalAircraft) || $globalAircraft) {
700
-		    ?>
700
+			?>
701 701
 		    <?php
702
-			    if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
703
-		    ?>
702
+				if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS)) {
703
+			?>
704 704
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
705 705
 			<select class="selectpicker" onchange="airlinestype(this);">
706 706
 			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
@@ -710,21 +710,21 @@  discard block
 block discarded – undo
710 710
 			</select>
711 711
 		    </li>
712 712
 		    <?php
713
-			    }
714
-		    ?>
713
+				}
714
+			?>
715 715
 		    <?php
716 716
 			}
717
-		    ?>
717
+			?>
718 718
 		    <?php
719 719
 			if (isset($globalMarine) && $globalMarine) {
720
-		    ?>
720
+			?>
721 721
 		    <li>
722 722
 			<?php echo _("Display vessels with MMSI:"); ?>
723 723
 			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
724 724
 		    </li>
725 725
 		    <?php
726 726
 			}
727
-		    ?>
727
+			?>
728 728
 		    <li>
729 729
 			<?php echo _("Display with ident:"); ?>
730 730
 			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	    </form>
738 738
     	</div>
739 739
 <?php
740
-    if (isset($globalSatellite) && $globalSatellite) {
740
+	if (isset($globalSatellite) && $globalSatellite) {
741 741
 ?>
742 742
         <div class="sidebar-pane" id="satellites">
743 743
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
@@ -777,14 +777,14 @@  discard block
 block discarded – undo
777 777
 						print '<option value="'.$type['tle_type'].'">'.$type_name.'</option>';
778 778
 					}
779 779
 				}
780
-			    ?>
780
+				?>
781 781
 			</select>
782 782
 		    </li>
783 783
 		</ul>
784 784
 	    </form>
785 785
 	</div>
786 786
 <?php
787
-    }
787
+	}
788 788
 ?>
789 789
     </div>
790 790
 </div>
Please login to merge, or discard this patch.
Braces   +534 added lines, -135 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
 ?>
@@ -145,8 +148,14 @@  discard block
 block discarded – undo
145 148
 ?>
146 149
 		<form>
147 150
 			<ul>
148
-				<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>
149
-				<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>
151
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
152
+	print 'checked';
153
+}
154
+?> /><?php echo _("Display waypoints"); ?></label></div></li>
155
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
156
+	print 'checked';
157
+}
158
+?> /><?php echo _("Display airspace"); ?></label></div></li>
150 159
 			</ul>
151 160
 		</form>
152 161
 <?php
@@ -154,8 +163,14 @@  discard block
 block discarded – undo
154 163
 ?>
155 164
 		<form>
156 165
 			<ul>
157
-				<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>
158
-				<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>
166
+				<li><div class="checkbox"><label><input type="checkbox" name="waypoints" value="1" onclick="showWaypoints(this);" <?php if (isset($_COOKIE['waypoints']) && $_COOKIE['waypoints'] == 'true') {
167
+	print 'checked';
168
+}
169
+?> /><?php echo _("Display waypoints"); ?> Beta</label></div></li>
170
+				<li><div class="checkbox"><label><input type="checkbox" name="airspace" value="1" onclick="showAirspace(this);" <?php if (isset($_COOKIE['airspace']) && $_COOKIE['airspace'] == 'true') {
171
+	print 'checked';
172
+}
173
+?> /><?php echo _("Display airspace"); ?> Beta</label></div></li>
159 174
 			</ul>
160 175
 			<p>This layers are in Beta, this can and will crash.</p>
161 176
 		</form>
@@ -166,14 +181,32 @@  discard block
 block discarded – undo
166 181
 		<h1>NOTAM</h1>
167 182
 		<form>
168 183
 			<ul>
169
-				<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>
184
+				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam(this);" <?php if (isset($_COOKIE['notam']) && $_COOKIE['notam'] == 'true') {
185
+	print 'checked';
186
+}
187
+?> /><?php echo _("Display NOTAM"); ?></label></div></li>
170 188
 				<li><?php echo _("NOTAM scope:"); ?>
171 189
 					<select class="selectpicker" onchange="notamscope(this);">
172
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
173
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
174
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
175
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
176
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
190
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
191
+	print ' selected';
192
+}
193
+?>>All</option>
194
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
195
+	print ' selected';
196
+}
197
+?>>Airport/Enroute warning</option>
198
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
199
+	print ' selected';
200
+}
201
+?>>Airport warning</option>
202
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
203
+	print ' selected';
204
+}
205
+?>>Navigation warning</option>
206
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
207
+	print ' selected';
208
+}
209
+?>>Enroute warning</option>
177 210
 					</select
178 211
 				</li>
179 212
 			</ul>
@@ -201,7 +234,10 @@  discard block
 block discarded – undo
201 234
 		    <div class="form-group">
202 235
 			<label><?php echo _("From:"); ?></label>
203 236
 			<div class='input-group date' id='datetimepicker1'>
204
-			    <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 />
237
+			    <input type='text' id="start_date" name="start_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_begin']) && $_COOKIE['archive_begin'] != '') {
238
+	print date("Y-m-d H:i",$_COOKIE['archive_begin']).' UTC';
239
+}
240
+?>" required />
205 241
 			    <span class="input-group-addon">
206 242
 				<span class="glyphicon glyphicon-calendar"></span>
207 243
 			    </span>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 		    <div class="form-group">
211 247
 			<label><?php echo _("To:"); ?></label>
212 248
 			<div class='input-group date' id='datetimepicker2'>
213
-			    <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'; ?>" />
249
+			    <input type='text' id="end_date" name="end_date" class="form-control" autocomplete="off" value="<?php if (isset($_COOKIE['archive_end']) && $_COOKIE['archive_end'] != '') {
250
+	print date("Y-m-d H:i",$_COOKIE['archive_end']).' UTC';
251
+}
252
+?>" />
214 253
 			    <span class="input-group-addon">
215 254
 				<span class="glyphicon glyphicon-calendar"></span>
216 255
 			    </span>
@@ -242,8 +281,20 @@  discard block
 block discarded – undo
242 281
 		    </script>
243 282
 		<li><?php echo _("Playback speed:"); ?>
244 283
 		    <div class="range">
245
-			<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'; ?>">
246
-			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
284
+			<input type="range" min="0" max="50" step="1" id="archivespeed" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
285
+	print $_POST['archivespeed'];
286
+} elseif (isset($_COOKIE['archive_speed'])) {
287
+	print $_COOKIE['archive_speed'];
288
+} else {
289
+	print '1';
290
+}
291
+?>">
292
+			<output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
293
+	print $_COOKIE['archive_speed'];
294
+} else {
295
+	print '1';
296
+}
297
+?></output>
247 298
 		    </div>
248 299
 		</li>
249 300
 		<?php
@@ -272,14 +323,20 @@  discard block
 block discarded – undo
272 323
 		    <li><?php echo _("Type of Map:"); ?>
273 324
 			    <?php
274 325
 				if ((!isset($_COOKIE['MapFormat']) && (!isset($globalMap3Ddefault) || !$globalMap3Ddefault)) || (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] != '3d')) {
275
-					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
276
-					else $MapType = $_COOKIE['MapType'];
326
+					if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
327
+						$MapType = $globalMapProvider;
328
+					} else {
329
+						$MapType = $_COOKIE['MapType'];
330
+					}
277 331
 			    ?>
278 332
 			<select  class="selectpicker" onchange="mapType(this);">
279 333
 			    <?php
280 334
 				} else {
281
-					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') $MapType = $globalMapProvider;
282
-					else $MapType = $_COOKIE['MapType3D'];
335
+					if (!isset($_COOKIE['MapType3D']) || $_COOKIE['MapType3D'] == '') {
336
+						$MapType = $globalMapProvider;
337
+					} else {
338
+						$MapType = $_COOKIE['MapType3D'];
339
+					}
283 340
 			    ?>
284 341
 			<select  class="selectpicker" onchange="mapType3D(this);">
285 342
 			    <?php
@@ -288,23 +345,44 @@  discard block
 block discarded – undo
288 345
 			    <?php
289 346
 				if (isset($globalMapOffline) && $globalMapOffline === TRUE) {
290 347
 			    ?>
291
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
348
+			    <option value="offline"<?php if ($MapType == 'offline') {
349
+	print ' selected';
350
+}
351
+?>>Natural Earth (local)</option>
292 352
 			    <?php
293 353
 				} else {
294 354
 				    if (file_exists(dirname(__FILE__).'/js/Cesium/Assets/Textures/NaturalEarthII/tilemapresource.xml')) {
295 355
 			    ?>
296
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth (local)</option>
356
+			    <option value="offline"<?php if ($MapType == 'offline') {
357
+	print ' selected';
358
+}
359
+?>>Natural Earth (local)</option>
297 360
 			    <?php
298 361
 				    }
299 362
 			    ?>
300
-			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') print ' selected'; ?>>ArcGIS Streetmap</option>
301
-			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') print ' selected'; ?>>ArcGIS Satellite</option>
363
+			    <option value="ArcGIS-Streetmap"<?php if ($MapType == 'ArcGIS-Streetmap') {
364
+	print ' selected';
365
+}
366
+?>>ArcGIS Streetmap</option>
367
+			    <option value="ArcGIS-Satellite"<?php if ($MapType == 'ArcGIS-Satellite') {
368
+	print ' selected';
369
+}
370
+?>>ArcGIS Satellite</option>
302 371
 			    <?php
303 372
 				    if (isset($globalBingMapKey) && $globalBingMapKey != '') {
304 373
 			    ?>
305
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
306
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
307
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
374
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
375
+	print ' selected';
376
+}
377
+?>>Bing-Aerial</option>
378
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
379
+	print ' selected';
380
+}
381
+?>>Bing-Hybrid</option>
382
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
383
+	print ' selected';
384
+}
385
+?>>Bing-Road</option>
308 386
 			    <?php
309 387
 				    }
310 388
 			    ?>
@@ -314,59 +392,143 @@  discard block
 block discarded – undo
314 392
 			    <?php
315 393
 					if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
316 394
 			    ?>
317
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
318
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
319
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
395
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
396
+	print ' selected';
397
+}
398
+?>>Here-Aerial</option>
399
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
400
+	print ' selected';
401
+}
402
+?>>Here-Hybrid</option>
403
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
404
+	print ' selected';
405
+}
406
+?>>Here-Road</option>
320 407
 			    <?php
321 408
 					}
322 409
 			    ?>
323 410
 			    <?php
324 411
 					if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
325 412
 			    ?>
326
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
327
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
328
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
329
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
413
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
414
+	print ' selected';
415
+}
416
+?>>Google Roadmap</option>
417
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
418
+	print ' selected';
419
+}
420
+?>>Google Satellite</option>
421
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
422
+	print ' selected';
423
+}
424
+?>>Google Hybrid</option>
425
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
426
+	print ' selected';
427
+}
428
+?>>Google Terrain</option>
330 429
 			    <?php
331 430
 					}
332 431
 			    ?>
333 432
 			    <?php
334 433
 					if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
335 434
 			    ?>
336
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
337
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
338
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
435
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
436
+	print ' selected';
437
+}
438
+?>>MapQuest-OSM</option>
439
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
440
+	print ' selected';
441
+}
442
+?>>MapQuest-Aerial</option>
443
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
444
+	print ' selected';
445
+}
446
+?>>MapQuest-Hybrid</option>
339 447
 			    <?php
340 448
 					}
341 449
 			    ?>
342
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
343
-			    <option value="offline"<?php if ($MapType == 'offline') print ' selected'; ?>>Natural Earth</option>
450
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
451
+	print ' selected';
452
+}
453
+?>>Yandex</option>
454
+			    <option value="offline"<?php if ($MapType == 'offline') {
455
+	print ' selected';
456
+}
457
+?>>Natural Earth</option>
344 458
 			    <?php
345 459
 				    }
346 460
 			    ?>
347
-			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') print ' selected'; ?>>National Geographic Street</option>
461
+			    <option value="NatGeo-Street"<?php if ($MapType == 'NatGeo-Street') {
462
+	print ' selected';
463
+}
464
+?>>National Geographic Street</option>
348 465
 			    <?php
349 466
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
350
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
351
-					else $MapBoxId = $_COOKIE['MapTypeId'];
467
+					if (!isset($_COOKIE['MapTypeId'])) {
468
+						$MapBoxId = 'default';
469
+					} else {
470
+						$MapBoxId = $_COOKIE['MapTypeId'];
471
+					}
352 472
 			    ?>
353
-			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') print ' selected'; ?>>Mapbox GL</option>
354
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
355
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
356
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
357
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
358
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
359
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
360
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
361
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
362
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
363
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
364
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
365
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
473
+			    <option value="MapboxGL"<?php if ($MapType == 'MapboxGL') {
474
+	print ' selected';
475
+}
476
+?>>Mapbox GL</option>
477
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
478
+	print ' selected';
479
+}
480
+?>>Mapbox default</option>
481
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
482
+	print ' selected';
483
+}
484
+?>>Mapbox streets</option>
485
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
486
+	print ' selected';
487
+}
488
+?>>Mapbox light</option>
489
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
490
+	print ' selected';
491
+}
492
+?>>Mapbox dark</option>
493
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
494
+	print ' selected';
495
+}
496
+?>>Mapbox satellite</option>
497
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
498
+	print ' selected';
499
+}
500
+?>>Mapbox streets-satellite</option>
501
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
502
+	print ' selected';
503
+}
504
+?>>Mapbox streets-basic</option>
505
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
506
+	print ' selected';
507
+}
508
+?>>Mapbox comic</option>
509
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
510
+	print ' selected';
511
+}
512
+?>>Mapbox outdoors</option>
513
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
514
+	print ' selected';
515
+}
516
+?>>Mapbox pencil</option>
517
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
518
+	print ' selected';
519
+}
520
+?>>Mapbox pirates</option>
521
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
522
+	print ' selected';
523
+}
524
+?>>Mapbox emerald</option>
366 525
 			    <?php
367 526
 				    }
368 527
 			    ?>
369
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
528
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
529
+	print ' selected';
530
+}
531
+?>>OpenStreetMap</option>
370 532
 			    <?php
371 533
 				}
372 534
 			    ?>
@@ -377,10 +539,22 @@  discard block
 block discarded – undo
377 539
 ?>
378 540
 		    <li><?php echo _("Type of Terrain:"); ?>
379 541
 			<select  class="selectpicker" onchange="terrainType(this);">
380
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
381
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
382
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
383
-			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') print ' selected';?>>ArticDEM</option>
542
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
543
+	print ' selected';
544
+}
545
+?>>stk terrain</option>
546
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
547
+	print ' selected';
548
+}
549
+?>>ellipsoid</option>
550
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
551
+	print ' selected';
552
+}
553
+?>>vr terrain</option>
554
+			    <option value="articdem"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'articdem') {
555
+	print ' selected';
556
+}
557
+?>>ArticDEM</option>
384 558
 			</select>
385 559
 		    </li>
386 560
 <?php
@@ -390,57 +564,108 @@  discard block
 block discarded – undo
390 564
 <?php
391 565
     if (isset($globalMap3D) && $globalMap3D) {
392 566
 ?>
393
-		    <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>
567
+		    <li><div class="checkbox"><label><input type="checkbox" name="synchro2d3d" value="1" onclick="clickSyncMap2D3D(this)" <?php if (isset($_COOKIE['Map2D3DSync']) && $_COOKIE['Map2D3DSync'] == 'true') {
568
+	print 'checked';
569
+}
570
+?> ><?php echo _("Use same type of map for 2D & 3D"); ?></label></div></li>
394 571
 <?php
395 572
     }
396 573
 ?>
397 574
 <?php
398 575
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
399 576
 ?>
400
-		    <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>
577
+		    <li><div class="checkbox"><label><input type="checkbox" name="display2dbuildings" value="1" onclick="clickDisplay2DBuildings(this)" <?php if (isset($_COOKIE['Map2DBuildings']) && $_COOKIE['Map2DBuildings'] == 'true') {
578
+	print 'checked';
579
+}
580
+?> ><?php echo _("Display 2.5D buidings on map"); ?></label></div></li>
401 581
 
402 582
 <?php
403 583
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
404 584
 ?>
405
-		    <!--<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>-->
406
-		    <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>
407
-		    <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>
408
-		    <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>
409
-		    <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>
585
+		    <!--<li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
586
+	print 'checked';
587
+}
588
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>-->
589
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
590
+	print 'checked';
591
+}
592
+?> ><?php echo _("Display flight path"); ?></label></div></li>
593
+		    <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)) {
594
+	print 'checked';
595
+}
596
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
597
+		    <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)) {
598
+	print 'checked';
599
+}
600
+?> ><?php echo _("Display flight remaining route on click"); ?></label></div></li>
601
+		    <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)) {
602
+	print 'checked';
603
+}
604
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
410 605
 <?php
411 606
 	} elseif (!isset($globalTracker) || $globalTracker === TRUE) {
412 607
 ?>
413
-		    <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>
608
+		    <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)) {
609
+	print 'checked';
610
+}
611
+?> ><?php echo _("Enable map matching"); ?></label></div></li>
414 612
 <?php
415 613
 	}
416 614
 	if (isset($globalSatellite) && $globalSatellite === TRUE) {
417 615
 ?>
418
-		    <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>
616
+		    <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)) {
617
+	print 'checked';
618
+}
619
+?> ><?php echo _("Satellites animate between updates"); ?></label></div></li>
419 620
 <?php
420 621
 	}
421 622
     }
422 623
 ?>
423
-		    <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>
424
-		    <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>
425
-		    <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>
426
-		    <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>
624
+		    <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'])) {
625
+	print 'checked';
626
+}
627
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
628
+		    <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))) {
629
+	print 'checked';
630
+}
631
+?> ><?php echo _("Display ground station on map"); ?></label></div></li>
632
+		    <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))) {
633
+	print 'checked';
634
+}
635
+?> ><?php echo _("Display weather station on map"); ?></label></div></li>
636
+		    <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))) {
637
+	print 'checked';
638
+}
639
+?> ><?php echo _("Display lightning on map"); ?></label></div></li>
427 640
 <?php
428 641
 	if (isset($globalFires)) {
429 642
 ?>
430
-		    <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>
643
+		    <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))) {
644
+	print 'checked';
645
+}
646
+?> ><?php echo _("Display fires on map"); ?></label></div></li>
431 647
 <?php
432 648
 	}
433 649
 	if (isset($globalMap3D) && $globalMap3D) {
434 650
 ?>
435
-		    <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>
651
+		    <li><div class="checkbox"><label><input type="checkbox" name="singlemodel" value="1" onclick="clickSingleModel(this)" <?php if (isset($_COOKIE['singlemodel']) && $_COOKIE['singlemodel'] == 'true') {
652
+	print 'checked';
653
+}
654
+?> ><?php echo _("Only display selected flight on 3D mode"); ?></label></div></li>
436 655
 <?php
437 656
 	}
438 657
 ?>
439 658
 <?php
440 659
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
441 660
 ?>
442
-		    <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>
443
-		    <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>
661
+		    <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')) {
662
+	print 'checked';
663
+}
664
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
665
+		    <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)) {
666
+	print 'checked';
667
+}
668
+?> ><?php echo _("Use same 3D model for all aircraft (use fewer resources)"); ?></label></div></li>
444 669
 <?php
445 670
     }
446 671
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -453,17 +678,25 @@  discard block
 block discarded – undo
453 678
 			if (function_exists('array_column')) {
454 679
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
455 680
 		    ?>
456
-		    <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>
681
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
682
+	print 'checked';
683
+}
684
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
457 685
 		    <?php
458 686
 			    }
459 687
 			} elseif (isset($globalSources)) {
460 688
 			    $dispolar = false;
461 689
 			    foreach ($globalSources as $testsource) {
462
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
690
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
691
+			        	$dispolar = true;
692
+			        }
463 693
 			    }
464 694
 			    if ($dispolar) {
465 695
 		    ?>
466
-		    <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>
696
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
697
+	print 'checked';
698
+}
699
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
467 700
 		    <?php
468 701
 			    }
469 702
 		        }
@@ -476,11 +709,21 @@  discard block
 block discarded – undo
476 709
 			if (!isset($globalAircraft) || $globalAircraft === TRUE) {
477 710
 		    	    if (extension_loaded('gd') && function_exists('gd_info')) {
478 711
 		    ?>
479
-		    <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>
712
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
713
+	print 'checked';
714
+}
715
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
480 716
 		    <?php 
481 717
 				if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
482 718
 		    ?>
483
-			<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>
719
+			<li><?php echo _("Aircraft icon color:"); ?><input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
720
+	print $_COOKIE['IconColor'];
721
+} elseif (isset($globalAircraftIconColor)) {
722
+	print $globalAircraftIconColor;
723
+} else {
724
+	print '1a3151';
725
+}
726
+?>"></li>
484 727
 		    <?php
485 728
 				}
486 729
 			    }
@@ -491,7 +734,14 @@  discard block
 block discarded – undo
491 734
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
492 735
 		    ?>
493 736
 		    <li><?php echo _("Marine icon color:"); ?>
494
-			<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'; ?>">
737
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
738
+	print $_COOKIE['MarineIconColor'];
739
+} elseif (isset($globalMarineIconColor)) {
740
+	print $globalMarineIconColor;
741
+} else {
742
+	print '1a3151';
743
+}
744
+?>">
495 745
 		    </li>
496 746
 		    <?php
497 747
 			    }
@@ -502,7 +752,14 @@  discard block
 block discarded – undo
502 752
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
503 753
 		    ?>
504 754
 		    <li><?php echo _("Tracker icon color:"); ?>
505
-			<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'; ?>">
755
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
756
+	print $_COOKIE['TrackerIconColor'];
757
+} elseif (isset($globalTrackerIconColor)) {
758
+	print $globalTrackerIconColor;
759
+} else {
760
+	print '1a3151';
761
+}
762
+?>">
506 763
 		    </li>
507 764
 		    <?php
508 765
 			    }
@@ -513,8 +770,22 @@  discard block
 block discarded – undo
513 770
 		    ?>
514 771
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
515 772
 			<div class="range">
516
-			    <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'; ?>">
517
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
773
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
774
+	print $_COOKIE['AirportZoom'];
775
+} elseif (isset($globalAirportZoom)) {
776
+	print $globalAirportZoom;
777
+} else {
778
+	print '7';
779
+}
780
+?>">
781
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
782
+	print $_COOKIE['AirportZoom'];
783
+} elseif (isset($globalAirportZoom)) {
784
+	print $globalAirportZoom;
785
+} else {
786
+	print '7';
787
+}
788
+?></output>
518 789
 			</div>
519 790
 		    </li>
520 791
 		    <?php
@@ -525,17 +796,40 @@  discard block
 block discarded – undo
525 796
 ?>
526 797
 		    <li><?php echo _("Set scaling factor for rendering resolution:"); ?>
527 798
 			<div class="range">
528
-			    <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'; ?>">
529
-			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) print $_COOKIE['resolutionScale']; else print '1'; ?></output>
799
+			    <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'])) {
800
+	print $_COOKIE['resolutionScale'];
801
+} else {
802
+	print '1';
803
+}
804
+?>">
805
+			    <output id="scale"><?php if (isset($_COOKIE['resolutionScale'])) {
806
+	print $_COOKIE['resolutionScale'];
807
+} else {
808
+	print '1';
809
+}
810
+?></output>
530 811
 			</div>
531 812
 		    </li>
532 813
 <?php
533 814
 	if (!isset($globalAircraft) || $globalAircraft === TRUE) {
534 815
 ?>
535
-		    <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>
536
-		    <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;
816
+		    <li><input type="checkbox" name="useliveries" value="1" onclick="useLiveries(this)" <?php if (isset($_COOKIE['UseLiveries']) && $_COOKIE['UseLiveries'] == 'true') {
817
+	print 'checked';
818
+}
819
+?> > <?php echo _("Use airlines liveries"); ?></li>
820
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
821
+	print 'checked';
822
+}
823
+?> > <?php echo _("Force Aircraft color"); ?>&nbsp;
537 824
 		    <!--<li><?php echo _("Aircraft icon color:"); ?>-->
538
-			<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'; ?>">
825
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
826
+	print $_COOKIE['IconColor'];
827
+} elseif (isset($globalAircraftIconColor)) {
828
+	print $globalAircraftIconColor;
829
+} else {
830
+	print 'ff0000';
831
+}
832
+?>">
539 833
 		    </li>
540 834
 <?php
541 835
 	}
@@ -543,9 +837,19 @@  discard block
 block discarded – undo
543 837
 <?php
544 838
 	if (isset($globalMarine) && $globalMarine === TRUE) {
545 839
 ?>
546
-		    <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;
840
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="MarineiconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
841
+	print 'checked';
842
+}
843
+?> ><?php echo _("Force Marine color"); ?>&nbsp;
547 844
 		    <!--<li><?php echo _("Marine icon color:"); ?>-->
548
-			<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'; ?>">
845
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="MarineiconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
846
+	print $_COOKIE['MarineIconColor'];
847
+} elseif (isset($globalMarineIconColor)) {
848
+	print $globalMarineIconColor;
849
+} else {
850
+	print 'ff0000';
851
+}
852
+?>">
549 853
 		    </li>
550 854
 <?php
551 855
 	}
@@ -553,9 +857,19 @@  discard block
 block discarded – undo
553 857
 <?php
554 858
 	if (isset($globalTracker) && $globalTracker === TRUE) {
555 859
 ?>
556
-		    <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;
860
+		    <li><input type="checkbox" name="trackercolorforce" value="1" onclick="TrackericonColorForce(this)" <?php if (isset($_COOKIE['TrackerIconColorForce']) && $_COOKIE['TrackerIconColorForce'] == 'true') {
861
+	print 'checked';
862
+}
863
+?> ><?php echo _("Force Tracker color"); ?>&nbsp;
557 864
 		    <!--<li><?php echo _("Tracker icon color:"); ?>-->
558
-			<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'; ?>">
865
+			<input type="color" name="trackercolor" id="html5colorpicker" onchange="TrackericonColor(trackercolor.value);" value="#<?php if (isset($_COOKIE['TrackerIconColor'])) {
866
+	print $_COOKIE['TrackerIconColor'];
867
+} elseif (isset($globalTrackerIconColor)) {
868
+	print $globalTrackerIconColor;
869
+} else {
870
+	print 'ff0000';
871
+}
872
+?>">
559 873
 		    </li>
560 874
 <?php
561 875
 	}
@@ -563,22 +877,46 @@  discard block
 block discarded – undo
563 877
 ?>
564 878
 		    <li><?php echo _("Distance unit:"); ?>
565 879
 			<select class="selectpicker" onchange="unitdistance(this);">
566
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
567
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
568
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
880
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
881
+	echo ' selected';
882
+}
883
+?>>km</option>
884
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
885
+	echo ' selected';
886
+}
887
+?>>nm</option>
888
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
889
+	echo ' selected';
890
+}
891
+?>>mi</option>
569 892
 		        </select>
570 893
 		    </li>
571 894
 		    <li><?php echo _("Altitude unit:"); ?>
572 895
 			<select class="selectpicker" onchange="unitaltitude(this);">
573
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
574
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
896
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
897
+	echo ' selected';
898
+}
899
+?>>m</option>
900
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
901
+	echo ' selected';
902
+}
903
+?>>feet</option>
575 904
 		        </select>
576 905
 		    </li>
577 906
 		    <li><?php echo _("Speed unit:"); ?>
578 907
 			<select class="selectpicker" onchange="unitspeed(this);">
579
-			    <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>
580
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
581
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
908
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
909
+	echo ' selected';
910
+}
911
+?>>km/h</option>
912
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
913
+	echo ' selected';
914
+}
915
+?>>mph</option>
916
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
917
+	echo ' selected';
918
+}
919
+?>>knots</option>
582 920
 		        </select>
583 921
 		    </li>
584 922
 
@@ -596,9 +934,18 @@  discard block
 block discarded – undo
596 934
 		    <?php
597 935
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
598 936
 		    ?>
599
-			<?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 } ?>
600
-			<?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 } ?>
601
-			<?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 } ?>
937
+			<?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'])) {
938
+	print 'checked';
939
+}
940
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
941
+			<?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'])) {
942
+	print 'checked';
943
+}
944
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
945
+			<?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'])) {
946
+	print 'checked';
947
+}
948
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
602 949
 		    <?php
603 950
 			}
604 951
 		    ?>
@@ -606,10 +953,16 @@  discard block
 block discarded – undo
606 953
 			if (!(isset($globalVA) && $globalVA) && !(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
607 954
 		    ?>
608 955
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
609
-			    <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>
956
+			    <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'])) {
957
+	print 'checked';
958
+}
959
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
610 960
 			<?php } ?>
611 961
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
612
-			    <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>
962
+			    <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'])) {
963
+	print 'checked';
964
+}
965
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
613 966
 			<?php } ?>
614 967
 		    <?php
615 968
 			}
@@ -626,7 +979,9 @@  discard block
 block discarded – undo
626 979
 				}
627 980
 				foreach($allairlinenames as $airline) {
628 981
 					$airline_name = $airline['airline_name'];
629
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
982
+					if (strlen($airline_name) > 30) {
983
+						$airline_name = substr($airline_name,0,30).'...';
984
+					}
630 985
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
631 986
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
632 987
 					} else {
@@ -644,7 +999,10 @@  discard block
 block discarded – undo
644 999
 		    <li><?php echo _("Display alliance:"); ?>
645 1000
 		    <br/>
646 1001
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
647
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
1002
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
1003
+	echo ' selected';
1004
+}
1005
+?>><?php echo _("All"); ?></option>
648 1006
 			    <?php
649 1007
 				foreach($allalliancenames as $alliance) {
650 1008
 					$alliance_name = $alliance['alliance'];
@@ -703,10 +1061,22 @@  discard block
 block discarded – undo
703 1061
 		    ?>
704 1062
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
705 1063
 			<select class="selectpicker" onchange="airlinestype(this);">
706
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
707
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
708
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
709
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
1064
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
1065
+	echo ' selected';
1066
+}
1067
+?>><?php echo _("All"); ?></option>
1068
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
1069
+	echo ' selected';
1070
+}
1071
+?>><?php echo _("Passenger"); ?></option>
1072
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
1073
+	echo ' selected';
1074
+}
1075
+?>><?php echo _("Cargo"); ?></option>
1076
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
1077
+	echo ' selected';
1078
+}
1079
+?>><?php echo _("Military"); ?></option>
710 1080
 			</select>
711 1081
 		    </li>
712 1082
 		    <?php
@@ -720,14 +1090,20 @@  discard block
 block discarded – undo
720 1090
 		    ?>
721 1091
 		    <li>
722 1092
 			<?php echo _("Display vessels with MMSI:"); ?>
723
-			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) print $_COOKIE['filter_mmsi']; ?>" />
1093
+			<input type="text" name="mmsifilter" onchange="mmsifilter();" id="mmsifilter" value="<?php if (isset($_COOKIE['filter_mmsi'])) {
1094
+	print $_COOKIE['filter_mmsi'];
1095
+}
1096
+?>" />
724 1097
 		    </li>
725 1098
 		    <?php
726 1099
 			}
727 1100
 		    ?>
728 1101
 		    <li>
729 1102
 			<?php echo _("Display with ident:"); ?>
730
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
1103
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
1104
+	print $_COOKIE['filter_ident'];
1105
+}
1106
+?>" />
731 1107
 		    </li>
732 1108
 		</ul>
733 1109
 	    </form>
@@ -743,7 +1119,10 @@  discard block
 block discarded – undo
743 1119
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
744 1120
 	    <form>
745 1121
 		<ul>
746
-		    <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>
1122
+		    <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'])) {
1123
+	print 'checked';
1124
+}
1125
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
747 1126
 		    <li><?php echo _("Type:"); ?>
748 1127
 			<select class="selectpicker" multiple onchange="sattypes(this);">
749 1128
 			    <?php
@@ -751,25 +1130,45 @@  discard block
 block discarded – undo
751 1130
 				$types = $Satellite->get_tle_types();
752 1131
 				foreach ($types as $type) {
753 1132
 					$type_name = $type['tle_type'];
754
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
755
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
756
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
757
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
758
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
759
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
760
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
761
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
762
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
763
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
764
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
765
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
766
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
767
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
768
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
769
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
770
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
771
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
772
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
1133
+					if ($type_name == 'musson') {
1134
+						$type_name = 'Russian LEO Navigation';
1135
+					} else if ($type_name == 'nnss') {
1136
+						$type_name = 'Navi Navigation Satellite System';
1137
+					} else if ($type_name == 'sbas') {
1138
+						$type_name = 'Satellite-Based Augmentation System';
1139
+					} else if ($type_name == 'glo-ops') {
1140
+						$type_name = 'Glonass Operational';
1141
+					} else if ($type_name == 'gps-ops') {
1142
+						$type_name = 'GPS Operational';
1143
+					} else if ($type_name == 'argos') {
1144
+						$type_name = 'ARGOS Data Collection System';
1145
+					} else if ($type_name == 'tdrss') {
1146
+						$type_name = 'Tracking and Data Relay Satellite System';
1147
+					} else if ($type_name == 'sarsat') {
1148
+						$type_name = 'Search & Rescue';
1149
+					} else if ($type_name == 'dmc') {
1150
+						$type_name = 'Disaster Monitoring';
1151
+					} else if ($type_name == 'resource') {
1152
+						$type_name = 'Earth Resources';
1153
+					} else if ($type_name == 'stations') {
1154
+						$type_name = 'Space Stations';
1155
+					} else if ($type_name == 'geo') {
1156
+						$type_name = 'Geostationary';
1157
+					} else if ($type_name == 'amateur') {
1158
+						$type_name = 'Amateur Radio';
1159
+					} else if ($type_name == 'x-comm') {
1160
+						$type_name = 'Experimental';
1161
+					} else if ($type_name == 'other-comm') {
1162
+						$type_name = 'Other Comm';
1163
+					} else if ($type_name == 'science') {
1164
+						$type_name = 'Space & Earth Science';
1165
+					} else if ($type_name == 'military') {
1166
+						$type_name = 'Miscellaneous Military';
1167
+					} else if ($type_name == 'radar') {
1168
+						$type_name = 'Radar Calibration';
1169
+					} else if ($type_name == 'tle-new') {
1170
+						$type_name = 'Last 30 days launches';
1171
+					}
773 1172
 					
774 1173
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
775 1174
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.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 SpotterImport {
16
-    private $all_flights = 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_flights = 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, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,43 +78,43 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
106
+			}
107
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116 116
 		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
117
-       }
117
+	   }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
120 120
 	$Translation->db = null;
@@ -129,65 +129,65 @@  discard block
 block discarded – undo
129 129
 	}
130 130
 	  */
131 131
 	}
132
-    }
132
+	}
133 133
 
134
-    public function checkAll() {
134
+	public function checkAll() {
135 135
 	global $globalDebug, $globalNoImport;
136 136
 	if ($globalDebug) echo "Update last seen flights data...\n";
137 137
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138
-	    foreach ($this->all_flights as $key => $flight) {
138
+		foreach ($this->all_flights as $key => $flight) {
139 139
 		if (isset($this->all_flights[$key]['id'])) {
140
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
-    		    $Spotter = new Spotter($this->db);
142
-        	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
-        	}
145
-	    }
140
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141
+				$Spotter = new Spotter($this->db);
142
+				$real_arrival = $this->arrival($key);
143
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
144
+			}
145
+		}
146
+	}
146 147
 	}
147
-    }
148 148
 
149
-    public function arrival($key) {
149
+	public function arrival($key) {
150 150
 	global $globalClosestMinDist, $globalDebug;
151 151
 	if ($globalDebug) echo 'Update arrival...'."\n";
152 152
 	$Spotter = new Spotter($this->db);
153
-        $airport_icao = '';
154
-        $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
153
+		$airport_icao = '';
154
+		$airport_time = '';
155
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
-    	    if (isset($closestAirports[0])) {
159
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
-        	    $airport_icao = $closestAirports[0]['icao'];
161
-        	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
-        	    foreach ($closestAirports as $airport) {
165
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
-        		    $airport_icao = $airport['icao'];
167
-        		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
-        		    break;
170
-        		}
171
-        	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
-        		$airport_icao = $closestAirports[0]['icao'];
174
-        		$airport_time = $this->all_flights[$key]['datetime'];
175
-        	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
-        	}
178
-    	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
-    	    }
157
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158
+			if (isset($closestAirports[0])) {
159
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160
+				$airport_icao = $closestAirports[0]['icao'];
161
+				$airport_time = $this->all_flights[$key]['datetime'];
162
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164
+				foreach ($closestAirports as $airport) {
165
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166
+					$airport_icao = $airport['icao'];
167
+					$airport_time = $this->all_flights[$key]['datetime'];
168
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+					break;
170
+				}
171
+				}
172
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
173
+				$airport_icao = $closestAirports[0]['icao'];
174
+				$airport_time = $this->all_flights[$key]['datetime'];
175
+			} else {
176
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
177
+			}
178
+			} else {
179
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
180
+			}
181 181
 
182
-        } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
-        }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
-    }
182
+		} else {
183
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184
+		}
185
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186
+	}
187 187
 
188 188
 
189 189
 
190
-    public function del() {
190
+	public function del() {
191 191
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 192
 	// Delete old infos
193 193
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 			}
200 200
 		}
201 201
 	}
202
-    }
202
+	}
203 203
 
204
-    public function delKey($key) {
204
+	public function delKey($key) {
205 205
 	global $globalDebug, $globalNoImport, $globalNoDB;
206 206
 	// Delete old infos
207 207
 	if (isset($this->all_flights[$key]['id'])) {
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 		if ($globalDebug) echo "\n";
224 224
 	}
225 225
 	unset($this->all_flights[$key]);
226
-    }
226
+	}
227 227
 
228
-    public function add($line) {
228
+	public function add($line) {
229 229
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
230 230
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
231 231
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	
252 252
 	// SBS format is CSV format
253 253
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254
-	    //print_r($line);
255
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
254
+		//print_r($line);
255
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 257
 
258 258
 		// Increment message number
259 259
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
260
-		    $current_date = date('Y-m-d');
261
-		    if (isset($line['source_name'])) $source = $line['source_name'];
262
-		    else $source = '';
263
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
264
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
265
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
266
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
260
+			$current_date = date('Y-m-d');
261
+			if (isset($line['source_name'])) $source = $line['source_name'];
262
+			else $source = '';
263
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
264
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
265
+				$this->stats[$current_date][$source]['msg']['date'] = time();
266
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
268 268
 		}
269 269
 		
270 270
 		/*
@@ -280,54 +280,54 @@  discard block
 block discarded – undo
280 280
 		//$this->db = $dbc;
281 281
 
282 282
 		//$hex = trim($line['hex']);
283
-	        if (!isset($line['id'])) $id = trim($line['hex']);
284
-	        else $id = trim($line['id']);
283
+			if (!isset($line['id'])) $id = trim($line['hex']);
284
+			else $id = trim($line['id']);
285 285
 		
286 286
 		if (!isset($this->all_flights[$id])) {
287
-		    if ($globalDebug) echo 'New flight...'."\n";
288
-		    $this->all_flights[$id] = array();
289
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
292
-		    if (!isset($line['id'])) {
287
+			if ($globalDebug) echo 'New flight...'."\n";
288
+			$this->all_flights[$id] = array();
289
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
292
+			if (!isset($line['id'])) {
293 293
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294 294
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 295
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296 296
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
297
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
297
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
+			if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		}
301 301
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
302
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
303 303
 		}
304 304
 		
305 305
 		//print_r($this->all_flights);
306 306
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
308
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
307
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
308
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
309 309
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
310
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
311
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
310
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
311
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
312 312
 			$timeelapsed = microtime(true);
313 313
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
314
-			    $Spotter = new Spotter($this->db);
315
-			    if (isset($this->all_flights[$id]['source_type'])) {
314
+				$Spotter = new Spotter($this->db);
315
+				if (isset($this->all_flights[$id]['source_type'])) {
316 316
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
317
-			    } else {
317
+				} else {
318 318
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319
-			    }
320
-			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
319
+				}
320
+				$Spotter->db = null;
321
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324
-		    }
325
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
326
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
324
+			}
325
+			if ($globalAllFlights !== FALSE) $dataFound = true;
326
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
327 327
 		}
328
-	        if (isset($line['id']) && !isset($line['hex'])) {
329
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
330
-	        }
328
+			if (isset($line['id']) && !isset($line['hex'])) {
329
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
330
+			}
331 331
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
332 332
 			$icao = $line['aircraft_icao'];
333 333
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 		}
358 358
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
359 359
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
360
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
360
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361 361
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
362
-		    } else {
362
+			} else {
363 363
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364 364
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
365 365
 				/*
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 				print_r($line);
369 369
 				*/
370 370
 				return '';
371
-		    }
371
+			}
372 372
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
373 373
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
374 374
 			return '';
@@ -384,21 +384,21 @@  discard block
 block discarded – undo
384 384
 		}
385 385
 
386 386
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
387
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
388 388
 		}
389 389
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
390
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
390
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
391 391
 		}
392 392
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
394 394
 		}
395 395
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
396
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
396
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
397 397
 		}
398 398
  
399 399
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
400 400
 
401
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
401
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 402
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403 403
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
404 404
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -407,23 +407,23 @@  discard block
 block discarded – undo
407 407
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408 408
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
409 409
 			} else {
410
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 412
 				$timeelapsed = microtime(true);
413
-            			$Spotter = new Spotter($this->db);
414
-            			$fromsource = NULL;
415
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
413
+						$Spotter = new Spotter($this->db);
414
+						$fromsource = NULL;
415
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
417 417
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418 418
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419 419
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
420
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
420
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
421 421
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
422 422
 				$Spotter->db = null;
423 423
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
424
-			    }
424
+				}
425 425
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
426
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
427 427
 		    
428 428
 /*
429 429
 		    if (!isset($line['id'])) {
@@ -433,63 +433,63 @@  discard block
 block discarded – undo
433 433
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 434
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 435
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
437 437
 
438
-		    //$putinarchive = true;
439
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
438
+			//$putinarchive = true;
439
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
440 440
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
441
-		    }
442
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
441
+			}
442
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
443 443
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
444
-		    }
445
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
447
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
444
+			}
445
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
447
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
448 448
 			$timeelapsed = microtime(true);
449 449
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
450 450
 				$Spotter = new Spotter($this->db);
451 451
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 452
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
453
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454 454
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
455
-                        }
456
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
455
+						}
456
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 457
 			$timeelapsed = microtime(true);
458 458
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
459
-			    $Spotter = new Spotter($this->db);
460
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
461
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
459
+				$Spotter = new Spotter($this->db);
460
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
461
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
462 462
 				$Translation = new Translation($this->db);
463 463
 				$ident = $Translation->checkTranslation(trim($line['ident']));
464 464
 				$route = $Spotter->getRouteInfo($ident);
465 465
 				$Translation->db = null;
466
-			    }
467
-			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
469
-                    	}
466
+				}
467
+				$Spotter->db = null;
468
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
469
+						}
470 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
471
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
473 473
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
474
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475
-		    	    }
474
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475
+					}
476 476
 			}
477 477
 			if (!isset($globalFork)) $globalFork = TRUE;
478 478
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479 479
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
480 480
 			}
481
-		    }
481
+			}
482 482
 		}
483 483
 
484 484
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
485 485
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
486
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
488
-		    //$dataFound = true;
486
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
488
+			//$dataFound = true;
489 489
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
490
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
491
-		    if ($distance > 1000 && $distance < 10000) {
492
-		    // use datetime
490
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
491
+			if ($distance > 1000 && $distance < 10000) {
492
+			// use datetime
493 493
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
494 494
 			$speed = $speed*3.6;
495 495
 			if ($speed < 1000) {
@@ -498,49 +498,49 @@  discard block
 block discarded – undo
498 498
 	  		} else {
499 499
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
500 500
 	  		}
501
-		    }
501
+			}
502 502
 		}
503 503
 
504 504
 
505 505
 
506
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509
-	    	    	return false;
510
-	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
-	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
-	    	    else unset($timediff_archive);
515
-	    	    if ($this->tmd > 5
516
-	    	        || (isset($line['format_source']) 
517
-	    	    	    && $line['format_source'] == 'airwhere' 
518
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
519
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
520
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
521
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
522
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
523
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
524
-	    	    		)
525
-	    	    	    )
526
-	    	    	)
527
-	    		|| (isset($globalVA) && $globalVA) 
528
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
529
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
530
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
531
-	    	    	|| (isset($globalVAM) && $globalVAM)
532
-	    	    	|| !isset($timediff)
533
-	    	    	|| $timediff > $globalLiveInterval
534
-	    	    	|| $globalArchive
535
-	    	    	|| ($timediff > 30 
536
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
537
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
538
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
539
-	    	    	    )
540
-	    	    	) {
506
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509
+					return false;
510
+				}
511
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
+				else unset($timediff);
513
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
+				else unset($timediff_archive);
515
+				if ($this->tmd > 5
516
+					|| (isset($line['format_source']) 
517
+						&& $line['format_source'] == 'airwhere' 
518
+						&& ((!isset($this->all_flights[$id]['latitude']) 
519
+						|| !isset($this->all_flights[$id]['longitude'])) 
520
+						|| (isset($this->all_flights[$id]['latitude']) 
521
+							&& isset($this->all_flights[$id]['longitude']) 
522
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
523
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
524
+						)
525
+						)
526
+					)
527
+				|| (isset($globalVA) && $globalVA) 
528
+					|| (isset($globalIVAO) && $globalIVAO)
529
+					|| (isset($globalVATSIM) && $globalVATSIM)
530
+					|| (isset($globalphpVMS) && $globalphpVMS)
531
+					|| (isset($globalVAM) && $globalVAM)
532
+					|| !isset($timediff)
533
+					|| $timediff > $globalLiveInterval
534
+					|| $globalArchive
535
+					|| ($timediff > 30 
536
+						&& isset($this->all_flights[$id]['latitude']) 
537
+						&& isset($this->all_flights[$id]['longitude']) 
538
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
539
+						)
540
+					) {
541 541
 
542 542
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
543
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
543
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
544 544
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
545 545
 				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
546 546
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
 				$this->all_flights[$id]['putinarchive'] = true;
549 549
 				$this->tmd = 0;
550 550
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
551
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
552
-				    $timeelapsed = microtime(true);
553
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
551
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
552
+					$timeelapsed = microtime(true);
553
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 554
 					$Spotter = new Spotter($this->db);
555 555
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
556 556
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 					$Spotter->db = null;
559 559
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
560 560
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
561
-				    }
561
+					}
562 562
 				}
563 563
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
564
-			    } 
565
-			    /*
564
+				} 
565
+				/*
566 566
 			    else {
567 567
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
568 568
 				else {
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 			}
577 577
 
578 578
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
579
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
579
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
580 580
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
581 581
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
582 582
 					$this->all_flights[$id]['time_last_coord'] = time();
583 583
 				}
584 584
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585 585
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
586
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587
-				    $dataFound = true;
588
-				    $this->all_flights[$id]['time_last_coord'] = time();
586
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587
+					$dataFound = true;
588
+					$this->all_flights[$id]['time_last_coord'] = time();
589 589
 				}
590 590
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
591 591
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -596,24 +596,24 @@  discard block
 block discarded – undo
596 596
 				    //$putinarchive = true;
597 597
 				}
598 598
 				*/
599
-			    /*
599
+				/*
600 600
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
601 601
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
602 602
 			    }
603 603
 			    */
604 604
 			}
605 605
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
606
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
607
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
606
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
607
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
608 608
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
609 609
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
610 610
 					$this->all_flights[$id]['time_last_coord'] = time();
611 611
 				}
612 612
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613 613
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
614
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615
-				    $dataFound = true;
616
-				    $this->all_flights[$id]['time_last_coord'] = time();
614
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615
+					$dataFound = true;
616
+					$this->all_flights[$id]['time_last_coord'] = time();
617 617
 				}
618 618
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
619 619
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -631,67 +631,67 @@  discard block
 block discarded – undo
631 631
 			    */
632 632
 			}
633 633
 
634
-		    } else if ($globalDebug && $timediff > 30) {
634
+			} else if ($globalDebug && $timediff > 30) {
635 635
 			$this->tmd = $this->tmd + 1;
636 636
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
637 637
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
638 638
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
639 639
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
640
-		    }
640
+			}
641 641
 		}
642 642
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
643
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
645 645
 		}
646 646
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
648
-		    //$dataFound = true;
647
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
648
+			//$dataFound = true;
649 649
 		}
650 650
 		if (isset($line['format_source']) && $line['format_source'] != '') {
651
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
651
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
652 652
 		}
653 653
 		if (isset($line['source_name']) && $line['source_name'] != '') {
654
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
654
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
655 655
 		}
656 656
 		if (isset($line['emergency']) && $line['emergency'] != '') {
657
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
658
-		    //$dataFound = true;
657
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
658
+			//$dataFound = true;
659 659
 		}
660 660
 		if (isset($line['ground']) && $line['ground'] != '') {
661
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
661
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
662 662
 			// Here we force archive of flight because after ground it's a new one (or should be)
663 663
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664 664
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665 665
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
666
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667 667
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
668
-		    }
669
-		    if ($line['ground'] != 1) $line['ground'] = 0;
670
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671
-		    //$dataFound = true;
668
+			}
669
+			if ($line['ground'] != 1) $line['ground'] = 0;
670
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671
+			//$dataFound = true;
672 672
 		}
673 673
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677
-			    $highlight = '';
678
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
681
-			    if ($highlight != '') {
674
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677
+				$highlight = '';
678
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
681
+				if ($highlight != '') {
682 682
 				$timeelapsed = microtime(true);
683 683
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684
-				    $Spotter = new Spotter($this->db);
685
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686
-				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
684
+					$Spotter = new Spotter($this->db);
685
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686
+					$Spotter->db = null;
687
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
688 688
 				}
689 689
 				//$putinarchive = true;
690 690
 				//$highlight = '';
691
-			    }
691
+				}
692 692
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
694
-		    //$dataFound = true;
693
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
694
+			//$dataFound = true;
695 695
 		}
696 696
 
697 697
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -702,13 +702,13 @@  discard block
 block discarded – undo
702 702
 					$line['altitude'] = $line['altitude'] - $geoid;
703 703
 				}
704 704
 			}
705
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
705
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706 706
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707 707
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708 708
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
709 709
 			//$dataFound = true;
710
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
710
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 712
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713 713
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
714 714
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -717,27 +717,27 @@  discard block
 block discarded – undo
717 717
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718 718
 				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
719 719
 			}
720
-		    }
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
720
+			}
721
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
722 722
 		}
723 723
 
724 724
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
725
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
725
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
726 726
 		}
727 727
 		
728 728
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732
-		    //$dataFound = true;
729
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732
+			//$dataFound = true;
733 733
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
734
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
738 738
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739
-  		    // If not enough messages and ACARS set heading to 0
740
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
739
+  			// If not enough messages and ACARS set heading to 0
740
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
741 741
   		}
742 742
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743 743
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -750,133 +750,133 @@  discard block
 block discarded – undo
750 750
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
751 751
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
752 752
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
753
-		    $this->all_flights[$id]['lastupdate'] = time();
754
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756
-			    //print_r($this->all_flights);
757
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
753
+			$this->all_flights[$id]['lastupdate'] = time();
754
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756
+				//print_r($this->all_flights);
757
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
760 760
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
761
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
762
-				    $timeelapsed = microtime(true);
763
-				    $SpotterLive = new SpotterLive($this->db);
764
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
761
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
762
+					$timeelapsed = microtime(true);
763
+					$SpotterLive = new SpotterLive($this->db);
764
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 765
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766 766
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
767
-				    } elseif (isset($line['id'])) {
767
+					} elseif (isset($line['id'])) {
768 768
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769 769
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
770
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
770
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 771
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772 772
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
773
-				    } else $recent_ident = '';
774
-				    $SpotterLive->db=null;
775
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
773
+					} else $recent_ident = '';
774
+					$SpotterLive->db=null;
775
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777 777
 				} else $recent_ident = '';
778
-			    } else {
778
+				} else {
779 779
 				$recent_ident = '';
780 780
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
781
-			    }
782
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
-			    if($recent_ident == "")
784
-			    {
781
+				}
782
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
+				if($recent_ident == "")
784
+				{
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
786 786
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 787
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 788
 				//adds the spotter data for the archive
789 789
 				$ignoreImport = false;
790 790
 				foreach($globalAirportIgnore as $airportIgnore) {
791
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
792 792
 					$ignoreImport = true;
793
-				    }
793
+					}
794 794
 				}
795 795
 				if (count($globalAirportAccept) > 0) {
796
-				    $ignoreImport = true;
797
-				    foreach($globalAirportIgnore as $airportIgnore) {
796
+					$ignoreImport = true;
797
+					foreach($globalAirportIgnore as $airportIgnore) {
798 798
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
799
-					    $ignoreImport = false;
799
+						$ignoreImport = false;
800
+					}
800 801
 					}
801
-				    }
802 802
 				}
803 803
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
804
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
804
+					foreach($globalAirlineIgnore as $airlineIgnore) {
805 805
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
806
-					    $ignoreImport = true;
806
+						$ignoreImport = true;
807
+					}
807 808
 					}
808
-				    }
809 809
 				}
810 810
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
811
-				    $ignoreImport = true;
812
-				    foreach($globalAirlineAccept as $airlineAccept) {
811
+					$ignoreImport = true;
812
+					foreach($globalAirlineAccept as $airlineAccept) {
813 813
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
814
-					    $ignoreImport = false;
814
+						$ignoreImport = false;
815
+					}
815 816
 					}
816
-				    }
817 817
 				}
818 818
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
819
-				    $ignoreImport = true;
820
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
819
+					$ignoreImport = true;
820
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
821 821
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
822
-					    $ignoreImport = false;
822
+						$ignoreImport = false;
823
+					}
823 824
 					}
824
-				    }
825 825
 				}
826 826
 				
827 827
 				if (!$ignoreImport) {
828
-				    $highlight = '';
829
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833
-				    $timeelapsed = microtime(true);
834
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
828
+					$highlight = '';
829
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833
+					$timeelapsed = microtime(true);
834
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 835
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836
-					    $Spotter = new Spotter($this->db);
837
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838
-					    $Spotter->db = null;
839
-					    if ($globalDebug) {
836
+						$Spotter = new Spotter($this->db);
837
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838
+						$Spotter->db = null;
839
+						if ($globalDebug) {
840 840
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
841 841
 						else echo 'Success';
842
-					    }
843
-					    if (count($result) > 1) {
844
-					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
842
+						}
843
+						if (count($result) > 1) {
844
+						// ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
845 845
 						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
846 846
 						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
847
-					    }
847
+						}
848 848
 					}
849
-				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
851
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
849
+					}
850
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
851
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 852
 
853
-				    // Add source stat in DB
854
-				    $Stats = new Stats($this->db);
855
-				    if (!empty($this->stats)) {
853
+					// Add source stat in DB
854
+					$Stats = new Stats($this->db);
855
+					if (!empty($this->stats)) {
856 856
 					if ($globalDebug) echo 'Add source stats : ';
857
-				        foreach($this->stats as $date => $data) {
858
-					    foreach($data as $source => $sourced) {
859
-					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
862
-				    		if (isset($sourced['msg'])) {
863
-				    		    if (time() - $sourced['msg']['date'] > 10) {
864
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
866
-			    			        unset($this->stats[$date][$source]['msg']);
867
-			    			    }
868
-			    			}
869
-			    		    }
870
-			    		    if ($date != date('Y-m-d')) {
871
-			    			unset($this->stats[$date]);
872
-			    		    }
873
-				    	}
874
-				    	if ($globalDebug) echo 'Done'."\n";
857
+						foreach($this->stats as $date => $data) {
858
+						foreach($data as $source => $sourced) {
859
+							//print_r($sourced);
860
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
862
+							if (isset($sourced['msg'])) {
863
+								if (time() - $sourced['msg']['date'] > 10) {
864
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
866
+									unset($this->stats[$date][$source]['msg']);
867
+								}
868
+							}
869
+							}
870
+							if ($date != date('Y-m-d')) {
871
+							unset($this->stats[$date]);
872
+							}
873
+						}
874
+						if ($globalDebug) echo 'Done'."\n";
875 875
 
876
-				    }
877
-				    $Stats->db = null;
878
-				    }
879
-				    $this->del();
876
+					}
877
+					$Stats->db = null;
878
+					}
879
+					$this->del();
880 880
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
881 881
 				//$ignoreImport = false;
882 882
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -894,41 +894,41 @@  discard block
 block discarded – undo
894 894
 			*/
895 895
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
896 896
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
897
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
898
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
899
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
897
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
898
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
899
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901
-					    $SpotterLive = new SpotterLive($this->db);
902
-					    $SpotterLive->deleteLiveSpotterData();
903
-					    $SpotterLive->db=null;
901
+						$SpotterLive = new SpotterLive($this->db);
902
+						$SpotterLive->deleteLiveSpotterData();
903
+						$SpotterLive->db=null;
904 904
 					}
905
-				    }
906
-				    if ($globalDebug) echo " Done\n";
907
-				    $this->last_delete = time();
905
+					}
906
+					if ($globalDebug) echo " Done\n";
907
+					$this->last_delete = time();
908 908
 				}
909
-			    } else {
909
+				} else {
910 910
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
911
-				    $this->all_flights[$id]['id'] = $recent_ident;
912
-				    $this->all_flights[$id]['addedSpotter'] = 1;
911
+					$this->all_flights[$id]['id'] = $recent_ident;
912
+					$this->all_flights[$id]['addedSpotter'] = 1;
913 913
 				}
914 914
 				if (isset($globalDaemon) && !$globalDaemon) {
915
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
915
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
916 916
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917
-					    $Spotter = new Spotter($this->db);
918
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
919
-					    $Spotter->db = null;
917
+						$Spotter = new Spotter($this->db);
918
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
919
+						$Spotter->db = null;
920
+					}
920 921
 					}
921
-				    }
922 922
 				}
923 923
 				
924
-			    }
924
+				}
925 925
 			}
926
-		    }
927
-		    //adds the spotter LIVE data
928
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
929
-		    //echo "\nAdd in Live !! \n";
930
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931
-		    if ($globalDebug) {
926
+			}
927
+			//adds the spotter LIVE data
928
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
929
+			//echo "\nAdd in Live !! \n";
930
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931
+			if ($globalDebug) {
932 932
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
933 933
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
934 934
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -936,60 +936,60 @@  discard block
 block discarded – undo
936 936
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
937 937
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
938 938
 			}
939
-		    }
940
-		    $ignoreImport = false;
941
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
939
+			}
940
+			$ignoreImport = false;
941
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
943 943
 
944
-		    foreach($globalAirportIgnore as $airportIgnore) {
945
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946
-			    $ignoreImport = true;
944
+			foreach($globalAirportIgnore as $airportIgnore) {
945
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946
+				$ignoreImport = true;
947
+			}
947 948
 			}
948
-		    }
949
-		    if (count($globalAirportAccept) > 0) {
950
-		        $ignoreImport = true;
951
-		        foreach($globalAirportIgnore as $airportIgnore) {
952
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
949
+			if (count($globalAirportAccept) > 0) {
950
+				$ignoreImport = true;
951
+				foreach($globalAirportIgnore as $airportIgnore) {
952
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
953 953
 				$ignoreImport = false;
954
-			    }
954
+				}
955 955
 			}
956
-		    }
957
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
956
+			}
957
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
958 958
 			foreach($globalAirlineIgnore as $airlineIgnore) {
959
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
959
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
960 960
 				$ignoreImport = true;
961
-			    }
961
+				}
962 962
 			}
963
-		    }
964
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
963
+			}
964
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
965 965
 			$ignoreImport = true;
966 966
 			foreach($globalAirlineAccept as $airlineAccept) {
967
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
967
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
968 968
 				$ignoreImport = false;
969
-			    }
969
+				}
970
+			}
970 971
 			}
971
-		    }
972
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
972
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
973 973
 			$ignoreImport = true;
974 974
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
975
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976
-			        $ignoreImport = false;
977
-			    }
975
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976
+					$ignoreImport = false;
977
+				}
978
+			}
978 979
 			}
979
-		    }
980 980
 
981
-		    if (!$ignoreImport) {
981
+			if (!$ignoreImport) {
982 982
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983 983
 				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
984 984
 				$timeelapsed = microtime(true);
985 985
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
986
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 987
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
988 988
 					$SpotterLive = new SpotterLive($this->db);
989 989
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
990 990
 					$SpotterLive->db = null;
991 991
 					if ($globalDebug) echo $result."\n";
992
-				    }
992
+					}
993 993
 				}
994 994
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995 995
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 				//if ($line['format_source'] != 'aprs') {
1002 1002
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
1003 1003
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1004
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1004
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1005 1005
 					$source = $this->all_flights[$id]['source_name'];
1006 1006
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1007 1007
 					if (!isset($this->source_location[$source])) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 					if ($stats_heading == 16) $stats_heading = 0;
1028 1028
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029 1029
 						for ($i=0;$i<=15;$i++) {
1030
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1030
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1033 1033
 					} else {
@@ -1040,17 +1040,17 @@  discard block
 block discarded – undo
1040 1040
 					//var_dump($this->stats);
1041 1041
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1042 1042
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043
-						    end($this->stats[$current_date][$source]['hist']);
1044
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1043
+							end($this->stats[$current_date][$source]['hist']);
1044
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1045 1045
 						} else $mini = 0;
1046 1046
 						for ($i=$mini;$i<=$distance;$i+=10) {
1047
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1047
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1048
 						}
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1050 1050
 					} else {
1051 1051
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1052 1052
 					}
1053
-				    }
1053
+					}
1054 1054
 				}
1055 1055
 
1056 1056
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 			//$this->del();
1061 1061
 			
1062 1062
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1063
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1063
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1064 1064
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1065 1065
 				$SpotterLive = new SpotterLive($this->db);
1066 1066
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1068,19 +1068,19 @@  discard block
 block discarded – undo
1068 1068
 				//SpotterLive->deleteLiveSpotterData();
1069 1069
 				if ($globalDebug) echo " Done\n";
1070 1070
 				$this->last_delete_hourly = time();
1071
-			    } else {
1071
+				} else {
1072 1072
 				$this->del();
1073 1073
 				$this->last_delete_hourly = time();
1074
-			    }
1074
+				}
1075 1075
 			}
1076 1076
 			
1077
-		    }
1078
-		    //$ignoreImport = false;
1077
+			}
1078
+			//$ignoreImport = false;
1079 1079
 		}
1080 1080
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1081 1081
 		if ($send) return $this->all_flights[$id];
1082
-	    }
1082
+		}
1083
+	}
1083 1084
 	}
1084
-    }
1085 1085
 }
1086 1086
 ?>
Please login to merge, or discard this patch.
Spacing   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
37
+		    foreach ($sourcestat as $srcst) {
38 38
 		    	$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40 40
 			    $source = $srcst['source_name'];
41 41
 			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
43 43
 	    		}
44 44
 		    }
45 45
 		}
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	if (isset($globalGeoid) && $globalGeoid) {
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54
-		} catch(Exception $e) {
54
+		} catch (Exception $e) {
55 55
 			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59 59
     }
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+    public function get_Schedule($id, $ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85 85
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
86
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
87
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
88 88
 		    // Should also check if route schedule = route from DB
89 89
 		    if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			    }
105 105
 			}
106 106
 		    }
107
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
107
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
108 108
 		}
109 109
 	    } else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
        if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114 114
     		$sch = $Schedule->getSchedule($operator);
115
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
115
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
116
+		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'], $sch['departure_airport_icao'], $sch['departure_airport_time'], $sch['arrival_airport_icao'], $sch['arrival_airport_time']);
117 117
        }
118 118
 	$Spotter->db = null;
119 119
 	$Schedule->db = null;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 141
     		    $Spotter = new Spotter($this->db);
142 142
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
143
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
144 144
         	}
145 145
 	    }
146 146
 	}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
         $airport_time = '';
155 155
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
156 156
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
158 158
     	    if (isset($closestAirports[0])) {
159 159
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 160
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         		    break;
170 170
         		}
171 171
         	    }
172
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
173 173
         		$airport_icao = $closestAirports[0]['icao'];
174 174
         		$airport_time = $this->all_flights[$key]['datetime'];
175 175
         	} else {
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         } else {
183 183
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
184 184
         }
185
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
186 186
     }
187 187
 
188 188
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	
195 195
 	foreach ($this->all_flights as $key => $flight) {
196 196
 		if (isset($flight['lastupdate'])) {
197
-			if ($flight['lastupdate'] < (time()-1800)) {
197
+			if ($flight['lastupdate'] < (time() - 1800)) {
198 198
 				$this->delKey($key);
199 199
 			}
200 200
 		}
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 			$Spotter = new Spotter($this->db);
212 212
 			$SpotterLive = new SpotterLive($this->db);
213 213
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
214
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
214
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
215 215
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
216 216
 				$this->all_flights[$key]['putinarchive'] = true;
217
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
217
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'], $this->all_flights[$key]['route_stop'], $this->all_flights[$key]['hex'], $this->all_flights[$key]['putinarchive'], $this->all_flights[$key]['registration'], $this->all_flights[$key]['pilot_id'], $this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['format_source'], $this->all_flights[$key]['source_name'], $this->all_flights[$key]['over_country']);
218 218
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
219 219
 			}
220 220
 			$Spotter->db = null;
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	$send = false;
251 251
 	
252 252
 	// SBS format is CSV format
253
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
253
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254 254
 	    //print_r($line);
255 255
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
256
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
256
+  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'], 0, 1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 257
 
258 258
 		// Increment message number
259 259
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
 		if (!isset($this->all_flights[$id])) {
287 287
 		    if ($globalDebug) echo 'New flight...'."\n";
288 288
 		    $this->all_flights[$id] = array();
289
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
289
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
290
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
291
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
292 292
 		    if (!isset($line['id'])) {
293 293
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294 294
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 295
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
296
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
297 297
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
298
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
299 299
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
300 300
 		}
301 301
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
302
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
303 303
 		}
304 304
 		
305 305
 		//print_r($this->all_flights);
306 306
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
307
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
308 308
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
309 309
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
310 310
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
314 314
 			    $Spotter = new Spotter($this->db);
315 315
 			    if (isset($this->all_flights[$id]['source_type'])) {
316
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
316
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
317 317
 			    } else {
318 318
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319 319
 			    }
320 320
 			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
321
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
322
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
323 323
 			}
324 324
 		    }
325 325
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
326 326
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
327 327
 		}
328 328
 	        if (isset($line['id']) && !isset($line['hex'])) {
329
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
329
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
330 330
 	        }
331 331
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
332 332
 			$icao = $line['aircraft_icao'];
@@ -335,14 +335,14 @@  discard block
 block discarded – undo
335 335
 				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
336 336
 				$Spotter->db = null;
337 337
 			}
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
339 339
 		} elseif (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
340 340
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 341
 				// Get aircraft ICAO from aircraft name
342 342
 				$Spotter = new Spotter($this->db);
343 343
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
344 344
 				$Spotter->db = null;
345
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
345
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
346 346
 			}
347 347
 		}
348 348
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -350,15 +350,15 @@  discard block
 block discarded – undo
350 350
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
351 351
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
352 352
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
353
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
353
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
354 354
 		}
355 355
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
356
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
356
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
357 357
 		}
358 358
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
359
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
359
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
360 360
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
361
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
362 362
 		    } else {
363 363
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364 364
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -369,31 +369,31 @@  discard block
 block discarded – undo
369 369
 				*/
370 370
 				return '';
371 371
 		    }
372
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
372
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
373 373
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
374 374
 			return '';
375
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
375
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
376 376
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
377 377
 			return '';
378 378
 		} elseif (!isset($line['datetime'])) {
379 379
 			date_default_timezone_set('UTC');
380
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
380
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
381 381
 		} else {
382 382
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
383 383
 			return '';
384 384
 		}
385 385
 
386 386
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
387
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
387
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
388 388
 		}
389 389
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
390
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
390
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
391 391
 		}
392 392
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
393
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
393
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
394 394
 		}
395 395
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
396
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
396
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
397 397
 		}
398 398
  
399 399
 		if (isset($line['ident']) && trim($line['ident']) != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -401,13 +401,13 @@  discard block
 block discarded – undo
401 401
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 402
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403 403
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
404
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
405
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
406
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
407
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
404
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
405
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
406
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
407
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
408
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
409 409
 			} else {
410
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
410
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
411 411
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 412
 				$timeelapsed = microtime(true);
413 413
             			$Spotter = new Spotter($this->db);
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418 418
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419 419
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
420
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
420
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource, $this->all_flights[$id]['source_type']);
421 421
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
422 422
 				$Spotter->db = null;
423
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
423
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
424 424
 			    }
425 425
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
426
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
427 427
 		    
428 428
 /*
429 429
 		    if (!isset($line['id'])) {
@@ -433,25 +433,25 @@  discard block
 block discarded – undo
433 433
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 434
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 435
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
436
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
437 437
 
438 438
 		    //$putinarchive = true;
439 439
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
440
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
440
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
441 441
 		    }
442 442
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
443
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
443
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
444 444
 		    }
445 445
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
446
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
446
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
447 447
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
448 448
 			$timeelapsed = microtime(true);
449 449
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
450 450
 				$Spotter = new Spotter($this->db);
451 451
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 452
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
454
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
455 455
                         }
456 456
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 457
 			$timeelapsed = microtime(true);
@@ -465,35 +465,35 @@  discard block
 block discarded – undo
465 465
 				$Translation->db = null;
466 466
 			    }
467 467
 			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
469 469
                     	}
470 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471 471
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
472 472
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
473 473
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
474
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
474
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
475 475
 		    	    }
476 476
 			}
477 477
 			if (!isset($globalFork)) $globalFork = TRUE;
478 478
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
479
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
480 480
 			}
481 481
 		    }
482 482
 		}
483 483
 
484 484
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
485 485
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
486
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
487
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
486
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
487
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
488 488
 		    //$dataFound = true;
489 489
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
490
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
490
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
491 491
 		    if ($distance > 1000 && $distance < 10000) {
492 492
 		    // use datetime
493 493
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
494 494
 			$speed = $speed*3.6;
495 495
 			if ($speed < 1000) {
496
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
496
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
497 497
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
498 498
 	  		} else {
499 499
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
509 509
 	    	    	return false;
510 510
 	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
511
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
512 512
 	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
513
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
514 514
 	    	    else unset($timediff_archive);
515 515
 	    	    if ($this->tmd > 5
516 516
 	    	        || (isset($line['format_source']) 
@@ -535,14 +535,14 @@  discard block
 block discarded – undo
535 535
 	    	    	|| ($timediff > 30 
536 536
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
537 537
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
538
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
538
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
539 539
 	    	    	    )
540 540
 	    	    	) {
541 541
 
542 542
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
543 543
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
544 544
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
545
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
545
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
546 546
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547 547
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
548 548
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -552,11 +552,11 @@  discard block
 block discarded – undo
552 552
 				    $timeelapsed = microtime(true);
553 553
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 554
 					$Spotter = new Spotter($this->db);
555
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
555
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
556 556
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
557 557
 					else $this->all_flights[$id]['over_country'] = '';
558 558
 					$Spotter->db = null;
559
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
559
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
560 560
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
561 561
 				    }
562 562
 				}
@@ -582,13 +582,13 @@  discard block
 block discarded – undo
582 582
 					$this->all_flights[$id]['time_last_coord'] = time();
583 583
 				}
584 584
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
585
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
586 586
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
587 587
 				    $dataFound = true;
588 588
 				    $this->all_flights[$id]['time_last_coord'] = time();
589 589
 				}
590 590
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
591
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
591
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
592 592
 				/*
593 593
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
594 594
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
 					$this->all_flights[$id]['time_last_coord'] = time();
611 611
 				}
612 612
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
613
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
614 614
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
615 615
 				    $dataFound = true;
616 616
 				    $this->all_flights[$id]['time_last_coord'] = time();
617 617
 				}
618 618
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
619
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
619
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
620 620
 				/*
621 621
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
622 622
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -634,46 +634,46 @@  discard block
 block discarded – undo
634 634
 		    } else if ($globalDebug && $timediff > 30) {
635 635
 			$this->tmd = $this->tmd + 1;
636 636
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
637
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
638
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
637
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
638
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
639 639
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
640 640
 		    }
641 641
 		}
642 642
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643 643
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
644
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
644
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
645 645
 		}
646 646
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
647
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
647
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
648 648
 		    //$dataFound = true;
649 649
 		}
650 650
 		if (isset($line['format_source']) && $line['format_source'] != '') {
651
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
651
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
652 652
 		}
653 653
 		if (isset($line['source_name']) && $line['source_name'] != '') {
654
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
654
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
655 655
 		}
656 656
 		if (isset($line['emergency']) && $line['emergency'] != '') {
657
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
657
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
658 658
 		    //$dataFound = true;
659 659
 		}
660 660
 		if (isset($line['ground']) && $line['ground'] != '') {
661 661
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
662 662
 			// Here we force archive of flight because after ground it's a new one (or should be)
663
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
663
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
664
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
665
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
666
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
667
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
668 668
 		    }
669 669
 		    if ($line['ground'] != 1) $line['ground'] = 0;
670
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
670
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
671 671
 		    //$dataFound = true;
672 672
 		}
673 673
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674 674
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675 675
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
676
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
676
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
677 677
 			    $highlight = '';
678 678
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679 679
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -682,66 +682,66 @@  discard block
 block discarded – undo
682 682
 				$timeelapsed = microtime(true);
683 683
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684 684
 				    $Spotter = new Spotter($this->db);
685
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
685
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
686 686
 				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
687
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
688 688
 				}
689 689
 				//$putinarchive = true;
690 690
 				//$highlight = '';
691 691
 			    }
692 692
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
693
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
694 694
 		    //$dataFound = true;
695 695
 		}
696 696
 
697 697
 		if (isset($line['altitude']) && $line['altitude'] != '') {
698 698
 			if (isset($line['altitude_relative']) && isset($GeoidClass) && is_object($GeoidClass)) {
699 699
 				if ($line['altitude_relative'] == 'AMSL' || $line['altitude_relative'] == 'MSL') {
700
-					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'])*3.28084,2);
700
+					$geoid = round($GeoidClass->get($this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'])*3.28084, 2);
701 701
 					//if ($globalDebug) echo '=> Set altitude to WGS84 Ellipsoid, add '.$geoid.' to '.$line['altitude']."\n";
702 702
 					$line['altitude'] = $line['altitude'] - $geoid;
703 703
 				}
704 704
 			}
705 705
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
706
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
707
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
708
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
709 709
 			//$dataFound = true;
710 710
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711 711
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 712
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713 713
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
714
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
715
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
716
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
717
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
714
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
715
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
716
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
717
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
718
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
719 719
 			}
720 720
 		    }
721
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
721
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
722 722
 		}
723 723
 
724 724
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
725
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
725
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
726 726
 		}
727 727
 		
728 728
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
729
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
730
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
731
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
732 732
 		    //$dataFound = true;
733 733
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
734
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
735
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
736
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737 737
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
738 738
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739 739
   		    // If not enough messages and ACARS set heading to 0
740
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
740
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
741 741
   		}
742
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
742
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
745 745
 
746 746
 //		print_r($this->all_flights[$id]);
747 747
 		//gets the callsign from the last hour
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
753 753
 		    $this->all_flights[$id]['lastupdate'] = time();
754 754
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
755
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
755
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
756 756
 			    //print_r($this->all_flights);
757 757
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
758 758
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -763,61 +763,61 @@  discard block
 block discarded – undo
763 763
 				    $SpotterLive = new SpotterLive($this->db);
764 764
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 765
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
766
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
767 767
 				    } elseif (isset($line['id'])) {
768 768
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
769
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
770 770
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 771
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
772
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
773 773
 				    } else $recent_ident = '';
774
-				    $SpotterLive->db=null;
774
+				    $SpotterLive->db = null;
775 775
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776 776
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777 777
 				} else $recent_ident = '';
778 778
 			    } else {
779 779
 				$recent_ident = '';
780
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
780
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
781 781
 			    }
782 782
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783
-			    if($recent_ident == "")
783
+			    if ($recent_ident == "")
784 784
 			    {
785 785
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
786 786
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 787
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 788
 				//adds the spotter data for the archive
789 789
 				$ignoreImport = false;
790
-				foreach($globalAirportIgnore as $airportIgnore) {
790
+				foreach ($globalAirportIgnore as $airportIgnore) {
791 791
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
792 792
 					$ignoreImport = true;
793 793
 				    }
794 794
 				}
795 795
 				if (count($globalAirportAccept) > 0) {
796 796
 				    $ignoreImport = true;
797
-				    foreach($globalAirportIgnore as $airportIgnore) {
797
+				    foreach ($globalAirportIgnore as $airportIgnore) {
798 798
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
799 799
 					    $ignoreImport = false;
800 800
 					}
801 801
 				    }
802 802
 				}
803 803
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
804
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
805
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
804
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
805
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
806 806
 					    $ignoreImport = true;
807 807
 					}
808 808
 				    }
809 809
 				}
810 810
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
811 811
 				    $ignoreImport = true;
812
-				    foreach($globalAirlineAccept as $airlineAccept) {
813
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
812
+				    foreach ($globalAirlineAccept as $airlineAccept) {
813
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
814 814
 					    $ignoreImport = false;
815 815
 					}
816 816
 				    }
817 817
 				}
818 818
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
819 819
 				    $ignoreImport = true;
820
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
820
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
821 821
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
822 822
 					    $ignoreImport = false;
823 823
 					}
@@ -829,12 +829,12 @@  discard block
 block discarded – undo
829 829
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830 830
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831 831
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
832
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
833 833
 				    $timeelapsed = microtime(true);
834 834
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 835
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 					    $Spotter = new Spotter($this->db);
837
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
837
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
838 838
 					    $Spotter->db = null;
839 839
 					    if ($globalDebug) {
840 840
 						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
@@ -847,22 +847,22 @@  discard block
 block discarded – undo
847 847
 					    }
848 848
 					}
849 849
 				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
850
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
851 851
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 852
 
853 853
 				    // Add source stat in DB
854 854
 				    $Stats = new Stats($this->db);
855 855
 				    if (!empty($this->stats)) {
856 856
 					if ($globalDebug) echo 'Add source stats : ';
857
-				        foreach($this->stats as $date => $data) {
858
-					    foreach($data as $source => $sourced) {
857
+				        foreach ($this->stats as $date => $data) {
858
+					    foreach ($data as $source => $sourced) {
859 859
 					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
860
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
861
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
862 862
 				    		if (isset($sourced['msg'])) {
863 863
 				    		    if (time() - $sourced['msg']['date'] > 10) {
864 864
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
865
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
865
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
866 866
 			    			        unset($this->stats[$date][$source]['msg']);
867 867
 			    			    }
868 868
 			    			}
@@ -900,14 +900,14 @@  discard block
 block discarded – undo
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901 901
 					    $SpotterLive = new SpotterLive($this->db);
902 902
 					    $SpotterLive->deleteLiveSpotterData();
903
-					    $SpotterLive->db=null;
903
+					    $SpotterLive->db = null;
904 904
 					}
905 905
 				    }
906 906
 				    if ($globalDebug) echo " Done\n";
907 907
 				    $this->last_delete = time();
908 908
 				}
909 909
 			    } else {
910
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
910
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
911 911
 				    $this->all_flights[$id]['id'] = $recent_ident;
912 912
 				    $this->all_flights[$id]['addedSpotter'] = 1;
913 913
 				}
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
916 916
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
917 917
 					    $Spotter = new Spotter($this->db);
918
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
918
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
919 919
 					    $Spotter->db = null;
920 920
 					}
921 921
 				    }
@@ -941,37 +941,37 @@  discard block
 block discarded – undo
941 941
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
942 942
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
943 943
 
944
-		    foreach($globalAirportIgnore as $airportIgnore) {
944
+		    foreach ($globalAirportIgnore as $airportIgnore) {
945 945
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
946 946
 			    $ignoreImport = true;
947 947
 			}
948 948
 		    }
949 949
 		    if (count($globalAirportAccept) > 0) {
950 950
 		        $ignoreImport = true;
951
-		        foreach($globalAirportIgnore as $airportIgnore) {
951
+		        foreach ($globalAirportIgnore as $airportIgnore) {
952 952
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
953 953
 				$ignoreImport = false;
954 954
 			    }
955 955
 			}
956 956
 		    }
957 957
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
958
-			foreach($globalAirlineIgnore as $airlineIgnore) {
959
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
958
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
959
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
960 960
 				$ignoreImport = true;
961 961
 			    }
962 962
 			}
963 963
 		    }
964 964
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
965 965
 			$ignoreImport = true;
966
-			foreach($globalAirlineAccept as $airlineAccept) {
967
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
966
+			foreach ($globalAirlineAccept as $airlineAccept) {
967
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
968 968
 				$ignoreImport = false;
969 969
 			    }
970 970
 			}
971 971
 		    }
972 972
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
973 973
 			$ignoreImport = true;
974
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
974
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
975 975
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
976 976
 			        $ignoreImport = false;
977 977
 			    }
@@ -979,23 +979,23 @@  discard block
 block discarded – undo
979 979
 		    }
980 980
 
981 981
 		    if (!$ignoreImport) {
982
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
982
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
984 984
 				$timeelapsed = microtime(true);
985 985
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986 986
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987 987
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
988 988
 					$SpotterLive = new SpotterLive($this->db);
989
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
989
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
990 990
 					$SpotterLive->db = null;
991 991
 					if ($globalDebug) echo $result."\n";
992 992
 				    }
993 993
 				}
994 994
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
995
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
996 996
 				}
997 997
 				$this->all_flights[$id]['putinarchive'] = false;
998
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
998
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
999 999
 
1000 1000
 				// Put statistics in $this->stats variable
1001 1001
 				//if ($line['format_source'] != 'aprs') {
@@ -1014,19 +1014,19 @@  discard block
 block discarded – undo
1014 1014
 							$latitude = $globalCenterLatitude;
1015 1015
 							$longitude = $globalCenterLongitude;
1016 1016
 						}
1017
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
1017
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
1018 1018
 					} else {
1019 1019
 						$latitude = $this->source_location[$source]['latitude'];
1020 1020
 						$longitude = $this->source_location[$source]['longitude'];
1021 1021
 					}
1022
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1022
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1023 1023
 					//$stats_heading = $stats_heading%22.5;
1024 1024
 					$stats_heading = round($stats_heading/22.5);
1025
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1025
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
1026 1026
 					$current_date = date('Y-m-d');
1027 1027
 					if ($stats_heading == 16) $stats_heading = 0;
1028 1028
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029
-						for ($i=0;$i<=15;$i++) {
1029
+						for ($i = 0; $i <= 15; $i++) {
1030 1030
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1031 1031
 						}
1032 1032
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1041,9 +1041,9 @@  discard block
 block discarded – undo
1041 1041
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1042 1042
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043 1043
 						    end($this->stats[$current_date][$source]['hist']);
1044
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1044
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1045 1045
 						} else $mini = 0;
1046
-						for ($i=$mini;$i<=$distance;$i+=10) {
1046
+						for ($i = $mini; $i <= $distance; $i += 10) {
1047 1047
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1048
 						}
1049 1049
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1056,7 +1056,7 @@  discard block
 block discarded – undo
1056 1056
 				$this->all_flights[$id]['lastupdate'] = time();
1057 1057
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1058 1058
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1060 1060
 			//$this->del();
1061 1061
 			
1062 1062
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +418 added lines, -149 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
 		try {
53 53
 			$GeoidClass = new GeoidHeight();
54 54
 		} catch(Exception $e) {
55
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
55
+			if ($globalDebug) {
56
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
57
+			}
56 58
 			$GeoidClass = FALSE;
57 59
 		}
58 60
 	}
@@ -71,7 +73,9 @@  discard block
 block discarded – undo
71 73
 	$dbc = $this->db;
72 74
 	$this->all_flights[$id]['schedule_check'] = true;
73 75
 	if ($globalSchedulesFetch) {
74
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
76
+	if ($globalDebug) {
77
+		echo 'Getting schedule info...'."\n";
78
+	}
75 79
 	$Spotter = new Spotter($dbc);
76 80
 	$Schedule = new Schedule($dbc);
77 81
 	$Translation = new Translation($dbc);
@@ -82,7 +86,9 @@  discard block
 block discarded – undo
82 86
 	    if ($Schedule->checkSchedule($operator) == 0) {
83 87
 		$schedule = $Schedule->fetchSchedule($operator);
84 88
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
89
+		    if ($globalDebug) {
90
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
91
+		    }
86 92
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87 93
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88 94
 		    // Should also check if route schedule = route from DB
@@ -91,7 +97,9 @@  discard block
 block discarded – undo
91 97
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92 98
 			    if (trim($airport_icao) != '') {
93 99
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
100
+				if ($globalDebug) {
101
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
102
+				}
95 103
 			    }
96 104
 			}
97 105
 		    }
@@ -100,20 +108,30 @@  discard block
 block discarded – undo
100 108
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101 109
 			    if (trim($airport_icao) != '') {
102 110
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
111
+				if ($globalDebug) {
112
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
113
+				}
104 114
 			    }
105 115
 			}
106 116
 		    }
107 117
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
108 118
 		}
109
-	    } else $scheduleexist = true;
110
-	} else $scheduleexist = true;
119
+	    } else {
120
+	    	$scheduleexist = true;
121
+	    }
122
+	} else {
123
+		$scheduleexist = true;
124
+	}
111 125
 	// close connection, at least one way will work ?
112 126
        if ($scheduleexist) {
113
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
127
+		if ($globalDebug) {
128
+			echo "-> get arrival/departure airport info for ".$ident."\n";
129
+		}
114 130
     		$sch = $Schedule->getSchedule($operator);
115 131
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
116
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
132
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
133
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
134
+		}
117 135
        }
118 136
 	$Spotter->db = null;
119 137
 	$Schedule->db = null;
@@ -133,14 +151,18 @@  discard block
 block discarded – undo
133 151
 
134 152
     public function checkAll() {
135 153
 	global $globalDebug, $globalNoImport;
136
-	if ($globalDebug) echo "Update last seen flights data...\n";
154
+	if ($globalDebug) {
155
+		echo "Update last seen flights data...\n";
156
+	}
137 157
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
138 158
 	    foreach ($this->all_flights as $key => $flight) {
139 159
 		if (isset($this->all_flights[$key]['id'])) {
140 160
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
141 161
     		    $Spotter = new Spotter($this->db);
142 162
         	    $real_arrival = $this->arrival($key);
143
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
163
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
164
+        	    	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
165
+        	    }
144 166
         	}
145 167
 	    }
146 168
 	}
@@ -148,24 +170,32 @@  discard block
 block discarded – undo
148 170
 
149 171
     public function arrival($key) {
150 172
 	global $globalClosestMinDist, $globalDebug;
151
-	if ($globalDebug) echo 'Update arrival...'."\n";
173
+	if ($globalDebug) {
174
+		echo 'Update arrival...'."\n";
175
+	}
152 176
 	$Spotter = new Spotter($this->db);
153 177
         $airport_icao = '';
154 178
         $airport_time = '';
155
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
179
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
180
+        	$globalClosestMinDist = 50;
181
+        }
156 182
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
157 183
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
158 184
     	    if (isset($closestAirports[0])) {
159 185
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
160 186
         	    $airport_icao = $closestAirports[0]['icao'];
161 187
         	    $airport_time = $this->all_flights[$key]['datetime'];
162
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
188
+        	    if ($globalDebug) {
189
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
190
+        	    }
163 191
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
164 192
         	    foreach ($closestAirports as $airport) {
165 193
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
166 194
         		    $airport_icao = $airport['icao'];
167 195
         		    $airport_time = $this->all_flights[$key]['datetime'];
168
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
196
+        		    if ($globalDebug) {
197
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
198
+        		    }
169 199
         		    break;
170 200
         		}
171 201
         	    }
@@ -173,14 +203,20 @@  discard block
 block discarded – undo
173 203
         		$airport_icao = $closestAirports[0]['icao'];
174 204
         		$airport_time = $this->all_flights[$key]['datetime'];
175 205
         	} else {
176
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
206
+        		if ($globalDebug) {
207
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
208
+        		}
177 209
         	}
178 210
     	    } else {
179
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
211
+    		    if ($globalDebug) {
212
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
213
+    		    }
180 214
     	    }
181 215
 
182 216
         } else {
183
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
217
+        	if ($globalDebug) {
218
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
219
+        	}
184 220
         }
185 221
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
186 222
     }
@@ -190,7 +226,9 @@  discard block
 block discarded – undo
190 226
     public function del() {
191 227
 	global $globalDebug, $globalNoImport, $globalNoDB;
192 228
 	// Delete old infos
193
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
229
+	if ($globalDebug) {
230
+		echo 'Delete old values and update latest data...'."\n";
231
+	}
194 232
 	
195 233
 	foreach ($this->all_flights as $key => $flight) {
196 234
 		if (isset($flight['lastupdate'])) {
@@ -205,22 +243,30 @@  discard block
 block discarded – undo
205 243
 	global $globalDebug, $globalNoImport, $globalNoDB;
206 244
 	// Delete old infos
207 245
 	if (isset($this->all_flights[$key]['id'])) {
208
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
246
+		if ($globalDebug) {
247
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
248
+		}
209 249
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
210 250
 			$real_arrival = $this->arrival($key);
211 251
 			$Spotter = new Spotter($this->db);
212 252
 			$SpotterLive = new SpotterLive($this->db);
213 253
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
214 254
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
215
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
255
+				if ($globalDebug && $result != 'success') {
256
+					echo '!!! ERROR : '.$result."\n";
257
+				}
216 258
 				$this->all_flights[$key]['putinarchive'] = true;
217 259
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
218
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
260
+				if ($globalDebug && $result != 'success') {
261
+					echo '!!! ERROR : '.$result."\n";
262
+				}
219 263
 			}
220 264
 			$Spotter->db = null;
221 265
 			$SpotterLive->db = null;
222 266
 		}
223
-		if ($globalDebug) echo "\n";
267
+		if ($globalDebug) {
268
+			echo "\n";
269
+		}
224 270
 	}
225 271
 	unset($this->all_flights[$key]);
226 272
     }
@@ -228,9 +274,13 @@  discard block
 block discarded – undo
228 274
     public function add($line) {
229 275
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
230 276
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
231
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
232
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
233
-/*
277
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
278
+		$globalCoordMinChange = '0.01';
279
+	}
280
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
281
+		$globalAircraftMaxUpdate = 3000;
282
+	}
283
+	/*
234 284
 	$Spotter = new Spotter();
235 285
 	$dbc = $Spotter->db;
236 286
 	$SpotterLive = new SpotterLive($dbc);
@@ -252,19 +302,28 @@  discard block
 block discarded – undo
252 302
 	// SBS format is CSV format
253 303
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
254 304
 	    //print_r($line);
255
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
305
+	    if (isset($line['hex'])) {
306
+	    	$line['hex'] = strtoupper($line['hex']);
307
+	    }
256 308
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
257 309
 
258 310
 		// Increment message number
259 311
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
260 312
 		    $current_date = date('Y-m-d');
261
-		    if (isset($line['source_name'])) $source = $line['source_name'];
262
-		    else $source = '';
263
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
313
+		    if (isset($line['source_name'])) {
314
+		    	$source = $line['source_name'];
315
+		    } else {
316
+		    	$source = '';
317
+		    }
318
+		    if ($source == '' || $line['format_source'] == 'aprs') {
319
+		    	$source = $line['format_source'];
320
+		    }
264 321
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
265 322
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
266 323
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
267
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
324
+		    } else {
325
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
326
+		    }
268 327
 		}
269 328
 		
270 329
 		/*
@@ -280,23 +339,38 @@  discard block
 block discarded – undo
280 339
 		//$this->db = $dbc;
281 340
 
282 341
 		//$hex = trim($line['hex']);
283
-	        if (!isset($line['id'])) $id = trim($line['hex']);
284
-	        else $id = trim($line['id']);
342
+	        if (!isset($line['id'])) {
343
+	        	$id = trim($line['hex']);
344
+	        } else {
345
+	        	$id = trim($line['id']);
346
+	        }
285 347
 		
286 348
 		if (!isset($this->all_flights[$id])) {
287
-		    if ($globalDebug) echo 'New flight...'."\n";
349
+		    if ($globalDebug) {
350
+		    	echo 'New flight...'."\n";
351
+		    }
288 352
 		    $this->all_flights[$id] = array();
289 353
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
290 354
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
291
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
355
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
356
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
357
+		    }
292 358
 		    if (!isset($line['id'])) {
293
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
294
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
359
+			if (!isset($globalDaemon)) {
360
+				$globalDaemon = TRUE;
361
+			}
362
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
295 363
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
296
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
364
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
365
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
366
+			}
297 367
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
298
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
299
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
368
+		     } else {
369
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
370
+		     }
371
+		    if ($globalAllFlights !== FALSE) {
372
+		    	$dataFound = true;
373
+		    }
300 374
 		}
301 375
 		if (isset($line['source_type']) && $line['source_type'] != '') {
302 376
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -318,12 +392,20 @@  discard block
 block discarded – undo
318 392
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
319 393
 			    }
320 394
 			    $Spotter->db = null;
321
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
395
+			    if ($globalDebugTimeElapsed) {
396
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397
+			    }
398
+			    if ($aircraft_icao != '') {
399
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
400
+			    }
323 401
 			}
324 402
 		    }
325
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
326
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
403
+		    if ($globalAllFlights !== FALSE) {
404
+		    	$dataFound = true;
405
+		    }
406
+		    if ($globalDebug) {
407
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
408
+		    }
327 409
 		}
328 410
 	        if (isset($line['id']) && !isset($line['hex'])) {
329 411
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -332,7 +414,9 @@  discard block
 block discarded – undo
332 414
 			$icao = $line['aircraft_icao'];
333 415
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
334 416
 				$Spotter = new Spotter($this->db);
335
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
417
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
418
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
419
+				}
336 420
 				$Spotter->db = null;
337 421
 			}
338 422
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -342,15 +426,24 @@  discard block
 block discarded – undo
342 426
 				$Spotter = new Spotter($this->db);
343 427
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
344 428
 				$Spotter->db = null;
345
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
429
+				if ($aircraft_icao != '') {
430
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
431
+				}
346 432
 			}
347 433
 		}
348 434
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
349
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
350
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
351
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
352
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
353
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
435
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
436
+				$aircraft_icao = 'GLID';
437
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
438
+				$aircraft_icao = 'UHEL';
439
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
440
+				$aircraft_icao = 'TOWPLANE';
441
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
442
+				$aircraft_icao = 'POWAIRC';
443
+			}
444
+			if (isset($aircraft_icao)) {
445
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
446
+			}
354 447
 		}
355 448
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
356 449
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -360,8 +453,11 @@  discard block
 block discarded – undo
360 453
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
361 454
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
362 455
 		    } else {
363
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
364
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
456
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
457
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
458
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
459
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
460
+				}
365 461
 				/*
366 462
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
367 463
 				print_r($this->all_flights[$id]);
@@ -370,16 +466,22 @@  discard block
 block discarded – undo
370 466
 				return '';
371 467
 		    }
372 468
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
373
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
469
+			if ($globalDebug) {
470
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
471
+			}
374 472
 			return '';
375 473
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
376
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
474
+			if ($globalDebug) {
475
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
476
+			}
377 477
 			return '';
378 478
 		} elseif (!isset($line['datetime'])) {
379 479
 			date_default_timezone_set('UTC');
380 480
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
381 481
 		} else {
382
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
482
+			if ($globalDebug) {
483
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
484
+			}
383 485
 			return '';
384 486
 		}
385 487
 
@@ -400,30 +502,48 @@  discard block
 block discarded – undo
400 502
 
401 503
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
402 504
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
403
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
505
+				if ($globalDebug) {
506
+					echo '---!!!! New ident, reset aircraft data...'."\n";
507
+				}
404 508
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
405 509
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
406
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
407
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
408
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
510
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
511
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
512
+				} elseif (isset($line['id'])) {
513
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
514
+				} elseif (isset($this->all_flights[$id]['ident'])) {
515
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
516
+				}
409 517
 			} else {
410 518
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
411 519
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412 520
 				$timeelapsed = microtime(true);
413 521
             			$Spotter = new Spotter($this->db);
414 522
             			$fromsource = NULL;
415
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
416
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
417
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
418
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
419
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
523
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
524
+            				$fromsource = $globalAirlinesSource;
525
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
526
+            				$fromsource = 'vatsim';
527
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
528
+					$fromsource = 'ivao';
529
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
530
+					$fromsource = 'vatsim';
531
+				} elseif (isset($globalIVAO) && $globalIVAO) {
532
+					$fromsource = 'ivao';
533
+				}
420 534
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
421
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
535
+				if ($globalDebug && $result != 'success') {
536
+					echo '!!! ERROR : '.$result."\n";
537
+				}
422 538
 				$Spotter->db = null;
423
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
539
+				if ($globalDebugTimeElapsed) {
540
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+				}
424 542
 			    }
425 543
 			}
426
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
544
+		    } else {
545
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
546
+		    }
427 547
 		    
428 548
 /*
429 549
 		    if (!isset($line['id'])) {
@@ -433,7 +553,9 @@  discard block
 block discarded – undo
433 553
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434 554
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
435 555
   */
436
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
556
+		    if (!isset($this->all_flights[$id]['id'])) {
557
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
558
+		    }
437 559
 
438 560
 		    //$putinarchive = true;
439 561
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -451,7 +573,9 @@  discard block
 block discarded – undo
451 573
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
452 574
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
453 575
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
454
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
576
+				if ($globalDebugTimeElapsed) {
577
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+				}
455 579
                         }
456 580
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
457 581
 			$timeelapsed = microtime(true);
@@ -465,7 +589,9 @@  discard block
 block discarded – undo
465 589
 				$Translation->db = null;
466 590
 			    }
467 591
 			    $Spotter->db = null;
468
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
592
+			    if ($globalDebugTimeElapsed) {
593
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
594
+			    }
469 595
                     	}
470 596
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
471 597
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -474,9 +600,13 @@  discard block
 block discarded – undo
474 600
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
475 601
 		    	    }
476 602
 			}
477
-			if (!isset($globalFork)) $globalFork = TRUE;
603
+			if (!isset($globalFork)) {
604
+				$globalFork = TRUE;
605
+			}
478 606
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
479
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
607
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
608
+					$this->get_Schedule($id,trim($line['ident']));
609
+				}
480 610
 			}
481 611
 		    }
482 612
 		}
@@ -494,9 +624,13 @@  discard block
 block discarded – undo
494 624
 			$speed = $speed*3.6;
495 625
 			if ($speed < 1000) {
496 626
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
497
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
627
+	  			if ($globalDebug) {
628
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
629
+	  			}
498 630
 	  		} else {
499
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
631
+	  			if ($globalDebug) {
632
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
633
+	  			}
500 634
 	  		}
501 635
 		    }
502 636
 		}
@@ -505,13 +639,21 @@  discard block
 block discarded – undo
505 639
 
506 640
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
507 641
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
508
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
642
+	    	    	if ($globalDebug) {
643
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
644
+	    	    	}
509 645
 	    	    	return false;
510 646
 	    	    }
511
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
512
-	    	    else unset($timediff);
513
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
514
-	    	    else unset($timediff_archive);
647
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
648
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
649
+	    	    } else {
650
+	    	    	unset($timediff);
651
+	    	    }
652
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
653
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
654
+	    	    } else {
655
+	    	    	unset($timediff_archive);
656
+	    	    }
515 657
 	    	    if ($this->tmd > 5
516 658
 	    	        || (isset($line['format_source']) 
517 659
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -548,16 +690,25 @@  discard block
 block discarded – undo
548 690
 				$this->all_flights[$id]['putinarchive'] = true;
549 691
 				$this->tmd = 0;
550 692
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
551
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
693
+				    if ($globalDebug) {
694
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
695
+				    }
552 696
 				    $timeelapsed = microtime(true);
553 697
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
554 698
 					$Spotter = new Spotter($this->db);
555 699
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
556
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
557
-					else $this->all_flights[$id]['over_country'] = '';
700
+					if (!empty($all_country)) {
701
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
702
+					} else {
703
+						$this->all_flights[$id]['over_country'] = '';
704
+					}
558 705
 					$Spotter->db = null;
559
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
560
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
706
+					if ($globalDebugTimeElapsed) {
707
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
708
+					}
709
+					if ($globalDebug) {
710
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
711
+					}
561 712
 				    }
562 713
 				}
563 714
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -603,7 +754,9 @@  discard block
 block discarded – undo
603 754
 			    */
604 755
 			}
605 756
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
606
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
757
+			    if ($line['longitude'] > 180) {
758
+			    	$line['longitude'] = $line['longitude'] - 360;
759
+			    }
607 760
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
608 761
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
609 762
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -640,7 +793,9 @@  discard block
 block discarded – undo
640 793
 		    }
641 794
 		}
642 795
 		if (isset($line['last_update']) && $line['last_update'] != '') {
643
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
796
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
797
+		    	$dataFound = true;
798
+		    }
644 799
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
645 800
 		}
646 801
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -662,35 +817,53 @@  discard block
 block discarded – undo
662 817
 			// Here we force archive of flight because after ground it's a new one (or should be)
663 818
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
664 819
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
665
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
666
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
667
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
820
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
821
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
822
+			} elseif (isset($line['id'])) {
823
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
824
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
825
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
826
+			}
827
+		    }
828
+		    if ($line['ground'] != 1) {
829
+		    	$line['ground'] = 0;
668 830
 		    }
669
-		    if ($line['ground'] != 1) $line['ground'] = 0;
670 831
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
671 832
 		    //$dataFound = true;
672 833
 		}
673 834
 		if (isset($line['squawk']) && $line['squawk'] != '') {
674 835
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
675
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
836
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
837
+			    	$this->all_flights[$id]['putinarchive'] = true;
838
+			    }
676 839
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
677 840
 			    $highlight = '';
678
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
679
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
680
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
841
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
842
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
843
+			    }
844
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
845
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
846
+			    }
847
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
848
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
849
+			    }
681 850
 			    if ($highlight != '') {
682 851
 				$timeelapsed = microtime(true);
683 852
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
684 853
 				    $Spotter = new Spotter($this->db);
685 854
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
686 855
 				    $Spotter->db = null;
687
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
856
+				    if ($globalDebugTimeElapsed) {
857
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
858
+				    }
688 859
 				}
689 860
 				//$putinarchive = true;
690 861
 				//$highlight = '';
691 862
 			    }
692 863
 			    
693
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
864
+		    } else {
865
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
866
+		    }
694 867
 		    //$dataFound = true;
695 868
 		}
696 869
 
@@ -703,19 +876,27 @@  discard block
 block discarded – undo
703 876
 				}
704 877
 			}
705 878
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
706
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
879
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
880
+				$this->all_flights[$id]['putinarchive'] = true;
881
+			}
707 882
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
708 883
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
709 884
 			//$dataFound = true;
710 885
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
711 886
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
712 887
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
713
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
888
+				if ($globalDebug) {
889
+					echo '--- Reset because of altitude'."\n";
890
+				}
714 891
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
715 892
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
716
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
717
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
718
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
893
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
894
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
895
+				} elseif (isset($line['id'])) {
896
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
897
+				} elseif (isset($this->all_flights[$id]['ident'])) {
898
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
899
+				}
719 900
 			}
720 901
 		    }
721 902
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -726,22 +907,32 @@  discard block
 block discarded – undo
726 907
 		}
727 908
 		
728 909
 		if (isset($line['heading']) && $line['heading'] != '') {
729
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
910
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
911
+		    	$this->all_flights[$id]['putinarchive'] = true;
912
+		    }
730 913
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
731 914
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
732 915
 		    //$dataFound = true;
733 916
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
734 917
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
735 918
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
736
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
737
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
919
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
920
+		    	$this->all_flights[$id]['putinarchive'] = true;
921
+		    }
922
+  		    if ($globalDebug) {
923
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
924
+  		    }
738 925
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
739 926
   		    // If not enough messages and ACARS set heading to 0
740 927
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
741 928
   		}
742
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
743
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
744
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) $dataFound = false;
929
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
930
+			$dataFound = false;
931
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
932
+			$dataFound = false;
933
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinupdate) {
934
+			$dataFound = false;
935
+		}
745 936
 
746 937
 //		print_r($this->all_flights[$id]);
747 938
 		//gets the callsign from the last hour
@@ -758,23 +949,38 @@  discard block
 block discarded – undo
758 949
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
759 950
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
760 951
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
761
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
952
+				    if ($globalDebug) {
953
+				    	echo "Check if aircraft is already in DB...";
954
+				    }
762 955
 				    $timeelapsed = microtime(true);
763 956
 				    $SpotterLive = new SpotterLive($this->db);
764 957
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
765 958
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
766
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
959
+					if ($globalDebugTimeElapsed) {
960
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
961
+					}
767 962
 				    } elseif (isset($line['id'])) {
768 963
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
769
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
964
+					if ($globalDebugTimeElapsed) {
965
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
966
+					}
770 967
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
771 968
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
772
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
773
-				    } else $recent_ident = '';
969
+					if ($globalDebugTimeElapsed) {
970
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
971
+					}
972
+				    } else {
973
+				    	$recent_ident = '';
974
+				    }
774 975
 				    $SpotterLive->db=null;
775
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
776
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
777
-				} else $recent_ident = '';
976
+				    if ($globalDebug && $recent_ident == '') {
977
+				    	echo " Not in DB.\n";
978
+				    } elseif ($globalDebug && $recent_ident != '') {
979
+				    	echo " Already in DB.\n";
980
+				    }
981
+				} else {
982
+					$recent_ident = '';
983
+				}
778 984
 			    } else {
779 985
 				$recent_ident = '';
780 986
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -782,7 +988,9 @@  discard block
 block discarded – undo
782 988
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
783 989
 			    if($recent_ident == "")
784 990
 			    {
785
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
991
+				if ($globalDebug) {
992
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
993
+				}
786 994
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
787 995
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
788 996
 				//adds the spotter data for the archive
@@ -826,10 +1034,18 @@  discard block
 block discarded – undo
826 1034
 				
827 1035
 				if (!$ignoreImport) {
828 1036
 				    $highlight = '';
829
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
830
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
831
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
832
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1037
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1038
+				    	$highlight = 'Squawk 7500 : Hijack';
1039
+				    }
1040
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1041
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1042
+				    }
1043
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1044
+				    	$highlight = 'Squawk 7700 : Emergency';
1045
+				    }
1046
+				    if (!isset($this->all_flights[$id]['id'])) {
1047
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1048
+				    }
833 1049
 				    $timeelapsed = microtime(true);
834 1050
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
835 1051
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -837,28 +1053,43 @@  discard block
 block discarded – undo
837 1053
 					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
838 1054
 					    $Spotter->db = null;
839 1055
 					    if ($globalDebug) {
840
-						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
841
-						else echo 'Success';
1056
+						if (isset($result['error'])) {
1057
+							echo 'Error: '.$result['error']."\n";
1058
+						} else {
1059
+							echo 'Success';
1060
+						}
842 1061
 					    }
843 1062
 					    if (count($result) > 1) {
844 1063
 					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
845
-						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
846
-						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
1064
+						if ($this->all_flights[$id]['aircraft_icao'] == '') {
1065
+							$this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
1066
+						}
1067
+						if ($this->all_flights[$id]['registration'] == '') {
1068
+							$this->all_flights[$id]['registration'] = $result[':registration'];
1069
+						}
847 1070
 					    }
848 1071
 					}
849 1072
 				    }
850
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1073
+				    if ($globalDebugTimeElapsed) {
1074
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1075
+				    }
851 1076
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852 1077
 
853 1078
 				    // Add source stat in DB
854 1079
 				    $Stats = new Stats($this->db);
855 1080
 				    if (!empty($this->stats)) {
856
-					if ($globalDebug) echo 'Add source stats : ';
1081
+					if ($globalDebug) {
1082
+						echo 'Add source stats : ';
1083
+					}
857 1084
 				        foreach($this->stats as $date => $data) {
858 1085
 					    foreach($data as $source => $sourced) {
859 1086
 					        //print_r($sourced);
860
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
861
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1087
+				    	        if (isset($sourced['polar'])) {
1088
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1089
+				    	        }
1090
+				    	        if (isset($sourced['hist'])) {
1091
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1092
+				    	        }
862 1093
 				    		if (isset($sourced['msg'])) {
863 1094
 				    		    if (time() - $sourced['msg']['date'] > 10) {
864 1095
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -871,13 +1102,17 @@  discard block
 block discarded – undo
871 1102
 			    			unset($this->stats[$date]);
872 1103
 			    		    }
873 1104
 				    	}
874
-				    	if ($globalDebug) echo 'Done'."\n";
1105
+				    	if ($globalDebug) {
1106
+				    		echo 'Done'."\n";
1107
+				    	}
875 1108
 
876 1109
 				    }
877 1110
 				    $Stats->db = null;
878 1111
 				    }
879 1112
 				    $this->del();
880
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1113
+				} elseif ($globalDebug) {
1114
+					echo 'Ignore data'."\n";
1115
+				}
881 1116
 				//$ignoreImport = false;
882 1117
 				$this->all_flights[$id]['addedSpotter'] = 1;
883 1118
 				//print_r($this->all_flights[$id]);
@@ -894,7 +1129,9 @@  discard block
 block discarded – undo
894 1129
 			*/
895 1130
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
896 1131
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
897
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1132
+				    if ($globalDebug) {
1133
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1134
+				    }
898 1135
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
899 1136
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 1137
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -903,7 +1140,9 @@  discard block
 block discarded – undo
903 1140
 					    $SpotterLive->db=null;
904 1141
 					}
905 1142
 				    }
906
-				    if ($globalDebug) echo " Done\n";
1143
+				    if ($globalDebug) {
1144
+				    	echo " Done\n";
1145
+				    }
907 1146
 				    $this->last_delete = time();
908 1147
 				}
909 1148
 			    } else {
@@ -930,11 +1169,17 @@  discard block
 block discarded – undo
930 1169
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
931 1170
 		    if ($globalDebug) {
932 1171
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
933
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
934
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1172
+				if (isset($this->all_flights[$id]['source_name'])) {
1173
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
1174
+				} else {
1175
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
1176
+				}
935 1177
 			} else {
936
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
937
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1178
+				if (isset($this->all_flights[$id]['source_name'])) {
1179
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
1180
+				} else {
1181
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
1182
+				}
938 1183
 			}
939 1184
 		    }
940 1185
 		    $ignoreImport = false;
@@ -980,22 +1225,30 @@  discard block
 block discarded – undo
980 1225
 
981 1226
 		    if (!$ignoreImport) {
982 1227
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
983
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1228
+				if (!isset($this->all_flights[$id]['id'])) {
1229
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1230
+				}
984 1231
 				$timeelapsed = microtime(true);
985 1232
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
986 1233
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
987
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1234
+					if ($globalDebug) {
1235
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1236
+					}
988 1237
 					$SpotterLive = new SpotterLive($this->db);
989 1238
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
990 1239
 					$SpotterLive->db = null;
991
-					if ($globalDebug) echo $result."\n";
1240
+					if ($globalDebug) {
1241
+						echo $result."\n";
1242
+					}
992 1243
 				    }
993 1244
 				}
994 1245
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
995 1246
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
996 1247
 				}
997 1248
 				$this->all_flights[$id]['putinarchive'] = false;
998
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1249
+				if ($globalDebugTimeElapsed) {
1250
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1251
+				}
999 1252
 
1000 1253
 				// Put statistics in $this->stats variable
1001 1254
 				//if ($line['format_source'] != 'aprs') {
@@ -1003,7 +1256,9 @@  discard block
 block discarded – undo
1003 1256
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1004 1257
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1005 1258
 					$source = $this->all_flights[$id]['source_name'];
1006
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1259
+					if ($source == '') {
1260
+						$source = $this->all_flights[$id]['format_source'];
1261
+					}
1007 1262
 					if (!isset($this->source_location[$source])) {
1008 1263
 						$Location = new Source($this->db);
1009 1264
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1024,7 +1279,9 @@  discard block
 block discarded – undo
1024 1279
 					$stats_heading = round($stats_heading/22.5);
1025 1280
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1026 1281
 					$current_date = date('Y-m-d');
1027
-					if ($stats_heading == 16) $stats_heading = 0;
1282
+					if ($stats_heading == 16) {
1283
+						$stats_heading = 0;
1284
+					}
1028 1285
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1029 1286
 						for ($i=0;$i<=15;$i++) {
1030 1287
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1042,7 +1299,9 @@  discard block
 block discarded – undo
1042 1299
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1043 1300
 						    end($this->stats[$current_date][$source]['hist']);
1044 1301
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1045
-						} else $mini = 0;
1302
+						} else {
1303
+							$mini = 0;
1304
+						}
1046 1305
 						for ($i=$mini;$i<=$distance;$i+=10) {
1047 1306
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1048 1307
 						}
@@ -1054,19 +1313,27 @@  discard block
 block discarded – undo
1054 1313
 				}
1055 1314
 
1056 1315
 				$this->all_flights[$id]['lastupdate'] = time();
1057
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1316
+				if ($this->all_flights[$id]['putinarchive']) {
1317
+					$send = true;
1318
+				}
1058 1319
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1059
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1320
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1321
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1322
+			}
1060 1323
 			//$this->del();
1061 1324
 			
1062 1325
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1063 1326
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1064
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1327
+				if ($globalDebug) {
1328
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1329
+				}
1065 1330
 				$SpotterLive = new SpotterLive($this->db);
1066 1331
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1067 1332
 				$SpotterLive->db = null;
1068 1333
 				//SpotterLive->deleteLiveSpotterData();
1069
-				if ($globalDebug) echo " Done\n";
1334
+				if ($globalDebug) {
1335
+					echo " Done\n";
1336
+				}
1070 1337
 				$this->last_delete_hourly = time();
1071 1338
 			    } else {
1072 1339
 				$this->del();
@@ -1078,7 +1345,9 @@  discard block
 block discarded – undo
1078 1345
 		    //$ignoreImport = false;
1079 1346
 		}
1080 1347
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1081
-		if ($send) return $this->all_flights[$id];
1348
+		if ($send) {
1349
+			return $this->all_flights[$id];
1350
+		}
1082 1351
 	    }
1083 1352
 	}
1084 1353
     }
Please login to merge, or discard this patch.