Completed
Push — master ( 6c4f55...213543 )
by Yannick
10:31
created
index.php 1 patch
Braces   +393 added lines, -101 removed lines patch added patch discarded remove patch
@@ -150,11 +150,26 @@  discard block
 block discarded – undo
150 150
 				<li><div class="checkbox"><label><input type="checkbox" name="notamcb" value="1" onclick="showNotam();" /><?php echo _("Display NOTAM"); ?></label></div></li>
151 151
 				<li><?php echo _("NOTAM scope:"); ?>
152 152
 					<select class="selectpicker" onchange="notamscope(this);">
153
-						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') print ' selected'; ?>>All</option>
154
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') print ' selected'; ?>>Airport/Enroute warning</option>
155
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') print ' selected'; ?>>Airport warning</option>
156
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') print ' selected'; ?>>Navigation warning</option>
157
-						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') print ' selected'; ?>>Enroute warning</option>
153
+						<option<?php if (!isset($_COOKIE['notamscope']) || $_COOKIE['notamscope'] == 'All') {
154
+	print ' selected';
155
+}
156
+?>>All</option>
157
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport/Enroute warning') {
158
+	print ' selected';
159
+}
160
+?>>Airport/Enroute warning</option>
161
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Airport warning') {
162
+	print ' selected';
163
+}
164
+?>>Airport warning</option>
165
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Navigation warning') {
166
+	print ' selected';
167
+}
168
+?>>Navigation warning</option>
169
+						<option<?php if (isset($_COOKIE['notamscope']) && $_COOKIE['notamscope'] == 'Enroute warning') {
170
+	print ' selected';
171
+}
172
+?>>Enroute warning</option>
158 173
 					</select
159 174
 				</li>
160 175
 			</ul>
@@ -182,7 +197,12 @@  discard block
 block discarded – undo
182 197
 		        <div class="form-group">
183 198
 			    <label>From (UTC):</label>
184 199
 		            <div class='input-group date' id='datetimepicker1'>
185
-            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) print $_POST['start_date']; elseif (isset($_COOKIE['archive_begin'])) print date("m/d/Y h:i a",$_COOKIE['archive_begin']); ?>" required />
200
+            			<input type='text' name="start_date" class="form-control" value="<?php if (isset($_POST['start_date'])) {
201
+	print $_POST['start_date'];
202
+} elseif (isset($_COOKIE['archive_begin'])) {
203
+	print date("m/d/Y h:i a",$_COOKIE['archive_begin']);
204
+}
205
+?>" required />
186 206
 		                <span class="input-group-addon">
187 207
             			    <span class="glyphicon glyphicon-calendar"></span>
188 208
 		                </span>
@@ -191,7 +211,12 @@  discard block
 block discarded – undo
191 211
 		        <div class="form-group">
192 212
 			    <label>To (UTC):</label>
193 213
 		            <div class='input-group date' id='datetimepicker2'>
194
-		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) print $_POST['end_date']; elseif (isset($_COOKIE['archive_end'])) print date("m/d/Y h:i a",$_COOKIE['archive_end']); ?>" />
214
+		                <input type='text' name="end_date" class="form-control" value="<?php if (isset($_POST['end_date'])) {
215
+	print $_POST['end_date'];
216
+} elseif (isset($_COOKIE['archive_end'])) {
217
+	print date("m/d/Y h:i a",$_COOKIE['archive_end']);
218
+}
219
+?>" />
195 220
             			<span class="input-group-addon">
196 221
 		                    <span class="glyphicon glyphicon-calendar"></span>
197 222
             			</span>
@@ -217,8 +242,20 @@  discard block
 block discarded – undo
217 242
 
218 243
 		    <li><?php echo _("Playback speed:"); ?>
219 244
 			<div class="range">
220
-			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) print $_POST['archivespeed']; elseif (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?>">
221
-			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) print $_COOKIE['archive_speed']; else print '1'; ?></output>
245
+			    <input type="range" min="0" max="50" step="1" name="archivespeed" onChange="archivespeedrange.value=value;" value="<?php  if (isset($_POST['archivespeed'])) {
246
+	print $_POST['archivespeed'];
247
+} elseif (isset($_COOKIE['archive_speed'])) {
248
+	print $_COOKIE['archive_speed'];
249
+} else {
250
+	print '1';
251
+}
252
+?>">
253
+			    <output id="archivespeedrange"><?php  if (isset($_COOKIE['archive_speed'])) {
254
+	print $_COOKIE['archive_speed'];
255
+} else {
256
+	print '1';
257
+}
258
+?></output>
222 259
 			</div>
223 260
 		    </li>
224 261
 		    <li><input type="submit" name="archive" value="Show archive" class="btn btn-primary" /></li>
@@ -240,15 +277,27 @@  discard block
 block discarded – undo
240 277
 		    <li><?php echo _("Type of Map:"); ?>
241 278
 			<select  class="selectpicker" onchange="mapType(this);">
242 279
 			    <?php
243
-				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') $MapType = $globalMapProvider;
244
-				else $MapType = $_COOKIE['MapType'];
280
+				if (!isset($_COOKIE['MapType']) || $_COOKIE['MapType'] == '') {
281
+					$MapType = $globalMapProvider;
282
+				} else {
283
+					$MapType = $_COOKIE['MapType'];
284
+				}
245 285
 			    ?>
246 286
 			    <?php
247 287
 				if (isset($globalBingMapKey) && $globalBingMapKey != '') {
248 288
 			    ?>
249
-			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') print ' selected'; ?>>Bing-Aerial</option>
250
-			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') print ' selected'; ?>>Bing-Hybrid</option>
251
-			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') print ' selected'; ?>>Bing-Road</option>
289
+			    <option value="Bing-Aerial"<?php if ($MapType == 'Bing-Aerial') {
290
+	print ' selected';
291
+}
292
+?>>Bing-Aerial</option>
293
+			    <option value="Bing-Hybrid"<?php if ($MapType == 'Bing-Hybrid') {
294
+	print ' selected';
295
+}
296
+?>>Bing-Hybrid</option>
297
+			    <option value="Bing-Road"<?php if ($MapType == 'Bing-Road') {
298
+	print ' selected';
299
+}
300
+?>>Bing-Road</option>
252 301
 			    <?php
253 302
 				}
254 303
 			    ?>
@@ -258,56 +307,131 @@  discard block
 block discarded – undo
258 307
 			    <?php
259 308
 				    if (isset($globalHereappId) && $globalHereappId != '' && isset($globalHereappCode) && $globalHereappCode != '') {
260 309
 			    ?>
261
-			    <option value="Here-Aerial"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Aerial</option>
262
-			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Hybrid</option>
263
-			    <option value="Here-Road"<?php if ($MapType == 'Here') print ' selected'; ?>>Here-Road</option>
310
+			    <option value="Here-Aerial"<?php if ($MapType == 'Here') {
311
+	print ' selected';
312
+}
313
+?>>Here-Aerial</option>
314
+			    <option value="Here-Hybrid"<?php if ($MapType == 'Here') {
315
+	print ' selected';
316
+}
317
+?>>Here-Hybrid</option>
318
+			    <option value="Here-Road"<?php if ($MapType == 'Here') {
319
+	print ' selected';
320
+}
321
+?>>Here-Road</option>
264 322
 			    <?php
265 323
 				    }
266 324
 			    ?>
267 325
 			    <?php
268 326
 				    if (isset($globalGoogleAPIKey) && $globalGoogleAPIKey != '') {
269 327
 			    ?>
270
-			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') print ' selected'; ?>>Google Roadmap</option>
271
-			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') print ' selected'; ?>>Google Satellite</option>
272
-			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') print ' selected'; ?>>Google Hybrid</option>
273
-			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') print ' selected'; ?>>Google Terrain</option>
328
+			    <option value="Google-Roadmap"<?php if ($MapType == 'Google-Roadmap') {
329
+	print ' selected';
330
+}
331
+?>>Google Roadmap</option>
332
+			    <option value="Google-Satellite"<?php if ($MapType == 'Google-Satellite') {
333
+	print ' selected';
334
+}
335
+?>>Google Satellite</option>
336
+			    <option value="Google-Hybrid"<?php if ($MapType == 'Google-Hybrid') {
337
+	print ' selected';
338
+}
339
+?>>Google Hybrid</option>
340
+			    <option value="Google-Terrain"<?php if ($MapType == 'Google-Terrain') {
341
+	print ' selected';
342
+}
343
+?>>Google Terrain</option>
274 344
 			    <?php
275 345
 				    }
276 346
 			    ?>
277 347
 			    <?php
278 348
 				    if (isset($globalMapQuestKey) && $globalMapQuestKey != '') {
279 349
 			    ?>
280
-			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') print ' selected'; ?>>MapQuest-OSM</option>
281
-			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') print ' selected'; ?>>MapQuest-Aerial</option>
282
-			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') print ' selected'; ?>>MapQuest-Hybrid</option>
350
+			    <option value="MapQuest-OSM"<?php if ($MapType == 'MapQuest-OSM') {
351
+	print ' selected';
352
+}
353
+?>>MapQuest-OSM</option>
354
+			    <option value="MapQuest-Aerial"<?php if ($MapType == 'MapQuest-Aerial') {
355
+	print ' selected';
356
+}
357
+?>>MapQuest-Aerial</option>
358
+			    <option value="MapQuest-Hybrid"<?php if ($MapType == 'MapQuest-Hybrid') {
359
+	print ' selected';
360
+}
361
+?>>MapQuest-Hybrid</option>
283 362
 			    <?php
284 363
 				    }
285 364
 			    ?>
286
-			    <option value="Yandex"<?php if ($MapType == 'Yandex') print ' selected'; ?>>Yandex</option>
365
+			    <option value="Yandex"<?php if ($MapType == 'Yandex') {
366
+	print ' selected';
367
+}
368
+?>>Yandex</option>
287 369
 			    <?php
288 370
 				}
289 371
 			    ?>
290 372
 			    <?php
291 373
 				    if (isset($globalMapboxToken) && $globalMapboxToken != '') {
292
-					if (!isset($_COOKIE['MapTypeId'])) $MapBoxId = 'default';
293
-					else $MapBoxId = $_COOKIE['MapTypeId'];
374
+					if (!isset($_COOKIE['MapTypeId'])) {
375
+						$MapBoxId = 'default';
376
+					} else {
377
+						$MapBoxId = $_COOKIE['MapTypeId'];
378
+					}
294 379
 			    ?>
295
-			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') print ' selected'; ?>>Mapbox default</option>
296
-			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') print ' selected'; ?>>Mapbox streets</option>
297
-			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') print ' selected'; ?>>Mapbox light</option>
298
-			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') print ' selected'; ?>>Mapbox dark</option>
299
-			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') print ' selected'; ?>>Mapbox satellite</option>
300
-			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') print ' selected'; ?>>Mapbox streets-satellite</option>
301
-			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') print ' selected'; ?>>Mapbox streets-basic</option>
302
-			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') print ' selected'; ?>>Mapbox comic</option>
303
-			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') print ' selected'; ?>>Mapbox outdoors</option>
304
-			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') print ' selected'; ?>>Mapbox pencil</option>
305
-			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') print ' selected'; ?>>Mapbox pirates</option>
306
-			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') print ' selected'; ?>>Mapbox emerald</option>
380
+			    <option value="Mapbox-default"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'default') {
381
+	print ' selected';
382
+}
383
+?>>Mapbox default</option>
384
+			    <option value="Mapbox-mapbox.streets"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets') {
385
+	print ' selected';
386
+}
387
+?>>Mapbox streets</option>
388
+			    <option value="Mapbox-mapbox.light"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.light') {
389
+	print ' selected';
390
+}
391
+?>>Mapbox light</option>
392
+			    <option value="Mapbox-mapbox.dark"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.dark') {
393
+	print ' selected';
394
+}
395
+?>>Mapbox dark</option>
396
+			    <option value="Mapbox-mapbox.satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.satellite') {
397
+	print ' selected';
398
+}
399
+?>>Mapbox satellite</option>
400
+			    <option value="Mapbox-mapbox.streets-satellite"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-satellite') {
401
+	print ' selected';
402
+}
403
+?>>Mapbox streets-satellite</option>
404
+			    <option value="Mapbox-mapbox.streets-basic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.streets-basic') {
405
+	print ' selected';
406
+}
407
+?>>Mapbox streets-basic</option>
408
+			    <option value="Mapbox-mapbox.comic"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.comic') {
409
+	print ' selected';
410
+}
411
+?>>Mapbox comic</option>
412
+			    <option value="Mapbox-mapbox.outdoors"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.outdoors') {
413
+	print ' selected';
414
+}
415
+?>>Mapbox outdoors</option>
416
+			    <option value="Mapbox-mapbox.pencil"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pencil') {
417
+	print ' selected';
418
+}
419
+?>>Mapbox pencil</option>
420
+			    <option value="Mapbox-mapbox.pirates"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.pirates') {
421
+	print ' selected';
422
+}
423
+?>>Mapbox pirates</option>
424
+			    <option value="Mapbox-mapbox.emerald"<?php if ($MapType == 'Mapbox' && $MapBoxId == 'mapbox.emerald') {
425
+	print ' selected';
426
+}
427
+?>>Mapbox emerald</option>
307 428
 			    <?php
308 429
 				    }
309 430
 			    ?>
310
-			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') print ' selected'; ?>>OpenStreetMap</option>
431
+			    <option value="OpenStreetMap"<?php if ($MapType == 'OpenStreetMap') {
432
+	print ' selected';
433
+}
434
+?>>OpenStreetMap</option>
311 435
 			</select>
312 436
 		    </li>
313 437
 <?php
@@ -315,9 +439,18 @@  discard block
 block discarded – undo
315 439
 ?>
316 440
 		    <li><?php echo _("Type of Terrain:"); ?>
317 441
 			<select  class="selectpicker" onchange="terrainType(this);">
318
-			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') print ' selected'; ?>>stk terrain</option>
319
-			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') print ' selected';?>>ellipsoid</option>
320
-			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') print ' selected';?>>vr terrain</option>
442
+			    <option value="stk"<?php if (!isset($_COOKIE['MapTerrain']) || $_COOKIE['MapTerrain'] == 'stk') {
443
+	print ' selected';
444
+}
445
+?>>stk terrain</option>
446
+			    <option value="ellipsoid"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'ellipsoid') {
447
+	print ' selected';
448
+}
449
+?>>ellipsoid</option>
450
+			    <option value="vrterrain"<?php if (isset($_COOKIE['MapTerrain']) && $_COOKIE['MapTerrain'] == 'vrterrain') {
451
+	print ' selected';
452
+}
453
+?>>vr terrain</option>
321 454
 			</select>
322 455
 		    </li>
323 456
 <?php
@@ -327,18 +460,36 @@  discard block
 block discarded – undo
327 460
     if (!isset($_COOKIE['MapFormat']) || $_COOKIE['MapFormat'] != '3d') {
328 461
 ?>
329 462
 		    
330
-		    <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>
331
-		    <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>
332
-		    <li><div class="checkbox"><label><input type="checkbox" name="flightroute" value="1" onclick="clickFlightRoute(this)" <?php if ((isset($_COOKIE['MapRoute']) && $_COOKIE['MapRoute'] == 'true') || !isset($_COOKIE['MapRoute'])) print 'checked'; ?> ><?php echo _("Display flight route on click"); ?></label></div></li>
333
-		    <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>
463
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpopup" value="1" onclick="clickFlightPopup(this)" <?php if (isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true') {
464
+	print 'checked';
465
+}
466
+?> ><?php echo _("Display flight info as popup"); ?></label></div></li>
467
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpath" value="1" onclick="clickFlightPath(this)" <?php if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true')) {
468
+	print 'checked';
469
+}
470
+?> ><?php echo _("Display flight path"); ?></label></div></li>
471
+		    <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'])) {
472
+	print 'checked';
473
+}
474
+?> ><?php echo _("Display flight route on click"); ?></label></div></li>
475
+		    <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)) {
476
+	print 'checked';
477
+}
478
+?> ><?php echo _("Planes animate between updates"); ?></label></div></li>
334 479
 <?php
335 480
     }
336 481
 ?>
337
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') print 'checked'; ?> ><?php echo _("Display airports on map"); ?></label></div></li>
482
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayairports" value="1" onclick="clickDisplayAirports(this)" <?php if (isset($_COOKIE['displayairports']) && $_COOKIE['displayairports'] == 'true') {
483
+	print 'checked';
484
+}
485
+?> ><?php echo _("Display airports on map"); ?></label></div></li>
338 486
 <?php
339 487
     if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
340 488
 ?>
341
-		    <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>
489
+		    <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')) {
490
+	print 'checked';
491
+}
492
+?> ><?php echo _("Show mini-map"); ?></label></div></li>
342 493
 <?php
343 494
     }
344 495
     if (time() > mktime(0,0,0,12,1,date("Y")) && time() < mktime(0,0,0,12,31,date("Y"))) {
@@ -352,17 +503,25 @@  discard block
 block discarded – undo
352 503
 			if (function_exists('array_column')) {
353 504
 			    if (array_search(TRUE, array_column($globalSources, 'sourcestats')) !== FALSE) {
354 505
 		    ?>
355
-		    <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>
506
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
507
+	print 'checked';
508
+}
509
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
356 510
 		    <?php
357 511
 			    }
358 512
 			} elseif (isset($globalSources)) {
359 513
 			    $dispolar = false;
360 514
 			    foreach ($globalSources as $testsource) {
361
-			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) $dispolar = true;
515
+			        if (isset($globalSources['sourcestats']) && $globalSources['sourcestats'] !== FALSE) {
516
+			        	$dispolar = true;
517
+			        }
362 518
 			    }
363 519
 			    if ($dispolar) {
364 520
 		    ?>
365
-		    <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>
521
+		    <li><div class="checkbox"><label><input type="checkbox" name="flightpolar" value="1" onclick="clickPolar(this)" <?php if ((isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
522
+	print 'checked';
523
+}
524
+?> ><?php echo _("Display polar on map"); ?></label></div></li>
366 525
 		    <?php
367 526
 			    }
368 527
 		        }
@@ -374,12 +533,22 @@  discard block
 block discarded – undo
374 533
 		    <?php
375 534
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
376 535
 		    ?>
377
-		    <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>
536
+		    <li><input type="checkbox" name="aircraftcoloraltitude" value="1" onclick="iconColorAltitude(this)" <?php if (isset($_COOKIE['IconColorAltitude']) && $_COOKIE['IconColorAltitude'] == 'true') {
537
+	print 'checked';
538
+}
539
+?> ><?php echo _("Aircraft icon color based on altitude"); ?></li>
378 540
 		    <?php 
379 541
 			if (!isset($_COOKIE['IconColorAltitude']) || $_COOKIE['IconColorAltitude'] == 'false') {
380 542
 		    ?>
381 543
 		    <li><?php echo _("Aircraft icon color:"); ?>
382
-			<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'; ?>">
544
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
545
+	print $_COOKIE['IconColor'];
546
+} elseif (isset($globalAircraftIconColor)) {
547
+	print $globalAircraftIconColor;
548
+} else {
549
+	print '1a3151';
550
+}
551
+?>">
383 552
 		    </li>
384 553
 		    <?php
385 554
 			    }
@@ -389,30 +558,71 @@  discard block
 block discarded – undo
389 558
 		        if (extension_loaded('gd') && function_exists('gd_info')) {
390 559
 		    ?>
391 560
 		    <li><?php echo _("Marine icon color:"); ?>
392
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print '1a3151'; ?>">
561
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
562
+	print $_COOKIE['MarineIconColor'];
563
+} elseif (isset($globalMarineIconColor)) {
564
+	print $globalMarineIconColor;
565
+} else {
566
+	print '1a3151';
567
+}
568
+?>">
393 569
 		    </li>
