Completed
Push — master ( d37442...9b55c0 )
by Yannick
30:57
created
install/index.php 1 patch
Braces   +639 added lines, -170 removed lines patch added patch discarded remove patch
@@ -4,12 +4,22 @@  discard block
 block discarded – undo
4 4
 if (isset($_SESSION['error'])) {
5 5
 	header('Content-Encoding: none;');
6 6
 	echo 'Error : '.$_SESSION['error'].' - Resetting install... You need to fix the problem and run install again.';
7
-	if (isset($_SESSION['error'])) unset($_SESSION['error']);
8
-	if (isset($_SESSION['errorlst'])) unset($_SESSION['errorlst']);
9
-	if (isset($_SESSION['next'])) unset($_SESSION['next']);
10
-	if (isset($_SESSION['install'])) unset($_SESSION['install']);
11
-	if (isset($_SESSION['identitied'])) unset($_SESSION['identified']);
12
-}
7
+	if (isset($_SESSION['error'])) {
8
+		unset($_SESSION['error']);
9
+	}
10
+	if (isset($_SESSION['errorlst'])) {
11
+		unset($_SESSION['errorlst']);
12
+	}
13
+	if (isset($_SESSION['next'])) {
14
+		unset($_SESSION['next']);
15
+	}
16
+	if (isset($_SESSION['install'])) {
17
+		unset($_SESSION['install']);
18
+	}
19
+	if (isset($_SESSION['identitied'])) {
20
+		unset($_SESSION['identified']);
21
+	}
22
+	}
13 23
 /*
14 24
 if (isset($_SESSION['errorlst'])) {
15 25
 	header('Content-Encoding: none;');
@@ -128,7 +138,9 @@  discard block
 block discarded – undo
128 138
 		if (count($alllng) != count($availablelng)) {
129 139
 			$notavailable = array();
130 140
 			foreach($alllng as $lng) {
131
-				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
141
+				if (!isset($availablelng[$lng])) {
142
+					$notavailable[] = $lng;
143
+				}
132 144
 			}
133 145
 			print '<div class="alert alert-warning">The following translation can\'t be used on your system: '.implode(', ',$notavailable).'. You need to add the system locales: <a href="https://github.com/Ysurac/FlightAirMap/wiki/Translation">documentation</a>.</div>';
134 146
 		}
@@ -167,7 +179,10 @@  discard block
 block discarded – undo
167 179
 			<legend>Install script configuration</legend>
168 180
 			<p>
169 181
 				<label for="installpass">Install password</label>
170
-				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) print $globalInstallPassword; ?>" />
182
+				<input type="password" name="installpass" id="installpass" value="<?php if (isset($globalInstallPassword)) {
183
+	print $globalInstallPassword;
184
+}
185
+?>" />
171 186
 			</p>
172 187
 			<p class="help-block">Password needed to access this install script. If empty, to access this script,  you will need to change the $globalInstalled setting in require/settings.php to FALSE</p>
173 188
 		</fieldset>
@@ -197,31 +212,49 @@  discard block
 block discarded – undo
197 212
 			</div>
198 213
 			<p>
199 214
 				<label for="dbhost">Database hostname</label>
200
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
215
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
216
+	print $globalDBhost;
217
+}
218
+?>" />
201 219
 			</p>
202 220
 			<p>
203 221
 				<label for="dbport">Database port</label>
204
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
222
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
223
+	print $globalDBport;
224
+}
225
+?>" />
205 226
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
206 227
 			</p>
207 228
 			<p>
208 229
 				<label for="dbname">Database name</label>
209
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
230
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
231
+	print $globalDBname;
232
+}
233
+?>" />
210 234
 			</p>
211 235
 			<p>
212 236
 				<label for="dbuser">Database user</label>
213
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
237
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
238
+	print $globalDBuser;
239
+}
240
+?>" />
214 241
 			</p>
215 242
 			<p>
216 243
 				<label for="dbuserpass">Database user password</label>
217
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
244
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
245
+	print $globalDBpass;
246
+}
247
+?>" />
218 248
 			</p>
219 249
 		</fieldset>
220 250
 		<fieldset id="site">
221 251
 			<legend>Site configuration</legend>
222 252
 			<p>
223 253
 				<label for="sitename">Site name</label>
224
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
254
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
255
+	print $globalName;
256
+}
257
+?>" />
225 258
 			</p>
226 259
 			<p>
227 260
 				<label for="siteurl">Site directory</label>
@@ -234,18 +267,27 @@  discard block
 block discarded – undo
234 267
 					}
235 268
 				    }
236 269
 				?>
237
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
270
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
271
+	print $globalURL;
272
+}
273
+?>" />
238 274
 				<p class="help-block">ex : <i>/flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
239 275
 				<p class="help-block">Can be empty</p>
240 276
 			</p>
241 277
 			<p>
242 278
 				<label for="timezone">Timezone</label>
243
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
279
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
280
+	print $globalTimezone;
281
+}
282
+?>" />
244 283
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
245 284
 			</p>
246 285
 			<p>
247 286
 				<label for="language">Language</label>
248
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
287
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
288
+	print $globalLanguage;
289
+}
290
+?>" />
249 291
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
250 292
 			</p>
251 293
 		</fieldset>
@@ -265,11 +307,17 @@  discard block
 block discarded – undo
265 307
 			<div id="mapbox_data">
266 308
 				<p>
267 309
 					<label for="mapboxid">Mapbox id</label>
268
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
310
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
311
+	print $globalMapboxId;
312
+}
313
+?>" />
269 314
 				</p>
270 315
 				<p>
271 316
 					<label for="mapboxtoken">Mapbox token</label>
272
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
317
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
318
+	print $globalMapboxToken;
319
+}
320
+?>" />
273 321
 				</p>
274 322
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
275 323
 			</div>
@@ -277,7 +325,10 @@  discard block
 block discarded – undo
277 325
 			<div id="google_data">
278 326
 				<p>
279 327
 					<label for="googlekey">Google API key</label>
280
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
328
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
329
+	print $globalGoogleAPIKey;
330
+}
331
+?>" />
281 332
 					<p class="help-block">Get a key <a href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">here</a></p>
282 333
 				</p>
283 334
 			</div>
@@ -285,7 +336,10 @@  discard block
 block discarded – undo
285 336
 			<div id="bing_data">
286 337
 				<p>
287 338
 					<label for="bingkey">Bing Map key</label>
288
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
339
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
340
+	print $globalBingMapKey;
341
+}
342
+?>" />
289 343
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
290 344
 				</p>
291 345
 			</div>
@@ -293,7 +347,10 @@  discard block
 block discarded – undo
293 347
 			<div id="mapquest_data">
294 348
 				<p>
295 349
 					<label for="mapquestkey">MapQuest key</label>
296
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
350
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
351
+	print $globalMapQuestKey;
352
+}
353
+?>" />
297 354
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
298 355
 				</p>
299 356
 			</div>
@@ -301,11 +358,17 @@  discard block
 block discarded – undo
301 358
 			<div id="here_data">
302 359
 				<p>
303 360
 					<label for="hereappid">Here App_Id</label>
304
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
361
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
362
+	print $globalHereappId;
363
+}
364
+?>" />
305 365
 				</p>
306 366
 				<p>
307 367
 					<label for="hereappcode">Here App_Code</label>
308
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
368
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
369
+	print $globalHereappCode;
370
+}
371
+?>" />
309 372
 				</p>
310 373
 				<p class="help-block">Get a key <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-tile/topics/quick-start.html">here</a></p>
311 374
 			</div>
@@ -313,7 +376,10 @@  discard block
 block discarded – undo
313 376
 			<div id="openweathermap_data">
314 377
 				<p>
315 378
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
316
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
379
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
380
+	print $globalOpenWeatherMapKey;
381
+}
382
+?>" />
317 383
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
318 384
 				</p>
319 385
 			</div>
@@ -342,42 +408,86 @@  discard block
 block discarded – undo
342 408
 			<legend>Coverage area</legend>
343 409
 			<p>
344 410
 				<label for="latitudemax">The maximum latitude (north)</label>
345
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
411
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
412
+	print $globalLatitudeMax;
413
+}
414
+?>" />
346 415
 			</p>
347 416
 			<p>
348 417
 				<label for="latitudemin">The minimum latitude (south)</label>
349
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
418
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
419
+	print $globalLatitudeMin;
420
+}
421
+?>" />
350 422
 			</p>
351 423
 			<p>
352 424
 				<label for="longitudemax">The maximum longitude (west)</label>
353
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
425
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
426
+	print $globalLongitudeMax;
427
+}
428
+?>" />
354 429
 			</p>
355 430
 			<p>
356 431
 				<label for="longitudemin">The minimum longitude (east)</label>
357
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
432
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
433
+	print $globalLongitudeMin;
434
+}
435
+?>" />
358 436
 			</p>
359 437
 			<p>
360 438
 				<label for="latitudecenter">The latitude center</label>
361
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
439
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
440
+	print $globalCenterLatitude;
441
+}
442
+?>" />
362 443
 			</p>
363 444
 			<p>
364 445
 				<label for="longitudecenter">The longitude center</label>
365
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
446
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
447
+	print $globalCenterLongitude;
448
+}
449
+?>" />
366 450
 			</p>
367 451
 			<p>
368 452
 				<label for="livezoom">Default Zoom on live map</label>
369
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
453
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
454
+	print $globalLiveZoom;
455
+} else {
456
+	print '9';
457
+}
458
+?>" />
370 459
 			</p>
371 460
 			<p>
372 461
 				<label for="squawk_country">Country for squawk usage</label>
373 462
 				<select name="squawk_country" id="squawk_country">
374
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
375
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
376
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
377
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
378
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
379
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
380
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
463
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
464
+	print ' selected ';
465
+}
466
+?>>UK</option>
467
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
468
+	print ' selected ';
469
+}
470
+?>>NZ</option>
471
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
472
+	print ' selected ';
473
+}
474
+?>>US</option>
475
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
476
+	print ' selected ';
477
+}
478
+?>>AU</option>
479
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
480
+	print ' selected ';
481
+}
482
+?>>NL</option>
483
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
484
+	print ' selected ';
485
+}
486
+?>>FR</option>
487
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
488
+	print ' selected ';
489
+}
490
+?>>TR</option>
381 491
 				</select>
382 492
 			</p>
383 493
 		</fieldset>
@@ -386,15 +496,24 @@  discard block
 block discarded – undo
386 496
 			<p><i>Only put in DB flights that are inside a circle</i></p>
387 497
 			<p>
388 498
 				<label for="latitude">Center latitude</label>
389
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
499
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
500
+	echo $globalDistanceIgnore['latitude'];
501
+}
502
+?>" />
390 503
 			</p>
391 504
 			<p>
392 505
 				<label for="longitude">Center longitude</label>
393
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
506
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
507
+	echo $globalDistanceIgnore['longitude'];
508
+}
509
+?>" />
394 510
 			</p>
395 511
 			<p>
396 512
 				<label for="Distance">Distance (in km)</label>
397
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
513
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
514
+	echo $globalDistanceIgnore['distance'];
515
+}
516
+?>" />
398 517
 			</p>
399 518
 		</fieldset>
400 519
 		<fieldset id="sourceloc">
@@ -517,22 +636,34 @@  discard block
 block discarded – undo
517 636
 			<div id="flightaware_data">
518 637
 				<p>
519 638
 					<label for="flightawareusername">FlightAware username</label>
520
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
639
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
640
+	print $globalFlightAwareUsername;
641
+}
642
+?>" />
521 643
 				</p>
522 644
 				<p>
523 645
 					<label for="flightawarepassword">FlightAware password/API key</label>
524
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
646
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
647
+	print $globalFlightAwarePassword;
648
+}
649
+?>" />
525 650
 				</p>
526 651
 			</div>
527 652
 -->
528 653
 			<div id="sailaway_data">
529 654
 				<p>
530 655
 					<label for="sailawayemail">Sailaway email</label>
531
-					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) print $globalSailaway['email']; ?>" />
656
+					<input type="text" name="sailawayemail" id="sailawayemail" value="<?php if (isset($globalSailaway['email'])) {
657
+	print $globalSailaway['email'];
658
+}
659
+?>" />
532 660
 				</p>
533 661
 				<p>
534 662
 					<label for="sailawaypassword">Sailaway password</label>
535
-					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) print $globalSailaway['password']; ?>" />
663
+					<input type="text" name="sailawaypassword" id="sailawaypassword" value="<?php if (isset($globalSailaway['password'])) {
664
+	print $globalSailaway['password'];
665
+}
666
+?>" />
536 667
 				</p>
537 668
 			</div>
538 669
 
@@ -574,7 +705,10 @@  discard block
 block discarded – undo
574 705
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
575 706
 								?>
576 707
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
577
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
708
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
709
+	print $source['port'];
710
+}
711
+?>" /></td>
578 712
 								<?php
579 713
 								    } else {
580 714
 									$hostport = explode(':',$source['host']);
@@ -593,37 +727,118 @@  discard block
 block discarded – undo
593 727
 								?>
594 728
 								<td>
595 729
 									<select name="format[]" id="format">
596
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
597
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
598
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
599
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
600
-										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') print 'selected'; ?>>Dump1090 aircraft.json</option>
601
-										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') print 'selected'; ?>>Planefinder client</option>
602
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
603
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
604
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
605
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
606
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
607
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
608
-										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>Virtual Airline Operations System (VAOS)</option>
609
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
610
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
611
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
612
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
613
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
614
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
615
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
616
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
617
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
618
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
619
-										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') print 'selected'; ?>>Sailaway</option>
730
+										<option value="auto" <?php if (!isset($source['format'])) {
731
+	print 'selected';
732
+}
733
+?>>Auto</option>
734
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
735
+	print 'selected';
736
+}
737
+?>>SBS</option>
738
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
739
+	print 'selected';
740
+}
741
+?>>TSV</option>
742
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
743
+	print 'selected';
744
+}
745
+?>>Raw</option>
746
+										<option value="aircraftjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftjson') {
747
+	print 'selected';
748
+}
749
+?>>Dump1090 aircraft.json</option>
750
+										<option value="planefinderclient" <?php if (isset($source['format']) && $source['format'] == 'planefinderclient') {
751
+	print 'selected';
752
+}
753
+?>>Planefinder client</option>
754
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
755
+	print 'selected';
756
+}
757
+?>>APRS</option>
758
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
759
+	print 'selected';
760
+}
761
+?>>Radarcape deltadb.txt</option>
762
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
763
+	print 'selected';
764
+}
765
+?>>Vatsim</option>
766
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
767
+	print 'selected';
768
+}
769
+?>>Virtual Radar Server AircraftList.json</option>
770
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
771
+	print 'selected';
772
+}
773
+?>>Virtual Radar Server TCP</option>
774
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
775
+	print 'selected';
776
+}
777
+?>>phpVMS</option>
778
+										<option value="vaos" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
779
+	print 'selected';
780
+}
781
+?>>Virtual Airline Operations System (VAOS)</option>
782
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
783
+	print 'selected';
784
+}
785
+?>>Virtual Airlines Manager</option>
786
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
787
+	print 'selected';
788
+}
789
+?>>IVAO</option>
790
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
791
+	print 'selected';
792
+}
793
+?>>FlightGear Multiplayer</option>
794
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
795
+	print 'selected';
796
+}
797
+?>>FlightGear Singleplayer</option>
798
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
799
+	print 'selected';
800
+}
801
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
802
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
803
+	print 'selected';
804
+}
805
+?>>ACARS SBS-3 over TCP</option>
806
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
807
+	print 'selected';
808
+}
809
+?>>NMEA AIS over TCP</option>
810
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
811
+	print 'selected';
812
+}
813
+?>>AirWhere website</option>
814
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
815
+	print 'selected';
816
+}
817
+?>>HidnSeek Callback</option>
818
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
819
+	print 'selected';
820
+}
821
+?>>Blitzortung</option>
822
+										<option value="sailaway" <?php if (isset($source['format']) && $source['format'] == 'sailaway') {
823
+	print 'selected';
824
+}
825
+?>>Sailaway</option>
620 826
 									</select>
621 827
 								</td>
622 828
 								<td>
623
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
829
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
830
+	print $source['name'];
831
+}
832
+?>" />
624 833
 								</td>
625
-								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) print 'checked'; ?> /></td>
626
-								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) print 'checked'; ?> /></td>
834
+								<td><input type="checkbox" name="sourcestats[]" id="sourcestats" title="Create statistics for the source like number of messages, distance,..." value="1" <?php if (isset($source['sourcestats']) && $source['sourcestats']) {
835
+	print 'checked';
836
+}
837
+?> /></td>
838
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
839
+	print 'checked';
840
+}
841
+?> /></td>
627 842
 								<td>
628 843
 									<select name="timezones[]" id="timezones">
629 844
 								<?php
@@ -633,7 +848,9 @@  discard block
 block discarded – undo
633 848
 											print '<option selected>'.$timezones.'</option>';
634 849
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
635 850
 											print '<option selected>'.$timezones.'</option>';
636
-										} else print '<option>'.$timezones.'</option>';
851
+										} else {
852
+											print '<option>'.$timezones.'</option>';
853
+										}
637 854
 									}
638 855
 								?>
639 856
 									</select>
@@ -687,7 +904,9 @@  discard block
 block discarded – undo
687 904
 									foreach($timezonelist as $timezones){
688 905
 										if ($timezones == 'UTC') {
689 906
 											print '<option selected>'.$timezones.'</option>';
690
-										} else print '<option>'.$timezones.'</option>';
907
+										} else {
908
+											print '<option>'.$timezones.'</option>';
909
+										}
691 910
 									}
692 911
 								?>
693 912
 									</select>
@@ -712,11 +931,17 @@  discard block
 block discarded – undo
712 931
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
713 932
 					<p>
714 933
 						<label for="acarshost">ACARS UDP host</label>
715
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
934
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
935
+	print $globalACARSHost;
936
+}
937
+?>" />
716 938
 					</p>
717 939
 					<p>
718 940
 						<label for="acarsport">ACARS UDP port</label>
719
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
941
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
942
+	print $globalACARSPort;
943
+}
944
+?>" />
720 945
 					</p>
721 946
 					<p class="help-block"><i>daemon-acars.php</i> can only be run as daemon. It's an alternate script for ACARS data, <i>daemon-spotter.php</i> may be better.</p>
722 947
 				</fieldset>
@@ -743,17 +968,38 @@  discard block
 block discarded – undo
743 968
 				    <td><input type="url" name="newsurl[]" value="<?php print $feed; ?>"/></td>
744 969
 				    <td>
745 970
 					<select name="newslang[]">
746
-					    <option value="en"<?php if ($lng == 'en') print ' selected'; ?>>English</option>
747
-					    <option value="fr"<?php if ($lng == 'fr') print ' selected'; ?>>French</option>
971
+					    <option value="en"<?php if ($lng == 'en') {
972
+	print ' selected';
973
+}
974
+?>>English</option>
975
+					    <option value="fr"<?php if ($lng == 'fr') {
976
+	print ' selected';
977
+}
978
+?>>French</option>
748 979
 					</select>
749 980
 				    </td>
750 981
 				    <td>
751 982
 					<select name="newstype[]">
752
-					    <option value="global"<?php if ($type == 'global') print ' selected'; ?>>Global</option>
753
-					    <option value="aircraft"<?php if ($type == 'aircraft') print ' selected'; ?>>Aircraft</option>
754
-					    <option value="marine"<?php if ($type == 'marine') print ' selected'; ?>>Marine</option>
755
-					    <option value="tracker"<?php if ($type == 'tracker') print ' selected'; ?>>Tracker</option>
756
-					    <option value="satellite"<?php if ($type == 'Satellite') print ' selected'; ?>>Satellite</option>
983
+					    <option value="global"<?php if ($type == 'global') {
984
+	print ' selected';
985
+}
986
+?>>Global</option>
987
+					    <option value="aircraft"<?php if ($type == 'aircraft') {
988
+	print ' selected';
989
+}
990
+?>>Aircraft</option>
991
+					    <option value="marine"<?php if ($type == 'marine') {
992
+	print ' selected';
993
+}
994
+?>>Marine</option>
995
+					    <option value="tracker"<?php if ($type == 'tracker') {
996
+	print ' selected';
997
+}
998
+?>>Tracker</option>
999
+					    <option value="satellite"<?php if ($type == 'Satellite') {
1000
+	print ' selected';
1001
+}
1002
+?>>Satellite</option>
757 1003
 					</select>
758 1004
 				    </td>
759 1005
 				    <td><input type="button" value="Delete" onclick="deleteRowNews(this)" /> <input type="button" value="Add" onclick="insRowNews()" /></td>
@@ -837,7 +1083,10 @@  discard block
 block discarded – undo
837 1083
 			</p>
838 1084
 			<p>
839 1085
 				<label for="corsproxy">CORS proxy</label>
840
-				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) print $globalCORSproxy; else print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
1086
+				<input type="text" name="corsproxy" id="corsproxy" value="<?php if (isset($globalCORSproxy)) {
1087
+	print $globalCORSproxy;
1088
+} else {
1089
+	print 'https://galvanize-cors-proxy.herokuapp.com/' ?>" />
841 1090
 				<p class="help-block">CORS proxy used for some WMS servers</p>
842 1091
 			</p>
843 1092
 <!--
@@ -900,13 +1149,18 @@  discard block
 block discarded – undo
900 1149
 			<div id="schedules_options">
901 1150
 				<p>
902 1151
 					<label for="britishairways">British Airways API Key</label>
903
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
1152
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey;
1153
+}
1154
+?>" />
904 1155
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
905 1156
 				</p>
906 1157
 				<!--
907 1158
 				<p>
908 1159
 					<label for="transavia">Transavia Test API Consumer Key</label>
909
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
1160
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
1161
+	print $globalTransaviaKey;
1162
+}
1163
+?>" />
910 1164
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
911 1165
 				</p>
912 1166
 				-->
@@ -915,10 +1169,16 @@  discard block
 block discarded – undo
915 1169
 						<b>Lufthansa API Key</b>
916 1170
 						<p>
917 1171
 							<label for="lufthansakey">Key</label>
918
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
1172
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
1173
+	print $globalLufthansaKey['key'];
1174
+}
1175
+?>" />
919 1176
 						</p><p>
920 1177
 							<label for="lufthansasecret">Secret</label>
921
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
1178
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
1179
+	print $globalLufthansaKey['secret'];
1180
+}
1181
+?>" />
922 1182
 						</p>
923 1183
 					</div>
924 1184
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -928,11 +1188,17 @@  discard block
 block discarded – undo
928 1188
 						<b>FlightAware API Key</b>
929 1189
 						<p>
930 1190
 							<label for="flightawareusername">Username</label>
931
-							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
1191
+							<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
1192
+	print $globalFlightAwareUsername;
1193
+}
1194
+?>" />
932 1195
 						</p>
933 1196
 						<p>
934 1197
 							<label for="flightawarepassword">API key</label>
935
-							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
1198
+							<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
1199
+	print $globalFlightAwarePassword;
1200
+}
1201
+?>" />
936 1202
 						</p>
937 1203
 					</div>
938 1204
 					<p class="help-block">Register an account on <a href="https://www.flightaware.com/">https://www.flightaware.com/</a></p>
@@ -949,10 +1215,22 @@  discard block
 block discarded – undo
949 1215
 				<p>
950 1216
 					<label for="mapmatchingsource">Map Matching source</label>
951 1217
 					<select name="mapmatchingsource" id="mapmatchingsource">
952
-						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) print 'selected="selected" '; ?>>FlightAirMap Map Matching</option>
953
-						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') print 'selected="selected" '; ?>>GraphHopper</option>
954
-						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') print 'selected="selected" '; ?>>OSMR</option>
955
-						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') print 'selected="selected" '; ?>>Mapbox</option>
1218
+						<option value="fam" <?php if ((isset($globalMapMatchingSource) && $globalMapMatchingSource == 'fam') || !isset($globalMatchingSource)) {
1219
+	print 'selected="selected" ';
1220
+}
1221
+?>>FlightAirMap Map Matching</option>
1222
+						<option value="graphhopper" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'graphhopper') {
1223
+	print 'selected="selected" ';
1224
+}
1225
+?>>GraphHopper</option>
1226
+						<option value="osmr" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'osmr') {
1227
+	print 'selected="selected" ';
1228
+}
1229
+?>>OSMR</option>
1230
+						<option value="mapbox" <?php if (isset($globalMapMatchingSource) && $globalMapMatchingSource == 'mapbox') {
1231
+	print 'selected="selected" ';
1232
+}
1233
+?>>Mapbox</option>
956 1234
 					</select>
957 1235
 					<p class="help-block">Mapbox need the API Key defined in map section.</p>
958 1236
 					<p class="help-block">FlightAirMap Map Matching is free, without API key but limited to about 100 input points to keep fast results.</p>
@@ -960,7 +1238,10 @@  discard block
 block discarded – undo
960 1238
 				<br />
961 1239
 				<p>
962 1240
 					<label for="graphhopper">GraphHopper API Key</label>
963
-					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) print $globalGraphHopperKey; ?>" />
1241
+					<input type="text" name="graphhopper" id="graphhopper" value="<?php if (isset($globalGraphHopperKey)) {
1242
+	print $globalGraphHopperKey;
1243
+}
1244
+?>" />
964 1245
 					<p class="help-block">Register an account on <a href="https://www.graphhopper.com/">https://www.graphhopper.com/</a></p>
965 1246
 				</p>
966 1247
 			</div>
@@ -978,7 +1259,10 @@  discard block
 block discarded – undo
978 1259
 			</p>
979 1260
 			<p>
980 1261
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
981
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
1262
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
1263
+	print $globalNOTAMSource;
1264
+}
1265
+?>" />
982 1266
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
983 1267
 			</p>
984 1268
 			<br />
@@ -994,14 +1278,20 @@  discard block
 block discarded – undo
994 1278
 			<div id="metarsrc">
995 1279
 				<p>
996 1280
 					<label for="metarsource">URL of your METAR source</label>
997
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
1281
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
1282
+	print $globalMETARurl;
1283
+}
1284
+?>" />
998 1285
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
999 1286
 				</p>
1000 1287
 			</div>
1001 1288
 			<br />
1002 1289
 			<p>
1003 1290
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
1004
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
1291
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
1292
+	print $globalBitlyAccessToken;
1293
+}
1294
+?>" />
1005 1295
 			</p>
1006 1296
 			<br />
1007 1297
 			<p>
@@ -1017,11 +1307,26 @@  discard block
 block discarded – undo
1017 1307
 			<p>
1018 1308
 				<label for="geoid_source">Geoid Source</label>
1019 1309
 				<select name="geoid_source" id="geoid_source">
1020
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
1021
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
1022
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
1023
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
1024
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
1310
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
1311
+	print ' selected="selected"';
1312
+}
1313
+?>>EGM96 15' (2.1MB)</option>
1314
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
1315
+	print ' selected="selected"';
1316
+}
1317
+?>>EGM96 5' (19MB)</option>
1318
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
1319
+	print ' selected="selected"';
1320
+}
1321
+?>>EGM2008 5' (19MB)</option>
1322
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
1323
+	print ' selected="selected"';
1324
+}
1325
+?>>EGM2008 2.5' (75MB)</option>
1326
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
1327
+	print ' selected="selected"';
1328
+}
1329
+?>>EGM2008 1' (470MB)</option>
1025 1330
 				</select>
1026 1331
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
1027 1332
 			</p>
@@ -1043,7 +1348,12 @@  discard block
 block discarded – undo
1043 1348
 			</p>
1044 1349
 			<p>
1045 1350
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
1046
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1351
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1352
+	print $globalArchiveMonths;
1353
+} else {
1354
+	echo '1';
1355
+}
1356
+?>" />
1047 1357
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
1048 1358
 			</p>
1049 1359
 			<p>
@@ -1053,12 +1363,22 @@  discard block
 block discarded – undo
1053 1363
 			</p>
1054 1364
 			<p>
1055 1365
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
1056
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1366
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1367
+	print $globalArchiveKeepMonths;
1368
+} else {
1369
+	echo '1';
1370
+}
1371
+?>" />
1057 1372
 				<p class="help-block">0 to disable</p>
1058 1373
 			</p>
1059 1374
 			<p>
1060 1375
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
1061
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1376
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1377
+	print $globalArchiveKeepTrackMonths;
1378
+} else {
1379
+	echo '1';
1380
+}
1381
+?>" />
1062 1382
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
1063 1383
 			</p>
1064 1384
 			<br />
@@ -1068,7 +1388,12 @@  discard block
 block discarded – undo
1068 1388
 				<p class="help-block">Uncheck if the script is running as cron job. You should always run it as daemon when it's possible.</p>
1069 1389
 				<div id="cronends"> 
1070 1390
 					<label for="cronend">Run script for xx seconds</label>
1071
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1391
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1392
+	print $globalCronEnd;
1393
+} else {
1394
+	print '0';
1395
+}
1396
+?>" />
1072 1397
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
1073 1398
 				</div>
1074 1399
 			</p>
@@ -1127,20 +1452,40 @@  discard block
 block discarded – undo
1127 1452
 			<br />
1128 1453
 			<p>
1129 1454
 				<label for="refresh">Show flights detected since xxx seconds</label>
1130
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1455
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1456
+	echo $globalLiveInterval;
1457
+} else {
1458
+	echo '200';
1459
+}
1460
+?>" />
1131 1461
 			</p>
1132 1462
 			<p>
1133 1463
 				<label for="maprefresh">Live map refresh (in seconds)</label>
1134
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1464
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1465
+	echo $globalMapRefresh;
1466
+} else {
1467
+	echo '30';
1468
+}
1469
+?>" />
1135 1470
 			</p>
1136 1471
 			<p>
1137 1472
 				<label for="mapidle">Map idle timeout (in minutes)</label>
1138
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1473
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1474
+	echo $globalMapIdleTimeout;
1475
+} else {
1476
+	echo '30';
1477
+}
1478
+?>" />
1139 1479
 				<p class="help-block">0 to disable</p>
1140 1480
 			</p>
1141 1481
 			<p>
1142 1482
 				<label for="minfetch">HTTP/file source fetch every xxx seconds</label>
1143
-				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) echo $globalMinFetch; else echo '20'; ?>" />
1483
+				<input type="number" name="minfetch" id="minfetch" value="<?php if (isset($globalMinFetch)) {
1484
+	echo $globalMinFetch;
1485
+} else {
1486
+	echo '20';
1487
+}
1488
+?>" />
1144 1489
 			</p>
1145 1490
 			<p>
1146 1491
 				<label for="bbox">Only display flights that we can see on screen (bounding box)</label>
@@ -1159,12 +1504,20 @@  discard block
 block discarded – undo
1159 1504
 			<br />
1160 1505
 			<p>
1161 1506
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
1162
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1507
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1508
+	echo $globalClosestMinDist;
1509
+} else {
1510
+	echo '50';
1511
+}
1512
+?>" />
1163 1513
 			</p>
1164 1514
 			<br />
1165 1515
 			<p>
1166 1516
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
1167
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1517
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1518
+	echo $globalAircraftSize;
1519
+}
1520
+?>" />
1168 1521
 			</p>
1169 1522
 			<br />
1170 1523
 			<p>
@@ -1183,22 +1536,42 @@  discard block
 block discarded – undo
1183 1536
 			<br />
1184 1537
 			<p>
1185 1538
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1186
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1539
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1540
+	echo $globalAircraftIconColor;
1541
+} else {
1542
+	echo '1a3151';
1543
+}
1544
+?>" />
1187 1545
 			</p>
1188 1546
 			<br />
1189 1547
 			<p>
1190 1548
 				<label for="marineiconcolor">Color of marine icon on map</label>
1191
-				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) echo $globalMarineIconColor; else echo '43d1d8'; ?>" />
1549
+				<input type="color" name="marineiconcolor" id="marineiconcolor" value="#<?php if (isset($globalMarineIconColor)) {
1550
+	echo $globalMarineIconColor;
1551
+} else {
1552
+	echo '43d1d8';
1553
+}
1554
+?>" />
1192 1555
 			</p>
1193 1556
 			<br />
1194 1557
 			<p>
1195 1558
 				<label for="trackericoncolor">Color of tracker icon on map</label>
1196
-				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) echo $globalTrackerIconColor; else echo '1a3151'; ?>" />
1559
+				<input type="color" name="trackericoncolor" id="trackericoncolor" value="#<?php if (isset($globalTrackerIconColor)) {
1560
+	echo $globalTrackerIconColor;
1561
+} else {
1562
+	echo '1a3151';
1563
+}
1564
+?>" />
1197 1565
 			</p>
1198 1566
 			<br />
1199 1567
 			<p>
1200 1568
 				<label for="satelliteiconcolor">Color of satellite icon on map</label>
1201
-				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) echo $globalSatelliteIconColor; else echo '1a3151'; ?>" />
1569
+				<input type="color" name="satelliteiconcolor" id="satelliteiconcolor" value="#<?php if (isset($globalSatelliteIconColor)) {
1570
+	echo $globalSatelliteIconColor;
1571
+} else {
1572
+	echo '1a3151';
1573
+}
1574
+?>" />
1202 1575
 			</p>
1203 1576
 			<?php
1204 1577
 				if (!is_writable('../cache')) {
@@ -1222,14 +1595,27 @@  discard block
 block discarded – undo
1222 1595
 			<p>
1223 1596
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
1224 1597
 				<div class="range">
1225
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
1226
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1598
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1599
+	echo $globalAirportZoom;
1600
+} else {
1601
+	echo '7';
1602
+}
1603
+?>" />
1604
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1605
+	echo $globalAirportZoom;
1606
+} else {
1607
+	echo '7';
1608
+}
1609
+?></output>
1227 1610
 				</div>
1228 1611
 			</p>
1229 1612
 			<br />
1230 1613
 			<p>
1231 1614
 				<label for="customcss">Custom CSS web path</label>
1232
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1615
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1616
+	echo $globalCustomCSS;
1617
+}
1618
+?>" />
1233 1619
 			</p>
1234 1620
 		</fieldset>
1235 1621
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -1259,8 +1645,12 @@  discard block
 block discarded – undo
1259 1645
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1260 1646
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1261 1647
 
1262
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1263
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1648
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1649
+		$error .= 'Mysql driver for PDO must be loaded';
1650
+	}
1651
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1652
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1653
+	}
1264 1654
 	
1265 1655
 	$_SESSION['database_root'] = $dbroot;
1266 1656
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1338,15 +1728,23 @@  discard block
 block discarded – undo
1338 1728
 	$source_city = $_POST['source_city'];
1339 1729
 	$source_country = $_POST['source_country'];
1340 1730
 	$source_ref = $_POST['source_ref'];
1341
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1342
-	else $source_id = array();
1731
+	if (isset($source_id)) {
1732
+		$source_id = $_POST['source_id'];
1733
+	} else {
1734
+		$source_id = array();
1735
+	}
1343 1736
 	
1344 1737
 	$sources = array();
1345 1738
 	foreach ($source_name as $keys => $name) {
1346
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1347
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1739
+	    if (isset($source_id[$keys])) {
1740
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1741
+	    } else {
1742
+	    	$sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1743
+	    }
1744
+	}
1745
+	if (count($sources) > 0) {
1746
+		$_SESSION['sources'] = $sources;
1348 1747
 	}
1349
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1350 1748
 
1351 1749
 	$newsurl = $_POST['newsurl'];
1352 1750
 	$newslng = $_POST['newslang'];
@@ -1359,7 +1757,9 @@  discard block
 block discarded – undo
1359 1757
 		$lng = $newslng[$newskey];
1360 1758
 		if (isset($newsfeeds[$type][$lng])) {
1361 1759
 		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1362
-		} else $newsfeeds[$type][$lng] = array($url);
1760
+		} else {
1761
+			$newsfeeds[$type][$lng] = array($url);
1762
+		}
1363 1763
 	    }
1364 1764
 	}
1365 1765
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
@@ -1384,17 +1784,29 @@  discard block
 block discarded – undo
1384 1784
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1385 1785
 
1386 1786
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1387
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1388
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1787
+	if ($globalaircraft == 'aircraft') {
1788
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1789
+	} else {
1790
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1791
+	}
1389 1792
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1390
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1391
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1793
+	if ($globaltracker == 'tracker') {
1794
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1795
+	} else {
1796
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1797
+	}
1392 1798
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1393
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1394
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1799
+	if ($globalmarine == 'marine') {
1800
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1801
+	} else {
1802
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1803
+	}
1395 1804
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1396
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1397
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1805
+	if ($globalsatellite == 'satellite') {
1806
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1807
+	} else {
1808
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1809
+	}
1398 1810
 
1399 1811
 /*	
1400 1812
 	$globalSBS1Hosts = array();
@@ -1416,23 +1828,37 @@  discard block
 block discarded – undo
1416 1828
 	$name = $_POST['name'];
1417 1829
 	$format = $_POST['format'];
1418 1830
 	$timezones = $_POST['timezones'];
1419
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1420
-	else $sourcestats = array();
1421
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1422
-	else $noarchive = array();
1831
+	if (isset($_POST['sourcestats'])) {
1832
+		$sourcestats = $_POST['sourcestats'];
1833
+	} else {
1834
+		$sourcestats = array();
1835
+	}
1836
+	if (isset($_POST['noarchive'])) {
1837
+		$noarchive = $_POST['noarchive'];
1838
+	} else {
1839
+		$noarchive = array();
1840
+	}
1423 1841
 	$gSources = array();
1424 1842
 	$forcepilots = false;
1425 1843
 	foreach ($host as $key => $h) {
1426
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1427
-		else $cov = 'FALSE';
1428
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1429
-		else $arch = 'FALSE';
1844
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1845
+			$cov = 'TRUE';
1846
+		} else {
1847
+			$cov = 'FALSE';
1848
+		}
1849
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1850
+			$arch = 'TRUE';
1851
+		} else {
1852
+			$arch = 'FALSE';
1853
+		}
1430 1854
 		if (strpos($format[$key],'_callback')) {
1431 1855
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1432 1856
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1433 1857
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1434 1858
 		}
1435
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1859
+		if ($format[$key] == 'airwhere') {
1860
+			$forcepilots = true;
1861
+		}
1436 1862
 	}
1437 1863
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1438 1864
 
@@ -1463,7 +1889,9 @@  discard block
 block discarded – undo
1463 1889
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1464 1890
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1465 1891
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1466
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1892
+	} else {
1893
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1894
+	}
1467 1895
 
1468 1896
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1469 1897
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1504,7 +1932,9 @@  discard block
 block discarded – undo
1504 1932
 
1505 1933
 	// Create in settings.php keys not yet configurable if not already here
1506 1934
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1507
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1935
+	if (!isset($globalDebug)) {
1936
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1937
+	}
1508 1938
 
1509 1939
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1510 1940
 	if ($resetyearstats == 'resetyearstats') {
@@ -1547,37 +1977,56 @@  discard block
 block discarded – undo
1547 1977
 	}
1548 1978
 */