394 570
 		    <?php
395 571
 		        }
396 572
 		    ?>
397 573
 		    <li><?php echo _("Show airport icon at zoom level:"); ?>
398 574
 			<div class="range">
399
-			    <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'; ?>">
400
-			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) print $_COOKIE['AirportZoom']; elseif (isset($globalAirportZoom)) print $globalAirportZoom; else print '7'; ?></output>
575
+			    <input type="range" min="0" max="19" step="1" name="airportzoom" onchange="range.value=value;airportDisplayZoom(airportzoom.value);" value="<?php if (isset($_COOKIE['AirportZoom'])) {
576
+	print $_COOKIE['AirportZoom'];
577
+} elseif (isset($globalAirportZoom)) {
578
+	print $globalAirportZoom;
579
+} else {
580
+	print '7';
581
+}
582
+?>">
583
+			    <output id="range"><?php if (isset($_COOKIE['AirportZoom'])) {
584
+	print $_COOKIE['AirportZoom'];
585
+} elseif (isset($globalAirportZoom)) {
586
+	print $globalAirportZoom;
587
+} else {
588
+	print '7';
589
+}
590
+?></output>
401 591
 			</div>
402 592
 		    </li>
403 593
 <?php
404 594
     } elseif (isset($_COOKIE['MapFormat']) || $_COOKIE['MapFOrmat'] == '3d') {
405 595
 ?>
406
-		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Aircraft color"); ?></li>
596
+		    <li><input type="checkbox" name="aircraftcolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['IconColorForce']) && $_COOKIE['IconColorForce'] == 'true') {
597
+	print 'checked';
598
+}
599
+?> ><?php echo _("Force Aircraft color"); ?></li>
407 600
 		    <li><?php echo _("Aircraft icon color:"); ?>
408
-			<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'; ?>">
601
+			<input type="color" name="aircraftcolor" id="html5colorpicker" onchange="iconColor(aircraftcolor.value);" value="#<?php if (isset($_COOKIE['IconColor'])) {
602
+	print $_COOKIE['IconColor'];
603
+} elseif (isset($globalAircraftIconColor)) {
604
+	print $globalAircraftIconColor;
605
+} else {
606
+	print 'ff0000';
607
+}
608
+?>">
409 609
 		    </li>
410 610
 <?php
411 611
 	if (isset($globalMarine) && $globalMarine) {
412 612
 ?>
413
-		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') print 'checked'; ?> ><?php echo _("Force Marine color"); ?></li>
613
+		    <li><input type="checkbox" name="marinecolorforce" value="1" onclick="iconColorForce(this)" <?php if (isset($_COOKIE['MarineIconColorForce']) && $_COOKIE['MarineIconColorForce'] == 'true') {
614
+	print 'checked';
615
+}
616
+?> ><?php echo _("Force Marine color"); ?></li>
414 617
 		    <li><?php echo _("Marine icon color:"); ?>
415
-			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) print $_COOKIE['MarineIconColor']; elseif (isset($globalMarineIconColor)) print $globalMarineIconColor; else print 'ff0000'; ?>">
618
+			<input type="color" name="marinecolor" id="html5colorpicker" onchange="iconColor(marinecolor.value);" value="#<?php if (isset($_COOKIE['MarineIconColor'])) {
619
+	print $_COOKIE['MarineIconColor'];
620
+} elseif (isset($globalMarineIconColor)) {
621
+	print $globalMarineIconColor;
622
+} else {
623
+	print 'ff0000';
624
+}
625
+?>">
416 626
 		    </li>
417 627
 <?php
418 628
 	}
@@ -420,22 +630,46 @@  discard block
 block discarded – undo
420 630
 ?>
421 631
 		    <li><?php echo _("Distance unit:"); ?>
422 632
 			<select class="selectpicker" onchange="unitdistance(this);">
423
-			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) echo ' selected'; ?>>km</option>
424
-			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) echo ' selected'; ?>>nm</option>
425
-			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) echo ' selected'; ?>>mi</option>
633
+			    <option value="km"<?php if ((!isset($_COOKIE['unitdistance']) && (!isset($globalUnitDistance) || (isset($globalUnitDistance) && $globalUnitDistance == 'km'))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
634
+	echo ' selected';
635
+}
636
+?>>km</option>
637
+			    <option value="nm"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
638
+	echo ' selected';
639
+}
640
+?>>nm</option>
641
+			    <option value="mi"<?php if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
642
+	echo ' selected';
643
+}
644
+?>>mi</option>
426 645
 		        </select>
427 646
 		    </li>
428 647
 		    <li><?php echo _("Altitude unit:"); ?>
429 648
 			<select class="selectpicker" onchange="unitaltitude(this);">
430
-			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) echo ' selected'; ?>>m</option>
431
-			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) echo ' selected'; ?>>feet</option>
649
+			    <option value="m"<?php if ((!isset($_COOKIE['unitaltitude']) && (!isset($globalUnitAltitude) || (isset($globalUnitAltitude) && $globalUnitAltitude == 'm'))) || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'm')) {
650
+	echo ' selected';
651
+}
652
+?>>m</option>
653
+			    <option value="feet"<?php if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
654
+	echo ' selected';
655
+}
656
+?>>feet</option>
432 657
 		        </select>
433 658
 		    </li>
434 659
 		    <li><?php echo _("Speed unit:"); ?>
435 660
 			<select class="selectpicker" onchange="unitspeed(this);">
436
-			    <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>
437
-			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) echo ' selected'; ?>>mph</option>
438
-			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) echo ' selected'; ?>>knots</option>
661
+			    <option value="kmh"<?php if ((!isset($_COOKIE['unitspeed']) && (!isset($globalUnitSpeed) || (isset($globalUnitSpeed) && $globalUnitSpeed == 'kmh'))) || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'kmh')) {
662
+	echo ' selected';
663
+}
664
+?>>km/h</option>
665
+			    <option value="mph"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
666
+	echo ' selected';
667
+}
668
+?>>mph</option>
669
+			    <option value="knots"<?php if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
670
+	echo ' selected';
671
+}
672
+?>>knots</option>
439 673
 		        </select>
440 674
 		    </li>
441 675
 
@@ -450,9 +684,18 @@  discard block
 block discarded – undo
450 684
 		    <?php
451 685
 			if (((isset($globalVATSIM) && $globalVATSIM) || isset($globalIVAO) && $globalIVAO || isset($globalphpVMS) && $globalphpVMS) && (!isset($globalMapVAchoose) || $globalMapVAchoose)) {
452 686
 		    ?>
453
-			<?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 } ?>
454
-			<?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 } ?>
455
-			<?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 } ?>
687
+			<?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'])) {
688
+	print 'checked';
689
+}
690
+?> ><?php echo _("Display VATSIM data"); ?></li><?php } ?>
691
+			<?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'])) {
692
+	print 'checked';
693
+}
694
+?> ><?php echo _("Display IVAO data"); ?></li><?php } ?>
695
+			<?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'])) {
696
+	print 'checked';
697
+}
698
+?> ><?php echo _("Display phpVMS data"); ?></li><?php } ?>
456 699
 		    <?php
457 700
 			}
458 701
 		    ?>
@@ -460,10 +703,16 @@  discard block
 block discarded – undo
460 703
 			if (!(isset($globalVATSIM) && $globalVATSIM) && !(isset($globalIVAO) && $globalIVAO) && !(isset($globalphpVMS) && $globalphpVMS) && isset($globalSBS1) && $globalSBS1 && isset($globalAPRS) && $globalAPRS && (!isset($globalMapchoose) || $globalMapchoose)) {
461 704
 		    ?>
462 705
 			<?php if (isset($globalSBS1) && $globalSBS1) { ?>
463
-			    <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>
706
+			    <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'])) {
707
+	print 'checked';
708
+}
709
+?> ><?php echo _("Display ADS-B data"); ?></label></div></li>
464 710
 			<?php } ?>
465 711
 			<?php if (isset($globalAPRS) && $globalAPRS) { ?>
466
-			    <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>
712
+			    <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'])) {
713
+	print 'checked';
714
+}
715
+?> ><?php echo _("Display APRS data"); ?></label></div></li>
467 716
 			<?php } ?>
468 717
 		    <?php
469 718
 			}
@@ -480,7 +729,9 @@  discard block
 block discarded – undo
480 729
 				}
481 730
 				foreach($allairlinenames as $airline) {
482 731
 					$airline_name = $airline['airline_name'];
483
-					if (strlen($airline_name) > 30) $airline_name = substr($airline_name,0,30).'...';
732
+					if (strlen($airline_name) > 30) {
733
+						$airline_name = substr($airline_name,0,30).'...';
734
+					}
484 735
 					if (isset($_COOKIE['filter_Airlines']) && in_array($airline['airline_icao'],explode(',',$_COOKIE['filter_Airlines']))) {
485 736
 						echo '<option value="'.$airline['airline_icao'].'" selected>'.$airline_name.'</option>';
486 737
 					} else {
@@ -498,7 +749,10 @@  discard block
 block discarded – undo
498 749
 		    <li><?php echo _("Display alliance:"); ?>
499 750
 		    <br/>
500 751
 			<select class="selectpicker" onchange="alliance(this);" id="display_alliance">
501
-			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
752
+			    <option value="all"<?php if (!isset($_COOKIE['filter_alliance']) || $_COOKIE['filter_alliance'] == 'all' || $_COOKIE['filter_alliance'] == '') {
753
+	echo ' selected';
754
+}
755
+?>><?php echo _("All"); ?></option>
502 756
 			    <?php
503 757
 				foreach($allalliancenames as $alliance) {
504 758
 					$alliance_name = $alliance['alliance'];
@@ -539,10 +793,22 @@  discard block
 block discarded – undo
539 793
 		    ?>
540 794
 		    <li><?php echo _("Display airlines of type:"); ?><br/>
541 795
 			<select class="selectpicker" onchange="airlinestype(this);">
542
-			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') echo ' selected'; ?>><?php echo _("All"); ?></option>
543
-			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') echo ' selected'; ?>><?php echo _("Passenger"); ?></option>
544
-			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') echo ' selected'; ?>><?php echo _("Cargo"); ?></option>
545
-			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') echo ' selected'; ?>><?php echo _("Military"); ?></option>
796
+			    <option value="all"<?php if (!isset($_COOKIE['filter_airlinestype']) || $_COOKIE['filter_airlinestype'] == 'all' || $_COOKIE['filter_airlinestype'] == '') {
797
+	echo ' selected';
798
+}
799
+?>><?php echo _("All"); ?></option>
800
+			    <option value="passenger"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'passenger') {
801
+	echo ' selected';
802
+}
803
+?>><?php echo _("Passenger"); ?></option>
804
+			    <option value="cargo"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'cargo') {
805
+	echo ' selected';
806
+}
807
+?>><?php echo _("Cargo"); ?></option>
808
+			    <option value="military"<?php if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] == 'military') {
809
+	echo ' selected';
810
+}
811
+?>><?php echo _("Military"); ?></option>
546 812
 			</select>
547 813
 		    </li>
548 814
 		    <?php
@@ -550,7 +816,10 @@  discard block
 block discarded – undo
550 816
 		    ?>
551 817
 		    <li>
552 818
 			<?php echo _("Display flight with ident:"); ?>
553
-			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) print $_COOKIE['filter_ident']; ?>" />
819
+			<input type="text" name="identfilter" onchange="identfilter();" id="identfilter" value="<?php if (isset($_COOKIE['filter_ident'])) {
820
+	print $_COOKIE['filter_ident'];
821
+}
822
+?>" />
554 823
 		    </li>
555 824
 		</ul>
556 825
 	    </form>
@@ -566,7 +835,10 @@  discard block
 block discarded – undo
566 835
 	    <h1 class="sidebar-header"><?php echo _("Satellites"); ?><span class="sidebar-close"><i class="fa fa-caret-left"></i></span></h1>
567 836
 	    <form>
568 837
 		<ul>
569
-		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') print 'checked'; ?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
838
+		    <li><div class="checkbox"><label><input type="checkbox" name="displayiss" value="1" onclick="clickDisplayISS(this)" <?php if (isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') {
839
+	print 'checked';
840
+}
841
+?> ><?php echo _("Show ISS, Tiangong-1 and Tiangong-2 on map"); ?></label></div></li>
570 842
 		    <li><?php echo _("Type:"); ?>
571 843
 			<select class="selectpicker" multiple onchange="sattypes(this);">
572 844
 			    <?php
@@ -574,25 +846,45 @@  discard block
 block discarded – undo
574 846
 				$types = $Satellite->get_tle_types();