1549 1979
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1550
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1551
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1552
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1553
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1980
+	if ($globalsbs == 'sbs') {
1981
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1982
+	} else {
1983
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1984
+	}
1985
+	if ($globalaprs == 'aprs') {
1986
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1987
+	} else {
1988
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1989
+	}
1554 1990
 	$va = false;
1555 1991
 	if ($globalivao == 'ivao') {
1556 1992
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1557 1993
 		$va = true;
1558
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1994
+	} else {
1995
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1996
+	}
1559 1997
 	if ($globalvatsim == 'vatsim') {
1560 1998
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1561 1999
 		$va = true;
1562
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2000
+	} else {
2001
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
2002
+	}
1563 2003
 	if ($globalphpvms == 'phpvms') {
1564 2004
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1565 2005
 		$va = true;
1566
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2006
+	} else {
2007
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
2008
+	}
1567 2009
 	if ($globalvam == 'vam') {
1568 2010
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1569 2011
 		$va = true;
1570
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2012
+	} else {
2013
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
2014
+	}
1571 2015
 	if ($va) {
1572 2016
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1573
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2017
+	} else {
2018
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
2019
+	}
1574 2020
 	if ($globalva == 'va' || $va) {
1575 2021
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1576 2022
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1577 2023
 	} else {
1578 2024
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1579
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1580
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2025
+		if ($forcepilots) {
2026
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
2027
+		} else {
2028
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
2029
+		}
1581 2030
 	}