575 847
 				foreach ($types as $type) {
576 848
 					$type_name = $type['tle_type'];
577
-					if ($type_name == 'musson') $type_name = 'Russian LEO Navigation';
578
-					else if ($type_name == 'nnss') $type_name = 'Navi Navigation Satellite System';
579
-					else if ($type_name == 'sbas') $type_name = 'Satellite-Based Augmentation System';
580
-					else if ($type_name == 'glo-ops') $type_name = 'Glonass Operational';
581
-					else if ($type_name == 'gps-ops') $type_name = 'GPS Operational';
582
-					else if ($type_name == 'argos') $type_name = 'ARGOS Data Collection System';
583
-					else if ($type_name == 'tdrss') $type_name = 'Tracking and Data Relay Satellite System';
584
-					else if ($type_name == 'sarsat') $type_name = 'Search & Rescue';
585
-					else if ($type_name == 'dmc') $type_name = 'Disaster Monitoring';
586
-					else if ($type_name == 'resource') $type_name = 'Earth Resources';
587
-					else if ($type_name == 'stations') $type_name = 'Space Stations';
588
-					else if ($type_name == 'geo') $type_name = 'Geostationary';
589
-					else if ($type_name == 'amateur') $type_name = 'Amateur Radio';
590
-					else if ($type_name == 'x-comm') $type_name = 'Experimental';
591
-					else if ($type_name == 'other-comm') $type_name = 'Other Comm';
592
-					else if ($type_name == 'science') $type_name = 'Space & Earth Science';
593
-					else if ($type_name == 'military') $type_name = 'Miscellaneous Military';
594
-					else if ($type_name == 'radar') $type_name = 'Radar Calibration';
595
-					else if ($type_name == 'tle-new') $type_name = 'Last 30 days launches';
849
+					if ($type_name == 'musson') {
850
+						$type_name = 'Russian LEO Navigation';
851
+					} else if ($type_name == 'nnss') {
852
+						$type_name = 'Navi Navigation Satellite System';
853
+					} else if ($type_name == 'sbas') {
854
+						$type_name = 'Satellite-Based Augmentation System';
855
+					} else if ($type_name == 'glo-ops') {
856
+						$type_name = 'Glonass Operational';
857
+					} else if ($type_name == 'gps-ops') {
858
+						$type_name = 'GPS Operational';
859
+					} else if ($type_name == 'argos') {
860
+						$type_name = 'ARGOS Data Collection System';
861
+					} else if ($type_name == 'tdrss') {
862
+						$type_name = 'Tracking and Data Relay Satellite System';
863
+					} else if ($type_name == 'sarsat') {
864
+						$type_name = 'Search & Rescue';
865
+					} else if ($type_name == 'dmc') {
866
+						$type_name = 'Disaster Monitoring';
867
+					} else if ($type_name == 'resource') {
868
+						$type_name = 'Earth Resources';
869
+					} else if ($type_name == 'stations') {
870
+						$type_name = 'Space Stations';
871
+					} else if ($type_name == 'geo') {
872
+						$type_name = 'Geostationary';
873
+					} else if ($type_name == 'amateur') {
874
+						$type_name = 'Amateur Radio';
875
+					} else if ($type_name == 'x-comm') {
876
+						$type_name = 'Experimental';
877
+					} else if ($type_name == 'other-comm') {
878
+						$type_name = 'Other Comm';
879
+					} else if ($type_name == 'science') {
880
+						$type_name = 'Space & Earth Science';
881
+					} else if ($type_name == 'military') {
882
+						$type_name = 'Miscellaneous Military';
883
+					} else if ($type_name == 'radar') {
884
+						$type_name = 'Radar Calibration';
885
+					} else if ($type_name == 'tle-new') {
886
+						$type_name = 'Last 30 days launches';
887
+					}
596 888
 					
597 889
 					if (isset($_COOKIE['sattypes']) && in_array($type['tle_type'],explode(',',$_COOKIE['sattypes']))) {
598 890
 						print '<option value="'.$type['tle_type'].'" selected>'.$type_name.'</option>';
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Braces   +152 added lines, -52 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     public function checkAll() {
55 55
 	global $globalDebug;
56
-	if ($globalDebug) echo "Update last seen tracked data...\n";
56
+	if ($globalDebug) {
57
+		echo "Update last seen tracked data...\n";
58
+	}
57 59
 	foreach ($this->all_tracked as $key => $flight) {
58 60
 	    if (isset($this->all_tracked[$key]['id'])) {
59 61
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -66,13 +68,17 @@  discard block
 block discarded – undo
66 68
     public function del() {
67 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
68 70
 	// Delete old infos
69
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
71
+	if ($globalDebug) {
72
+		echo 'Delete old values and update latest data...'."\n";
73
+	}
70 74
 	foreach ($this->all_tracked as $key => $flight) {
71 75
     	    if (isset($flight['lastupdate'])) {
72 76
         	if ($flight['lastupdate'] < (time()-3000)) {
73 77
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 78
             		if (isset($this->all_tracked[$key]['id'])) {
75
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
79
+            		    if ($globalDebug) {
80
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    }
76 82
 			    /*
77 83
 			    $MarineLive = new MarineLive();
78 84
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -82,7 +88,9 @@  discard block
 block discarded – undo
82 88
             		    $Marine = new Marine($this->db);
83 89
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84 90
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
85
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
91
+				if ($globalDebug && $result != 'success') {
92
+					echo '!!! ERROR : '.$result."\n";
93
+				}
86 94
 			    }
87 95
 			    // Put in archive
88 96
 //				$Marine->db = null;
@@ -96,7 +104,9 @@  discard block
 block discarded – undo
96 104
 
97 105
     public function add($line) {
98 106
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
99
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
107
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
108
+		$globalCoordMinChange = '0.02';
109
+	}
100 110
 	date_default_timezone_set('UTC');
101 111
 	$dataFound = false;
102 112
 	$send = false;
@@ -121,8 +131,11 @@  discard block
 block discarded – undo
121 131
 		
122 132
 		$Common = new Common();
123 133
 		$AIS = new AIS();
124
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
125
-	        else $id = trim($line['id']);
134
+	        if (!isset($line['id'])) {
135
+	        	$id = trim($line['mmsi']);
136
+	        } else {
137
+	        	$id = trim($line['id']);
138
+	        }
126 139
 		
127 140
 		if (!isset($this->all_tracked[$id])) {
128 141
 		    $this->all_tracked[$id] = array();
@@ -130,10 +143,16 @@  discard block
 block discarded – undo
130 143
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131 144
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
132 145
 		    if (!isset($line['id'])) {
133
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
146
+			if (!isset($globalDaemon)) {
147
+				$globalDaemon = TRUE;
148
+			}
134 149
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
136
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
150
+		     } else {
151
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
152
+		     }
153
+		    if ($globalAllTracked !== FALSE) {
154
+		    	$dataFound = true;
155
+		    }
137 156
 		}
138 157
 		
139 158
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -183,13 +202,19 @@  discard block
 block discarded – undo
183 202
 				$Marine = new Marine($this->db);
184 203
 				$fromsource = NULL;
185 204
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
186
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205
+				if ($globalDebug && $result != 'success') {
206
+					echo '!!! ERROR : '.$result."\n";
207
+				}
187 208
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
209
+				if ($globalDebugTimeElapsed) {
210
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
211
+				}
189 212
 			    }
190 213
 			}
191 214
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
215
+		    if (!isset($this->all_tracked[$id]['id'])) {
216
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
217
+		    }
193 218
 		}
194 219
 
195 220
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -200,14 +225,21 @@  discard block
 block discarded – undo
200 225
 		    if ($distance > 1000 && $distance < 10000) {
201 226
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
202 227
 			$speed = $speed*3.6;
203
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
204
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
228
+			if ($speed < 1000) {
229
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
230
+			}
231
+  			if ($globalDebug) {
232
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
233
+  			}
205 234
 		    }
206 235
 		}
207 236
 
208 237
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
209
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
210
-	    	    else unset($timediff);
238
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
239
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
240
+	    	    } else {
241
+	    	    	unset($timediff);
242
+	    	    }
211 243
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
212 244
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
213 245
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -215,22 +247,32 @@  discard block
 block discarded – undo
215 247
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
216 248
 				$this->all_tracked[$id]['putinarchive'] = true;
217 249
 				
218
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
250
+				if ($globalDebug) {
251
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
252
+				}
219 253
 				$timeelapsed = microtime(true);
220 254
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
221 255
 				    $Marine = new Marine($this->db);
222 256
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
223
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
257
+				    if (!empty($all_country)) {
258
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
259
+				    }
224 260
 				    $Marine->db = null;
225
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
261
+				    if ($globalDebugTimeElapsed) {
262
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
263
+				    }
226 264
 				}
227 265
 				$this->tmd = 0;
228
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
266
+				if ($globalDebug) {
267
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
268
+				}
229 269
 			    }
230 270
 			}
231 271
 
232 272
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
233
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
273
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
274
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
275
+				}
234 276
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
235 277
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
236 278
 				    $dataFound = true;
@@ -239,8 +281,12 @@  discard block
 block discarded – undo
239 281
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
240 282
 			}
241 283
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
242
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
243
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
284
+			    if ($line['longitude'] > 180) {
285
+			    	$line['longitude'] = $line['longitude'] - 360;
286
+			    }
287
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
288
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
289
+				}
244 290
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
245 291
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
246 292
 				    $dataFound = true;
@@ -258,7 +304,9 @@  discard block
 block discarded – undo
258 304
 		    }
259 305
 		}
260 306
 		if (isset($line['last_update']) && $line['last_update'] != '') {
261
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
307
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
308
+		    	$dataFound = true;
309
+		    }
262 310
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
263 311
 		}
264 312
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -276,15 +324,21 @@  discard block
 block discarded – undo
276 324
 		}
277 325
 		
278 326
 		if (isset($line['heading']) && $line['heading'] != '') {
279
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
280 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
281 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
282 332
 		    //$dataFound = true;
283 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
284 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
285 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
286
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
287
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
288 342
   		}
289 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
290 344
 
@@ -292,8 +346,11 @@  discard block
 block discarded – undo
292 346
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
293 347
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
294 348
 		    } else {
295
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
296
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
349
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
350
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
351
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
352
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
353
+				}
297 354
 				return '';
298 355
 		    }
299 356
 		} else {
@@ -308,23 +365,38 @@  discard block
 block discarded – undo
308 365
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
309 366
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
310 367
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
311
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
368
+				    if ($globalDebug) {
369
+				    	echo "Check if aircraft is already in DB...";
370
+				    }
312 371
 				    $timeelapsed = microtime(true);
313 372
 				    $MarineLive = new MarineLive($this->db);
314 373
 				    if (isset($line['id'])) {
315 374
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
316
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375
+					if ($globalDebugTimeElapsed) {
376
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
377
+					}
317 378
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
318 379
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
319
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
380
+					if ($globalDebugTimeElapsed) {
381
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
382
+					}
320 383
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
321 384
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
322
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
323
-				    } else $recent_ident = '';
385
+					if ($globalDebugTimeElapsed) {
386
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
387
+					}
388
+				    } else {
389
+				    	$recent_ident = '';
390
+				    }
324 391
 				    $MarineLive->db=null;
325
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
326
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
327
-				} else $recent_ident = '';
392
+				    if ($globalDebug && $recent_ident == '') {
393
+				    	echo " Not in DB.\n";
394
+				    } elseif ($globalDebug && $recent_ident != '') {
395
+				    	echo " Already in DB.\n";
396
+				    }
397
+				} else {
398
+					$recent_ident = '';
399
+				}
328 400
 			    } else {
329 401
 				$recent_ident = '';
330 402
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -332,18 +404,26 @@  discard block
 block discarded – undo
332 404
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
333 405
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
334 406
 			    {
335
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
407
+				if ($globalDebug) {
408
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
409
+				}
336 410
 				//adds the spotter data for the archive
337 411
 				    $highlight = '';
338
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
412
+				    if (!isset($this->all_tracked[$id]['id'])) {
413
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
414
+				    }
339 415
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
340 416
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 417
 					    $timeelapsed = microtime(true);
342 418
 					    $Marine = new Marine($this->db);
343 419
 					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
344 420
 					    $Marine->db = null;
345
-					    if ($globalDebug && isset($result)) echo $result."\n";
346
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+					    if ($globalDebug && isset($result)) {
422
+					    	echo $result."\n";
423
+					    }
424
+					    if ($globalDebugTimeElapsed) {
425
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
426
+					    }
347 427
 					}
348 428
 				    }
349 429
 				    /*
@@ -378,13 +458,17 @@  discard block
 block discarded – undo
378 458
 				$this->all_tracked[$id]['addedMarine'] = 1;
379 459
 				//print_r($this->all_tracked[$id]);
380 460
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
381
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
461
+				    if ($globalDebug) {
462
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
463
+				    }
382 464
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
383 465
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
384 466
 					$MarineLive = new MarineLive($this->db);
385 467
 					$MarineLive->deleteLiveMarineData();
386 468
 					$MarineLive->db=null;
387
-					if ($globalDebug) echo " Done\n";
469
+					if ($globalDebug) {
470
+						echo " Done\n";
471
+					}
388 472
 				    }
389 473
 				    $this->last_delete = time();
390 474
 				}
@@ -410,15 +494,21 @@  discard block
 block discarded – undo
410 494
 
411 495
 		    if (!$ignoreImport) {
412 496
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
413
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
497
+				if ($globalDebug) {
498
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
499
+				}
414 500
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
415 501
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
416 502
 					$timeelapsed = microtime(true);
417 503
 					$MarineLive = new MarineLive($this->db);
418 504
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
419 505
 					$MarineLive->db = null;
420
-					if ($globalDebug) echo $result."\n";
421
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
506
+					if ($globalDebug) {
507
+						echo $result."\n";
508
+					}
509
+					if ($globalDebugTimeElapsed) {
510
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
511
+					}
422 512
 				    }
423 513
 				}
424 514
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -481,19 +571,27 @@  discard block
 block discarded – undo
481 571
 				*/
482 572
 
483 573
 				$this->all_tracked[$id]['lastupdate'] = time();
484
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
485
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
574
+				if ($this->all_tracked[$id]['putinarchive']) {
575
+					$send = true;
576
+				}
577
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
578
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
579
+			}
486 580
 			//$this->del();
487 581
 			
488 582
 			
489 583
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
490 584
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
491
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
585
+				if ($globalDebug) {
586
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
587
+				}
492 588
 				$MarineLive = new MarineLive($this->db);
493 589
 				$MarineLive->deleteLiveMarineDataNotUpdated();
494 590
 				$MarineLive->db = null;
495 591
 				//MarineLive->deleteLiveMarineData();
496
-				if ($globalDebug) echo " Done\n";
592
+				if ($globalDebug) {
593
+					echo " Done\n";
594
+				}
497 595
 			    }
498 596
 			    $this->last_delete_hourly = time();
499 597
 			}
@@ -502,7 +600,9 @@  discard block
 block discarded – undo
502 600
 		    //$ignoreImport = false;
503 601
 		}
504 602
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
505
-		if ($send) return $this->all_tracked[$id];
603
+		if ($send) {
604
+			return $this->all_tracked[$id];
605
+		}
506 606
 	    }
507 607
 	}
508 608
     }
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Braces   +65 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate";
125 132
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
150 159
 			FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0";
@@ -178,7 +187,9 @@  discard block
 block discarded – undo
178 187
 
179 188
 		$filter_query = $this->getFilter($filter,true,true);
180 189
 
181
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190
+		if (!isset($globalLiveInterval)) {
191
+			$globalLiveInterval = '200';
192
+		}
182 193
 		if ($globalDBdriver == 'mysql') {
183 194
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 195
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
@@ -211,7 +222,9 @@  discard block
 block discarded – undo
211 222
 		global $globalDBdriver, $globalLiveInterval;
212 223
 		$filter_query = $this->getFilter($filter,true,true);
213 224
 
214
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
225
+		if (!isset($globalLiveInterval)) {
226
+			$globalLiveInterval = '200';
227
+		}
215 228
 		if ($globalDBdriver == 'mysql') {
216 229
 			$query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
217 230
 		} else {
@@ -239,7 +252,9 @@  discard block
 block discarded – undo
239 252
 	{
240 253
 		global $globalDBdriver, $globalLiveInterval;
241 254
 		$Spotter = new Spotter($this->db);
242
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
243 258
 		$filter_query = $this->getFilter($filter);
244 259
 
245 260
 		if (is_array($coord)) {
@@ -247,7 +262,9 @@  discard block
 block discarded – undo
247 262
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248 263
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249 264
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
-		} else return array();
265
+		} else {
266
+			return array();
267
+		}
251 268
 		if ($globalDBdriver == 'mysql') {
252 269
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
253 270
 		} else {
@@ -267,7 +284,9 @@  discard block
 block discarded – undo
267 284
 	{
268 285
 		global $globalDBdriver, $globalLiveInterval;
269 286
 		$Spotter = new Spotter($this->db);
270
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
287
+		if (!isset($globalLiveInterval)) {
288
+			$globalLiveInterval = '200';
289
+		}
271 290
 		$filter_query = $this->getFilter($filter);
272 291
 
273 292
 		if (is_array($coord)) {
@@ -275,7 +294,9 @@  discard block
 block discarded – undo
275 294
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276 295
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277 296
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-		} else return array();
297
+		} else {
298
+			return array();
299
+		}
279 300
 		if ($globalDBdriver == 'mysql') {
280 301
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
281 302
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -443,11 +464,15 @@  discard block
 block discarded – undo
443 464
 		//$query  = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date';
444 465
 		if ($globalDBdriver == 'mysql') {
445 466
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
446
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
467
+			if ($liveinterval) {
468
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
469
+			}
447 470
 			$query .= ' ORDER BY date';
448 471
 		} else {
449 472
 			$query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id';
450
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
473
+			if ($liveinterval) {
474
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
475
+			}
451 476
 			$query .= ' ORDER BY date';
452 477
 		}
453 478
 
@@ -542,7 +567,9 @@  discard block
 block discarded – undo
542 567
 				$i++;
543 568
 				$j++;
544 569
 				if ($j == 30) {
545
-					if ($globalDebug) echo ".";
570
+					if ($globalDebug) {
571
+						echo ".";
572
+					}
546 573
 				    	try {
547 574
 						
548 575
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -822,7 +849,9 @@  discard block
 block discarded – undo
822 849
 			{
823 850
 				return false;
824 851
 			}
825
-		} else return '';
852
+		} else {
853
+			return '';
854
+		}
826 855
 
827 856
 		if ($longitude != '')
828 857
 		{
@@ -830,7 +859,9 @@  discard block
 block discarded – undo
830 859
 			{
831 860
 				return false;
832 861
 			}
833
-		} else return '';
862
+		} else {
863
+			return '';
864
+		}
834 865
 
835 866
 
836 867
 		if ($heading != '')
@@ -839,7 +870,9 @@  discard block
 block discarded – undo
839 870
 			{
840 871
 				return false;
841 872
 			}
842
-		} else $heading = 0;
873
+		} else {
874
+			$heading = 0;
875
+		}
843 876
 
844 877
 		if ($groundspeed != '')
845 878
 		{
@@ -847,9 +880,13 @@  discard block
 block discarded – undo
847 880
 			{
848 881
 				return false;
849 882
 			}
850
-		} else $groundspeed = 0;
883
+		} else {
884
+			$groundspeed = 0;
885
+		}
851 886
 		date_default_timezone_set('UTC');
852
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
887
+		if ($date == '') {
888
+			$date = date("Y-m-d H:i:s", time());
889
+		}
853 890
 
854 891
         
855 892
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -870,9 +907,15 @@  discard block
 block discarded – undo
870 907
 		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
871 908
 		
872 909
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
875
-            	if ($arrival_date == '') $arrival_date = NULL;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
916
+            	if ($arrival_date == '') {
917
+            		$arrival_date = NULL;
918
+            	}
876 919
 		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
877 920
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
878 921
 
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Braces   +65 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -76,8 +78,11 @@  discard block
 block discarded – undo
76 78
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77 79
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
78 80
 		}
79
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81
+		if ($filter_query_where == '' && $where) {
82
+			$filter_query_where = ' WHERE';
83
+		} elseif ($filter_query_where != '' && $and) {
84
+			$filter_query_where .= ' AND';
85
+		}
81 86
 		if ($filter_query_where != '') {
82 87
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
83 88
 		}
@@ -119,7 +124,9 @@  discard block
 block discarded – undo
119 124
 			}
120 125
 		}
121 126
 
122
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
127
+		if (!isset($globalLiveInterval)) {
128
+			$globalLiveInterval = '200';
129
+		}
123 130
 		if ($globalDBdriver == 'mysql') {
124 131
 			//$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate";
125 132
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -144,7 +151,9 @@  discard block
 block discarded – undo
144 151
 
145 152
 		$filter_query = $this->getFilter($filter,true,true);
146 153
 
147
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
154
+		if (!isset($globalLiveInterval)) {
155
+			$globalLiveInterval = '200';
156
+		}
148 157
 		if ($globalDBdriver == 'mysql') {
149 158
 			$query  = 'SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
150 159
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate'.$filter_query." tracker_live.latitude <> 0 AND tracker_live.longitude <> 0";
@@ -182,7 +191,9 @@  discard block
 block discarded – undo
182 191
 
183 192
 		$filter_query = $this->getFilter($filter,true,true);
184 193
 
185
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194
+		if (!isset($globalLiveInterval)) {
195
+			$globalLiveInterval = '200';
196
+		}
186 197
 		if ($globalDBdriver == 'mysql') {
187 198
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 199
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
@@ -215,7 +226,9 @@  discard block
 block discarded – undo
215 226
 		global $globalDBdriver, $globalLiveInterval;
216 227
 		$filter_query = $this->getFilter($filter,true,true);
217 228
 
218
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229
+		if (!isset($globalLiveInterval)) {
230
+			$globalLiveInterval = '200';
231
+		}
219 232
 		if ($globalDBdriver == 'mysql') {
220 233
 			$query = 'SELECT COUNT(DISTINCT tracker_live.famtrackid) as nb FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
221 234
 		} else {
@@ -243,7 +256,9 @@  discard block
 block discarded – undo
243 256
 	{
244 257
 		global $globalDBdriver, $globalLiveInterval;
245 258
 		$Spotter = new Spotter($this->db);
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
259
+		if (!isset($globalLiveInterval)) {
260
+			$globalLiveInterval = '200';
261
+		}
247 262
 		$filter_query = $this->getFilter($filter);
248 263
 
249 264
 		if (is_array($coord)) {
@@ -251,7 +266,9 @@  discard block
 block discarded – undo
251 266
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252 267
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253 268
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-		} else return array();
269
+		} else {
270
+			return array();
271
+		}
255 272
 		if ($globalDBdriver == 'mysql') {
256 273
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
257 274
 		} else {
@@ -271,7 +288,9 @@  discard block
 block discarded – undo
271 288
 	{
272 289
 		global $globalDBdriver, $globalLiveInterval;
273 290
 		$Spotter = new Spotter($this->db);
274
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291
+		if (!isset($globalLiveInterval)) {
292
+			$globalLiveInterval = '200';
293
+		}
275 294
 		$filter_query = $this->getFilter($filter);
276 295
 
277 296
 		if (is_array($coord)) {
@@ -279,7 +298,9 @@  discard block
 block discarded – undo
279 298
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280 299
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281 300
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
282
-		} else return array();
301
+		} else {
302
+			return array();
303
+		}
283 304
 		if ($globalDBdriver == 'mysql') {
284 305
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285 306
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
@@ -472,11 +493,15 @@  discard block
 block discarded – undo
472 493
 		//$query  = self::$global_query.' WHERE tracker_live.famtrackid = :id ORDER BY date';
473 494
 		if ($globalDBdriver == 'mysql') {
474 495
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
475
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
496
+			if ($liveinterval) {
497
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
498
+			}
476 499
 			$query .= ' ORDER BY date';
477 500
 		} else {
478 501
 			$query = 'SELECT tracker_live.* FROM tracker_live WHERE tracker_live.famtrackid = :id';
479
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
502
+			if ($liveinterval) {
503
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
504
+			}
480 505
 			$query .= ' ORDER BY date';
481 506
 		}
482 507
 
@@ -571,7 +596,9 @@  discard block
 block discarded – undo
571 596
 				$i++;
572 597
 				$j++;
573 598
 				if ($j == 30) {
574
-					if ($globalDebug) echo ".";
599
+					if ($globalDebug) {
600
+						echo ".";
601
+					}
575 602
 				    	try {
576 603
 						
577 604
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -818,7 +845,9 @@  discard block
 block discarded – undo
818 845
 			{
819 846
 				return false;
820 847
 			}
821
-		} else return '';
848
+		} else {
849
+			return '';
850
+		}
822 851
 
823 852
 		if ($longitude != '')
824 853
 		{
@@ -826,7 +855,9 @@  discard block
 block discarded – undo
826 855
 			{
827 856
 				return false;
828 857
 			}
829
-		} else return '';
858
+		} else {
859
+			return '';
860
+		}
830 861
 
831 862
 		if ($altitude != '')
832 863
 		{
@@ -834,7 +865,9 @@  discard block
 block discarded – undo
834 865
 			{
835 866
 				return false;
836 867
 			}
837
-		} else $altitude = 0;
868
+		} else {
869
+			$altitude = 0;
870
+		}
838 871
 
839 872
 		if ($heading != '')
840 873
 		{
@@ -842,7 +875,9 @@  discard block
 block discarded – undo
842 875
 			{
843 876
 				return false;
844 877
 			}
845
-		} else $heading = 0;
878
+		} else {
879
+			$heading = 0;
880
+		}
846 881
 
847 882
 		if ($groundspeed != '')
848 883
 		{
@@ -850,9 +885,13 @@  discard block
 block discarded – undo
850 885
 			{
851 886
 				return false;
852 887
 			}
853
-		} else $groundspeed = 0;
888
+		} else {
889
+			$groundspeed = 0;
890
+		}
854 891
 		date_default_timezone_set('UTC');
855
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
892
+		if ($date == '') {
893
+			$date = date("Y-m-d H:i:s", time());
894
+		}
856 895
 
857 896
         
858 897
 		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
@@ -868,8 +907,12 @@  discard block
 block discarded – undo
868 907
 		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869 908
 		$type = filter_var($type,FILTER_SANITIZE_STRING);
870 909
 
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
910
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
911
+            		$groundspeed = 0;
912
+            	}
913
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
914
+            		$heading = 0;
915
+            	}
873 916
             	
874 917
 		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
875 918
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +153 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -68,8 +70,11 @@  discard block
 block discarded – undo
68 70
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
69 71
 			}
70 72
 		}