1582 2031
 	if ($globalvm == 'vm') {
1583 2032
 		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
@@ -1837,7 +2286,9 @@  discard block
 block discarded – undo
1837 2286
 	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1838 2287
 	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1839 2288
 
1840
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2289
+	if (!isset($globalTransaction)) {
2290
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
2291
+	}
1841 2292
 
1842 2293
 	// Set some defaults values...
1843 2294
 	if (!isset($globalAircraftImageSources)) {
@@ -1852,15 +2303,23 @@  discard block
 block discarded – undo
1852 2303
 
1853 2304
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1854 2305
 
1855
-	if ($error == '') settings::modify_settings($settings);
1856
-	if ($error == '') settings::comment_settings($settings_comment);
2306
+	if ($error == '') {
2307
+		settings::modify_settings($settings);
2308
+	}
2309
+	if ($error == '') {
2310
+		settings::comment_settings($settings_comment);
2311
+	}
1857 2312
 	if ($error != '') {
1858 2313
 		print '<div class="info column">'.$error.'</div>';
1859 2314
 		require('../footer.php');
1860 2315
 		exit;
1861 2316
 	} else {
1862
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1863
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
2317
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
2318
+			$_SESSION['waypoints'] = 1;
2319
+		}
2320
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
2321
+			$_SESSION['owner'] = 1;
2322
+		}
1864 2323
 		if (isset($_POST['createdb'])) {
1865 2324
 			$_SESSION['install'] = 'database_create';
1866 2325
 		} else {
@@ -1897,10 +2356,18 @@  discard block
 block discarded – undo
1897 2356
 	$popw = false;
1898 2357
 	foreach ($_SESSION['done'] as $done) {
1899 2358
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1900
-	    if ($done == 'Create database') $pop = true;
1901
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1902
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1903
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
2359
+	    if ($done == 'Create database') {
2360
+	    	$pop = true;
2361
+	    }
2362
+	    if ($_SESSION['install'] == 'database_create') {
2363
+	    	$pop = true;
2364
+	    }
2365
+	    if ($_SESSION['install'] == 'database_import') {
2366
+	    	$popi = true;
2367
+	    }
2368
+	    if ($_SESSION['install'] == 'waypoints') {
2369
+	    	$popw = true;
2370
+	    }
1904 2371
 	}
1905 2372
 	if ($pop) {
1906 2373
 	    sleep(5);
@@ -1911,7 +2378,9 @@  discard block
 block discarded – undo
1911 2378
 	} else if ($popw) {
1912 2379
 	    sleep(5);
1913 2380
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1914
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2381
+	} else {
2382
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
2383
+	}
1915 2384
 	print '</div></ul>';
1916 2385
 	print '<div id="error"></div>';
1917 2386
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Braces   +1209 added lines, -406 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 // Check if schema is at latest version
28 30
 $Connection = new Connection();
@@ -65,66 +67,107 @@  discard block
 block discarded – undo
65 67
 //elseif (isset($options['source'])) $hosts = array($options['source']);
66 68
 if (isset($options['s'])) {
67 69
     $globalSources = array();
68
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
69
-    else $globalSources[] = array('host' => $options['s']);
70
-} elseif (isset($options['source'])) {
70
+    if (isset($options['format'])) {
71
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+    } else {
73
+    	$globalSources[] = array('host' => $options['s']);
74
+    }
75
+    } elseif (isset($options['source'])) {
71 76
     $globalSources = array();
72
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
73
-    else $globalSources[] = array('host' => $options['source']);
74
-}
77
+    if (isset($options['format'])) {
78
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
79
+    } else {
80
+    	$globalSources[] = array('host' => $options['source']);
81
+    }
82
+    }
75 83
 if (isset($options['aprsserverhost'])) {
76 84
 	$globalServerAPRS = TRUE;
77 85
 	$globalServerAPRShost = $options['aprsserverhost'];
78 86
 }
79
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
80
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
81
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
82
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
87
+if (isset($options['aprsserverport'])) {
88
+	$globalServerAPRSport = $options['aprsserverport'];
89
+}
90
+if (isset($options['aprsserverssid'])) {
91
+	$globalServerAPRSssid = $options['aprsserverssid'];
92
+}
93
+if (isset($options['aprsserverpass'])) {
94
+	$globalServerAPRSpass = $options['aprsserverpass'];
95
+}
96
+if (isset($options['noaprsserver'])) {
97
+	$globalServerAPRS = FALSE;
98
+}
83 99
 if (isset($options['enable-aircraft'])) {
84
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
100
+	if ($globalDebug) {
101
+		echo 'Enable Aircraft mode'."\n";
102
+	}
85 103
 	$globalAircraft = TRUE; 
86 104
 }
87 105
 if (isset($options['disable-aircraft'])) {
88
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
106
+	if ($globalDebug) {
107
+		echo 'Disable Aircraft mode'."\n";
108
+	}
89 109
 	$globalAircraft = FALSE;
90 110
 }
91 111
 if (isset($options['enable-tracker'])) {
92
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
112
+	if ($globalDebug) {
113
+		echo 'Enable Tracker mode'."\n";
114
+	}
93 115
 	$globalTracker = TRUE; 
94 116
 }
95 117
 if (isset($options['disable-tracker'])) {
96
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
118
+	if ($globalDebug) {
119
+		echo 'Disable Tracker mode'."\n";
120
+	}
97 121
 	$globalTracker = FALSE;
98 122
 }
99 123
 if (isset($options['enable-marine'])) {
100
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
124
+	if ($globalDebug) {
125
+		echo 'Enable Marine mode'."\n";
126
+	}
101 127
 	$globalMarine = TRUE;
102 128
 }
103 129
 if (isset($options['disable-marine'])) {
104
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
130
+	if ($globalDebug) {
131
+		echo 'Disable Marine mode'."\n";
132
+	}
105 133
 	$globalMarine = FALSE;
106 134
 }
107
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
108
-if (isset($options['server'])) $globalServer = TRUE;
109
-if (isset($options['idsource'])) $id_source = $options['idsource'];
110
-else $id_source = 1;
135
+if (isset($options['nodaemon'])) {
136
+	$globalDaemon = FALSE;
137
+}
138
+if (isset($options['server'])) {
139
+	$globalServer = TRUE;
140
+}
141
+if (isset($options['idsource'])) {
142
+	$id_source = $options['idsource'];
143
+} else {
144
+	$id_source = 1;
145
+}
111 146
 if (isset($globalServer) && $globalServer) {
112
-    if ($globalDebug) echo "Using Server Mode\n";
147
+    if ($globalDebug) {
148
+    	echo "Using Server Mode\n";
149
+    }
113 150
     $SI=new SpotterServer();
114 151
 /*
115 152
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
116 153
     $SI = new adsb2aprs();
117 154
     $SI->connect();
118 155
 */
119
-} else $SI=new SpotterImport($Connection->db);
156
+} else {
157
+	$SI=new SpotterImport($Connection->db);
158
+}
120 159
 
121
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
160
+if (isset($globalTracker) && $globalTracker) {
161
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
162
+}
122 163
 if (isset($globalMarine) && $globalMarine) {
123 164
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
124 165
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
125 166
 }
126 167
 
127
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
168
+if (isset($globalTracker) && $globalTracker) {
169
+	$TI = new TrackerImport($Connection->db);
170
+}
128 171
 if (isset($globalMarine) && $globalMarine) {
129 172
     $AIS = new AIS();
130 173
     $MI = new MarineImport($Connection->db);
@@ -149,7 +192,9 @@  discard block
 block discarded – undo
149 192
 }
150 193
 
151 194
 // let's try and connect
152
-if ($globalDebug) echo "Connecting...\n";
195
+if ($globalDebug) {
196
+	echo "Connecting...\n";
197
+}
153 198
 $use_aprs = false;
154 199
 $aprs_full = false;
155 200
 $reset = 0;
@@ -158,7 +203,9 @@  discard block
 block discarded – undo
158 203
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
159 204
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
160 205
     $reset++;
161
-    if ($globalDebug) echo 'Connect to all...'."\n";
206
+    if ($globalDebug) {
207
+    	echo 'Connect to all...'."\n";
208
+    }
162 209
     foreach ($hosts as $id => $value) {
163 210
 	$host = $value['host'];
164 211
 	$globalSources[$id]['last_exec'] = 0;
@@ -168,32 +215,44 @@  discard block
 block discarded – undo
168 215
         	//$formats[$id] = 'deltadbtxt';
169 216
         	$globalSources[$id]['format'] = 'deltadbtxt';
170 217
         	//$last_exec['deltadbtxt'] = 0;
171
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
218
+        	if ($globalDebug) {
219
+        		echo "Connect to deltadb source (".$host.")...\n";
220
+        	}
172 221
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
173 222
         	//$formats[$id] = 'vatsimtxt';
174 223
         	$globalSources[$id]['format'] = 'vatsimtxt';
175 224
         	//$last_exec['vatsimtxt'] = 0;
176
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
225
+        	if ($globalDebug) {
226
+        		echo "Connect to vatsim source (".$host.")...\n";
227
+        	}
177 228
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
178 229
         	//$formats[$id] = 'aircraftlistjson';
179 230
         	$globalSources[$id]['format'] = 'aircraftlistjson';
180 231
         	//$last_exec['aircraftlistjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
234
+        	}
182 235
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
183 236
         	//$formats[$id] = 'aircraftjson';
184 237
         	$globalSources[$id]['format'] = 'aircraftjson';
185 238
         	//$last_exec['aircraftlistjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to aircraft.json source (".$host.")...\n";