71
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73
+		if ($filter_query_where == '' && $where) {
74
+			$filter_query_where = ' WHERE';
75
+		} elseif ($filter_query_where != '' && $and) {
76
+			$filter_query_where .= ' AND';
77
+		}
73 78
 		if ($filter_query_where != '') {
74 79
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
75 80
 		}
@@ -123,31 +128,51 @@  discard block
 block discarded – undo
123 128
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
124 129
 			} elseif (isset($row['spotter_archive_output_id'])) {
125 130
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
126
-			*/} 
127
-			elseif (isset($row['marineid'])) {
131
+			*/} elseif (isset($row['marineid'])) {
128 132
 				$temp_array['marineid'] = $row['marineid'];
129 133
 			} else {
130 134
 				$temp_array['marineid'] = '';
131 135
 			}
132
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
133
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
134
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
135
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
136
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
137
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
138
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
136
+			if (isset($row['fammarine_id'])) {
137
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
138
+			}
139
+			if (isset($row['mmsi'])) {
140
+				$temp_array['mmsi'] = $row['mmsi'];
141
+			}
142
+			if (isset($row['type'])) {
143
+				$temp_array['type'] = $row['type'];
144
+			}
145
+			if (isset($row['ident'])) {
146
+				$temp_array['ident'] = $row['ident'];
147
+			}
148
+			if (isset($row['latitude'])) {
149
+				$temp_array['latitude'] = $row['latitude'];
150
+			}
151
+			if (isset($row['longitude'])) {
152
+				$temp_array['longitude'] = $row['longitude'];
153
+			}
154
+			if (isset($row['format_source'])) {
155
+				$temp_array['format_source'] = $row['format_source'];
156
+			}
139 157
 			if (isset($row['heading'])) {
140 158
 				$temp_array['heading'] = $row['heading'];
141 159
 				$heading_direction = $this->parseDirection($row['heading']);
142
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
160
+				if (isset($heading_direction[0]['direction_fullname'])) {
161
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
162
+				}
163
+			}
164
+			if (isset($row['ground_speed'])) {
165
+				$temp_array['ground_speed'] = $row['ground_speed'];
143 166
 			}
144
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
145 167
 
146 168
 			if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
147 169
 			{
148 170
 				$Image = new Image($this->db);
149
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
150
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
171
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
172
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
173
+				} else {
174
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
175
+				}
151 176
 				unset($Image);
152 177
 				if (count($image_array) > 0) {
153 178
 					$temp_array['image'] = $image_array[0]['image'];
@@ -199,13 +224,21 @@  discard block
 block discarded – undo
199 224
 			}
200 225
 			
201 226
 			$fromsource = NULL;
202
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
203
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
204
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
227
+			if (isset($row['source_name']) && $row['source_name'] != '') {
228
+				$temp_array['source_name'] = $row['source_name'];
229
+			}
230
+			if (isset($row['over_country']) && $row['over_country'] != '') {
231
+				$temp_array['over_country'] = $row['over_country'];
232
+			}
233
+			if (isset($row['distance']) && $row['distance'] != '') {
234
+				$temp_array['distance'] = $row['distance'];
235
+			}
205 236
 			$temp_array['query_number_rows'] = $num_rows;
206 237
 			$spotter_array[] = $temp_array;
207 238
 		}
208
-		if ($num_rows == 0) return array();
239
+		if ($num_rows == 0) {
240
+			return array();
241
+		}
209 242
 		$spotter_array[0]['query_number_rows'] = $num_rows;
210 243
 		return $spotter_array;
211 244
 	}	
@@ -236,8 +269,12 @@  discard block
 block discarded – undo
236 269
 			{
237 270
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
238 271
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
239
-			} else $limit_query = "";
240
-		} else $limit_query = "";
272
+			} else {
273
+				$limit_query = "";
274
+			}
275
+		} else {
276
+			$limit_query = "";
277
+		}
241 278
 		
242 279
 		if ($sort != "")
243 280
 		{
@@ -265,7 +302,9 @@  discard block
 block discarded – undo
265 302
 		global $global_query;
266 303
 		
267 304
 		date_default_timezone_set('UTC');
268
-		if ($id == '') return array();
305
+		if ($id == '') {
306
+			return array();
307
+		}
269 308
 		$additional_query = "marine_output.fammarine_id = :id";
270 309
 		$query_values = array(':id' => $id);
271 310
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -408,8 +447,11 @@  discard block
 block discarded – undo
408 447
 		$query .= " ORDER BY marine_output.source_name ASC";
409 448
 
410 449
 		$sth = $this->db->prepare($query);
411
-		if (!empty($query_values)) $sth->execute($query_values);
412
-		else $sth->execute();
450
+		if (!empty($query_values)) {
451
+			$sth->execute($query_values);
452
+		} else {
453
+			$sth->execute();
454
+		}
413 455
 
414 456
 		$source_array = array();
415 457
 		$temp_array = array();
@@ -464,8 +506,11 @@  discard block
 block discarded – undo
464 506
 		$sth = $this->db->prepare($query);
465 507
 		$sth->execute(array(':mmsi' => $mmsi));
466 508
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
467
-		if (isset($result[0])) return $result[0];
468
-		else return array();
509
+		if (isset($result[0])) {
510
+			return $result[0];
511
+		} else {
512
+			return array();
513
+		}
469 514
 	}
470 515
 
471 516
 	/*
@@ -481,7 +526,9 @@  discard block
 block discarded – undo
481 526
 			date_default_timezone_set($globalTimezone);
482 527
 			$datetime = new DateTime();
483 528
 			$offset = $datetime->format('P');
484
-		} else $offset = '+00:00';
529
+		} else {
530
+			$offset = '+00:00';
531
+		}
485 532
 
486 533
 		if ($globalDBdriver == 'mysql') {
487 534
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -685,9 +732,15 @@  discard block
 block discarded – undo
685 732
             		$latitude = 0;
686 733
             		$longitude = 0;
687 734
             	}
688
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690
-                if ($arrival_date == '') $arrival_date = NULL;
735
+                if ($heading == '' || $Common->isInteger($heading) === false) {
736
+                	$heading = 0;
737
+                }
738
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
739
+                	$groundspeed = 0;
740
+                }
741
+                if ($arrival_date == '') {
742
+                	$arrival_date = NULL;
743
+                }
691 744
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 745
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 746
 
@@ -851,12 +904,18 @@  discard block
 block discarded – undo
851 904
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
852 905
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
853 906
 		 if ($olderthanmonths > 0) {
854
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
855
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
907
+			if ($globalDBdriver == 'mysql') {
908
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
909
+			} else {
910
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
911
+			}
856 912
 		}
857 913
 		if ($sincedate != '') {
858
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
859
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
914
+			if ($globalDBdriver == 'mysql') {
915
+				$query .= " AND marine_output.date > '".$sincedate."'";
916
+			} else {
917
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
918
+			}
860 919
 		}
861 920
 		$query_values = array();
862 921
 		if ($year != '') {
@@ -887,7 +946,9 @@  discard block
 block discarded – undo
887 946
 			}
888 947
 		}
889 948
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
890
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
949
+		if ($limit) {
950
+			$query .= " LIMIT 10 OFFSET 0";
951
+		}
891 952
       		
892 953
 		$sth = $this->db->prepare($query);
893 954
 		$sth->execute($query_values);
@@ -922,7 +983,9 @@  discard block
 block discarded – undo
922 983
 			date_default_timezone_set($globalTimezone);
923 984
 			$datetime = new DateTime();
924 985
 			$offset = $datetime->format('P');
925
-		} else $offset = '+00:00';
986
+		} else {
987
+			$offset = '+00:00';
988
+		}
926 989
 
927 990
 		if ($globalDBdriver == 'mysql') {
928 991
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -972,7 +1035,9 @@  discard block
 block discarded – undo
972 1035
 			date_default_timezone_set($globalTimezone);
973 1036
 			$datetime = new DateTime();
974 1037
 			$offset = $datetime->format('P');
975
-		} else $offset = '+00:00';
1038
+		} else {
1039
+			$offset = '+00:00';
1040
+		}
976 1041
 		$filter_query = $this->getFilter($filters,true,true);
977 1042
 		if ($globalDBdriver == 'mysql') {
978 1043
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1018,7 +1083,9 @@  discard block
 block discarded – undo
1018 1083
 			date_default_timezone_set($globalTimezone);
1019 1084
 			$datetime = new DateTime();
1020 1085
 			$offset = $datetime->format('P');
1021
-		} else $offset = '+00:00';
1086
+		} else {
1087
+			$offset = '+00:00';
1088
+		}
1022 1089
 		$filter_query = $this->getFilter($filters,true,true);
1023 1090
 		if ($globalDBdriver == 'mysql') {
1024 1091
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1066,7 +1133,9 @@  discard block
 block discarded – undo
1066 1133
 			date_default_timezone_set($globalTimezone);
1067 1134
 			$datetime = new DateTime();
1068 1135
 			$offset = $datetime->format('P');
1069
-		} else $offset = '+00:00';
1136
+		} else {
1137
+			$offset = '+00:00';
1138
+		}
1070 1139
 
1071 1140
 		if ($globalDBdriver == 'mysql') {
1072 1141
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1115,7 +1184,9 @@  discard block
 block discarded – undo
1115 1184
 			date_default_timezone_set($globalTimezone);
1116 1185
 			$datetime = new DateTime();
1117 1186
 			$offset = $datetime->format('P');
1118
-		} else $offset = '+00:00';
1187
+		} else {
1188
+			$offset = '+00:00';
1189
+		}
1119 1190
 		$filter_query = $this->getFilter($filters,true,true);
1120 1191
 		if ($globalDBdriver == 'mysql') {
1121 1192
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1164,7 +1235,9 @@  discard block
 block discarded – undo
1164 1235
 			date_default_timezone_set($globalTimezone);
1165 1236
 			$datetime = new DateTime();
1166 1237
 			$offset = $datetime->format('P');
1167
-		} else $offset = '+00:00';
1238
+		} else {
1239
+			$offset = '+00:00';
1240
+		}
1168 1241
 
1169 1242
 		$orderby_sql = '';
1170 1243
 		if ($orderby == "hour")
@@ -1233,7 +1306,9 @@  discard block
 block discarded – undo
1233 1306
 			date_default_timezone_set($globalTimezone);
1234 1307
 			$datetime = new DateTime($date);
1235 1308
 			$offset = $datetime->format('P');
1236
-		} else $offset = '+00:00';
1309
+		} else {
1310
+			$offset = '+00:00';
1311
+		}
1237 1312
 
1238 1313
 		if ($globalDBdriver == 'mysql') {
1239 1314
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1281,7 +1356,9 @@  discard block
 block discarded – undo
1281 1356
 			date_default_timezone_set($globalTimezone);
1282 1357
 			$datetime = new DateTime();
1283 1358
 			$offset = $datetime->format('P');
1284
-		} else $offset = '+00:00';
1359
+		} else {
1360
+			$offset = '+00:00';
1361
+		}
1285 1362
 
1286 1363
 		if ($globalDBdriver == 'mysql') {
1287 1364
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1345,8 +1422,11 @@  discard block
 block discarded – undo
1345 1422
 				$query_values = array_merge($query_values,array(':month' => $month));
1346 1423
 			}
1347 1424
 		}
1348
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1349
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1425
+		if (empty($query_values)) {
1426
+			$queryi .= $this->getFilter($filters);
1427
+		} else {
1428
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1429
+		}
1350 1430
 		
1351 1431
 		$sth = $this->db->prepare($queryi);
1352 1432
 		$sth->execute($query_values);
@@ -1368,7 +1448,9 @@  discard block
 block discarded – undo
1368 1448
 			date_default_timezone_set($globalTimezone);
1369 1449
 			$datetime = new DateTime();
1370 1450
 			$offset = $datetime->format('P');
1371
-		} else $offset = '+00:00';
1451
+		} else {
1452
+			$offset = '+00:00';
1453
+		}
1372 1454
 
1373 1455
 		if ($globalDBdriver == 'mysql') {
1374 1456
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1472,7 +1554,9 @@  discard block
 block discarded – undo
1472 1554
 	*/
1473 1555
 	public function parseDirection($direction = 0)
1474 1556
 	{
1475
-		if ($direction == '') $direction = 0;
1557
+		if ($direction == '') {
1558
+			$direction = 0;
1559
+		}
1476 1560
 		$direction_array = array();
1477 1561
 		$temp_array = array();
1478 1562
 
@@ -1561,7 +1645,9 @@  discard block
 block discarded – undo
1561 1645
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1562 1646
 	
1563 1647
 		$Connection = new Connection($this->db);
1564
-		if (!$Connection->tableExists('countries')) return '';
1648
+		if (!$Connection->tableExists('countries')) {
1649
+			return '';
1650
+		}
1565 1651
 	
1566 1652
 		try {
1567 1653
 			/*
@@ -1581,9 +1667,13 @@  discard block
 block discarded – undo
1581 1667
 			$sth->closeCursor();
1582 1668
 			if (count($row) > 0) {
1583 1669
 				return $row;
1584
-			} else return '';
1670
+			} else {
1671
+				return '';
1672
+			}
1585 1673
 		} catch (PDOException $e) {
1586
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1674
+			if (isset($globalDebug) && $globalDebug) {
1675
+				echo 'Error : '.$e->getMessage()."\n";
1676
+			}
1587 1677
 			return '';
1588 1678
 		}
1589 1679
 	
@@ -1601,7 +1691,9 @@  discard block
 block discarded – undo
1601 1691
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1602 1692
 	
1603 1693
 		$Connection = new Connection($this->db);
1604
-		if (!$Connection->tableExists('countries')) return '';
1694
+		if (!$Connection->tableExists('countries')) {
1695
+			return '';
1696
+		}
1605 1697
 	
1606 1698
 		try {
1607 1699
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1613,9 +1705,13 @@  discard block
 block discarded – undo
1613 1705
 			$sth->closeCursor();
1614 1706
 			if (count($row) > 0) {
1615 1707
 				return $row;
1616
-			} else return '';
1708
+			} else {
1709
+				return '';
1710
+			}
1617 1711
 		} catch (PDOException $e) {
1618
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1712
+			if (isset($globalDebug) && $globalDebug) {
1713
+				echo 'Error : '.$e->getMessage()."\n";
1714
+			}
1619 1715
 			return '';
1620 1716
 		}
1621 1717
 	
@@ -1633,7 +1729,9 @@  discard block
 block discarded – undo
1633 1729
 	{
1634 1730
 		global $globalBitlyAccessToken;
1635 1731
 		
1636
-		if ($globalBitlyAccessToken == '') return $url;
1732
+		if ($globalBitlyAccessToken == '') {
1733
+			return $url;
1734
+		}
1637 1735
         
1638 1736
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1639 1737
 		
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +188 added lines, -69 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@  discard block
 block discarded – undo
23 23
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24 24
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26
-		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
26
+		if ($reg == '' && $aircraft_icao != '') {
27
+			$reg = $aircraft_icao.$airline_icao;
28
+		}
27 29
 		$reg = trim($reg);
28 30
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 31
 			FROM spotter_image 
@@ -31,9 +33,13 @@  discard block
 block discarded – undo
31 33
 		$sth = $this->db->prepare($query);
32 34
 		$sth->execute(array(':registration' => $reg));
33 35
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34
-		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
36
-		else return array();
36
+		if (!empty($result)) {
37
+			return $result;
38
+		} elseif ($registration != '') {
39
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
40
+		} else {
41
+			return array();
42
+		}
37 43
 	}
38 44
 
39 45
 	/**
@@ -76,8 +82,11 @@  discard block
 block discarded – undo
76 82
 	public function getExifCopyright($url) {
77 83
 		$exif = exif_read_data($url);
78 84
 		$copyright = '';
79
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
85
+		if (isset($exif['COMPUTED']['copyright'])) {
86
+			$copyright = $exif['COMPUTED']['copyright'];
87
+		} elseif (isset($exif['copyright'])) {
88
+			$copyright = $exif['copyright'];
89
+		}
81 90
 		if ($copyright != '') {
82 91
 			$copyright = str_replace('Copyright ','',$copyright);
83 92
 			$copyright = str_replace('© ','',$copyright);
@@ -95,17 +104,27 @@  discard block
 block discarded – undo
95 104
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
96 105
 	{
97 106
 		global $globalDebug,$globalAircraftImageFetch;
98
-		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
107
+		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) {
108
+			return '';
109
+		}
99 110
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
100 111
 		$registration = trim($registration);
101 112
 		//getting the aircraft image
102
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
113
+		if ($globalDebug && $registration != '') {
114
+			echo 'Try to find an aircraft image for '.$registration.'...';
115
+		} elseif ($globalDebug && $aircraft_icao != '') {
116
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
117
+		} elseif ($globalDebug && $airline_icao != '') {
118
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
119
+		}
105 120
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
106
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
121
+		if ($registration == '' && $aircraft_icao != '') {
122
+			$registration = $aircraft_icao.$airline_icao;
123
+		}
107 124
 		if ($image_url['original'] != '') {
108
-			if ($globalDebug) echo 'Found !'."\n";
125
+			if ($globalDebug) {
126
+				echo 'Found !'."\n";
127
+			}
109 128
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 129
 			try {
111 130
 				$sth = $this->db->prepare($query);
@@ -114,7 +133,9 @@  discard block
 block discarded – undo
114 133
 				echo $e->getMessage()."\n";
115 134
 				return "error";
116 135
 			}
117
-		} elseif ($globalDebug) echo "Not found :'(\n";
136
+		} elseif ($globalDebug) {
137
+			echo "Not found :'(\n";
138
+		}
118 139
 		return "success";
119 140
 	}
120 141
 
@@ -127,7 +148,9 @@  discard block
 block discarded – undo
127 148
 	public function addMarineImage($mmsi,$imo = '',$name = '')
128 149
 	{
129 150
 		global $globalDebug,$globalMarineImageFetch;
130
-		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
151
+		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) {
152
+			return '';
153
+		}
131 154
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132 155
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133 156
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -137,16 +160,22 @@  discard block
 block discarded – undo
137 160
 			$identity = $Marine->getIdentity($mmsi);
138 161
 			if (isset($identity[0]['mmsi'])) {
139 162
 				$imo = $identity[0]['imo'];
140
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
163
+				if ($identity[0]['ship_name'] != '') {
164
+					$name = $identity[0]['ship_name'];
165
+				}
141 166
 			}
142 167
 		}
143 168
 		unset($Marine);
144 169
 
145 170
 		//getting the aircraft image
146
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
171
+		if ($globalDebug && $name != '') {
172
+			echo 'Try to find an vessel image for '.$name.'...';
173
+		}
147 174
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
148 175
 		if ($image_url['original'] != '') {
149
-			if ($globalDebug) echo 'Found !'."\n";
176
+			if ($globalDebug) {
177
+				echo 'Found !'."\n";
178
+			}
150 179
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 180
 			try {
152 181
 				$sth = $this->db->prepare($query);
@@ -155,7 +184,9 @@  discard block
 block discarded – undo
155 184
 				echo $e->getMessage()."\n";
156 185
 				return "error";
157 186
 			}
158
-		} elseif ($globalDebug) echo "Not found :'(\n";
187
+		} elseif ($globalDebug) {
188
+			echo "Not found :'(\n";
189
+		}
159 190
 		return "success";
160 191
 	}
161 192
 
@@ -170,41 +201,85 @@  discard block
 block discarded – undo
170 201
 	{
171 202
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
172 203
 		$Spotter = new Spotter($this->db);
173
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
204
+		if (!isset($globalIVAO)) {
205
+			$globalIVAO = FALSE;
206
+		}
174 207
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
175 208
 		if ($aircraft_registration != '') {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209
+			if (strpos($aircraft_registration,'/') !== false) {
210
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
211
+			}
177 212
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 213
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
180
-			else $aircraft_name = '';
181
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
182
-			else $aircraft_icao = '';
183
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
184
-			else $airline_icao = '';
214
+			if (isset($aircraft_info[0]['aircraft_name'])) {
215
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
216
+			} else {
217
+				$aircraft_name = '';
218
+			}
219
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
220
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
221
+			} else {
222
+				$aircraft_icao = '';
223
+			}
224
+			if (isset($aircraft_info[0]['airline_icao'])) {
225
+				$airline_icao = $aircraft_info[0]['airline_icao'];
226
+			} else {
227
+				$airline_icao = '';
228
+			}
185 229
 		} elseif ($aircraft_icao != '') {
186 230
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
187
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188
-			else $aircraft_name = '';
231
+			if (isset($aircraft_info[0]['type'])) {
232
+				$aircraft_name = $aircraft_info[0]['type'];
233
+			} else {
234
+				$aircraft_name = '';
235
+			}
189 236
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
237
+		} else {
238
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
239
+		}
191 240
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
241
+		if (!isset($globalAircraftImageSources)) {
242
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
243
+		}
193 244
 		foreach ($globalAircraftImageSources as $source) {
194 245
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
205
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206
-		}
207
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
246
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
247
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
248
+			}
249
+			if ($source == 'planespotters' && !$globalIVAO) {
250
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
251
+			}
252
+			if ($source == 'flickr') {
253
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
254
+			}
255
+			if ($source == 'bing') {
256
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
257
+			}
258
+			if ($source == 'deviantart') {
259
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
260
+			}
261
+			if ($source == 'wikimedia') {
262
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
263
+			}
264
+			if ($source == 'jetphotos' && !$globalIVAO) {
265
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
266
+			}
267
+			if ($source == 'planepictures' && !$globalIVAO) {
268
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
269
+			}
270
+			if ($source == 'airportdata' && !$globalIVAO) {
271
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
272
+			}
273
+			if ($source == 'customsources') {
274
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
275
+			}
276
+			if (isset($images_array) && $images_array['original'] != '') {
277
+				return $images_array;
278
+			}
279
+		}
280
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
281
+			return $this->findAircraftImage($aircraft_icao);
282
+		}
208 283
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
209 284
 	}
210 285
 
@@ -224,7 +299,9 @@  discard block
 block discarded – undo
224 299
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225 300
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
226 301
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
302
+		if (strlen($name) < 4) {
303
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
304
+		}
228 305
 		/*
229 306
 		$Marine = new Marine($this->db);
230 307
 		if ($imo == '' || $name == '') {
@@ -236,15 +313,29 @@  discard block
 block discarded – undo
236 313
 		}
237 314
 		unset($Marine);
238 315
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
316
+		if (!isset($globalMarineImageSources)) {
317
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
318
+		}
240 319
 		foreach ($globalMarineImageSources as $source) {
241 320
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
247
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
321
+			if ($source == 'flickr') {
322
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
323
+			}
324
+			if ($source == 'bing') {
325
+				$images_array = $this->fromBing('marine',$mmsi,$name);
326
+			}
327
+			if ($source == 'deviantart') {
328
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
329
+			}
330
+			if ($source == 'wikimedia') {
331
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
332
+			}
333
+			if ($source == 'customsources') {
334
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
335
+			}
336
+			if (isset($images_array) && $images_array['original'] != '') {
337
+				return $images_array;
338
+			}
248 339
 		}
249 340
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
250 341
 	}
@@ -407,11 +498,17 @@  discard block
 block discarded – undo
407 498
 	public function fromFlickr($type,$registration,$name='') {
408 499
 		$Common = new Common();
409 500
 		if ($type == 'aircraft') {
410
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
411
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
501
+			if ($name != '') {
502
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
503
+			} else {
504
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
505
+			}
412 506
 		} elseif ($type == 'marine') {
413
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
414
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
507
+			if ($name != '') {
508
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.urlencode($name);
509
+			} else {
510
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',vessel';
511
+			}
415 512
 		}
416 513
 		$data = $Common->getData($url);
417 514
 		if ($xml = simplexml_load_string($data)) {
@@ -456,9 +553,14 @@  discard block
 block discarded – undo
456 553
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
457 554
 		global $globalImageBingKey;
458 555
 		$Common = new Common();
459
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
460
-		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
461
-		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
556
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
557
+			return false;
558
+		}
559
+		if ($aircraft_name != '') {
560
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
561
+		} else {
562
+			$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
563
+		}
462 564
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
463 565
 		$data = $Common->getData($url,'get','',$headers);
464 566
 		$result = json_decode($data);
@@ -513,17 +615,25 @@  discard block
 block discarded – undo
513 615
 	public function fromWikimedia($type,$registration,$name='') {
514 616
 		$Common = new Common();
515 617
 		if ($type == 'aircraft') {
516
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
517
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
618
+			if ($name != '') {
619
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
620
+			} else {
621
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
622
+			}
518 623
 		} elseif ($type == 'marine') {
519
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
520
-			else return false;
624
+			if ($name != '') {
625
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'"';
626
+			} else {
627
+				return false;
628
+			}
521 629
 		}
522 630
 		$data = $Common->getData($url);
523 631
 		$result = json_decode($data);
524 632
 		if (isset($result->query->search[0]->title)) {
525 633
 			$fileo = $result->query->search[0]->title;
526
-			if (substr($fileo,-3) == 'pdf') return false;
634
+			if (substr($fileo,-3) == 'pdf') {
635
+				return false;
636
+			}
527 637
 			$file = urlencode($fileo);
528 638
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
529 639
 			$data2 = $Common->getData($url2);
@@ -594,18 +704,27 @@  discard block
 block discarded – undo
594 704
 					$image_url = array();
595 705
 					$image_url['thumbnail'] = $url_thumbnail;
596 706
 					$image_url['original'] = $url;
597
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
598
-					else $exifCopyright = '';
599
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
600
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
601
-					else $image_url['copyright'] = $source['source_website'];
707
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
708
+						$exifCopyright = $this->getExifCopyright($url);
709
+					} else {
710
+						$exifCopyright = '';
711
+					}
712
+					if ($exifCopyright  != '') {
713
+						$image_url['copyright'] = $exifCopyright;
714
+					} elseif (isset($source['copyright'])) {
715
+						$image_url['copyright'] = $source['copyright'];
716
+					} else {
717
+						$image_url['copyright'] = $source['source_website'];
718
+					}
602 719
 					$image_url['source_website'] = $source['source_website'];
603 720
 					$image_url['source'] = $source['source'];
604 721
 					return $image_url;
605 722
 				}
606 723
 			}
607 724
 			return false;
608
-		} else return false;
725
+		} else {
726
+			return false;
727
+		}
609 728
 	}
610 729
 }
611 730
 
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +80 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,7 +29,9 @@  discard block
 block discarded – undo
29 29
 		if (isset($filter[0]['source'])) {
30 30
 			$filters = array_merge($filters,$filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) {
33
+			$filter = array_merge($filter,$globalFilter);
34
+		}
33 35
 		$filter_query_join = '';
34 36
 		$filter_query_where = '';
35 37
 		foreach($filters as $flt) {
@@ -118,8 +120,11 @@  discard block
 block discarded – undo
118 120
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119 121
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
120 122
 		}
121
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123
+		if ($filter_query_where == '' && $where) {
124
+			$filter_query_where = ' WHERE';
125
+		} elseif ($filter_query_where != '' && $and) {
126
+			$filter_query_where .= ' AND';
127
+		}
123 128
 		if ($filter_query_where != '') {
124 129
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
125 130
 		}
@@ -161,7 +166,9 @@  discard block
 block discarded – undo
161 166
 			}
162 167
 		}
163 168
 
164
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
169
+		if (!isset($globalLiveInterval)) {
170
+			$globalLiveInterval = '200';
171
+		}
165 172
 		if ($globalDBdriver == 'mysql') {
166 173
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
167 174
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -186,7 +193,9 @@  discard block
 block discarded – undo
186 193
 
187 194
 		$filter_query = $this->getFilter($filter,true,true);
188 195
 
189
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
196
+		if (!isset($globalLiveInterval)) {
197
+			$globalLiveInterval = '200';
198
+		}
190 199
 		if ($globalDBdriver == 'mysql') {
191 200
 //			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
192 201
 //			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
@@ -243,7 +252,9 @@  discard block
 block discarded – undo
243 252
 
244 253
 		$filter_query = $this->getFilter($filter,true,true);
245 254
 
246
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
255
+		if (!isset($globalLiveInterval)) {
256
+			$globalLiveInterval = '200';
257
+		}
247 258
 		if ($globalDBdriver == 'mysql') {
248 259
 /*
249 260
 			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
@@ -287,7 +298,9 @@  discard block
 block discarded – undo
287 298
 		global $globalDBdriver, $globalLiveInterval;
288 299
 		$filter_query = $this->getFilter($filter,true,true);
289 300
 
290
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
301
+		if (!isset($globalLiveInterval)) {
302
+			$globalLiveInterval = '200';
303
+		}
291 304
 		if ($globalDBdriver == 'mysql') {
292 305
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
293 306
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -317,7 +330,9 @@  discard block
 block discarded – undo
317 330
 	{
318 331
 		global $globalDBdriver, $globalLiveInterval;
319 332
 		$Spotter = new Spotter($this->db);
320
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
333
+		if (!isset($globalLiveInterval)) {
334
+			$globalLiveInterval = '200';
335
+		}
321 336
 		$filter_query = $this->getFilter($filter);
322 337
 
323 338
 		if (is_array($coord)) {
@@ -325,7 +340,9 @@  discard block
 block discarded – undo
325 340
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326 341
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327 342
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
328
-		} else return array();
343
+		} else {
344
+			return array();
345
+		}
329 346
 		if ($globalDBdriver == 'mysql') {
330 347
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
331 348
 		} else {
@@ -346,7 +363,9 @@  discard block
 block discarded – undo
346 363
 	{
347 364
 		global $globalDBdriver, $globalLiveInterval;
348 365
 		$Spotter = new Spotter($this->db);
349
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
366
+		if (!isset($globalLiveInterval)) {
367
+			$globalLiveInterval = '200';
368
+		}
350 369
 		$filter_query = $this->getFilter($filter,true,true);
351 370
 
352 371
 		if (is_array($coord)) {
@@ -354,7 +373,9 @@  discard block
 block discarded – undo
354 373
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355 374
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356 375
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357
-		} else return array();
376
+		} else {
377
+			return array();
378
+		}
358 379
 		if ($globalDBdriver == 'mysql') {
359 380
 			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
360 381
 			FROM spotter_live 
@@ -568,11 +589,15 @@  discard block
 block discarded – undo
568 589
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
569 590
 		if ($globalDBdriver == 'mysql') {
570 591
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
571
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
592
+			if ($liveinterval) {
593
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
594
+			}
572 595
 			$query .= ' ORDER BY date';
573 596
 		} else {
574 597
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
575
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
598
+			if ($liveinterval) {
599
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
600
+			}
576 601
 			$query .= ' ORDER BY date';
577 602
 		}
578 603
 
@@ -667,7 +692,9 @@  discard block
 block discarded – undo
667 692
 				$i++;
668 693
 				$j++;
669 694
 				if ($j == 30) {
670
-					if ($globalDebug) echo ".";
695
+					if ($globalDebug) {
696
+						echo ".";
697
+					}
671 698
 				    	try {
672 699
 						
673 700
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -974,7 +1001,9 @@  discard block
 block discarded – undo
974 1001
 			{
975 1002
 				return false;
976 1003
 			}
977
-		} else return '';
1004
+		} else {
1005
+			return '';
1006
+		}
978 1007
 
979 1008
 		if ($longitude != '')
980 1009
 		{
@@ -982,7 +1011,9 @@  discard block
 block discarded – undo
982 1011
 			{
983 1012
 				return false;
984 1013
 			}
985
-		} else return '';
1014
+		} else {
1015
+			return '';
1016
+		}
986 1017
 
987 1018
 		if ($waypoints != '')
988 1019
 		{
@@ -998,7 +1029,9 @@  discard block
 block discarded – undo
998 1029
 			{
999 1030
 				return false;
1000 1031
 			}
1001
-		} else $altitude = 0;
1032
+		} else {
1033
+			$altitude = 0;
1034
+		}
1002 1035
 
1003 1036
 		if ($heading != '')
1004 1037
 		{
@@ -1006,7 +1039,9 @@  discard block
 block discarded – undo
1006 1039
 			{
1007 1040
 				return false;
1008 1041
 			}
1009
-		} else $heading = 0;
1042
+		} else {
1043
+			$heading = 0;
1044
+		}
1010 1045
 
1011 1046
 		if ($groundspeed != '')
1012 1047
 		{
@@ -1014,9 +1049,13 @@  discard block
 block discarded – undo
1014 1049
 			{
1015 1050
 				return false;
1016 1051
 			}
1017
-		} else $groundspeed = 0;
1052
+		} else {
1053
+			$groundspeed = 0;
1054
+		}
1018 1055
 		date_default_timezone_set('UTC');
1019
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1056
+		if ($date == '') {
1057
+			$date = date("Y-m-d H:i:s", time());
1058
+		}
1020 1059
 
1021 1060
         
1022 1061
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1060,14 +1099,24 @@  discard block
 block discarded – undo
1060 1099
 		$arrival_airport_country = '';
1061 1100
 		
1062 1101
             	
1063
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1102
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1103
+            		$squawk = NULL;
1104
+            	}
1105
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1106
+            		$verticalrate = NULL;
1107
+            	}
1108
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1109
+            		$groundspeed = 0;
1110
+            	}
1111
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1112
+            		$heading = 0;
1113
+            	}
1067 1114
 		
1068 1115
 		$query = '';
1069 1116
 		if ($globalArchive) {
1070
-			if ($globalDebug) echo '-- Delete previous data -- ';
1117
+			if ($globalDebug) {
1118
+				echo '-- Delete previous data -- ';
1119
+			}
1071 1120
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1072 1121
 		}
1073 1122
 
@@ -1083,10 +1132,14 @@  discard block
 block discarded – undo
1083 1132
 			return "error : ".$e->getMessage();
1084 1133
 		}
1085 1134
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1086
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1135
+		    if ($globalDebug) {
1136
+		    	echo '(Add to SBS archive : ';
1137
+		    }
1087 1138
 		    $SpotterArchive = new SpotterArchive($this->db);
1088 1139
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1089
-		    if ($globalDebug) echo $result.')';
1140
+		    if ($globalDebug) {
1141
+		    	echo $result.')';
1142
+		    }
1090 1143
 		}
1091 1144
 		return "success";
1092 1145
 
Please login to merge, or discard this patch.
js/map-marine.2d.js.php 1 patch
Braces   +42 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,8 +5,11 @@  discard block
 block discarded – undo
5 5
 setcookie("MapFormat",'2d');
6 6
 
7 7
 // Compressed GeoJson is used if true
8
-if (!isset($globalJsonCompress)) $compress = true;
9
-else $compress = $globalJsonCompress;
8
+if (!isset($globalJsonCompress)) {
9
+	$compress = true;
10
+} else {
11
+	$compress = $globalJsonCompress;
12
+}
10 13
 ?>
11 14
 
12 15
 
@@ -142,9 +145,13 @@  discard block
 block discarded – undo
142 145
 		    if (callsign != ""){ markerMarineLabel += callsign; }
143 146
 		    if (type != ""){ markerMarineLabel += ' - '+type; }
144 147
 <?php
145
-	if (isset($_COOKIE['MarineIconColor'])) $MarineIconColor = $_COOKIE['MarineIconColor'];
146
-	elseif (isset($globalMarineIconColor)) $MarineIconColor = $globalMarineIconColor;
147
-	else $MarineIconColor = '1a3151';
148
+	if (isset($_COOKIE['MarineIconColor'])) {
149
+		$MarineIconColor = $_COOKIE['MarineIconColor'];
150
+	} elseif (isset($globalMarineIconColor)) {
151
+		$MarineIconColor = $globalMarineIconColor;
152
+	} else {
153
+		$MarineIconColor = '1a3151';
154
+	}
148 155
 	if (!isset($ident) && !isset($fammarine_id)) {
149 156
 ?>
150 157
 		    info_marine_update(feature.properties.fc);
@@ -179,7 +186,12 @@  discard block
 block discarded – undo
179 186
 <?php
180 187
 		} else {
181 188
 ?>
182
-		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
189
+		    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
190
+	print $archiveupdatetime*1000;
191
+} else {
192
+	print $globalMapRefresh*1000+20000;
193
+}
194
+?>+feature.properties.sqt*1000);
183 195
 		    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
184 196
 <?php
185 197
 		}
@@ -228,7 +240,12 @@  discard block
 block discarded – undo
228 240
 <?php
229 241
 		} else {
230 242
 ?>
231
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
243
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
244
+	print $archiveupdatetime*1000;
245
+} else {
246
+	print $globalMapRefresh*1000+20000;
247
+}
248
+?>+feature.properties.sqt*1000);
232 249
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
233 250
 <?php
234 251
 		}
@@ -276,7 +293,12 @@  discard block
 block discarded – undo
276 293
 <?php
277 294
 		} else {
278 295
 ?>
279
-			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) print $archiveupdatetime*1000; else print $globalMapRefresh*1000+20000; ?>+feature.properties.sqt*1000);
296
+			    var movingtime = Math.round(<?php if (isset($archiveupdatetime)) {
297
+	print $archiveupdatetime*1000;
298
+} else {
299
+	print $globalMapRefresh*1000+20000;
300
+}
301
+?>+feature.properties.sqt*1000);
280 302
 			    return new L.Marker.movingMarker([latLng, feature.properties.nextlatlon],[movingtime],{
281 303
 <?php
282 304
 		}
@@ -559,14 +581,24 @@  discard block
 block discarded – undo
559 581
 	if (isset($archive) && $archive) {
560 582
 ?>
561 583
 //then load it again every 30 seconds
562
-//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print ($globalMapRefresh*1000)/2; else print '15000'; ?>);
584
+//  var reload = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
585
+	print ($globalMapRefresh*1000)/2;
586
+} else {
587
+	print '15000';
588
+}
589
+?>);
563 590
 reloadMarinePage = setInterval(function(){if (noTimeout) getLiveMarineData(0)},<?php print $archiveupdatetime*1000; ?>);
564 591
 <?php
565 592
 	} else {
566 593
 ?>
567 594
 //then load it again every 30 seconds
568 595
 reloadMarinePage = setInterval(
569
-    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
596
+    function(){if (noTimeout) getLiveMarineData(0)},<?php if (isset($globalMapRefresh)) {
597
+	print $globalMapRefresh*1000;
598
+} else {
599
+	print '30000';
600
+}
601
+?>);
570 602
 <?php
571 603
 	}
572 604
 ?>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +883 added lines, -303 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,27 +158,37 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
143 186
         	//$formats[$id] = 'radarvirtueljson';
144 187
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 188
         	//$last_exec['radarvirtueljson'] = 0;
146
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
189
+        	if ($globalDebug) {
190
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
191
+        	}
147 192
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
148 193
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 194
         	    exit(0);
@@ -152,7 +197,9 @@  discard block
 block discarded – undo
152 197
         	//$formats[$id] = 'planeupdatefaa';
153 198
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 199
         	//$last_exec['planeupdatefaa'] = 0;
155
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
200
+        	if ($globalDebug) {
201
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
202
+        	}
156 203
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
157 204
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 205
         	    exit(0);
@@ -161,26 +208,36 @@  discard block
 block discarded – undo
161 208
         	//$formats[$id] = 'phpvmacars';
162 209
         	$globalSources[$id]['format'] = 'phpvmacars';
163 210
         	//$last_exec['phpvmacars'] = 0;
164
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
211
+        	if ($globalDebug) {
212
+        		echo "Connect to phpvmacars source (".$host.")...\n";
213
+        	}
165 214
             } else if (preg_match('/VAM-json.php$/i',$host)) {
166 215
         	//$formats[$id] = 'phpvmacars';
167 216
         	$globalSources[$id]['format'] = 'vam';
168
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to Vam source (".$host.")...\n";
219
+        	}
169 220
             } else if (preg_match('/whazzup/i',$host)) {
170 221
         	//$formats[$id] = 'whazzup';
171 222
         	$globalSources[$id]['format'] = 'whazzup';
172 223
         	//$last_exec['whazzup'] = 0;
173
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
224
+        	if ($globalDebug) {
225
+        		echo "Connect to whazzup source (".$host.")...\n";
226
+        	}
174 227
             } else if (preg_match('/recentpireps/i',$host)) {
175 228
         	//$formats[$id] = 'pirepsjson';
176 229
         	$globalSources[$id]['format'] = 'pirepsjson';
177 230
         	//$last_exec['pirepsjson'] = 0;
178
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
231
+        	if ($globalDebug) {
232
+        		echo "Connect to pirepsjson source (".$host.")...\n";
233
+        	}
179 234
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
180 235
         	//$formats[$id] = 'fr24json';
181 236
         	$globalSources[$id]['format'] = 'fr24json';
182 237
         	//$last_exec['fr24json'] = 0;
183
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
238
+        	if ($globalDebug) {
239
+        		echo "Connect to fr24 source (".$host.")...\n";
240
+        	}
184 241
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
185 242
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 243
         	    exit(0);
@@ -189,7 +246,9 @@  discard block
 block discarded – undo
189 246
         	//$formats[$id] = 'fr24json';
190 247
         	$globalSources[$id]['format'] = 'myshiptracking';
191 248
         	//$last_exec['fr24json'] = 0;
192
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
249
+        	if ($globalDebug) {
250
+        		echo "Connect to myshiptracking source (".$host.")...\n";
251
+        	}
193 252
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
194 253
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
195 254
         	    exit(0);
@@ -198,17 +257,24 @@  discard block
 block discarded – undo
198 257
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 258
         	//$formats[$id] = 'tsv';
200 259
         	$globalSources[$id]['format'] = 'tsv';
201
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
260
+        	if ($globalDebug) {
261
+        		echo "Connect to tsv source (".$host.")...\n";
262
+        	}
202 263
             }
203 264
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
204 265
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205 266
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
206 267
     		    if ($idf !== false) {
207 268
     			$httpfeeds[$id] = $idf;
208
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
269
+        		if ($globalDebug) {
270
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
271
+        		}
272
+    		    } elseif ($globalDebug) {
273
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
209 274
     		    }
210
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
275
+    		} elseif ($globalDebug) {
276
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
277
+    		}
212 278
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213 279
 	    $hostport = explode(':',$host);
214 280
 	    if (isset($hostport[1])) {
@@ -248,17 +314,25 @@  discard block
 block discarded – undo
248 314
         		//$formats[$id] = 'beast';
249 315
         		$globalSources[$id]['format'] = 'beast';
250 316
 		    //} else $formats[$id] = 'sbs';
251
-		    } else $globalSources[$id]['format'] = 'sbs';
317
+		    } else {
318
+		    	$globalSources[$id]['format'] = 'sbs';
319
+		    }
252 320
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
253 321
 		}
254
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
322
+		if ($globalDebug) {
323
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
324
+		}
255 325
             } else {
256
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
326
+		if ($globalDebug) {
327
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
328
+		}
257 329
     	    }
258 330
         }
259 331
     }
260 332
 }
261
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
333
+if (!isset($globalMinFetch)) {
334
+	$globalMinFetch = 15;
335
+}
262 336
 
263 337
 // Initialize all
264 338
 $status = array();
@@ -267,13 +341,19 @@  discard block
 block discarded – undo
267 341
 $formats = array();
268 342
 $last_exec = array();
269 343
 $time = time();
270
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
271
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272
-else $timeout = 20;
344
+if (isset($globalSourcesTimeout)) {
345
+	$timeout = $globalSourcesTimeOut;
346
+} else if (isset($globalSBS1TimeOut)) {
347
+	$timeout = $globalSBS1TimeOut;
348
+} else {
349
+	$timeout = 20;
350
+}
273 351
 $errno = '';
274 352
 $errstr='';
275 353
 
276
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
354
+if (!isset($globalDaemon)) {
355
+	$globalDaemon = TRUE;
356
+}
277 357
 /* Initiate connections to all the hosts simultaneously */
278 358
 //connect_all($hosts);
279 359
 //connect_all($globalSources);
@@ -299,7 +379,9 @@  discard block
 block discarded – undo
299 379
     if (isset($source['format']) && $source['format'] == 'aprs') {
300 380
 	$aprs_connect = 0;
301 381
 	$use_aprs = true;
302
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
382
+	if (isset($source['port']) && $source['port'] == '10152') {
383
+		$aprs_full = true;
384
+	}
303 385
 	break;
304 386
     }
305 387
 }
@@ -310,25 +392,48 @@  discard block
 block discarded – undo
310 392
 	$aprs_connect = 0;
311 393
 	$aprs_keep = 120;
312 394
 	$aprs_last_tx = time();
313
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
315
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
317
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319
-	if ($aprs_full) $aprs_filter = '';
320
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321
-	else $aprs_pass = '-1';
395
+	if (isset($globalAPRSversion)) {
396
+		$aprs_version = $globalAPRSversion;
397
+	} else {
398
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
399
+	}
400
+	if (isset($globalAPRSssid)) {
401
+		$aprs_ssid = $globalAPRSssid;
402
+	} else {
403
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
404
+	}
405
+	if (isset($globalAPRSfilter)) {
406
+		$aprs_filter = $globalAPRSfilter;
407
+	} else {
408
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
409
+	}
410
+	if ($aprs_full) {
411
+		$aprs_filter = '';
412
+	}
413
+	if (isset($globalAPRSpass)) {
414
+		$aprs_pass = $globalAPRSpass;
415
+	} else {
416
+		$aprs_pass = '-1';
417
+	}
322 418
 
323
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
324
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
325
-}
419
+	if ($aprs_filter != '') {
420
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
421
+	} else {
422
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
423
+	}
424
+	}
326 425
 