241
+        	}
187 242
     	    } else if (preg_match('/aircraft$/i',$host)) {
188 243
         	//$formats[$id] = 'planefinderclient';
189 244
         	$globalSources[$id]['format'] = 'planefinderclient';
190 245
         	//$last_exec['aircraftlistjson'] = 0;
191
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
246
+        	if ($globalDebug) {
247
+        		echo "Connect to planefinderclient source (".$host.")...\n";
248
+        	}
192 249
     	    } else if (preg_match('/opensky/i',$host)) {
193 250
         	//$formats[$id] = 'aircraftlistjson';
194 251
         	$globalSources[$id]['format'] = 'opensky';
195 252
         	//$last_exec['aircraftlistjson'] = 0;
196
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
253
+        	if ($globalDebug) {
254
+        		echo "Connect to opensky source (".$host.")...\n";
255
+        	}
197 256
     	    /*
198 257
     	    // Disabled for now, site change source format
199 258
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -210,7 +269,9 @@  discard block
 block discarded – undo
210 269
         	//$formats[$id] = 'planeupdatefaa';
211 270
         	$globalSources[$id]['format'] = 'planeupdatefaa';
212 271
         	//$last_exec['planeupdatefaa'] = 0;
213
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
272
+        	if ($globalDebug) {
273
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
274
+        	}
214 275
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
215 276
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
216 277
         	    exit(0);
@@ -219,37 +280,53 @@  discard block
 block discarded – undo
219 280
         	//$formats[$id] = 'phpvmacars';
220 281
         	$globalSources[$id]['format'] = 'phpvmacars';
221 282
         	//$last_exec['phpvmacars'] = 0;
222
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
283
+        	if ($globalDebug) {
284
+        		echo "Connect to phpvmacars source (".$host.")...\n";
285
+        	}
223 286
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
224 287
         	//$formats[$id] = 'phpvmacars';
225 288
         	$globalSources[$id]['format'] = 'vaos';
226 289
         	//$last_exec['phpvmacars'] = 0;
227
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
290
+        	if ($globalDebug) {
291
+        		echo "Connect to vaos source (".$host.")...\n";
292
+        	}
228 293
             } else if (preg_match('/VAM-json.php$/i',$host)) {
229 294
         	//$formats[$id] = 'phpvmacars';
230 295
         	$globalSources[$id]['format'] = 'vam';
231
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
296
+        	if ($globalDebug) {
297
+        		echo "Connect to Vam source (".$host.")...\n";
298
+        	}
232 299
             } else if (preg_match('/whazzup/i',$host)) {
233 300
         	//$formats[$id] = 'whazzup';
234 301
         	$globalSources[$id]['format'] = 'whazzup';
235 302
         	//$last_exec['whazzup'] = 0;
236
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
303
+        	if ($globalDebug) {
304
+        		echo "Connect to whazzup source (".$host.")...\n";
305
+        	}
237 306
             } else if (preg_match('/blitzortung/i',$host)) {
238 307
         	$globalSources[$id]['format'] = 'blitzortung';
239
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
308
+        	if ($globalDebug) {
309
+        		echo "Connect to blitzortung source (".$host.")...\n";
310
+        	}
240 311
             } else if (preg_match('/airwhere/i',$host)) {
241 312
         	$globalSources[$id]['format'] = 'airwhere';
242
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
313
+        	if ($globalDebug) {
314
+        		echo "Connect to airwhere source (".$host.")...\n";
315
+        	}
243 316
             } else if (preg_match('/recentpireps/i',$host)) {
244 317
         	//$formats[$id] = 'pirepsjson';
245 318
         	$globalSources[$id]['format'] = 'pirepsjson';
246 319
         	//$last_exec['pirepsjson'] = 0;
247
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
320
+        	if ($globalDebug) {
321
+        		echo "Connect to pirepsjson source (".$host.")...\n";
322
+        	}
248 323
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
249 324
         	//$formats[$id] = 'fr24json';
250 325
         	$globalSources[$id]['format'] = 'fr24json';
251 326
         	//$last_exec['fr24json'] = 0;
252
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
327
+        	if ($globalDebug) {
328
+        		echo "Connect to fr24 source (".$host.")...\n";
329
+        	}
253 330
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
254 331
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
255 332
         	    exit(0);
@@ -258,7 +335,9 @@  discard block
 block discarded – undo
258 335
         	//$formats[$id] = 'fr24json';
259 336
         	$globalSources[$id]['format'] = 'myshiptracking';
260 337
         	//$last_exec['fr24json'] = 0;
261
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
338
+        	if ($globalDebug) {
339
+        		echo "Connect to myshiptracking source (".$host.")...\n";
340
+        	}
262 341
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
263 342
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
264 343
         	    exit(0);
@@ -267,17 +346,26 @@  discard block
 block discarded – undo
267 346
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
268 347
         	//$formats[$id] = 'tsv';
269 348
         	$globalSources[$id]['format'] = 'tsv';
270
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
349
+        	if ($globalDebug) {
350
+        		echo "Connect to tsv source (".$host.")...\n";
351
+        	}
271 352
             }
272 353
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
273 354
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
274 355
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
275 356
     		    if ($idf !== false) {
276 357
     			$httpfeeds[$id] = $idf;
277
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
278
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
279
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
280
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
358
+        		if ($globalDebug) {
359
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
360
+        		}
361
+    		    } elseif ($globalDebug) {
362
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
363
+    		    }
364
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
365
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
366
+    		} elseif ($globalDebug) {
367
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
368
+    		}
281 369
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
282 370
 	    $hostport = explode(':',$host);
283 371
 	    if (isset($hostport[1])) {
@@ -317,19 +405,27 @@  discard block
 block discarded – undo
317 405
         		//$formats[$id] = 'beast';
318 406
         		$globalSources[$id]['format'] = 'beast';
319 407
 		    //} else $formats[$id] = 'sbs';
320
-		    } else $globalSources[$id]['format'] = 'sbs';
408
+		    } else {
409
+		    	$globalSources[$id]['format'] = 'sbs';
410
+		    }
321 411
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
322 412
 		}
323
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
413
+		if ($globalDebug) {
414
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
415
+		}
324 416
             } else {
325
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
417
+		if ($globalDebug) {
418
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
419
+		}
326 420
 		sleep(10);
327 421
 		connect_all($hosts);
328 422
     	    }
329 423
         }
330 424
     }
331 425
 }
332
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
426
+if (!isset($globalMinFetch)) {
427
+	$globalMinFetch = 15;
428
+}
333 429
 
334 430
 // Initialize all
335 431
 $status = array();
@@ -338,13 +434,19 @@  discard block
 block discarded – undo
338 434
 $formats = array();
339 435
 $last_exec = array();
340 436
 $time = time();
341
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
342
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
343
-else $timeout = 20;
437
+if (isset($globalSourcesTimeout)) {
438
+	$timeout = $globalSourcesTimeOut;
439
+} else if (isset($globalSBS1TimeOut)) {
440
+	$timeout = $globalSBS1TimeOut;
441
+} else {
442
+	$timeout = 20;
443
+}
344 444
 $errno = '';
345 445
 $errstr='';
346 446
 
347
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
447
+if (!isset($globalDaemon)) {
448
+	$globalDaemon = TRUE;
449
+}
348 450
 /* Initiate connections to all the hosts simultaneously */
349 451
 //connect_all($hosts);
350 452
 //connect_all($globalSources);
@@ -373,7 +475,9 @@  discard block
 block discarded – undo
373 475
     if (isset($source['format']) && $source['format'] == 'aprs') {
374 476
 	$aprs_connect = 0;
375 477
 	$use_aprs = true;
376
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
478
+	if (isset($source['port']) && $source['port'] == '10152') {
479
+		$aprs_full = true;
480
+	}
377 481
 	break;
378 482
     }
379 483
 }
@@ -384,25 +488,46 @@  discard block
 block discarded – undo
384 488
 	$aprs_connect = 0;
385 489
 	$aprs_keep = 120;
386 490
 	$aprs_last_tx = time();
387
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
388
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
389
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
390
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
391
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
392
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
393
-	if ($aprs_full) $aprs_filter = '';
394
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
395
-	else $aprs_pass = '-1';
491
+	if (isset($globalAPRSversion)) {
492
+		$aprs_version = $globalAPRSversion;
493
+	} else {
494
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
495
+	}
496
+	if (isset($globalAPRSssid)) {
497
+		$aprs_ssid = $globalAPRSssid;
498
+	} else {
499
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
500
+	}
501
+	if (isset($globalAPRSfilter)) {
502
+		$aprs_filter = $globalAPRSfilter;
503
+	} else {
504
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
505
+	}
506
+	if ($aprs_full) {
507
+		$aprs_filter = '';
508
+	}
509
+	if (isset($globalAPRSpass)) {
510
+		$aprs_pass = $globalAPRSpass;
511
+	} else {
512
+		$aprs_pass = '-1';
513
+	}
396 514
 
397
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
398
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
399
-}
515
+	if ($aprs_filter != '') {
516
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
517
+	} else {
518
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
519
+	}
520
+	}
400 521
 
401 522
 // connected - lets do some work
402 523
 //if ($globalDebug) echo "Connected!\n";
403 524
 sleep(1);
404
-if ($globalDebug) echo "SCAN MODE \n\n";
405
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
525
+if ($globalDebug) {
526
+	echo "SCAN MODE \n\n";
527
+}
528
+if (!isset($globalCronEnd)) {
529
+	$globalCronEnd = 60;
530
+}
406 531
 $endtime = time()+$globalCronEnd;
407 532
 $i = 1;
408 533
 $tt = array();
@@ -416,22 +541,32 @@  discard block
 block discarded – undo
416 541
 
417 542
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
418 543
 while ($i > 0) {
419
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
544
+    if (function_exists('pcntl_fork')) {
545
+    	pcntl_signal_dispatch();
546
+    }
420 547
 
421
-    if (!$globalDaemon) $i = $endtime-time();
548
+    if (!$globalDaemon) {
549
+    	$i = $endtime-time();
550
+    }
422 551
     // Delete old ATC
423 552
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
424
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
553
+	if ($globalDebug) {
554
+		echo 'Delete old ATC...'."\n";
555
+	}
425 556
         $ATC->deleteOldATC();
426 557
     }
427 558
     
428 559
     if (count($last_exec) == count($globalSources)) {
429 560
 	$max = $globalMinFetch;
430 561
 	foreach ($last_exec as $last) {
431
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
562
+	    if ((time() - $last['last']) < $max) {
563
+	    	$max = time() - $last['last'];
564
+	    }
432 565
 	}
433 566
 	if ($max < $globalMinFetch) {
434
-	    if ($globalDebug) echo 'Sleeping...'."\n";
567
+	    if ($globalDebug) {
568
+	    	echo 'Sleeping...'."\n";
569
+	    }
435 570
 	    sleep($globalMinFetch-$max+2);
436 571
 	}
437 572
     }
@@ -441,7 +576,9 @@  discard block
 block discarded – undo
441 576
     foreach ($globalSources as $id => $value) {
442 577
 	date_default_timezone_set('UTC');
443 578
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
444
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
579
+	if (!isset($last_exec[$id]['last'])) {
580
+		$last_exec[$id]['last'] = 0;
581
+	}
445 582
 	if ($value['format'] === 'deltadbtxt' && 
446 583
 	    (
447 584
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -450,7 +587,9 @@  discard block
 block discarded – undo
450 587
 	) {
451 588
 	    //$buffer = $Common->getData($hosts[$id]);
452 589
 	    $buffer = $Common->getData($value['host']);
453
-	    if ($buffer != '') $reset = 0;
590
+	    if ($buffer != '') {
591
+	    	$reset = 0;
592
+	    }
454 593
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455 594
 	    $buffer = explode('\n',$buffer);
456 595
 	    foreach ($buffer as $line) {
@@ -459,20 +598,41 @@  discard block
 block discarded – undo
459 598
 	            $data = array();
460 599
 	            $data['hex'] = $line[1]; // hex
461 600
 	            $data['ident'] = $line[2]; // ident
462
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
463
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
464
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
465
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
466
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
601
+	            if (isset($line[3])) {
602
+	            	$data['altitude'] = $line[3];
603
+	            }
604
+	            // altitude
605
+	            if (isset($line[4])) {
606
+	            	$data['speed'] = $line[4];
607
+	            }
608
+	            // speed
609
+	            if (isset($line[5])) {
610
+	            	$data['heading'] = $line[5];
611
+	            }
612
+	            // heading
613
+	            if (isset($line[6])) {
614
+	            	$data['latitude'] = $line[6];
615
+	            }
616
+	            // lat
617
+	            if (isset($line[7])) {
618
+	            	$data['longitude'] = $line[7];
619
+	            }
620
+	            // long
467 621
 	            $data['verticalrate'] = ''; // vertical rate
468 622
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
469 623
 	            $data['emergency'] = ''; // emergency
470 624
 		    $data['datetime'] = date('Y-m-d H:i:s');
471 625
 		    $data['format_source'] = 'deltadbtxt';
472 626
     		    $data['id_source'] = $id_source;
473
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
474
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
475
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
627
+		    if (isset($value['name']) && $value['name'] != '') {
628
+		    	$data['source_name'] = $value['name'];
629
+		    }
630
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
631
+		    	$data['noarchive'] = true;
632
+		    }
633
+		    if (isset($value['sourcestats'])) {
634
+		    	$data['sourcestats'] = $value['sourcestats'];
635
+		    }
476 636
     		    $SI->add($data);
477 637
 		    unset($data);
478 638
     		}
@@ -487,7 +647,9 @@  discard block
 block discarded – undo
487 647
 	    date_default_timezone_set('CET');
488 648
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
489 649
 	    date_default_timezone_set('UTC');
490
-	    if ($buffer != '') $reset = 0;
650
+	    if ($buffer != '') {
651
+	    	$reset = 0;
652
+	    }
491 653
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
492 654
 	    $buffer = explode('\n',$buffer);
493 655
 	    foreach ($buffer as $line) {
@@ -496,18 +658,42 @@  discard block
 block discarded – undo
496 658
 		    $add = false;
497 659
 		    $ais_data = $AIS->parse_line(trim($line));
498 660
 		    $data = array();
499
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
500
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
501
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
502
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
503
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
504
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
505
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
506
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
507
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
508
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
509
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
510
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
661
+		    if (isset($ais_data['ident'])) {
662
+		    	$data['ident'] = $ais_data['ident'];
663
+		    }
664
+		    if (isset($ais_data['mmsi'])) {
665
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
666
+		    }
667
+		    if (isset($ais_data['speed'])) {
668
+		    	$data['speed'] = $ais_data['speed'];
669
+		    }
670
+		    if (isset($ais_data['heading'])) {
671
+		    	$data['heading'] = $ais_data['heading'];
672
+		    }
673
+		    if (isset($ais_data['latitude'])) {
674
+		    	$data['latitude'] = $ais_data['latitude'];
675
+		    }
676
+		    if (isset($ais_data['longitude'])) {
677
+		    	$data['longitude'] = $ais_data['longitude'];
678
+		    }
679
+		    if (isset($ais_data['status'])) {
680
+		    	$data['status'] = $ais_data['status'];
681
+		    }
682
+		    if (isset($ais_data['statusid'])) {
683
+		    	$data['status_id'] = $ais_data['statusid'];
684
+		    }
685
+		    if (isset($ais_data['type'])) {
686
+		    	$data['type'] = $ais_data['type'];
687
+		    }
688
+		    if (isset($ais_data['typeid'])) {
689
+		    	$data['type_id'] = $ais_data['typeid'];
690
+		    }
691
+		    if (isset($ais_data['imo'])) {
692
+		    	$data['imo'] = $ais_data['imo'];
693
+		    }
694
+		    if (isset($ais_data['callsign'])) {
695
+		    	$data['callsign'] = $ais_data['callsign'];
696
+		    }
511 697
 		    if (isset($ais_data['timestamp'])) {
512 698
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513 699
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -521,8 +707,12 @@  discard block
 block discarded – undo
521 707
 		    $data['format_source'] = 'aisnmeatxt';
522 708
     		    $data['id_source'] = $id_source;
523 709
 		    //print_r($data);
524
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
525
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
710
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
711
+		    	$data['noarchive'] = true;
712
+		    }
713
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
714
+		    	$MI->add($data);
715
+		    }
526 716
 		    unset($data);
527 717
 		}
528 718
     	    }
@@ -545,20 +735,48 @@  discard block
 block discarded – undo
545 735
 			    if ($line != '') {
546 736
 				$ais_data = $AIS->parse_line(trim($line));
547 737
 				$data = array();
548
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
549
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
550
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
551
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
552
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
553
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
554
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
555
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
556
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
557
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
558
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
559
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
560
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
561
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
738
+				if (isset($ais_data['ident'])) {
739
+					$data['ident'] = $ais_data['ident'];
740
+				}
741
+				if (isset($ais_data['mmsi'])) {
742
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
743
+				}
744
+				if (isset($ais_data['speed'])) {
745
+					$data['speed'] = $ais_data['speed'];
746
+				}
747
+				if (isset($ais_data['heading'])) {
748
+					$data['heading'] = $ais_data['heading'];
749
+				}
750
+				if (isset($ais_data['latitude'])) {
751
+					$data['latitude'] = $ais_data['latitude'];
752
+				}
753
+				if (isset($ais_data['longitude'])) {
754
+					$data['longitude'] = $ais_data['longitude'];
755
+				}
756
+				if (isset($ais_data['status'])) {
757
+					$data['status'] = $ais_data['status'];
758
+				}
759
+				if (isset($ais_data['statusid'])) {
760
+					$data['status_id'] = $ais_data['statusid'];
761
+				}
762
+				if (isset($ais_data['type'])) {
763
+					$data['type'] = $ais_data['type'];
764
+				}
765
+				if (isset($ais_data['typeid'])) {
766
+					$data['type_id'] = $ais_data['typeid'];
767
+				}
768
+				if (isset($ais_data['imo'])) {
769
+					$data['imo'] = $ais_data['imo'];
770
+				}
771
+				if (isset($ais_data['callsign'])) {
772
+					$data['callsign'] = $ais_data['callsign'];
773
+				}
774
+				if (isset($ais_data['destination'])) {
775
+					$data['arrival_code'] = $ais_data['destination'];
776
+				}
777
+				if (isset($ais_data['eta_ts'])) {
778
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
779
+				}
562 780
 				if (isset($ais_data['timestamp'])) {
563 781
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
564 782
 				} else {
@@ -566,18 +784,27 @@  discard block
 block discarded – undo
566 784
 				}
567 785
 				$data['format_source'] = 'aisnmeahttp';
568 786
 				$data['id_source'] = $id_source;
569
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
570
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
787
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
788
+					$data['noarchive'] = true;
789
+				}
790
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
791
+					$MI->add($data);
792
+				}
571 793
 				unset($data);
572 794
 			    }
573 795
 			}
574 796
 		    }
575 797
 		} else {
576 798
 		    $format = $value['format'];
577
-		    if (isset($tt[$format])) $tt[$format]++;
578
-		    else $tt[$format] = 0;
799
+		    if (isset($tt[$format])) {
800
+		    	$tt[$format]++;
801
+		    } else {
802
+		    	$tt[$format] = 0;
803
+		    }
579 804
 		    if ($tt[$format] > 30) {
580
-			if ($globalDebug) echo 'Reconnect...'."\n";
805
+			if ($globalDebug) {
806
+				echo 'Reconnect...'."\n";
807
+			}
581 808
 			sleep(2);
582 809
 			//$sourceeen[] = $value;
583 810
 			//connect_all($sourceeen);
@@ -613,12 +840,18 @@  discard block
 block discarded – undo
613 840
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
614 841
 			    //$data['type_id'] = $line['TYPE'];
615 842
 			    $data['imo'] = $line['IMO'];
616
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
617
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
843
+			    if ($line['DEST'] != '') {
844
+			    	$data['arrival_code'] = $line['DEST'];
845
+			    }
846
+			    if ($line['ARV'] != '') {
847
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
848
+			    }
618 849
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
619 850
 			    $data['format_source'] = 'myshiptracking';
620 851
 			    $data['id_source'] = $id_source;
621
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
852
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
853
+			    	$data['noarchive'] = true;
854
+			    }
622 855
 			    $MI->add($data);
623 856
 			    unset($data);
624 857
 			}
@@ -643,7 +876,9 @@  discard block
 block discarded – undo
643 876
 			    $data['callsign'] = $line['callsign'];
644 877
 			    $data['mmsi'] = substr($line['mmsi'],-9);
645 878
 			    $data['speed'] = $line['sog'];
646
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
879
+			    if ($line['heading'] != '511') {
880
+			    	$data['heading'] = $line['heading'];
881
+			    }
647 882
 			    $data['latitude'] = $line['latitude'];
648 883
 			    $data['longitude'] = $line['longitude'];
649 884
 			    $data['type_id'] = $line['shiptype'];
@@ -651,7 +886,9 @@  discard block
 block discarded – undo
651 886
 			    $data['datetime'] = $line['time'];
652 887
 			    $data['format_source'] = 'boatbeaconapp';
653 888
 			    $data['id_source'] = $id_source;
654
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
889
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
890
+			    	$data['noarchive'] = true;
891
+			    }
655 892
 			    $MI->add($data);
656 893
 			    unset($data);
657 894
 			}
@@ -673,22 +910,44 @@  discard block
 block discarded – undo
673 910
 		    foreach ($all_data['features'] as $line) {
674 911
 			print_r($line);
675 912
 			$data = array();
676
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
677
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
678
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
679
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
680
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
681
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
913
+			if (isset($line['properties']['name'])) {
914
+				$data['ident'] = $line['properties']['name'];
915
+			}
916
+			if (isset($line['properties']['callsign'])) {
917
+				$data['callsign'] = $line['properties']['callsign'];
918
+			}
919
+			if (isset($line['properties']['mmsi'])) {
920
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
921
+			}
922
+			if (isset($line['properties']['imo'])) {
923
+				$data['imo'] = $line['properties']['imo'];
924
+			}
925
+			if (isset($line['properties']['speed'])) {
926
+				$data['speed'] = $line['properties']['speed'];
927
+			}
928
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
929
+				$data['heading'] = $line['properties']['heading'];
930
+			}
682 931
 			$data['latitude'] = $line['geometry']['coordinates'][1];
683 932
 			$data['longitude'] = $line['geometry']['coordinates'][0];
684
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
685
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
686
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
933
+			if (isset($line['properties']['vesselType'])) {
934
+				$data['type'] = $line['properties']['vesselType'];
935
+			}
936
+			if (isset($line['properties']['destination'])) {
937
+				$data['arrival_code'] = $line['properties']['destination'];
938
+			}
939
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
940
+				$data['arrival_date'] = $line['properties']['eta'];
941
+			}
687 942
 			$data['format_source'] = 'boatnerd';
688 943
 			$data['id_source'] = $id_source;
689 944
 			$data['datetime'] = date('Y-m-d H:i:s');
690
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
691
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
945
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
946
+				$data['noarchive'] = true;
947
+			}
948
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
949
+				$MI->add($data);
950
+			}
692 951
 			unset($data);
693 952
 		    }
694 953
 		}
@@ -701,11 +960,17 @@  discard block
 block discarded – undo
701 960
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
702 961
 	    )
703 962
 	) {
704
-	    if ($globalDebug) echo 'download...';
963
+	    if ($globalDebug) {
964
+	    	echo 'download...';
965
+	    }
705 966
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
706
-	    if ($globalDebug) echo 'done !'."\n";
967
+	    if ($globalDebug) {
968
+	    	echo 'done !'."\n";
969
+	    }
707 970
 	    // FIXME: Need more work
708
-	    if ($buffer != '') $reset = 0;
971
+	    if ($buffer != '') {
972
+	    	$reset = 0;
973
+	    }
709 974
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
710 975
 	    $buffer = explode('\n',$buffer);
711 976
 	    foreach ($buffer as $line) {
@@ -731,7 +996,9 @@  discard block
 block discarded – undo
731 996
 		    //$data['etaTime'] = substr($line,135,5);
732 997
 		    $data['format_source'] = 'shipplotter';
733 998
     		    $data['id_source'] = $id_source;
734
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
999
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1000
+		    	$data['noarchive'] = true;
1001
+		    }
735 1002
 		    //print_r($data);
736 1003
 		    //echo 'Add...'."\n";
737 1004
 		    $MI->add($data);
@@ -754,11 +1021,17 @@  discard block
 block discarded – undo
754 1021
 		}
755 1022
 	    }
756 1023
 
757
-	    if ($globalDebug) echo '! Download... ';
1024
+	    if ($globalDebug) {
1025
+	    	echo '! Download... ';
1026
+	    }
758 1027
 	    for ($i =0; $i <= 1; $i++) {
759
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1028
+		if ($globalDebug) {
1029
+			echo 'Racetype: '.$i.' ';
1030
+		}
760 1031
 		$buffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
761
-	    if ($globalDebug) echo 'done'."\n";
1032
+	    if ($globalDebug) {
1033
+	    	echo 'done'."\n";
1034
+	    }
762 1035
 	    if ($buffer != '') {
763 1036
 		$all_data = json_decode($buffer,true);
764 1037
 		if (isset($all_data['missions'])) {
@@ -766,8 +1039,11 @@  discard block
 block discarded – undo
766 1039
 				$mission_user = $mission['usrname'];
767 1040
 				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
768 1041
 				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
769
-					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') $racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
770
-					else $racebuffer = '';
1042
+					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
1043
+						$racebuffer = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
1044
+					} else {
1045
+						$racebuffer = '';
1046
+					}
771 1047
 					$bufferm = $Common->getData('https://sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
772 1048
 				} else {
773 1049
 					$bufferm = '';
@@ -831,7 +1107,9 @@  discard block
 block discarded – undo
831 1107
 								$data['captain_id'] = $sail['usrnr'];
832 1108
 								$data['captain_name'] = $sail['usrname'];
833 1109
 								$data['race_id'] = $sail['misnr'];
834
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1110
+								if ($sail['rank'] != 'DNF') {
1111
+									$data['race_rank'] = $sail['rank'];
1112
+								}
835 1113
 								$data['race_time'] = $sail['racetime'];
836 1114
 								if ($mission_user != '') {
837 1115
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -841,7 +1119,9 @@  discard block
 block discarded – undo
841 1119
 								//$data['callsign'] = trim(substr($line,100,7);
842 1120
 								$data['format_source'] = 'sailaway';
843 1121
 								$data['id_source'] = $id_source;
844
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1122
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1123
+									$data['noarchive'] = true;
1124
+								}
845 1125
 								//print_r($data);
846 1126
 								//if ($data['race_id'] == '48') print_r($data);
847 1127
 								//echo 'Add...'."\n";
@@ -883,16 +1163,28 @@  discard block
 block discarded – undo
883 1163
     		    $line = explode(':', $line);
884 1164
     		    if (count($line) > 30 && $line[0] != 'callsign') {
885 1165
 			$data = array();
886
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
887
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1166
+			if (isset($line[37]) && $line[37] != '') {
1167
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1168
+			} else {
1169
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1170
+			}
888 1171
 			$data['pilot_id'] = $line[1];
889 1172
 			$data['pilot_name'] = $line[2];
890 1173
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
891 1174
 			$data['ident'] = $line[0]; // ident
892
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1175
+			if ($line[7] != '' && $line[7] != 0) {
1176
+				$data['altitude'] = $line[7];
1177
+			}
1178
+			// altitude
893 1179
 			$data['speed'] = $line[8]; // speed
894
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
895
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1180
+			if (isset($line[45])) {
1181
+				$data['heading'] = $line[45];
1182
+			}
1183
+			// heading
1184
+			elseif (isset($line[38])) {
1185
+				$data['heading'] = $line[38];
1186
+			}
1187
+			// heading
896 1188
 			$data['latitude'] = $line[5]; // lat
897 1189
 	        	$data['longitude'] = $line[6]; // long
898 1190
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -908,7 +1200,9 @@  discard block
 block discarded – undo
908 1200
 			$data['frequency'] = $line[4];
909 1201
 			$data['type'] = $line[18];
910 1202
 			$data['range'] = $line[19];
911
-			if (isset($line[35])) $data['info'] = $line[35];
1203
+			if (isset($line[35])) {
1204
+				$data['info'] = $line[35];
1205
+			}
912 1206
     			$data['id_source'] = $id_source;
913 1207
 	    		//$data['arrival_airport_time'] = ;
914 1208
 	    		if ($line[9] != '') {
@@ -922,27 +1216,47 @@  discard block
 block discarded – undo
922 1216
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
923 1217
 	    		*/
924 1218
 	    		$data['format_source'] = $value['format'];
925
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
926
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
927
-    			if ($line[3] === 'PILOT') $SI->add($data);
928
-			elseif ($line[3] === 'ATC') {
1219
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1220
+				$data['noarchive'] = true;
1221
+			}
1222
+			if (isset($value['name']) && $value['name'] != '') {
1223
+				$data['source_name'] = $value['name'];
1224
+			}
1225
+    			if ($line[3] === 'PILOT') {
1226
+    				$SI->add($data);
1227
+    			} elseif ($line[3] === 'ATC') {
929 1228
 				//print_r($data);
930 1229
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
931 1230
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
932 1231
 				$typec = substr($data['ident'],-3);
933
-				if ($typec === 'APP') $data['type'] = 'Approach';
934
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
935
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
936
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
937
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
938
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
939
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
940
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
941
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
942
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1232
+				if ($typec === 'APP') {
1233
+					$data['type'] = 'Approach';
1234
+				} elseif ($typec === 'TWR') {
1235
+					$data['type'] = 'Tower';
1236
+				} elseif ($typec === 'OBS') {
1237
+					$data['type'] = 'Observer';
1238
+				} elseif ($typec === 'GND') {
1239
+					$data['type'] = 'Ground';
1240
+				} elseif ($typec === 'DEL') {
1241
+					$data['type'] = 'Delivery';
1242
+				} elseif ($typec === 'DEP') {
1243
+					$data['type'] = 'Departure';
1244
+				} elseif ($typec === 'FSS') {
1245
+					$data['type'] = 'Flight Service Station';
1246
+				} elseif ($typec === 'CTR') {
1247
+					$data['type'] = 'Control Radar or Centre';
1248
+				} elseif ($data['type'] === '') {
1249
+					$data['type'] = 'Observer';
1250
+				}
1251
+				if (!isset($data['source_name'])) {
1252
+					$data['source_name'] = '';
1253
+				}
943 1254
 				if (isset($ATC)) {
944
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
945
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1255
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1256
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1257
+					} else {
1258
+						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']);
1259
+					}
946 1260
 				}
947 1261
 			}
948 1262
     			unset($data);
@@ -969,14 +1283,20 @@  discard block
 block discarded – undo
969 1283
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
970 1284
 			$data['latitude'] = (float)$line['pktLatitude'];
971 1285
 			$data['longitude'] = (float)$line['pktLongitude'];
972
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
973
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1286
+			if ((float)$line['pktTrack'] != 0) {
1287
+				$data['heading'] = (float)$line['pktTrack'];
1288
+			}
1289
+			if ((int)$line['pktSpeed'] != 0) {
1290
+				$data['speed'] = (int)$line['pktSpeed'];
1291
+			}
974 1292
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
975 1293
 			$data['altitude_relative'] = 'AMSL';
976 1294
 			$data['pilot_id'] = (int)$line['pktPilotID'];
977 1295
 			$data['aircraft_icao'] = 'PARAGLIDER';
978 1296
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
979
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1297
+			if (isset($pilot_data[4])) {
1298
+				$data['pilot_name'] = $pilot_data[4];
1299
+			}
980 1300
 			$data['format_source'] = $value['format'];
981 1301
 			$SI->add($data);
982 1302
 			unset($data);
@@ -1024,25 +1344,59 @@  discard block
 block discarded – undo
1024 1344
 		    foreach ($all_data['acList'] as $line) {
1025 1345
 			$data = array();
1026 1346
 			$data['hex'] = $line['Icao']; // hex
1027
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1028
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1029
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1030
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1031
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1032
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1347
+			if (isset($line['Call'])) {
1348
+				$data['ident'] = $line['Call'];
1349
+			}
1350
+			// ident
1351
+			if (isset($line['Alt'])) {
1352
+				$data['altitude'] = $line['Alt'];
1353
+			}
1354
+			// altitude
1355
+			if (isset($line['Spd'])) {
1356
+				$data['speed'] = $line['Spd'];
1357
+			}
1358
+			// speed
1359
+			if (isset($line['Trak'])) {
1360
+				$data['heading'] = $line['Trak'];
1361
+			}
1362
+			// heading
1363
+			if (isset($line['Lat'])) {
1364
+				$data['latitude'] = $line['Lat'];
1365
+			}
1366
+			// lat
1367
+			if (isset($line['Long'])) {
1368
+				$data['longitude'] = $line['Long'];
1369
+			}
1370
+			// long
1033 1371
 			//$data['verticalrate'] = $line['']; // verticale rate
1034
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1372
+			if (isset($line['Sqk'])) {
1373
+				$data['squawk'] = $line['Sqk'];
1374
+			}
1375
+			// squawk
1035 1376
 			$data['emergency'] = ''; // emergency
1036
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1037
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1038
-			else $data['datetime'] = date('Y-m-d H:i:s');
1377
+			if (isset($line['Reg'])) {
1378
+				$data['registration'] = $line['Reg'];
1379
+			}
1380
+			if (isset($line['PosTime'])) {
1381
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1382
+			} else {
1383
+				$data['datetime'] = date('Y-m-d H:i:s');
1384
+			}
1039 1385
 			//$data['datetime'] = date('Y-m-d H:i:s');
1040
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1386
+			if (isset($line['Type'])) {
1387
+				$data['aircraft_icao'] = $line['Type'];
1388
+			}
1041 1389
 			$data['format_source'] = 'aircraftlistjson';
1042 1390
 			$data['id_source'] = $id_source;
1043
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1044
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1045
-			if (isset($data['latitude'])) $SI->add($data);
1391
+			if (isset($value['name']) && $value['name'] != '') {
1392
+				$data['source_name'] = $value['name'];
1393
+			}
1394
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1395
+				$data['noarchive'] = true;
1396
+			}
1397
+			if (isset($data['latitude'])) {
1398
+				$SI->add($data);
1399
+			}
1046 1400
 			unset($data);
1047 1401
 		    }
1048 1402
 		} elseif (is_array($all_data)) {
@@ -1059,17 +1413,26 @@  discard block
 block discarded – undo
1059 1413
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1060 1414
 			$data['squawk'] = $line['squawk']; // squawk
1061 1415
 			$data['emergency'] = ''; // emergency
1062
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1063
-			else $data['datetime'] = date('Y-m-d H:i:s');
1416
+			if (isset($line['PosTime'])) {
1417
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1418
+			} else {
1419
+				$data['datetime'] = date('Y-m-d H:i:s');
1420
+			}
1064 1421
 			$data['format_source'] = 'aircraftlistjson';
1065 1422
 			$data['id_source'] = $id_source;
1066
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1067
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1423
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1424
+				$data['noarchive'] = true;
1425
+			}
1426
+			if (isset($value['name']) && $value['name'] != '') {
1427
+				$data['source_name'] = $value['name'];
1428
+			}
1068 1429
 			$SI->add($data);
1069 1430
 			unset($data);
1070 1431
 		    }
1071 1432
 		}