327 426
 // connected - lets do some work
328
-if ($globalDebug) echo "Connected!\n";
427
+if ($globalDebug) {
428
+	echo "Connected!\n";
429
+}
329 430
 sleep(1);
330
-if ($globalDebug) echo "SCAN MODE \n\n";
331
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
431
+if ($globalDebug) {
432
+	echo "SCAN MODE \n\n";
433
+}
434
+if (!isset($globalCronEnd)) {
435
+	$globalCronEnd = 60;
436
+}
332 437
 $endtime = time()+$globalCronEnd;
333 438
 $i = 1;
334 439
 $tt = array();
@@ -342,10 +447,14 @@  discard block
 block discarded – undo
342 447
 
343 448
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 449
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
450
+    if (!$globalDaemon) {
451
+    	$i = $endtime-time();
452
+    }
346 453
     // Delete old ATC
347 454
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
455
+	if ($globalDebug) {
456
+		echo 'Delete old ATC...'."\n";
457
+	}
349 458
         $ATC->deleteOldATC();
350 459
     }
351 460
     
@@ -353,10 +462,14 @@  discard block
 block discarded – undo
353 462
     if (count($last_exec) == count($globalSources)) {
354 463
 	$max = $globalMinFetch;
355 464
 	foreach ($last_exec as $last) {
356
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
465
+	    if ((time() - $last['last']) < $max) {
466
+	    	$max = time() - $last['last'];
467
+	    }
357 468
 	}
358 469
 	if ($max != $globalMinFetch) {
359
-	    if ($globalDebug) echo 'Sleeping...'."\n";
470
+	    if ($globalDebug) {
471
+	    	echo 'Sleeping...'."\n";
472
+	    }
360 473
 	    sleep($globalMinFetch-$max+2);
361 474
 	}
362 475
     }
@@ -365,11 +478,15 @@  discard block
 block discarded – undo
365 478
     //foreach ($formats as $id => $value) {
366 479
     foreach ($globalSources as $id => $value) {
367 480
 	date_default_timezone_set('UTC');
368
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
481
+	if (!isset($last_exec[$id]['last'])) {
482
+		$last_exec[$id]['last'] = 0;
483
+	}
369 484
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
370 485
 	    //$buffer = $Common->getData($hosts[$id]);
371 486
 	    $buffer = $Common->getData($value['host']);
372
-	    if ($buffer != '') $reset = 0;
487
+	    if ($buffer != '') {
488
+	    	$reset = 0;
489
+	    }
373 490
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374 491
 	    $buffer = explode('\n',$buffer);
375 492
 	    foreach ($buffer as $line) {
@@ -378,20 +495,41 @@  discard block
 block discarded – undo
378 495
 	            $data = array();
379 496
 	            $data['hex'] = $line[1]; // hex
380 497
 	            $data['ident'] = $line[2]; // ident
381
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
382
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
383
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
384
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
385
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
498
+	            if (isset($line[3])) {
499
+	            	$data['altitude'] = $line[3];
500
+	            }
501
+	            // altitude
502
+	            if (isset($line[4])) {
503
+	            	$data['speed'] = $line[4];
504
+	            }
505
+	            // speed
506
+	            if (isset($line[5])) {
507
+	            	$data['heading'] = $line[5];
508
+	            }
509
+	            // heading
510
+	            if (isset($line[6])) {
511
+	            	$data['latitude'] = $line[6];
512
+	            }
513
+	            // lat
514
+	            if (isset($line[7])) {
515
+	            	$data['longitude'] = $line[7];
516
+	            }
517
+	            // long
386 518
 	            $data['verticalrate'] = ''; // vertical rate
387 519
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
388 520
 	            $data['emergency'] = ''; // emergency
389 521
 		    $data['datetime'] = date('Y-m-d H:i:s');
390 522
 		    $data['format_source'] = 'deltadbtxt';
391 523
     		    $data['id_source'] = $id_source;
392
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
393
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
394
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
524
+		    if (isset($value['name']) && $value['name'] != '') {
525
+		    	$data['source_name'] = $value['name'];
526
+		    }
527
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
528
+		    	$data['noarchive'] = true;
529
+		    }
530
+		    if (isset($value['sourcestats'])) {
531
+		    	$data['sourcestats'] = $value['sourcestats'];
532
+		    }
395 533
     		    $SI->add($data);
396 534
 		    unset($data);
397 535
     		}
@@ -401,7 +539,9 @@  discard block
 block discarded – undo
401 539
 	    date_default_timezone_set('CET');
402 540
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
403 541
 	    date_default_timezone_set('UTC');
404
-	    if ($buffer != '') $reset = 0;
542
+	    if ($buffer != '') {
543
+	    	$reset = 0;
544
+	    }
405 545
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406 546
 	    $buffer = explode('\n',$buffer);
407 547
 	    foreach ($buffer as $line) {
@@ -410,16 +550,36 @@  discard block
 block discarded – undo
410 550
 		    $add = false;
411 551
 		    $ais_data = $AIS->parse_line(trim($line));
412 552
 		    $data = array();
413
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
414
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
415
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
416
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
417
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
418
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
419
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
420
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
421
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
553
+		    if (isset($ais_data['ident'])) {
554
+		    	$data['ident'] = $ais_data['ident'];
555
+		    }
556
+		    if (isset($ais_data['mmsi'])) {
557
+		    	$data['mmsi'] = $ais_data['mmsi'];
558
+		    }
559
+		    if (isset($ais_data['speed'])) {
560
+		    	$data['speed'] = $ais_data['speed'];
561
+		    }
562
+		    if (isset($ais_data['heading'])) {
563
+		    	$data['heading'] = $ais_data['heading'];
564
+		    }
565
+		    if (isset($ais_data['latitude'])) {
566
+		    	$data['latitude'] = $ais_data['latitude'];
567
+		    }
568
+		    if (isset($ais_data['longitude'])) {
569
+		    	$data['longitude'] = $ais_data['longitude'];
570
+		    }
571
+		    if (isset($ais_data['status'])) {
572
+		    	$data['status'] = $ais_data['status'];
573
+		    }
574
+		    if (isset($ais_data['type'])) {
575
+		    	$data['type'] = $ais_data['type'];
576
+		    }
577
+		    if (isset($ais_data['imo'])) {
578
+		    	$data['imo'] = $ais_data['imo'];
579
+		    }
580
+		    if (isset($ais_data['callsign'])) {
581
+		    	$data['callsign'] = $ais_data['callsign'];
582
+		    }
423 583
 		    if (isset($ais_data['timestamp'])) {
424 584
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
425 585
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -434,8 +594,12 @@  discard block
 block discarded – undo
434 594
     		    $data['id_source'] = $id_source;
435 595
 		    //print_r($data);
436 596
 		    echo 'Add...'."\n";
437
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
438
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
601
+		    	$MI->add($data);
602
+		    }
439 603
 		    unset($data);
440 604
 		}
441 605
     	    }
@@ -455,18 +619,42 @@  discard block
 block discarded – undo
455 619
 			    if ($line != '') {
456 620
 				$ais_data = $AIS->parse_line(trim($line));
457 621
 				$data = array();
458
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
459
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
460
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
461
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
462
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
463
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
464
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
465
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
466
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
467
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
468
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
469
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
622
+				if (isset($ais_data['ident'])) {
623
+					$data['ident'] = $ais_data['ident'];
624
+				}
625
+				if (isset($ais_data['mmsi'])) {
626
+					$data['mmsi'] = $ais_data['mmsi'];
627
+				}
628
+				if (isset($ais_data['speed'])) {
629
+					$data['speed'] = $ais_data['speed'];
630
+				}
631
+				if (isset($ais_data['heading'])) {
632
+					$data['heading'] = $ais_data['heading'];
633
+				}
634
+				if (isset($ais_data['latitude'])) {
635
+					$data['latitude'] = $ais_data['latitude'];
636
+				}
637
+				if (isset($ais_data['longitude'])) {
638
+					$data['longitude'] = $ais_data['longitude'];
639
+				}
640
+				if (isset($ais_data['status'])) {
641
+					$data['status'] = $ais_data['status'];
642
+				}
643
+				if (isset($ais_data['type'])) {
644
+					$data['type'] = $ais_data['type'];
645
+				}
646
+				if (isset($ais_data['imo'])) {
647
+					$data['imo'] = $ais_data['imo'];
648
+				}
649
+				if (isset($ais_data['callsign'])) {
650
+					$data['callsign'] = $ais_data['callsign'];
651
+				}
652
+				if (isset($ais_data['destination'])) {
653
+					$data['arrival_code'] = $ais_data['destination'];
654
+				}
655
+				if (isset($ais_data['eta_ts'])) {
656
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
657
+				}
470 658
 				if (isset($ais_data['timestamp'])) {
471 659
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
472 660
 				} else {
@@ -474,16 +662,23 @@  discard block
 block discarded – undo
474 662
 				}
475 663
 				$data['format_source'] = 'aisnmeahttp';
476 664
 				$data['id_source'] = $id_source;
477
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
478
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
665
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
666
+					$data['noarchive'] = true;
667
+				}
668
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
669
+					$MI->add($data);
670
+				}
479 671
 				unset($data);
480 672
 			    }
481 673
 			}
482 674
 		    }
483 675
 		} else {
484 676
 		    $format = $value['format'];
485
-		    if (isset($tt[$format])) $tt[$format]++;
486
-		    else $tt[$format] = 0;
677
+		    if (isset($tt[$format])) {
678
+		    	$tt[$format]++;
679
+		    } else {
680
+		    	$tt[$format] = 0;
681
+		    }
487 682
 		    if ($tt[$format] > 30) {
488 683
 			sleep(2);
489 684
 			$sourceeen[] = $value;
@@ -514,7 +709,9 @@  discard block
 block discarded – undo
514 709
 			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
515 710
 			$data['format_source'] = 'myshiptracking';
516 711
 			$data['id_source'] = $id_source;
517
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
712
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
713
+				$data['noarchive'] = true;
714
+			}
518 715
 			$MI->add($data);
519 716
 			unset($data);
520 717
 		    }
@@ -535,7 +732,9 @@  discard block
 block discarded – undo
535 732
 			    $data['callsign'] = $line['callsign'];
536 733
 			    $data['mmsi'] = $line['mmsi'];
537 734
 			    $data['speed'] = $line['sog'];
538
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
735
+			    if ($line['heading'] != '511') {
736
+			    	$data['heading'] = $line['heading'];
737
+			    }
539 738
 			    $data['latitude'] = $line['latitude'];
540 739
 			    $data['longitude'] = $line['longitude'];
541 740
 			    $data['type_id'] = $line['shiptype'];
@@ -543,7 +742,9 @@  discard block
 block discarded – undo
543 742
 			    $data['datetime'] = $line['time'];
544 743
 			    $data['format_source'] = 'boatbeaconapp';
545 744
 			    $data['id_source'] = $id_source;
546
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
745
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
746
+			    	$data['noarchive'] = true;
747
+			    }
547 748
 			    $MI->add($data);
548 749
 			    unset($data);
549 750
 			}
@@ -556,7 +757,9 @@  discard block
 block discarded – undo
556 757
 	    echo 'download...';
557 758
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
558 759
 	    echo 'done !'."\n";
559
-	    if ($buffer != '') $reset = 0;
760
+	    if ($buffer != '') {
761
+	    	$reset = 0;
762
+	    }
560 763
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
561 764
 	    $buffer = explode('\n',$buffer);
562 765
 	    foreach ($buffer as $line) {
@@ -581,7 +784,9 @@  discard block
 block discarded – undo
581 784
 		    //$data['etaTime'] = substr($line,135,5);
582 785
 		    $data['format_source'] = 'shipplotter';
583 786
     		    $data['id_source'] = $id_source;
584
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
787
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
788
+		    	$data['noarchive'] = true;
789
+		    }
585 790
 		    //print_r($data);
586 791
 		    echo 'Add...'."\n";
587 792
 		    $MI->add($data);
@@ -601,16 +806,28 @@  discard block
 block discarded – undo
601 806
     		    $line = explode(':', $line);
602 807
     		    if (count($line) > 30 && $line[0] != 'callsign') {
603 808
 			$data = array();
604
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
605
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
809
+			if (isset($line[37]) && $line[37] != '') {
810
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
811
+			} else {
812
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
813
+			}
606 814
 			$data['pilot_id'] = $line[1];
607 815
 			$data['pilot_name'] = $line[2];
608 816
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
609 817
 			$data['ident'] = $line[0]; // ident
610
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
818
+			if ($line[7] != '' && $line[7] != 0) {
819
+				$data['altitude'] = $line[7];
820
+			}
821
+			// altitude
611 822
 			$data['speed'] = $line[8]; // speed
612
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
613
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
823
+			if (isset($line[45])) {
824
+				$data['heading'] = $line[45];
825
+			}
826
+			// heading
827
+			elseif (isset($line[38])) {
828
+				$data['heading'] = $line[38];
829
+			}
830
+			// heading
614 831
 			$data['latitude'] = $line[5]; // lat
615 832
 	        	$data['longitude'] = $line[6]; // long
616 833
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -626,7 +843,9 @@  discard block
 block discarded – undo
626 843
 			$data['frequency'] = $line[4];
627 844
 			$data['type'] = $line[18];
628 845
 			$data['range'] = $line[19];
629
-			if (isset($line[35])) $data['info'] = $line[35];
846
+			if (isset($line[35])) {
847
+				$data['info'] = $line[35];
848
+			}
630 849
     			$data['id_source'] = $id_source;
631 850
 	    		//$data['arrival_airport_time'] = ;
632 851
 	    		if ($line[9] != '') {
@@ -640,25 +859,44 @@  discard block
 block discarded – undo
640 859
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
641 860
 	    		*/
642 861
 	    		$data['format_source'] = $value['format'];
643
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
644
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
645
-    			if ($line[3] == 'PILOT') $SI->add($data);
646
-			elseif ($line[3] == 'ATC') {
862
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
863
+				$data['noarchive'] = true;
864
+			}
865
+			if (isset($value['name']) && $value['name'] != '') {
866
+				$data['source_name'] = $value['name'];
867
+			}
868
+    			if ($line[3] == 'PILOT') {
869
+    				$SI->add($data);
870
+    			} elseif ($line[3] == 'ATC') {
647 871
 				//print_r($data);
648 872
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
649 873
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
650 874
 				$typec = substr($data['ident'],-3);
651
-				if ($typec == 'APP') $data['type'] = 'Approach';
652
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
653
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
654
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
655
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
656
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
657
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
658
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
659
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
660
-				if (!isset($data['source_name'])) $data['source_name'] = '';
661
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
875
+				if ($typec == 'APP') {
876
+					$data['type'] = 'Approach';
877
+				} elseif ($typec == 'TWR') {
878
+					$data['type'] = 'Tower';
879
+				} elseif ($typec == 'OBS') {
880
+					$data['type'] = 'Observer';
881
+				} elseif ($typec == 'GND') {
882
+					$data['type'] = 'Ground';
883
+				} elseif ($typec == 'DEL') {
884
+					$data['type'] = 'Delivery';
885
+				} elseif ($typec == 'DEP') {
886
+					$data['type'] = 'Departure';
887
+				} elseif ($typec == 'FSS') {
888
+					$data['type'] = 'Flight Service Station';
889
+				} elseif ($typec == 'CTR') {
890
+					$data['type'] = 'Control Radar or Centre';
891
+				} elseif ($data['type'] == '') {
892
+					$data['type'] = 'Observer';
893
+				}
894
+				if (!isset($data['source_name'])) {
895
+					$data['source_name'] = '';
896
+				}
897
+				if (isset($ATC)) {
898
+					echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
899
+				}
662 900
 			}
663 901
     			unset($data);
664 902
     		    }
@@ -677,27 +915,58 @@  discard block
 block discarded – undo
677 915
 		foreach ($all_data['acList'] as $line) {
678 916
 		    $data = array();
679 917
 		    $data['hex'] = $line['Icao']; // hex
680
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
681
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
682
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
683
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
684
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
685
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
918
+		    if (isset($line['Call'])) {
919
+		    	$data['ident'] = $line['Call'];
920
+		    }
921
+		    // ident
922
+		    if (isset($line['Alt'])) {
923
+		    	$data['altitude'] = $line['Alt'];
924
+		    }
925
+		    // altitude
926
+		    if (isset($line['Spd'])) {
927
+		    	$data['speed'] = $line['Spd'];
928
+		    }
929
+		    // speed
930
+		    if (isset($line['Trak'])) {
931
+		    	$data['heading'] = $line['Trak'];
932
+		    }
933
+		    // heading
934
+		    if (isset($line['Lat'])) {
935
+		    	$data['latitude'] = $line['Lat'];
936
+		    }
937
+		    // lat
938
+		    if (isset($line['Long'])) {
939
+		    	$data['longitude'] = $line['Long'];
940
+		    }
941
+		    // long
686 942
 		    //$data['verticalrate'] = $line['']; // verticale rate
687
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
943
+		    if (isset($line['Sqk'])) {
944
+		    	$data['squawk'] = $line['Sqk'];
945
+		    }
946
+		    // squawk
688 947
 		    $data['emergency'] = ''; // emergency
689
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
948
+		    if (isset($line['Reg'])) {
949
+		    	$data['registration'] = $line['Reg'];
950
+		    }
690 951
 		    /*
691 952
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
692 953
 		    else $data['datetime'] = date('Y-m-d H:i:s');
693 954
 		    */
694 955
 		    $data['datetime'] = date('Y-m-d H:i:s');
695
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
956
+		    if (isset($line['Type'])) {
957
+		    	$data['aircraft_icao'] = $line['Type'];
958
+		    }
696 959
 	    	    $data['format_source'] = 'aircraftlistjson';
697 960
 		    $data['id_source'] = $id_source;
698
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
699
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
700
-		    if (isset($data['latitude'])) $SI->add($data);
961
+		    if (isset($value['name']) && $value['name'] != '') {
962
+		    	$data['source_name'] = $value['name'];
963
+		    }
964
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
965
+		    	$data['noarchive'] = true;
966
+		    }
967
+		    if (isset($data['latitude'])) {
968
+		    	$SI->add($data);
969
+		    }
701 970
 		    unset($data);
702 971
 		}
703 972
 	    } elseif (is_array($all_data)) {
@@ -717,8 +986,12 @@  discard block
 block discarded – undo
717 986
 		    $data['datetime'] = date('Y-m-d H:i:s');
718 987
 	    	    $data['format_source'] = 'aircraftlistjson';
719 988
     		    $data['id_source'] = $id_source;
720
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
721
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
989
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
990
+		    	$data['noarchive'] = true;
991
+		    }
992
+		    if (isset($value['name']) && $value['name'] != '') {
993
+		    	$data['source_name'] = $value['name'];
994
+		    }
722 995
 		    $SI->add($data);
723 996
 		    unset($data);
724 997
 		}
@@ -754,8 +1027,12 @@  discard block
 block discarded – undo
754 1027
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
755 1028
 	    	    $data['format_source'] = 'planeupdatefaa';
756 1029
     		    $data['id_source'] = $id_source;
757
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
758
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1030
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1031
+		    	$data['noarchive'] = true;
1032
+		    }
1033
+		    if (isset($value['name']) && $value['name'] != '') {
1034
+		    	$data['source_name'] = $value['name'];
1035
+		    }
759 1036
 		    $SI->add($data);
760 1037
 		    unset($data);
761 1038
 		}
@@ -784,7 +1061,9 @@  discard block
 block discarded – undo
784 1061
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
785 1062
 	    	    $data['format_source'] = 'opensky';
786 1063
     		    $data['id_source'] = $id_source;
787
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1064
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1065
+		    	$data['noarchive'] = true;
1066
+		    }
788 1067
 		    $SI->add($data);
789 1068
 		    unset($data);
790 1069
 		}
@@ -796,7 +1075,9 @@  discard block
 block discarded – undo
796 1075
 	    //$buffer = $Common->getData($hosts[$id]);
797 1076
 	    $buffer = $Common->getData($value['host']);
798 1077
 	    $all_data = json_decode($buffer,true);
799
-	    if (!empty($all_data)) $reset = 0;
1078
+	    if (!empty($all_data)) {
1079
+	    	$reset = 0;
1080
+	    }
800 1081
 	    foreach ($all_data as $key => $line) {
801 1082
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
802 1083
 		    $data = array();
@@ -817,8 +1098,12 @@  discard block
 block discarded – undo
817 1098
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
818 1099
 	    	    $data['format_source'] = 'fr24json';
819 1100
     		    $data['id_source'] = $id_source;
820
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
821
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1101
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1102
+		    	$data['noarchive'] = true;
1103
+		    }
1104
+		    if (isset($value['name']) && $value['name'] != '') {
1105
+		    	$data['source_name'] = $value['name'];
1106
+		    }
822 1107
 		    $SI->add($data);
823 1108
 		    unset($data);
824 1109
 		}
@@ -842,24 +1127,42 @@  discard block
 block discarded – undo
842 1127
 		    if (isset($line['inf'])) {
843 1128
 			$data = array();
844 1129
 			$data['hex'] = $line['inf']['ia'];
845
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1130
+			if (isset($line['inf']['cs'])) {
1131
+				$data['ident'] = $line['inf']['cs'];
1132
+			}
1133
+			//$line[13]
846 1134
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
847
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
848
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1135
+	    		if (isset($line['inf']['gs'])) {
1136
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1137
+	    		}
1138
+	    		// speed
1139
+	    		if (isset($line['inf']['tr'])) {
1140
+	    			$data['heading'] = $line['inf']['tr'];
1141
+	    		}
1142
+	    		// heading
849 1143
 	    		$data['latitude'] = $line['pt'][0]; // lat
850 1144
 	    		$data['longitude'] = $line['pt'][1]; // long
851 1145
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
852
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1146
+	    		if (isset($line['inf']['sq'])) {
1147
+	    			$data['squawk'] = $line['inf']['sq'];
1148
+	    		}
1149
+	    		// squawk
853 1150
 	    		//$data['aircraft_icao'] = $line[8];
854
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1151
+	    		if (isset($line['inf']['rc'])) {
1152
+	    			$data['registration'] = $line['inf']['rc'];
1153
+	    		}
855 1154
 			//$data['departure_airport_iata'] = $line[11];
856 1155
 			//$data['arrival_airport_iata'] = $line[12];
857 1156
 	    		//$data['emergency'] = ''; // emergency
858 1157
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
859 1158
 	    		$data['format_source'] = 'radarvirtueljson';
860 1159
     			$data['id_source'] = $id_source;
861
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
862
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1160
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1161
+				$data['noarchive'] = true;
1162
+			}
1163
+			if (isset($value['name']) && $value['name'] != '') {
1164
+				$data['source_name'] = $value['name'];
1165
+			}
863 1166
 			$SI->add($data);
864 1167
 			unset($data);
865 1168
 		    }
@@ -880,30 +1183,65 @@  discard block
 block discarded – undo
880 1183
 		    $data['id'] = $line['id'];
881 1184
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
882 1185
 		    $data['ident'] = $line['callsign']; // ident
883
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
884
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
885
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
886
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
887
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
888
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1186
+		    if (isset($line['pilotid'])) {
1187
+		    	$data['pilot_id'] = $line['pilotid'];
1188
+		    }
1189
+		    // pilot id
1190
+		    if (isset($line['name'])) {
1191
+		    	$data['pilot_name'] = $line['name'];
1192
+		    }
1193
+		    // pilot name
1194
+		    if (isset($line['alt'])) {
1195
+		    	$data['altitude'] = $line['alt'];
1196
+		    }
1197
+		    // altitude
1198
+		    if (isset($line['gs'])) {
1199
+		    	$data['speed'] = $line['gs'];
1200
+		    }
1201
+		    // speed
1202
+		    if (isset($line['heading'])) {
1203
+		    	$data['heading'] = $line['heading'];
1204
+		    }
1205
+		    // heading
1206
+		    if (isset($line['route'])) {
1207
+		    	$data['waypoints'] = $line['route'];
1208
+		    }
1209
+		    // route
889 1210
 		    $data['latitude'] = $line['lat']; // lat
890 1211
 		    $data['longitude'] = $line['lon']; // long
891 1212
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
892 1213
 		    //$data['squawk'] = $line['squawk']; // squawk
893 1214
 		    //$data['emergency'] = ''; // emergency
894
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
895
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
896
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1215
+		    if (isset($line['depicao'])) {
1216
+		    	$data['departure_airport_icao'] = $line['depicao'];
1217
+		    }
1218
+		    if (isset($line['deptime'])) {
1219
+		    	$data['departure_airport_time'] = $line['deptime'];
1220
+		    }
1221
+		    if (isset($line['arricao'])) {
1222
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1223
+		    }
897 1224
 		    //$data['arrival_airport_time'] = $line['arrtime'];
898
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
899
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
900
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
901
-		    else $data['info'] = '';
1225
+		    if (isset($line['aircraft'])) {
1226
+		    	$data['aircraft_icao'] = $line['aircraft'];
1227
+		    }
1228
+		    if (isset($line['transponder'])) {
1229
+		    	$data['squawk'] = $line['transponder'];
1230
+		    }
1231
+		    if (isset($line['atis'])) {
1232
+		    	$data['info'] = $line['atis'];
1233
+		    } else {
1234
+		    	$data['info'] = '';
1235
+		    }
902 1236
 		    $data['format_source'] = 'pireps';
903 1237
     		    $data['id_source'] = $id_source;
904 1238
 		    $data['datetime'] = date('Y-m-d H:i:s');
905
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
906
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1239
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1240
+		    	$data['noarchive'] = true;
1241
+		    }
1242
+		    if (isset($value['name']) && $value['name'] != '') {
1243
+		    	$data['source_name'] = $value['name'];
1244
+		    }
907 1245
 		    if ($line['icon'] == 'plane') {
908 1246
 			$SI->add($data);
909 1247
 		    //    print_r($data);
@@ -912,16 +1250,28 @@  discard block
 block discarded – undo
912 1250
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
913 1251
 			$typec = substr($data['ident'],-3);
914 1252
 			$data['type'] = '';
915
-			if ($typec == 'APP') $data['type'] = 'Approach';
916
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
917
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
918
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
919
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
920
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
921
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
922
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
923
-			else $data['type'] = 'Observer';
924
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1253
+			if ($typec == 'APP') {
1254
+				$data['type'] = 'Approach';
1255
+			} elseif ($typec == 'TWR') {
1256
+				$data['type'] = 'Tower';
1257
+			} elseif ($typec == 'OBS') {
1258
+				$data['type'] = 'Observer';
1259
+			} elseif ($typec == 'GND') {
1260
+				$data['type'] = 'Ground';
1261
+			} elseif ($typec == 'DEL') {
1262
+				$data['type'] = 'Delivery';
1263
+			} elseif ($typec == 'DEP') {
1264
+				$data['type'] = 'Departure';
1265
+			} elseif ($typec == 'FSS') {
1266
+				$data['type'] = 'Flight Service Station';
1267
+			} elseif ($typec == 'CTR') {
1268
+				$data['type'] = 'Control Radar or Centre';
1269
+			} else {
1270
+				$data['type'] = 'Observer';
1271
+			}
1272
+			if (isset($ATC)) {
1273
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1274
+			}
925 1275
 		    }
926 1276
 		    unset($data);
927 1277
 		}
@@ -931,7 +1281,9 @@  discard block
 block discarded – undo
931 1281
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
932 1282
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
933 1283
 	    //$buffer = $Common->getData($hosts[$id]);
934
-	    if ($globalDebug) echo 'Get Data...'."\n";
1284
+	    if ($globalDebug) {
1285
+	    	echo 'Get Data...'."\n";
1286
+	    }
935 1287
 	    $buffer = $Common->getData($value['host']);
936 1288
 	    $all_data = json_decode($buffer,true);
937 1289
 	    if ($buffer != '' && is_array($all_data)) {
@@ -939,10 +1291,16 @@  discard block
 block discarded – undo
939 1291
 		foreach ($all_data as $line) {
940 1292
 	    	    $data = array();
941 1293
 	    	    //$data['id'] = $line['id']; // id not usable
942
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1294
+	    	    if (isset($line['pilotid'])) {
1295
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1296
+	    	    }
943 1297
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
944
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
945
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1298
+	    	    if (isset($line['pilotname'])) {
1299
+	    	    	$data['pilot_name'] = $line['pilotname'];
1300
+	    	    }
1301
+	    	    if (isset($line['pilotid'])) {
1302
+	    	    	$data['pilot_id'] = $line['pilotid'];
1303
+	    	    }
946 1304
 	    	    $data['ident'] = $line['flightnum']; // ident
947 1305
 	    	    $data['altitude'] = $line['alt']; // altitude
948 1306
 	    	    $data['speed'] = $line['gs']; // speed
@@ -960,28 +1318,44 @@  discard block
 block discarded – undo
960 1318
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
961 1319
     		    $data['arrival_airport_time'] = $line['arrtime'];
962 1320
     		    $data['registration'] = $line['aircraft'];
963
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
964
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1321
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1322
+		    	$data['noarchive'] = true;
1323
+		    }
1324
+		    if (isset($line['route'])) {
1325
+		    	$data['waypoints'] = $line['route'];
1326
+		    }
1327
+		    // route
965 1328
 		    if (isset($line['aircraftname'])) {
966 1329
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
967 1330
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
968 1331
 	    		$aircraft_data = explode('-',$line['aircraftname']);
969
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
970
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
971
-	    		else {
1332
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1333
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1334
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1335
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1336
+	    		} else {
972 1337
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
973
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
974
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1338
+	    		    if (isset($aircraft_data[1])) {
1339
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1340
+	    		    } else {
1341
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1342
+	    		    }
975 1343
 	    		}
976 1344
 	    	    }
977
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1345
+    		    if (isset($line['route'])) {
1346
+    		    	$data['waypoints'] = $line['route'];
1347
+    		    }
978 1348
     		    $data['id_source'] = $id_source;
979 1349
 	    	    $data['format_source'] = 'phpvmacars';
980
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1350
+		    if (isset($value['name']) && $value['name'] != '') {
1351
+		    	$data['source_name'] = $value['name'];
1352
+		    }
981 1353
 		    $SI->add($data);
982 1354
 		    unset($data);
983 1355
 		}
984
-		if ($globalDebug) echo 'No more data...'."\n";
1356
+		if ($globalDebug) {
1357
+			echo 'No more data...'."\n";
1358
+		}
985 1359
 		unset($buffer);
986 1360
 		unset($all_data);
987 1361
 	    }
@@ -989,7 +1363,9 @@  discard block
 block discarded – undo
989 1363
     	    $last_exec[$id]['last'] = time();
990 1364
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
991 1365
 	    //$buffer = $Common->getData($hosts[$id]);
992
-	    if ($globalDebug) echo 'Get Data...'."\n";
1366
+	    if ($globalDebug) {
1367
+	    	echo 'Get Data...'."\n";
1368
+	    }
993 1369
 	    $buffer = $Common->getData($value['host']);
994 1370
 	    $all_data = json_decode($buffer,true);
995 1371
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1018,16 +1394,25 @@  discard block
 block discarded – undo
1018 1394
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1019 1395
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1020 1396
     		    //$data['registration'] = $line['aircraft'];
1021
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1397
+		    if (isset($line['route'])) {
1398
+		    	$data['waypoints'] = $line['route'];
1399
+		    }
1400
+		    // route
1022 1401
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1023 1402
     		    $data['id_source'] = $id_source;
1024 1403
 	    	    $data['format_source'] = 'vam';
1025
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1026
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1404
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1405
+		    	$data['noarchive'] = true;
1406
+		    }
1407
+		    if (isset($value['name']) && $value['name'] != '') {
1408
+		    	$data['source_name'] = $value['name'];
1409
+		    }
1027 1410
 		    $SI->add($data);
1028 1411
 		    unset($data);
1029 1412
 		}
1030
-		if ($globalDebug) echo 'No more data...'."\n";
1413
+		if ($globalDebug) {
1414
+			echo 'No more data...'."\n";
1415
+		}
1031 1416
 		unset($buffer);
1032 1417
 		unset($all_data);
1033 1418
 	    }
@@ -1035,7 +1420,9 @@  discard block
 block discarded – undo
1035 1420
     	    $last_exec[$id]['last'] = time();
1036 1421
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1037 1422
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1038
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1423
+	    if (function_exists('pcntl_fork')) {
1424
+	    	pcntl_signal_dispatch();
1425
+	    }
1039 1426
     	    //$last_exec[$id]['last'] = time();
1040 1427
 
1041 1428
 	    //$read = array( $sockets[$id] );
@@ -1043,7 +1430,9 @@  discard block
 block discarded – undo
1043 1430
 	    $write = NULL;
1044 1431
 	    $e = NULL;
1045 1432
 	    $n = socket_select($read, $write, $e, $timeout);