1072
-	    } elseif ($globalDebug) echo 'No data'."\n";
1433
+	    } elseif ($globalDebug) {
1434
+	    	echo 'No data'."\n";
1435
+	    }
1073 1436
     	    //$last_exec['aircraftlistjson'] = time();
1074 1437
     	    $last_exec[$id]['last'] = time();
1075 1438
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1105,8 +1468,12 @@  discard block
 block discarded – undo
1105 1468
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1106 1469
 	    	    $data['format_source'] = 'planeupdatefaa';
1107 1470
     		    $data['id_source'] = $id_source;
1108
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1109
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1471
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1472
+		    	$data['noarchive'] = true;
1473
+		    }
1474
+		    if (isset($value['name']) && $value['name'] != '') {
1475
+		    	$data['source_name'] = $value['name'];
1476
+		    }
1110 1477
 		    $SI->add($data);
1111 1478
 		    unset($data);
1112 1479
 		}
@@ -1140,7 +1507,9 @@  discard block
 block discarded – undo
1140 1507
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1141 1508
 		    $data['format_source'] = 'opensky';
1142 1509
 		    $data['id_source'] = $id_source;
1143
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1510
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1511
+		    	$data['noarchive'] = true;
1512
+		    }
1144 1513
 		    $SI->add($data);
1145 1514
 		    unset($data);
1146 1515
 		}
@@ -1160,15 +1529,42 @@  discard block
 block discarded – undo
1160 1529
 		foreach ($all_data['aircraft'] as $key => $line) {
1161 1530
 		    $data = array();
1162 1531
 		    // add support for ground vehicule with ~ in front of hex
1163
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1164
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1165
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1166
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1167
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1168
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1169
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1170
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1171
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1532
+		    if (isset($line['hex'])) {
1533
+		    	$data['hex'] = $line['hex'];
1534
+		    }
1535
+		    // hex
1536
+		    if (isset($line['flight'])) {
1537
+		    	$data['ident'] = trim($line['flight']);
1538
+		    }
1539
+		    // ident
1540
+		    if (isset($line['altitude'])) {
1541
+		    	$data['altitude'] = $line['altitude'];
1542
+		    }
1543
+		    // altitude
1544
+		    if (isset($line['speed'])) {
1545
+		    	$data['speed'] = $line['speed'];
1546
+		    }
1547
+		    // speed
1548
+		    if (isset($line['track'])) {
1549
+		    	$data['heading'] = $line['track'];
1550
+		    }
1551
+		    // heading
1552
+		    if (isset($line['lat'])) {
1553
+		    	$data['latitude'] = $line['lat'];
1554
+		    }
1555
+		    // lat
1556
+		    if (isset($line['lon'])) {
1557
+		    	$data['longitude'] = $line['lon'];
1558
+		    }
1559
+		    // long
1560
+		    if (isset($line['vert_rate'])) {
1561
+		    	$data['verticalrate'] = $line['vert_rate'];
1562
+		    }
1563
+		    // verticale rate
1564
+		    if (isset($line['squawk'])) {
1565
+		    	$data['squawk'] = $line['squawk'];
1566
+		    }
1567
+		    // squawk
1172 1568
 		    //$data['emergency'] = ''; // emergency
1173 1569
 		    //$data['registration'] = $line[2];
1174 1570
 		    //$data['aircraft_icao'] = $line[0];
@@ -1176,10 +1572,17 @@  discard block
 block discarded – undo
1176 1572
 		    $data['format_source'] = 'aircraftjson';
1177 1573
 		    $data['id_source'] = $id_source;
1178 1574
 		    if (isset($value['name']) && $value['name'] != '') {
1179
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1180
-			    else $data['source_name'] = $value['name'];
1181
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1182
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1575
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1576
+			    	$data['source_name'] = $value['name'].'_MLAT';
1577
+			    } else {
1578
+			    	$data['source_name'] = $value['name'];
1579
+			    }
1580
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1581
+		    	$data['source_name'] = 'MLAT';
1582
+		    }
1583
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1584
+		    	$data['noarchive'] = true;
1585
+		    }
1183 1586
 		    $SI->add($data);
1184 1587
 		    unset($data);
1185 1588
 		}
@@ -1199,22 +1602,54 @@  discard block
 block discarded – undo
1199 1602
 		foreach ($all_data['aircraft'] as $key => $line) {
1200 1603
 		    $data = array();
1201 1604
 		    $data['hex'] = $key; // hex
1202
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1203
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1204
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1205
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1206
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1207
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1208
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1209
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1605
+		    if (isset($line['callsign'])) {
1606
+		    	$data['ident'] = trim($line['callsign']);
1607
+		    }
1608
+		    // ident
1609
+		    if (isset($line['altitude'])) {
1610
+		    	$data['altitude'] = $line['altitude'];
1611
+		    }
1612
+		    // altitude
1613
+		    if (isset($line['speed'])) {
1614
+		    	$data['speed'] = $line['speed'];
1615
+		    }
1616
+		    // speed
1617
+		    if (isset($line['heading'])) {
1618
+		    	$data['heading'] = $line['heading'];
1619
+		    }
1620
+		    // heading
1621
+		    if (isset($line['lat'])) {
1622
+		    	$data['latitude'] = $line['lat'];
1623
+		    }
1624
+		    // lat
1625
+		    if (isset($line['lon'])) {
1626
+		    	$data['longitude'] = $line['lon'];
1627
+		    }
1628
+		    // long
1629
+		    if (isset($line['vert_rate'])) {
1630
+		    	$data['verticalrate'] = $line['vert_rate'];
1631
+		    }
1632
+		    // verticale rate
1633
+		    if (isset($line['squawk'])) {
1634
+		    	$data['squawk'] = $line['squawk'];
1635
+		    }
1636
+		    // squawk
1210 1637
 		    //$data['emergency'] = ''; // emergency
1211
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1212
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1638
+		    if (isset($line['reg'])) {
1639
+		    	$data['registration'] = $line['reg'];
1640
+		    }
1641
+		    if (isset($line['type'])) {
1642
+		    	$data['aircraft_icao'] = $line['type'];
1643
+		    }
1213 1644
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1214 1645
 		    $data['format_source'] = 'planefinderclient';
1215 1646
 		    $data['id_source'] = $id_source;
1216
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1217
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1647
+		    if (isset($value['name']) && $value['name'] != '') {
1648
+		    	$data['source_name'] = $value['name'];
1649
+		    }
1650
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1651
+		    	$data['noarchive'] = true;
1652
+		    }
1218 1653
 		    $SI->add($data);
1219 1654
 		    unset($data);
1220 1655
 		}
@@ -1230,7 +1665,9 @@  discard block
 block discarded – undo
1230 1665
 	    //$buffer = $Common->getData($hosts[$id]);
1231 1666
 	    $buffer = $Common->getData($value['host']);
1232 1667
 	    $all_data = json_decode($buffer,true);
1233
-	    if (!empty($all_data)) $reset = 0;
1668
+	    if (!empty($all_data)) {
1669
+	    	$reset = 0;
1670
+	    }
1234 1671
 	    foreach ($all_data as $key => $line) {
1235 1672
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1236 1673
 		    $data = array();
@@ -1251,8 +1688,12 @@  discard block
 block discarded – undo
1251 1688
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1252 1689
 	    	    $data['format_source'] = 'fr24json';
1253 1690
     		    $data['id_source'] = $id_source;
1254
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1255
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1691
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1692
+		    	$data['noarchive'] = true;
1693
+		    }
1694
+		    if (isset($value['name']) && $value['name'] != '') {
1695
+		    	$data['source_name'] = $value['name'];
1696
+		    }
1256 1697
 		    $SI->add($data);
1257 1698
 		    unset($data);
1258 1699
 		}
@@ -1281,24 +1722,42 @@  discard block
 block discarded – undo
1281 1722
 		    if (isset($line['inf'])) {
1282 1723
 			$data = array();
1283 1724
 			$data['hex'] = $line['inf']['ia'];
1284
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1725
+			if (isset($line['inf']['cs'])) {
1726
+				$data['ident'] = $line['inf']['cs'];
1727
+			}
1728
+			//$line[13]
1285 1729
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1286
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1287
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1730
+	    		if (isset($line['inf']['gs'])) {
1731
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1732
+	    		}
1733
+	    		// speed
1734
+	    		if (isset($line['inf']['tr'])) {
1735
+	    			$data['heading'] = $line['inf']['tr'];
1736
+	    		}
1737
+	    		// heading
1288 1738
 	    		$data['latitude'] = $line['pt'][0]; // lat
1289 1739
 	    		$data['longitude'] = $line['pt'][1]; // long
1290 1740
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1291
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1741
+	    		if (isset($line['inf']['sq'])) {
1742
+	    			$data['squawk'] = $line['inf']['sq'];
1743
+	    		}
1744
+	    		// squawk
1292 1745
 	    		//$data['aircraft_icao'] = $line[8];
1293
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1746
+	    		if (isset($line['inf']['rc'])) {
1747
+	    			$data['registration'] = $line['inf']['rc'];
1748
+	    		}
1294 1749
 			//$data['departure_airport_iata'] = $line[11];
1295 1750
 			//$data['arrival_airport_iata'] = $line[12];
1296 1751
 	    		//$data['emergency'] = ''; // emergency
1297 1752
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1298 1753
 	    		$data['format_source'] = 'radarvirtueljson';
1299 1754
     			$data['id_source'] = $id_source;
1300
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1301
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1755
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1756
+				$data['noarchive'] = true;
1757
+			}
1758
+			if (isset($value['name']) && $value['name'] != '') {
1759
+				$data['source_name'] = $value['name'];
1760
+			}
1302 1761
 			$SI->add($data);
1303 1762
 			unset($data);
1304 1763
 		    }
@@ -1324,30 +1783,65 @@  discard block
 block discarded – undo
1324 1783
 		    $data['id'] = $line['id'];
1325 1784
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1326 1785
 		    $data['ident'] = $line['callsign']; // ident
1327
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1328
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1329
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1330
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1331
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1332
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1786
+		    if (isset($line['pilotid'])) {
1787
+		    	$data['pilot_id'] = $line['pilotid'];
1788
+		    }
1789
+		    // pilot id
1790
+		    if (isset($line['name'])) {
1791
+		    	$data['pilot_name'] = $line['name'];
1792
+		    }
1793
+		    // pilot name
1794
+		    if (isset($line['alt'])) {
1795
+		    	$data['altitude'] = $line['alt'];
1796
+		    }
1797
+		    // altitude
1798
+		    if (isset($line['gs'])) {
1799
+		    	$data['speed'] = $line['gs'];
1800
+		    }
1801
+		    // speed
1802
+		    if (isset($line['heading'])) {
1803
+		    	$data['heading'] = $line['heading'];
1804
+		    }
1805
+		    // heading
1806
+		    if (isset($line['route'])) {
1807
+		    	$data['waypoints'] = $line['route'];
1808
+		    }
1809
+		    // route
1333 1810
 		    $data['latitude'] = $line['lat']; // lat
1334 1811
 		    $data['longitude'] = $line['lon']; // long
1335 1812
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1336 1813
 		    //$data['squawk'] = $line['squawk']; // squawk
1337 1814
 		    //$data['emergency'] = ''; // emergency
1338
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1339
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1340
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1815
+		    if (isset($line['depicao'])) {
1816
+		    	$data['departure_airport_icao'] = $line['depicao'];
1817
+		    }
1818
+		    if (isset($line['deptime'])) {
1819
+		    	$data['departure_airport_time'] = $line['deptime'];
1820
+		    }
1821
+		    if (isset($line['arricao'])) {
1822
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1823
+		    }
1341 1824
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1342
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1343
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1344
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1345
-		    else $data['info'] = '';
1825
+		    if (isset($line['aircraft'])) {
1826
+		    	$data['aircraft_icao'] = $line['aircraft'];
1827
+		    }
1828
+		    if (isset($line['transponder'])) {
1829
+		    	$data['squawk'] = $line['transponder'];
1830
+		    }
1831
+		    if (isset($line['atis'])) {
1832
+		    	$data['info'] = $line['atis'];
1833
+		    } else {
1834
+		    	$data['info'] = '';
1835
+		    }
1346 1836
 		    $data['format_source'] = 'pireps';
1347 1837
     		    $data['id_source'] = $id_source;
1348 1838
 		    $data['datetime'] = date('Y-m-d H:i:s');
1349
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1350
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1839
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1840
+		    	$data['noarchive'] = true;
1841
+		    }
1842
+		    if (isset($value['name']) && $value['name'] != '') {
1843
+		    	$data['source_name'] = $value['name'];
1844
+		    }
1351 1845
 		    if ($line['icon'] === 'plane') {
1352 1846
 			$SI->add($data);
1353 1847
 		    //    print_r($data);
@@ -1356,16 +1850,28 @@  discard block
 block discarded – undo
1356 1850
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1357 1851
 			$typec = substr($data['ident'],-3);
1358 1852
 			$data['type'] = '';
1359
-			if ($typec === 'APP') $data['type'] = 'Approach';
1360
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1361
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1362
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1363
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1364
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1365
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1366
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1367
-			else $data['type'] = 'Observer';
1368
-			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']);
1853
+			if ($typec === 'APP') {
1854
+				$data['type'] = 'Approach';
1855
+			} elseif ($typec === 'TWR') {
1856
+				$data['type'] = 'Tower';
1857
+			} elseif ($typec === 'OBS') {
1858
+				$data['type'] = 'Observer';
1859
+			} elseif ($typec === 'GND') {
1860
+				$data['type'] = 'Ground';
1861
+			} elseif ($typec === 'DEL') {
1862
+				$data['type'] = 'Delivery';
1863
+			} elseif ($typec === 'DEP') {
1864
+				$data['type'] = 'Departure';
1865
+			} elseif ($typec === 'FSS') {
1866
+				$data['type'] = 'Flight Service Station';
1867
+			} elseif ($typec === 'CTR') {
1868
+				$data['type'] = 'Control Radar or Centre';
1869
+			} else {
1870
+				$data['type'] = 'Observer';
1871
+			}
1872
+			if (isset($ATC)) {
1873
+				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']);
1874
+			}
1369 1875
 		    }
1370 1876
 		    unset($data);
1371 1877
 		}
@@ -1380,7 +1886,9 @@  discard block
 block discarded – undo
1380 1886
 	    )
1381 1887
 	) {
1382 1888
 	    //$buffer = $Common->getData($hosts[$id]);
1383
-	    if ($globalDebug) echo 'Get Data...'."\n";
1889
+	    if ($globalDebug) {
1890
+	    	echo 'Get Data...'."\n";
1891
+	    }
1384 1892
 	    $buffer = $Common->getData($value['host']);
1385 1893
 	    $all_data = json_decode($buffer,true);
1386 1894
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1388,10 +1896,16 @@  discard block
 block discarded – undo
1388 1896
 		foreach ($all_data as $line) {
1389 1897
 	    	    $data = array();
1390 1898
 	    	    //$data['id'] = $line['id']; // id not usable
1391
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1899
+	    	    if (isset($line['pilotid'])) {
1900
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1901
+	    	    }
1392 1902
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1393
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1394
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1903
+	    	    if (isset($line['pilotname'])) {
1904
+	    	    	$data['pilot_name'] = $line['pilotname'];
1905
+	    	    }
1906
+	    	    if (isset($line['pilotid'])) {
1907
+	    	    	$data['pilot_id'] = $line['pilotid'];
1908
+	    	    }
1395 1909
 	    	    $data['ident'] = $line['flightnum']; // ident
1396 1910
 	    	    $data['altitude'] = $line['alt']; // altitude
1397 1911
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1407,7 +1921,9 @@  discard block
 block discarded – undo
1407 1921
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1408 1922
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1409 1923
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1410
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1924
+	    	    } else {
1925
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1926
+	    	    }
1411 1927
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1412 1928
 	    	    $data['departure_airport_time'] = $line['deptime'];
1413 1929
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1415,29 +1931,47 @@  discard block
 block discarded – undo
1415 1931
     		    if (isset($line['registration'])) {
1416 1932
     			$data['registration'] = $line['registration'];
1417 1933
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1418
-    		    } else $data['registration'] = $line['aircraft'];
1419
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1420
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1934
+    		    } else {
1935
+    		    	$data['registration'] = $line['aircraft'];
1936
+    		    }
1937
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1938
+		    	$data['noarchive'] = true;
1939
+		    }
1940
+		    if (isset($line['route'])) {
1941
+		    	$data['waypoints'] = $line['route'];
1942
+		    }
1943
+		    // route
1421 1944
 		    if (isset($line['aircraftname'])) {
1422 1945
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1423 1946
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1424 1947
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1425
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1426
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1427
-	    		else {
1948
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1949
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1950
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1951
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1952
+	    		} else {
1428 1953
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1429
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1430
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1954
+	    		    if (isset($aircraft_data[1])) {
1955
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1956
+	    		    } else {
1957
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1958
+	    		    }
1431 1959
 	    		}
1432 1960
 	    	    }