1046
-	    if ($e != NULL) var_dump($e);
1433
+	    if ($e != NULL) {
1434
+	    	var_dump($e);
1435
+	    }
1047 1436
 	    if ($n > 0) {
1048 1437
 		$reset = 0;
1049 1438
 		foreach ($read as $nb => $r) {
@@ -1064,12 +1453,16 @@  discard block
 block discarded – undo
1064 1453
 		    //$SI::del();
1065 1454
 		    if ($format == 'vrstcp') {
1066 1455
 			$buffer = explode('},{',$buffer);
1067
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1456
+		    } else {
1457
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1458
+		    }
1068 1459
 		    // SBS format is CSV format
1069 1460
 		    if ($buffer !== FALSE && $buffer != '') {
1070 1461
 			$tt[$format] = 0;
1071 1462
 			if ($format == 'acarssbs3') {
1072
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1463
+			    if ($globalDebug) {
1464
+			    	echo 'ACARS : '.$buffer."\n";
1465
+			    }
1073 1466
 			    $ACARS->add(trim($buffer));
1074 1467
 			    $ACARS->deleteLiveAcarsData();
1075 1468
 			} elseif ($format == 'raw') {
@@ -1078,27 +1471,61 @@  discard block
 block discarded – undo
1078 1471
 			    if (is_array($data)) {
1079 1472
 				$data['datetime'] = date('Y-m-d H:i:s');
1080 1473
 				$data['format_source'] = 'raw';
1081
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1082
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1083
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1084
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1474
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1475
+					$data['source_name'] = $globalSources[$nb]['name'];
1476
+				}
1477
+				if (isset($globalSources[$nb]['sourcestats'])) {
1478
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1479
+				}
1480
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1481
+					$data['noarchive'] = true;
1482
+				}
1483
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1484
+					$SI->add($data);
1485
+				}
1085 1486
 			    }
1086 1487
 			} elseif ($format == 'ais') {
1087 1488
 			    $ais_data = $AIS->parse_line(trim($buffer));
1088 1489
 			    $data = array();
1089
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1090
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1091
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1092
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1093
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1094
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1095
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1096
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1097
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1098
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1099
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1100
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1101
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1490
+			    if (isset($ais_data['ident'])) {
1491
+			    	$data['ident'] = $ais_data['ident'];
1492
+			    }
1493
+			    if (isset($ais_data['mmsi'])) {
1494
+			    	$data['mmsi'] = $ais_data['mmsi'];
1495
+			    }
1496
+			    if (isset($ais_data['speed'])) {
1497
+			    	$data['speed'] = $ais_data['speed'];
1498
+			    }
1499
+			    if (isset($ais_data['heading'])) {
1500
+			    	$data['heading'] = $ais_data['heading'];
1501
+			    }
1502
+			    if (isset($ais_data['latitude'])) {
1503
+			    	$data['latitude'] = $ais_data['latitude'];
1504
+			    }
1505
+			    if (isset($ais_data['longitude'])) {
1506
+			    	$data['longitude'] = $ais_data['longitude'];
1507
+			    }
1508
+			    if (isset($ais_data['status'])) {
1509
+			    	$data['status'] = $ais_data['status'];
1510
+			    }
1511
+			    if (isset($ais_data['type'])) {
1512
+			    	$data['type'] = $ais_data['type'];
1513
+			    }
1514
+			    if (isset($ais_data['imo'])) {
1515
+			    	$data['imo'] = $ais_data['imo'];
1516
+			    }
1517
+			    if (isset($ais_data['callsign'])) {
1518
+			    	$data['callsign'] = $ais_data['callsign'];
1519
+			    }
1520
+			    if (isset($ais_data['destination'])) {
1521
+			    	$data['arrival_code'] = $ais_data['destination'];
1522
+			    }
1523
+			    if (isset($ais_data['eta_ts'])) {
1524
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1525
+			    }
1526
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1527
+			    	$data['noarchive'] = true;
1528
+			    }
1102 1529
 
1103 1530
 			    if (isset($ais_data['timestamp'])) {
1104 1531
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1107,7 +1534,9 @@  discard block
 block discarded – undo
1107 1534
 			    }
1108 1535
 			    $data['format_source'] = 'aisnmea';
1109 1536
     			    $data['id_source'] = $id_source;
1110
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1537
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1538
+			    	$MI->add($data);
1539
+			    }
1111 1540
 			    unset($data);
1112 1541
                         } elseif ($format == 'flightgearsp') {
1113 1542
                     	    //echo $buffer."\n";
@@ -1125,12 +1554,18 @@  discard block
 block discarded – undo
1125 1554
 				$data['speed'] = round($line[5]*1.94384);
1126 1555
 				$data['datetime'] = date('Y-m-d H:i:s');
1127 1556
 				$data['format_source'] = 'flightgearsp';
1128
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1129
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1557
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1558
+					$data['noarchive'] = true;
1559
+				}
1560
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1561
+					$SI->add($data);
1562
+				}
1130 1563
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1131 1564
 			    }
1132 1565
                         } elseif ($format == 'acars') {
1133
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1566
+                    	    if ($globalDebug) {
1567
+                    	    	echo 'ACARS : '.$buffer."\n";
1568
+                    	    }
1134 1569
 			    $ACARS->add(trim($buffer));
1135 1570
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1136 1571
 			    $ACARS->deleteLiveAcarsData();
@@ -1151,8 +1586,12 @@  discard block
 block discarded – undo
1151 1586
 				    $aircraft_type = $line[10];
1152 1587
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1153 1588
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1154
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1155
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1589
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1590
+				    	$data['noarchive'] = true;
1591
+				    }
1592
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1593
+				    	$SI->add($data);
1594
+				    }
1156 1595
 				}
1157 1596
 			    }
1158 1597
 			} elseif ($format == 'beast') {
@@ -1162,28 +1601,62 @@  discard block
 block discarded – undo
1162 1601
 			    foreach($buffer as $all_data) {
1163 1602
 				$line = json_decode('{'.$all_data.'}',true);
1164 1603
 				$data = array();
1165
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1166
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1167
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1168
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1169
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1170
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1171
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1604
+				if (isset($line['Icao'])) {
1605
+					$data['hex'] = $line['Icao'];
1606
+				}
1607
+				// hex
1608
+				if (isset($line['Call'])) {
1609
+					$data['ident'] = $line['Call'];
1610
+				}
1611
+				// ident
1612
+				if (isset($line['Alt'])) {
1613
+					$data['altitude'] = $line['Alt'];
1614
+				}
1615
+				// altitude
1616
+				if (isset($line['Spd'])) {
1617
+					$data['speed'] = $line['Spd'];
1618
+				}
1619
+				// speed
1620
+				if (isset($line['Trak'])) {
1621
+					$data['heading'] = $line['Trak'];
1622
+				}
1623
+				// heading
1624
+				if (isset($line['Lat'])) {
1625
+					$data['latitude'] = $line['Lat'];
1626
+				}
1627
+				// lat
1628
+				if (isset($line['Long'])) {
1629
+					$data['longitude'] = $line['Long'];
1630
+				}
1631
+				// long
1172 1632
 				//$data['verticalrate'] = $line['']; // verticale rate
1173
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1633
+				if (isset($line['Sqk'])) {
1634
+					$data['squawk'] = $line['Sqk'];
1635
+				}
1636
+				// squawk
1174 1637
 				$data['emergency'] = ''; // emergency
1175
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1638
+				if (isset($line['Reg'])) {
1639
+					$data['registration'] = $line['Reg'];
1640
+				}
1176 1641
 				/*
1177 1642
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1178 1643
 				else $data['datetime'] = date('Y-m-d H:i:s');
1179 1644
 				*/
1180 1645
 				$data['datetime'] = date('Y-m-d H:i:s');
1181
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1646
+				if (isset($line['Type'])) {
1647
+					$data['aircraft_icao'] = $line['Type'];
1648
+				}
1182 1649
 		    		$data['format_source'] = 'vrstcp';
1183 1650
 				$data['id_source'] = $id_source;
1184
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1185
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1186
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1651
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1652
+					$data['noarchive'] = true;
1653
+				}
1654
+				if (isset($value['name']) && $value['name'] != '') {
1655
+					$data['source_name'] = $value['name'];
1656
+				}
1657
+				if (isset($data['latitude']) && isset($data['hex'])) {
1658
+					$SI->add($data);
1659
+				}
1187 1660
 				unset($data);
1188 1661
 			    }
1189 1662
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1196,22 +1669,46 @@  discard block
 block discarded – undo
1196 1669
     				$data['hex'] = $lined['hexid'];
1197 1670
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1198 1671
     				$data['datetime'] = date('Y-m-d H:i:s');;
1199
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1200
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1201
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1202
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1203
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1204
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1205
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1672
+    				if (isset($lined['ident'])) {
1673
+    					$data['ident'] = $lined['ident'];
1674
+    				}
1675
+    				if (isset($lined['lat'])) {
1676
+    					$data['latitude'] = $lined['lat'];
1677
+    				}
1678
+    				if (isset($lined['lon'])) {
1679
+    					$data['longitude'] = $lined['lon'];
1680
+    				}
1681
+    				if (isset($lined['speed'])) {
1682
+    					$data['speed'] = $lined['speed'];
1683
+    				}
1684
+    				if (isset($lined['squawk'])) {
1685
+    					$data['squawk'] = $lined['squawk'];
1686
+    				}
1687
+    				if (isset($lined['alt'])) {
1688
+    					$data['altitude'] = $lined['alt'];
1689
+    				}
1690
+    				if (isset($lined['heading'])) {
1691
+    					$data['heading'] = $lined['heading'];
1692
+    				}
1206 1693
     				$data['id_source'] = $id_source;
1207 1694
     				$data['format_source'] = 'tsv';
1208
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1209
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1210
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1211
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1695
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1696
+    					$data['source_name'] = $globalSources[$nb]['name'];
1697
+    				}
1698
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1699
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1700
+    				}
1701
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1702
+					$data['noarchive'] = true;
1703
+				}
1704
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1705
+    					$SI->add($data);
1706
+    				}
1212 1707
     				unset($lined);
1213 1708
     				unset($data);
1214
-    			    } else $error = true;
1709
+    			    } else {
1710
+    			    	$error = true;
1711
+    			    }
1215 1712
 			} elseif ($format == 'aprs' && $use_aprs) {
1216 1713
 			    if ($aprs_connect == 0) {
1217 1714
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1236,32 +1733,66 @@  discard block
 block discarded – undo
1236 1733
 				    $aprs_last_tx = time();
1237 1734
 				    $data = array();
1238 1735
 				    //print_r($line);
1239
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1240
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1241
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1242
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1736
+				    if (isset($line['address'])) {
1737
+				    	$data['hex'] = $line['address'];
1738
+				    }
1739
+				    if (isset($line['mmsi'])) {
1740
+				    	$data['mmsi'] = $line['mmsi'];
1741
+				    }
1742
+				    if (isset($line['timestamp'])) {
1743
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1744
+				    } else {
1745
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1746
+				    }
1243 1747
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1244
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1748
+				    if (isset($line['ident'])) {
1749
+				    	$data['ident'] = $line['ident'];
1750
+				    }
1245 1751
 				    $data['latitude'] = $line['latitude'];
1246 1752
 				    $data['longitude'] = $line['longitude'];
1247 1753
 				    //$data['verticalrate'] = $line[16];
1248
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1249
-				    else $data['speed'] = 0;
1250
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1251
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1252
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1253
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1754
+				    if (isset($line['speed'])) {
1755
+				    	$data['speed'] = $line['speed'];
1756
+				    } else {
1757
+				    	$data['speed'] = 0;
1758
+				    }
1759
+				    if (isset($line['altitude'])) {
1760
+				    	$data['altitude'] = $line['altitude'];
1761
+				    }
1762
+				    if (isset($line['comment'])) {
1763
+				    	$data['comment'] = $line['comment'];
1764
+				    }
1765
+				    if (isset($line['symbol'])) {
1766
+				    	$data['type'] = $line['symbol'];
1767
+				    }
1768
+				    if (isset($line['heading'])) {
1769
+				    	$data['heading'] = $line['heading'];
1770
+				    }
1254 1771
 				    //else $data['heading'] = 0;
1255
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1256
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) $data['noarchive'] = true;
1257
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1772
+				    if (isset($line['stealth'])) {
1773
+				    	$data['aircraft_type'] = $line['stealth'];
1774
+				    }
1775
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE)) {
1776
+				    	$data['noarchive'] = true;
1777
+				    }
1778
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1779
+				    	$data['noarchive'] = true;
1780
+				    }
1258 1781
     				    $data['id_source'] = $id_source;
1259
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1260
-				    else $data['format_source'] = 'aprs';
1782
+    				    if (isset($line['format_source'])) {
1783
+    				    	$data['format_source'] = $line['format_source'];
1784
+    				    } else {
1785
+				    	$data['format_source'] = 'aprs';
1786
+				    }
1261 1787
 				    $data['source_name'] = $line['source'];
1262
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1263
-				    else $data['source_type'] = 'flarm';
1264
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1788
+				    if (isset($line['source_type'])) {
1789
+				    	$data['source_type'] = $line['source_type'];
1790
+				    } else {
1791
+				    	$data['source_type'] = 'flarm';
1792
+				    }
1793
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1794
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1795
+    				    }
1265 1796
 				    $currentdate = date('Y-m-d H:i:s');
1266 1797
 				    $aprsdate = strtotime($data['datetime']);
1267 1798
 				    // Accept data if time <= system time + 20s
@@ -1271,19 +1802,22 @@  discard block
 block discarded – undo
1271 1802
 					echo 'add...'."\n";
1272 1803
 					$send = $MI->add($data);
1273 1804
 				    } elseif (isset($line['stealth'])) {
1274
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1275
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1805
+					if ($line['stealth'] != 0) {
1806
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1807
+					} else {
1808
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1809
+					}
1276 1810
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1277 1811
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1278 1812
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1279
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1813
+					if (isset($globalTracker) && $globalTracker) {
1814
+						$send = $TI->add($data);
1815
+					}
1280 1816
 				    }
1281 1817
 				    unset($data);
1282
-				} 
1283
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1818
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1284 1819
 					echo '!! Weather Station not yet supported'."\n";
1285
-				}
1286
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1820
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
1287 1821
 					echo '!! Car & Trucks not yet supported'."\n";
1288 1822
 				}
1289 1823
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1316,26 +1850,45 @@  discard block
 block discarded – undo
1316 1850
     				$data['ground'] = $line[21];
1317 1851
     				$data['emergency'] = $line[19];
1318 1852
     				$data['format_source'] = 'sbs';
1319
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1320
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1321
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1853
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1854
+					$data['source_name'] = $globalSources[$nb]['name'];
1855
+				}
1856
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1857
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1858
+    				}
1859
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1860
+					$data['noarchive'] = true;
1861
+				}
1322 1862
     				$data['id_source'] = $id_source;
1323
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1324
-    				else $error = true;
1863
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1864
+    					$send = $SI->add($data);
1865
+    				} else {
1866
+    					$error = true;
1867
+    				}
1325 1868
     				unset($data);
1326
-    			    } else $error = true;
1869
+    			    } else {
1870
+    			    	$error = true;
1871
+    			    }
1327 1872
 			    if ($error) {
1328 1873
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1329
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1874
+					if ($globalDebug) {
1875
+						echo "Not a message. Ignoring... \n";
1876
+					}
1330 1877
 				} else {
1331
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1878
+					if ($globalDebug) {
1879
+						echo "Wrong line format. Ignoring... \n";
1880
+					}
1332 1881
 					if ($globalDebug) {
1333 1882
 						echo $buffer;
1334 1883
 						//print_r($line);
1335 1884
 					}
1336 1885
 					//socket_close($r);
1337
-					if ($globalDebug) echo "Reconnect after an error...\n";
1338
-					if ($format == 'aprs') $aprs_connect = 0;
1886
+					if ($globalDebug) {
1887
+						echo "Reconnect after an error...\n";
1888
+					}
1889
+					if ($format == 'aprs') {
1890
+						$aprs_connect = 0;
1891
+					}
1339 1892
 					$sourceer[$nb] = $globalSources[$nb];
1340 1893
 					connect_all($sourceer);
1341 1894
 					$sourceer = array();
@@ -1343,10 +1896,14 @@  discard block
 block discarded – undo
1343 1896
 			    }
1344 1897
 			}
1345 1898
 			// Sleep for xxx microseconds
1346
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1899
+			if (isset($globalSBSSleep)) {
1900
+				usleep($globalSBSSleep);
1901
+			}
1347 1902
 		    } else {
1348 1903
 			if ($format == 'flightgearmp') {
1349
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1904
+			    	if ($globalDebug) {
1905
+			    		echo "Reconnect FlightGear MP...";
1906
+			    	}
1350 1907
 				//@socket_close($r);
1351 1908
 				sleep($globalMinFetch);
1352 1909
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1355,10 +1912,15 @@  discard block
 block discarded – undo
1355 1912
 				break;
1356 1913
 				
1357 1914
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1358
-			    if (isset($tt[$format])) $tt[$format]++;
1359
-			    else $tt[$format] = 0;
1915
+			    if (isset($tt[$format])) {
1916
+			    	$tt[$format]++;
1917
+			    } else {
1918
+			    	$tt[$format] = 0;
1919
+			    }
1360 1920
 			    if ($tt[$format] > 30) {
1361
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1921
+				if ($globalDebug) {
1922
+					echo "ERROR : Reconnect ".$format."...";
1923
+				}
1362 1924
 				//@socket_close($r);
1363 1925
 				sleep(2);
1364 1926
 				$aprs_connect = 0;
@@ -1375,11 +1937,17 @@  discard block
 block discarded – undo
1375 1937
 	    } else {
1376 1938
 		$error = socket_strerror(socket_last_error());
1377 1939
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1378
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1379
-			if (isset($globalDebug)) echo "Restarting...\n";
1940
+			if ($globalDebug) {
1941
+				echo "ERROR : socket_select give this error ".$error . "\n";
1942
+			}
1943
+			if (isset($globalDebug)) {
1944
+				echo "Restarting...\n";
1945
+			}
1380 1946
 			// Restart the script if possible
1381 1947
 			if (is_array($sockets)) {
1382
-			    if ($globalDebug) echo "Shutdown all sockets...";
1948
+			    if ($globalDebug) {
1949
+			    	echo "Shutdown all sockets...";
1950
+			    }
1383 1951
 			    
1384 1952
 			    foreach ($sockets as $sock) {
1385 1953
 				@socket_shutdown($sock,2);
@@ -1387,21 +1955,33 @@  discard block
 block discarded – undo
1387 1955
 			    }
1388 1956
 			    
1389 1957
 			}
1390
-			if ($globalDebug) echo "Restart all connections...";
1958
+			if ($globalDebug) {
1959
+				echo "Restart all connections...";
1960
+			}
1391 1961
 			sleep(2);
1392 1962
 			$time = time();
1393 1963
 			//connect_all($hosts);
1394 1964
 			$aprs_connect = 0;
1395
-			if ($reset%5 == 0) sleep(20);
1396
-			if ($reset%10 == 0) sleep(100);
1397
-			if ($reset%20 == 0) sleep(200);
1398
-			if ($reset > 100) exit('Too many attempts...');
1965
+			if ($reset%5 == 0) {
1966
+				sleep(20);
1967
+			}
1968
+			if ($reset%10 == 0) {
1969
+				sleep(100);
1970
+			}
1971
+			if ($reset%20 == 0) {
1972
+				sleep(200);
1973
+			}
1974
+			if ($reset > 100) {
1975
+				exit('Too many attempts...');
1976
+			}
1399 1977
 			connect_all($globalSources);
1400 1978
 		}
1401 1979
 	    }
1402 1980
 	}
1403 1981
 	if ($globalDaemon === false) {
1404
-	    if ($globalDebug) echo 'Check all...'."\n";
1982
+	    if ($globalDebug) {
1983
+	    	echo 'Check all...'."\n";
1984
+	    }
1405 1985
 	    $SI->checkAll();
1406 1986
 	}
1407 1987
     }
Please login to merge, or discard this patch.