1433
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1961
+    		    if (isset($line['route'])) {
1962
+    		    	$data['waypoints'] = $line['route'];
1963
+    		    }
1434 1964
     		    $data['id_source'] = $id_source;
1435 1965
 	    	    $data['format_source'] = 'phpvmacars';
1436
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1966
+		    if (isset($value['name']) && $value['name'] != '') {
1967
+		    	$data['source_name'] = $value['name'];
1968
+		    }
1437 1969
 		    $SI->add($data);
1438 1970
 		    unset($data);
1439 1971
 		}
1440
-		if ($globalDebug) echo 'No more data...'."\n";
1972
+		if ($globalDebug) {
1973
+			echo 'No more data...'."\n";
1974
+		}
1441 1975
 		unset($buffer);
1442 1976
 		unset($all_data);
1443 1977
 	    }
@@ -1450,7 +1984,9 @@  discard block
 block discarded – undo
1450 1984
 	    )
1451 1985
 	) {
1452 1986
 	    //$buffer = $Common->getData($hosts[$id]);
1453
-	    if ($globalDebug) echo 'Get Data...'."\n";
1987
+	    if ($globalDebug) {
1988
+	    	echo 'Get Data...'."\n";
1989
+	    }
1454 1990
 	    $buffer = $Common->getData($value['host']);
1455 1991
 	    $all_data = json_decode($buffer,true);
1456 1992
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1461,10 +1997,16 @@  discard block
 block discarded – undo
1461 1997
 	    	    //$data['id'] = $line['id']; // id not usable
1462 1998
 	    	    $data['id'] = $line['id'];
1463 1999
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1464
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1465
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2000
+	    	    if (isset($line['user']['username'])) {
2001
+	    	    	$data['pilot_name'] = $line['user']['username'];
2002
+	    	    }
2003
+	    	    if (isset($line['user_id'])) {
2004
+	    	    	$data['pilot_id'] = $line['user_id'];
2005
+	    	    }
1466 2006
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1467
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2007
+	    	    if (is_numeric($data['ident'])) {
2008
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2009
+	    	    }
1468 2010
 	    	    $data['altitude'] = $line['altitude']; // altitude
1469 2011
 	    	    $data['speed'] = $line['groundspeed']; // speed
1470 2012
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1477,7 +2019,9 @@  discard block
 block discarded – undo
1477 2019
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1478 2020
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1479 2021
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1480
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2022
+	    	    } else {
2023
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2024
+	    	    }
1481 2025
 	    	    
1482 2026
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1483 2027
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1485,17 +2029,26 @@  discard block
 block discarded – undo
1485 2029
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1486 2030
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1487 2031
 
1488
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1489
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2032
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2033
+		    	$data['noarchive'] = true;
2034
+		    }
2035
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2036
+		    	$data['waypoints'] = $line['bid']['route'];
2037
+		    }
2038
+		    // route
1490 2039
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1491 2040
 
1492 2041
     		    $data['id_source'] = $id_source;
1493 2042
 	    	    $data['format_source'] = 'vaos';
1494
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2043
+		    if (isset($value['name']) && $value['name'] != '') {
2044
+		    	$data['source_name'] = $value['name'];
2045
+		    }
1495 2046
 		    $SI->add($data);
1496 2047
 		    unset($data);
1497 2048
 		}
1498
-		if ($globalDebug) echo 'No more data...'."\n";
2049
+		if ($globalDebug) {
2050
+			echo 'No more data...'."\n";
2051
+		}
1499 2052
 		unset($buffer);
1500 2053
 		unset($all_data);
1501 2054
 	    }
@@ -1508,7 +2061,9 @@  discard block
 block discarded – undo
1508 2061
 	    )
1509 2062
 	) {
1510 2063
 	    //$buffer = $Common->getData($hosts[$id]);
1511
-	    if ($globalDebug) echo 'Get Data...'."\n";
2064
+	    if ($globalDebug) {
2065
+	    	echo 'Get Data...'."\n";
2066
+	    }
1512 2067
 	    $buffer = $Common->getData($value['host']);
1513 2068
 	    $all_data = json_decode($buffer,true);
1514 2069
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1537,16 +2092,25 @@  discard block
 block discarded – undo
1537 2092
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1538 2093
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1539 2094
     		    //$data['registration'] = $line['aircraft'];
1540
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2095
+		    if (isset($line['route'])) {
2096
+		    	$data['waypoints'] = $line['route'];
2097
+		    }
2098
+		    // route
1541 2099
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1542 2100
     		    $data['id_source'] = $id_source;
1543 2101
 	    	    $data['format_source'] = 'vam';
1544
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1545
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2102
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2103
+		    	$data['noarchive'] = true;
2104
+		    }
2105
+		    if (isset($value['name']) && $value['name'] != '') {
2106
+		    	$data['source_name'] = $value['name'];
2107
+		    }
1546 2108
 		    $SI->add($data);
1547 2109
 		    unset($data);
1548 2110
 		}
1549
-		if ($globalDebug) echo 'No more data...'."\n";
2111
+		if ($globalDebug) {
2112
+			echo 'No more data...'."\n";
2113
+		}
1550 2114
 		unset($buffer);
1551 2115
 		unset($all_data);
1552 2116
 	    }
@@ -1559,7 +2123,9 @@  discard block
 block discarded – undo
1559 2123
 	    )
1560 2124
 	) {
1561 2125
 	    //$buffer = $Common->getData($hosts[$id]);
1562
-	    if ($globalDebug) echo 'Get Data...'."\n";
2126
+	    if ($globalDebug) {
2127
+	    	echo 'Get Data...'."\n";
2128
+	    }
1563 2129
 	    $buffer = $Common->getData($value['host']);
1564 2130
 	    $all_data = json_decode($buffer,true);
1565 2131
 	    if ($buffer != '') {
@@ -1577,12 +2143,16 @@  discard block
 block discarded – undo
1577 2143
 			$data['id_source'] = $id_source;
1578 2144
 			$data['format_source'] = 'blitzortung';
1579 2145
 			$SI->add($data);
1580
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2146
+			if ($globalDebug) {
2147
+				echo '☈ Lightning added'."\n";
2148
+			}
1581 2149
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1582 2150
 			unset($data);
1583 2151
 		    }
1584 2152
 		}
1585
-		if ($globalDebug) echo 'No more data...'."\n";
2153
+		if ($globalDebug) {
2154
+			echo 'No more data...'."\n";
2155
+		}
1586 2156
 		unset($buffer);
1587 2157
 	    }
1588 2158
 	    $last_exec[$id]['last'] = time();
@@ -1594,7 +2164,9 @@  discard block
 block discarded – undo
1594 2164
 	    $write = NULL;
1595 2165
 	    $e = NULL;
1596 2166
 	    $n = socket_select($read, $write, $e, $timeout);
1597
-	    if ($e != NULL) var_dump($e);
2167
+	    if ($e != NULL) {
2168
+	    	var_dump($e);
2169
+	    }
1598 2170
 	    if ($n > 0) {
1599 2171
 		$reset = 0;
1600 2172
 		foreach ($read as $nb => $r) {
@@ -1616,13 +2188,17 @@  discard block
 block discarded – undo
1616 2188
 		    if ($buffer !== FALSE) {
1617 2189
 			if ($format === 'vrstcp') {
1618 2190
 			    $buffer = explode('},{',$buffer);
1619
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2191
+			} else {
2192
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2193
+			}
1620 2194
 		    }
1621 2195
 		    // SBS format is CSV format
1622 2196
 		    if ($buffer !== FALSE && $buffer !== '') {
1623 2197
 			$tt[$format] = 0;
1624 2198
 			if ($format === 'acarssbs3') {
1625
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2199
+			    if ($globalDebug) {
2200
+			    	echo 'ACARS : '.$buffer."\n";
2201
+			    }
1626 2202
 			    $ACARS->add(trim($buffer));
1627 2203
 			    $ACARS->deleteLiveAcarsData();
1628 2204
 			} elseif ($format === 'raw') {
@@ -1632,31 +2208,69 @@  discard block
 block discarded – undo
1632 2208
 				//print_r($data);
1633 2209
 				$data['datetime'] = date('Y-m-d H:i:s');
1634 2210
 				$data['format_source'] = 'raw';
1635
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1636
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1637
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2211
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2212
+					$data['source_name'] = $globalSources[$nb]['name'];
2213
+				}
2214
+				if (isset($globalSources[$nb]['sourcestats'])) {
2215
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2216
+				}
2217
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2218
+					$data['noarchive'] = true;
2219
+				}
1638 2220
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1639 2221
 				$SI->add($data);
1640 2222
 			    }
1641 2223
 			} elseif ($format === 'ais') {
1642 2224
 			    $ais_data = $AIS->parse_line(trim($buffer));
1643 2225
 			    $data = array();
1644
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1645
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1646
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1647
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1648
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1649
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1650
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1651
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1652
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1653
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1654
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1655
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1656
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1657
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1658
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1659
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2226
+			    if (isset($ais_data['ident'])) {
2227
+			    	$data['ident'] = $ais_data['ident'];
2228
+			    }
2229
+			    if (isset($ais_data['mmsi'])) {
2230
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2231
+			    }
2232
+			    if (isset($ais_data['speed'])) {
2233
+			    	$data['speed'] = $ais_data['speed'];
2234
+			    }
2235
+			    if (isset($ais_data['heading'])) {
2236
+			    	$data['heading'] = $ais_data['heading'];
2237
+			    }
2238
+			    if (isset($ais_data['latitude'])) {
2239
+			    	$data['latitude'] = $ais_data['latitude'];
2240
+			    }
2241
+			    if (isset($ais_data['longitude'])) {
2242
+			    	$data['longitude'] = $ais_data['longitude'];
2243
+			    }
2244
+			    if (isset($ais_data['status'])) {
2245
+			    	$data['status'] = $ais_data['status'];
2246
+			    }
2247
+			    if (isset($ais_data['statusid'])) {
2248
+			    	$data['status_id'] = $ais_data['statusid'];
2249
+			    }
2250
+			    if (isset($ais_data['type'])) {
2251
+			    	$data['type'] = $ais_data['type'];
2252
+			    }
2253
+			    if (isset($ais_data['imo'])) {
2254
+			    	$data['imo'] = $ais_data['imo'];
2255
+			    }
2256
+			    if (isset($ais_data['callsign'])) {
2257
+			    	$data['callsign'] = $ais_data['callsign'];
2258
+			    }
2259
+			    if (isset($ais_data['destination'])) {
2260
+			    	$data['arrival_code'] = $ais_data['destination'];
2261
+			    }
2262
+			    if (isset($ais_data['eta_ts'])) {
2263
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2264
+			    }
2265
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2266
+			    	$data['noarchive'] = true;
2267
+			    }
2268
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2269
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2270
+			    }
2271
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2272
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2273
+			    }
1660 2274
 
1661 2275
 			    if (isset($ais_data['timestamp'])) {
1662 2276
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1665,7 +2279,9 @@  discard block
 block discarded – undo
1665 2279
 			    }
1666 2280
 			    $data['format_source'] = 'aisnmea';
1667 2281
     			    $data['id_source'] = $id_source;
1668
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2282
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2283
+			    	$MI->add($data);
2284
+			    }
1669 2285
 			    unset($data);
1670 2286
                         } elseif ($format === 'flightgearsp') {
1671 2287
                     	    //echo $buffer."\n";
@@ -1683,12 +2299,18 @@  discard block
 block discarded – undo
1683 2299
 				$data['speed'] = round($line[5]*1.94384);
1684 2300
 				$data['datetime'] = date('Y-m-d H:i:s');
1685 2301
 				$data['format_source'] = 'flightgearsp';
1686
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1687
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2302
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2303
+					$data['noarchive'] = true;
2304
+				}
2305
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2306
+					$SI->add($data);
2307
+				}
1688 2308
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1689 2309
 			    }
1690 2310
                         } elseif ($format === 'acars') {
1691
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2311
+                    	    if ($globalDebug) {
2312
+                    	    	echo 'ACARS : '.$buffer."\n";
2313
+                    	    }
1692 2314
 			    $ACARS->add(trim($buffer));
1693 2315
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1694 2316
 			    $ACARS->deleteLiveAcarsData();
@@ -1709,8 +2331,12 @@  discard block
 block discarded – undo
1709 2331
 				    $aircraft_type = $line[10];
1710 2332
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1711 2333
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1712
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1713
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2334
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2335
+				    	$data['noarchive'] = true;
2336
+				    }
2337
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2338
+				    	$SI->add($data);
2339
+				    }
1714 2340
 				}
1715 2341
 			    }
1716 2342
 			} elseif ($format === 'beast') {
@@ -1720,28 +2346,62 @@  discard block
 block discarded – undo
1720 2346
 			    foreach($buffer as $all_data) {
1721 2347
 				$line = json_decode('{'.$all_data.'}',true);
1722 2348
 				$data = array();
1723
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1724
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1725
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1726
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1727
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1728
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1729
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2349
+				if (isset($line['Icao'])) {
2350
+					$data['hex'] = $line['Icao'];
2351
+				}
2352
+				// hex
2353
+				if (isset($line['Call'])) {
2354
+					$data['ident'] = $line['Call'];
2355
+				}
2356
+				// ident
2357
+				if (isset($line['Alt'])) {
2358
+					$data['altitude'] = $line['Alt'];
2359
+				}
2360
+				// altitude
2361
+				if (isset($line['Spd'])) {
2362
+					$data['speed'] = $line['Spd'];
2363
+				}
2364
+				// speed
2365
+				if (isset($line['Trak'])) {
2366
+					$data['heading'] = $line['Trak'];
2367
+				}
2368
+				// heading
2369
+				if (isset($line['Lat'])) {
2370
+					$data['latitude'] = $line['Lat'];
2371
+				}
2372
+				// lat
2373
+				if (isset($line['Long'])) {
2374
+					$data['longitude'] = $line['Long'];
2375
+				}
2376
+				// long
1730 2377
 				//$data['verticalrate'] = $line['']; // verticale rate
1731
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2378
+				if (isset($line['Sqk'])) {
2379
+					$data['squawk'] = $line['Sqk'];
2380
+				}
2381
+				// squawk
1732 2382
 				$data['emergency'] = ''; // emergency
1733
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2383
+				if (isset($line['Reg'])) {
2384
+					$data['registration'] = $line['Reg'];
2385
+				}
1734 2386
 				/*
1735 2387
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1736 2388
 				else $data['datetime'] = date('Y-m-d H:i:s');
1737 2389
 				*/
1738 2390
 				$data['datetime'] = date('Y-m-d H:i:s');
1739
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2391
+				if (isset($line['Type'])) {
2392
+					$data['aircraft_icao'] = $line['Type'];
2393
+				}
1740 2394
 		    		$data['format_source'] = 'vrstcp';
1741 2395
 				$data['id_source'] = $id_source;
1742
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1743
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1744
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2396
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2397
+					$data['noarchive'] = true;
2398
+				}
2399
+				if (isset($value['name']) && $value['name'] != '') {
2400
+					$data['source_name'] = $value['name'];
2401
+				}
2402
+				if (isset($data['latitude']) && isset($data['hex'])) {
2403
+					$SI->add($data);
2404
+				}
1745 2405
 				unset($data);
1746 2406
 			    }
1747 2407
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1754,22 +2414,46 @@  discard block
 block discarded – undo
1754 2414
     				$data['hex'] = $lined['hexid'];
1755 2415
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1756 2416
     				$data['datetime'] = date('Y-m-d H:i:s');;
1757
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1758
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1759
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1760
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1761
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1762
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1763
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2417
+    				if (isset($lined['ident'])) {
2418
+    					$data['ident'] = $lined['ident'];
2419
+    				}
2420
+    				if (isset($lined['lat'])) {
2421
+    					$data['latitude'] = $lined['lat'];
2422
+    				}
2423
+    				if (isset($lined['lon'])) {
2424
+    					$data['longitude'] = $lined['lon'];
2425
+    				}
2426
+    				if (isset($lined['speed'])) {
2427
+    					$data['speed'] = $lined['speed'];
2428
+    				}
2429
+    				if (isset($lined['squawk'])) {
2430
+    					$data['squawk'] = $lined['squawk'];
2431
+    				}
2432
+    				if (isset($lined['alt'])) {
2433
+    					$data['altitude'] = $lined['alt'];
2434
+    				}
2435
+    				if (isset($lined['heading'])) {
2436
+    					$data['heading'] = $lined['heading'];
2437
+    				}
1764 2438
     				$data['id_source'] = $id_source;
1765 2439
     				$data['format_source'] = 'tsv';
1766
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1767
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1768
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1769
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2440
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2441
+    					$data['source_name'] = $globalSources[$nb]['name'];
2442
+    				}
2443
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2444
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2445
+    				}
2446
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2447
+					$data['noarchive'] = true;
2448
+				}
2449
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2450
+    					$SI->add($data);
2451
+    				}
1770 2452
     				unset($lined);
1771 2453
     				unset($data);
1772
-    			    } else $error = true;
2454
+    			    } else {
2455
+    			    	$error = true;
2456
+    			    }
1773 2457
 			} elseif ($format === 'aprs' && $use_aprs) {
1774 2458
 			    if ($aprs_connect === 0) {
1775 2459
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1795,47 +2479,96 @@  discard block
 block discarded – undo
1795 2479
 				    $aprs_last_tx = time();
1796 2480
 				    $data = array();
1797 2481
 				    //print_r($line);
1798
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1799
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1800
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1801
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1802
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1803
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1804
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1805
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1806
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1807
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2482
+				    if (isset($line['address'])) {
2483
+				    	$data['hex'] = $line['address'];
2484
+				    }
2485
+				    if (isset($line['mmsi'])) {
2486
+				    	$data['mmsi'] = $line['mmsi'];
2487
+				    }
2488
+				    if (isset($line['imo'])) {
2489
+				    	$data['imo'] = $line['imo'];
2490
+				    }
2491
+				    if (isset($line['squawk'])) {
2492
+				    	$data['squawk'] = $line['squawk'];
2493
+				    }
2494
+				    if (isset($line['arrival_code'])) {
2495
+				    	$data['arrival_code'] = $line['arrival_code'];
2496
+				    }
2497
+				    if (isset($line['arrival_date'])) {
2498
+				    	$data['arrival_date'] = $line['arrival_date'];
2499
+				    }
2500
+				    if (isset($line['typeid'])) {
2501
+				    	$data['type_id'] = $line['typeid'];
2502
+				    }
2503
+				    if (isset($line['statusid'])) {
2504
+				    	$data['status_id'] = $line['statusid'];
2505
+				    }
2506
+				    if (isset($line['timestamp'])) {
2507
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2508
+				    } else {
2509
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2510
+				    }
1808 2511
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1809
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2512
+				    if (isset($line['ident'])) {
2513
+				    	$data['ident'] = $line['ident'];
2514
+				    }
1810 2515
 				    $data['latitude'] = $line['latitude'];
1811 2516
 				    $data['longitude'] = $line['longitude'];
1812 2517
 				    //$data['verticalrate'] = $line[16];
1813
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2518
+				    if (isset($line['speed'])) {
2519
+				    	$data['speed'] = $line['speed'];
2520
+				    }
1814 2521
 				    //else $data['speed'] = 0;
1815
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1816
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1817
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2522
+				    if (isset($line['altitude'])) {
2523
+				    	$data['altitude'] = $line['altitude'];
2524
+				    }
2525
+				    if (isset($line['comment'])) {
2526
+				    	$data['comment'] = $line['comment'];
2527
+				    }
2528
+				    if (isset($line['symbol'])) {
2529
+				    	$data['type'] = $line['symbol'];
2530
+				    }
1818 2531
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1819 2532
 				    
1820
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2533
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2534
+				    	$data['heading'] = $line['heading'];
2535
+				    }
1821 2536
 				    //else echo 'No heading...'."\n";
1822 2537
 				    //else $data['heading'] = 0;
1823
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2538
+				    if (isset($line['stealth'])) {
2539
+				    	$data['aircraft_type'] = $line['stealth'];
2540
+				    }
1824 2541
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1825
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1826
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1827
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1828
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2542
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2543
+				    	$data['noarchive'] = true;
2544
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2545
+				    	$data['noarchive'] = false;
2546
+				    }
2547
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2548
+				    	$data['noarchive'] = true;
2549
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2550
+				    	$data['noarchive'] = false;
2551
+				    }
1829 2552
     				    $data['id_source'] = $id_source;
1830
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1831
-				    else $data['format_source'] = 'aprs';
2553
+    				    if (isset($line['format_source'])) {
2554
+    				    	$data['format_source'] = $line['format_source'];
2555
+    				    } else {
2556
+				    	$data['format_source'] = 'aprs';
2557
+				    }
1832 2558
 				    $data['source_name'] = $line['source'];
1833
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1834
-				    else $data['source_type'] = 'flarm';
1835
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2559
+				    if (isset($line['source_type'])) {
2560
+				    	$data['source_type'] = $line['source_type'];
2561
+				    } else {
2562
+				    	$data['source_type'] = 'flarm';
2563
+				    }
2564
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2565
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2566
+    				    }
1836 2567
 				    $currentdate = date('Y-m-d H:i:s');
1837 2568
 				    $aprsdate = strtotime($data['datetime']);
1838
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2569
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2570
+				    	$data['altitude_relative'] = 'AMSL';
2571
+				    }
1839 2572
 				    // Accept data if time <= system time + 20s
1840 2573
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1841 2574
 				    if (
@@ -1847,7 +2580,9 @@  discard block
 block discarded – undo
1847 2580
 					$send = $SI->add($data);
1848 2581
 				    } elseif ($data['source_type'] === 'ais') {
1849 2582
 					$data['type'] = '';
1850
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2583
+					if (isset($globalMarine) && $globalMarine) {
2584
+						$send = $MI->add($data);
2585
+					}
1851 2586
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1852 2587
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1853 2588
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1855,8 +2590,12 @@  discard block
 block discarded – undo
1855 2590
 					    $line['symbol'] === 'Glider' || 
1856 2591
 					    $line['symbol'] === 'No. Plane' || 
1857 2592
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1858
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1859
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2593
+					    if ($line['symbol'] === 'Ballon') {
2594
+					    	$data['aircraft_icao'] = 'BALL';
2595
+					    }
2596
+					    if ($line['symbol'] === 'Glider') {
2597
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2598
+					    }
1860 2599
 					    $send = $SI->add($data);
1861 2600
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1862 2601
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1887,9 +2626,13 @@  discard block
 block discarded – undo
1887 2626
 				    //} 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') {
1888 2627
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1889 2628
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1890
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2629
+					if (isset($globalTracker) && $globalTracker) {
2630
+						$send = $TI->add($data);
2631
+					}
1891 2632
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1892
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2633
+					if (!isset($data['altitude'])) {
2634
+						$data['altitude'] = 0;
2635
+					}
1893 2636
 					$Source->deleteOldLocationByType('gs');
1894 2637
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1895 2638
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1898,7 +2641,9 @@  discard block
 block discarded – undo
1898 2641
 					}
1899 2642
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1900 2643
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1901
-					if ($globalDebug) echo '# Weather Station added'."\n";
2644
+					if ($globalDebug) {
2645
+						echo '# Weather Station added'."\n";
2646
+					}
1902 2647
 					$Source->deleteOldLocationByType('wx');
1903 2648
 					$weather_data = json_encode($line);
1904 2649
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1908,7 +2653,9 @@  discard block
 block discarded – undo
1908 2653
 					}
1909 2654
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1910 2655
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1911
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2656
+					if ($globalDebug) {
2657
+						echo '☈ Lightning added'."\n";
2658
+					}
1912 2659
 					$Source->deleteOldLocationByType('lightning');
1913 2660
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1914 2661
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1920,8 +2667,7 @@  discard block
 block discarded – undo
1920 2667
 				    	print_r($line);
1921 2668
 				    }
1922 2669
 				    unset($data);
1923
-				}
1924
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2670
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1925 2671
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1926 2672
 				}
1927 2673
 				/*
@@ -1930,7 +2676,9 @@  discard block
 block discarded – undo
1930 2676
 				}
1931 2677
 				*/
1932 2678
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1933
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2679
+				elseif ($line === true && $globalDebug) {
2680
+					echo '!! Failed : '.$buffer."!!\n";
2681
+				}
1934 2682
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1935 2683
 					$Source->deleteOldLocationByType('lightning');
1936 2684
 					$Source->deleteOldLocationByType('wx');
@@ -1967,27 +2715,47 @@  discard block
 block discarded – undo
1967 2715
     				$data['ground'] = $line[21];
1968 2716
     				$data['emergency'] = $line[19];
1969 2717
     				$data['format_source'] = 'sbs';
1970
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1971
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1972
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1973
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2718
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2719
+					$data['source_name'] = $globalSources[$nb]['name'];
2720
+				} elseif ($line[0] == 'MLAT') {
2721
+					$data['source_name'] = 'MLAT';
2722
+				}
2723
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2724
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2725
+    				}
2726
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2727
+					$data['noarchive'] = true;
2728
+				}
1974 2729
     				$data['id_source'] = $id_source;
1975
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1976
-    				else $error = true;
2730
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2731
+    					$send = $SI->add($data);
2732
+    				} else {
2733
+    					$error = true;
2734
+    				}
1977 2735
     				unset($data);
1978
-    			    } else $error = true;
2736
+    			    } else {
2737
+    			    	$error = true;
2738
+    			    }
1979 2739
 			    if ($error) {
1980 2740
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1981
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2741
+					if ($globalDebug) {
2742
+						echo "Not a message. Ignoring... \n";
2743
+					}
1982 2744
 				} else {
1983
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2745
+					if ($globalDebug) {
2746
+						echo "Wrong line format. Ignoring... \n";
2747
+					}
1984 2748
 					if ($globalDebug) {
1985 2749
 						echo $buffer;
1986 2750
 						//print_r($line);
1987 2751
 					}
1988 2752
 					//socket_close($r);
1989
-					if ($globalDebug) echo "Reconnect after an error...\n";
1990
-					if ($format === 'aprs') $aprs_connect = 0;
2753
+					if ($globalDebug) {
2754
+						echo "Reconnect after an error...\n";
2755
+					}
2756
+					if ($format === 'aprs') {
2757
+						$aprs_connect = 0;
2758
+					}
1991 2759
 					$sourceer[$nb] = $globalSources[$nb];
1992 2760
 					connect_all($sourceer);
1993 2761
 					$sourceer = array();
@@ -1995,10 +2763,14 @@  discard block
 block discarded – undo
1995 2763
 			    }
1996 2764
 			}
1997 2765
 			// Sleep for xxx microseconds
1998
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2766
+			if (isset($globalSBSSleep)) {
2767
+				usleep($globalSBSSleep);
2768
+			}
1999 2769
 		    } else {
2000 2770
 			if ($format === 'flightgearmp') {
2001
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2771
+			    	if ($globalDebug) {
2772
+			    		echo "Reconnect FlightGear MP...";
2773
+			    	}
2002 2774
 				//@socket_close($r);
2003 2775
 				sleep($globalMinFetch);
2004 2776
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2007,10 +2779,15 @@  discard block
 block discarded – undo
2007 2779
 				break;
2008 2780
 				
2009 2781
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2010
-			    if (isset($tt[$format])) $tt[$format]++;
2011
-			    else $tt[$format] = 0;
2782
+			    if (isset($tt[$format])) {
2783
+			    	$tt[$format]++;
2784
+			    } else {
2785
+			    	$tt[$format] = 0;
2786
+			    }
2012 2787
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2013
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2788
+				if ($globalDebug) {
2789
+					echo "ERROR : Reconnect ".$format."...";
2790
+				}
2014 2791
 				//@socket_close($r);
2015 2792
 				sleep(2);
2016 2793
 				$aprs_connect = 0;
@@ -2028,11 +2805,17 @@  discard block
 block discarded – undo
2028 2805
 	    } else {
2029 2806
 		$error = socket_strerror(socket_last_error());
2030 2807
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2031
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2032
-			if (isset($globalDebug)) echo "Restarting...\n";
2808
+			if ($globalDebug) {
2809
+				echo "ERROR : socket_select give this error ".$error . "\n";
2810
+			}
2811
+			if (isset($globalDebug)) {
2812
+				echo "Restarting...\n";
2813
+			}
2033 2814
 			// Restart the script if possible
2034 2815
 			if (is_array($sockets)) {
2035
-			    if ($globalDebug) echo "Shutdown all sockets...";
2816
+			    if ($globalDebug) {
2817
+			    	echo "Shutdown all sockets...";
2818
+			    }
2036 2819
 			    
2037 2820
 			    foreach ($sockets as $sock) {
2038 2821
 				@socket_shutdown($sock,2);
@@ -2040,25 +2823,45 @@  discard block
 block discarded – undo
2040 2823
 			    }
2041 2824
 			    
2042 2825
 			}
2043
-			if ($globalDebug) echo "Waiting...";
2826
+			if ($globalDebug) {
2827
+				echo "Waiting...";
2828
+			}
2044 2829
 			sleep(2);
2045 2830
 			$time = time();
2046 2831
 			//connect_all($hosts);
2047 2832
 			$aprs_connect = 0;
2048
-			if ($reset%5 === 0) sleep(20);
2049
-			if ($reset%10 === 0) sleep(100);
2050
-			if ($reset%20 === 0) sleep(200);
2051
-			if ($reset > 100) exit('Too many attempts...');
2052
-			if ($globalDebug) echo "Restart all connections...";
2833
+			if ($reset%5 === 0) {
2834
+				sleep(20);
2835
+			}
2836
+			if ($reset%10 === 0) {
2837
+				sleep(100);
2838
+			}
2839
+			if ($reset%20 === 0) {
2840
+				sleep(200);
2841
+			}
2842
+			if ($reset > 100) {
2843
+				exit('Too many attempts...');
2844
+			}
2845
+			if ($globalDebug) {
2846
+				echo "Restart all connections...";
2847
+			}
2053 2848
 			connect_all($globalSources);
2054 2849
 		}
2055 2850
 	    }
2056 2851
 	}
2057 2852
 	if ($globalDaemon === false) {
2058
-	    if ($globalDebug) echo 'Check all...'."\n";
2059
-	    if (isset($SI)) $SI->checkAll();
2060
-	    if (isset($TI)) $TI->checkAll();
2061
-	    if (isset($MI)) $MI->checkAll();
2853
+	    if ($globalDebug) {
2854
+	    	echo 'Check all...'."\n";
2855
+	    }
2856
+	    if (isset($SI)) {
2857
+	    	$SI->checkAll();
2858
+	    }
2859
+	    if (isset($TI)) {
2860
+	    	$TI->checkAll();
2861
+	    }
2862
+	    if (isset($MI)) {
2863
+	    	$MI->checkAll();
2864
+	    }
2062 2865
 	}
2063 2866
     }
2064 2867
 }
Please login to merge, or discard this patch.
scripts/daemon-acars.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,7 +37,9 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 // let's try and connect
40
-if ($globalDebug) echo "Listen to acarsdec ... ";
40
+if ($globalDebug) {
41
+	echo "Listen to acarsdec ... ";
42
+}
41 43
 // create our socket and set it to non-blocking
42 44
 $sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Unable to create socket\n");
43 45
 
@@ -50,7 +52,9 @@  discard block
 block discarded – undo
50 52
     die("Could not bind socket : [$errorcode] $errormsg \n");
51 53
 }
52 54
 
53
-if ($globalDebug) echo "LISTEN UDP MODE \n\n";
55
+if ($globalDebug) {
56
+	echo "LISTEN UDP MODE \n\n";
57
+}
54 58
 while(1) {
55 59
     $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port);
56 60
 
@@ -58,7 +62,9 @@  discard block
 block discarded – undo
58 62
     pcntl_signal_dispatch();
59 63
     $dataFound = false;
60 64
     //  (null) 2 23/02/2015 14:46:06 0 -16 X .D-AIPW ! 1L 7 M82A LH077P 010952342854:VP-MIBI+W+0)-V+(),GB1
61
-    if ($globalDebug) echo $buffer."\n";
65
+    if ($globalDebug) {
66
+    	echo $buffer."\n";
67
+    }
62 68
     $ACARS->add(trim($buffer));
63 69
     socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
64 70
     $ACARS->deleteLiveAcarsData();
Please login to merge, or discard this patch.