Completed
Push — master ( d37442...9b55c0 )
by Yannick
30:57
created
install/index.php 2 patches
Spacing   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 require_once(dirname(__FILE__).'/class.create_db.php');
24 24
 require_once(dirname(__FILE__).'/class.update_schema.php');
25 25
 require_once(dirname(__FILE__).'/class.settings.php');
26
-$title="Install";
26
+$title = "Install";
27 27
 require(dirname(__FILE__).'/../require/settings.php');
28 28
 require_once(dirname(__FILE__).'/../require/class.Common.php');
29 29
 require(dirname(__FILE__).'/header.php');
30 30
 
31 31
 if (!isset($_SESSION['install']) && !isset($_SESSION['identified'])) {
32
-	$password = filter_input(INPUT_POST,'password',FILTER_SANITIZE_STRING);
32
+	$password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
33 33
 	if ($password == '') {
34 34
 		if ($globalInstalled && (!isset($globalInstallPassword) || $globalInstallPassword == '')) {
35 35
 			print '<div class="alert alert-danger">You need to change $globalInstalled in settings.php to FALSE if you want to access setup again.</div>';
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	if (!extension_loaded('curl')) {
108 108
 		$error[] = "Curl is not loaded.";
109 109
 	}
110
-	if(function_exists('apache_get_modules') ){
111
-		if(!in_array('mod_rewrite',apache_get_modules())) {
110
+	if (function_exists('apache_get_modules')) {
111
+		if (!in_array('mod_rewrite', apache_get_modules())) {
112 112
 			$error[] = "mod_rewrite is not available.";
113 113
 		}
114 114
 	/*
@@ -127,22 +127,22 @@  discard block
 block discarded – undo
127 127
 		$alllng = $Language->listLocaleDir();
128 128
 		if (count($alllng) != count($availablelng)) {
129 129
 			$notavailable = array();
130
-			foreach($alllng as $lng) {
130
+			foreach ($alllng as $lng) {
131 131
 				if (!isset($availablelng[$lng])) $notavailable[] = $lng;
132 132
 			}
133
-			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>';
133
+			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 134
 		}
135 135
 	}
136 136
 	print '<div class="alert alert-info">If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some tables can fail.</div>';
137 137
 	if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
138 138
 		if (function_exists('get_headers')) {
139 139
 			//$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
140
-			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'live/geojson?test',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
141
-			if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
140
+			$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'live/geojson?test', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
141
+			if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
142 142
 				print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
143 143
 			} else {
144
-				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/','install'),'search',str_replace('index.php','',$_SERVER["REQUEST_URI"])));
145
-				if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
144
+				$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace(array('install/', 'install'), 'search', str_replace('index.php', '', $_SERVER["REQUEST_URI"])));
145
+				if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
146 146
 					print '<div class="alert alert-danger"><strong>Error</strong> Check your configuration, rewrite don\'t seems to work well. If using Apache, you need to desactivate MultiViews <a href="https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration">https://github.com/Ysurac/FlightAirMap/wiki/Apache-configuration</a></div>';
147 147
 				}
148 148
 			}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 				    if ((!isset($globalURL) || $globalURL == '') && (!isset($globalDBuser) || $globalDBuser == '')) {
231 231
 					if (isset($_SERVER['REQUEST_URI'])) {
232 232
 						$URL = $_SERVER['REQUEST_URI'];
233
-						$globalURL = str_replace('/install','',str_replace('/install/','',str_replace('/install/index.php','',$URL)));
233
+						$globalURL = str_replace('/install', '', str_replace('/install/', '', str_replace('/install/index.php', '', $URL)));
234 234
 					}
235 235
 				    }
236 236
 				?>
@@ -571,13 +571,13 @@  discard block
 block discarded – undo
571 571
 ?>
572 572
 							<tr>
573 573
 								<?php
574
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
574
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
575 575
 								?>
576 576
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
577 577
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
578 578
 								<?php
579 579
 								    } else {
580
-									$hostport = explode(':',$source['host']);
580
+									$hostport = explode(':', $source['host']);
581 581
 									if (isset($hostport[1])) {
582 582
 										$host = $hostport[0];
583 583
 										$port = $hostport[1];
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 									<select name="timezones[]" id="timezones">
629 629
 								<?php
630 630
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
631
-									foreach($timezonelist as $timezones){
631
+									foreach ($timezonelist as $timezones) {
632 632
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
633 633
 											print '<option selected>'.$timezones.'</option>';
634 634
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 									<select name="timezones[]" id="timezones">
685 685
 								<?php
686 686
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
687
-									foreach($timezonelist as $timezones){
687
+									foreach ($timezonelist as $timezones) {
688 688
 										if ($timezones == 'UTC') {
689 689
 											print '<option selected>'.$timezones.'</option>';
690 690
 										} else print '<option>'.$timezones.'</option>';
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 			<br />
1165 1165
 			<p>
1166 1166
 				<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;?>" />
1167
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
1168 1168
 			</p>
1169 1169
 			<br />
1170 1170
 			<p>
@@ -1247,17 +1247,17 @@  discard block
 block discarded – undo
1247 1247
 $error = '';
1248 1248
 
1249 1249
 if (isset($_POST['dbtype'])) {
1250
-	$installpass = filter_input(INPUT_POST,'installpass',FILTER_SANITIZE_STRING);
1251
-	$settings = array_merge($settings,array('globalInstallPassword' => $installpass));
1250
+	$installpass = filter_input(INPUT_POST, 'installpass', FILTER_SANITIZE_STRING);
1251
+	$settings = array_merge($settings, array('globalInstallPassword' => $installpass));
1252 1252
 
1253
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
1254
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
1255
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
1256
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
1257
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
1258
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
1259
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
1260
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
1253
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
1254
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
1255
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
1256
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
1257
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
1258
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
1259
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
1260
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
1261 1261
 
1262 1262
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
1263 1263
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -1277,59 +1277,59 @@  discard block
 block discarded – undo
1277 1277
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1278 1278
 	*/
1279 1279
 	
1280
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
1280
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
1281 1281
 
1282
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
1283
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
1284
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
1285
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
1286
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
1282
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
1283
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
1284
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
1285
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
1286
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
1287 1287
 
1288
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
1289
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
1290
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
1291
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
1292
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
1293
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
1294
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
1295
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
1296
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
1297
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
1288
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
1289
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
1290
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
1291
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
1292
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
1293
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
1294
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
1295
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
1296
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
1297
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
1298 1298
 	
1299
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
1300
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
1301
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
1302
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
1303
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
1304
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
1299
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
1300
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
1301
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
1302
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
1303
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
1304
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
1305 1305
 
1306
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
1307
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
1306
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
1307
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
1308 1308
 
1309
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
1310
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
1311
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
1309
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
1310
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
1311
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
1312 1312
 
1313
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
1313
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
1314 1314
 	if ($acars == 'acars') {
1315
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
1315
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
1316 1316
 	} else {
1317
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
1317
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1318 1318
 	}
1319
-	$updatecheck = filter_input(INPUT_POST,'updatecheck',FILTER_SANITIZE_STRING);
1319
+	$updatecheck = filter_input(INPUT_POST, 'updatecheck', FILTER_SANITIZE_STRING);
1320 1320
 	if ($updatecheck == 'updatecheck') {
1321
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'TRUE'));
1321
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'TRUE'));
1322 1322
 	} else {
1323
-		$settings = array_merge($settings,array('globalDisableUpdateCheck' => 'FALSE'));
1323
+		$settings = array_merge($settings, array('globalDisableUpdateCheck' => 'FALSE'));
1324 1324
 	}
1325 1325
 
1326
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1327
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1328
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1326
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1327
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1328
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1329 1329
 	
1330
-	$sailawayemail = filter_input(INPUT_POST,'sailawayemail',FILTER_SANITIZE_STRING);
1331
-	$sailawaypass = filter_input(INPUT_POST,'sailawaypassword',FILTER_SANITIZE_STRING);
1332
-	$settings = array_merge($settings,array('globalSailaway' => array('email' => $sailawayemail,'password' => $sailawaypass)));
1330
+	$sailawayemail = filter_input(INPUT_POST, 'sailawayemail', FILTER_SANITIZE_STRING);
1331
+	$sailawaypass = filter_input(INPUT_POST, 'sailawaypassword', FILTER_SANITIZE_STRING);
1332
+	$settings = array_merge($settings, array('globalSailaway' => array('email' => $sailawayemail, 'password' => $sailawaypass)));
1333 1333
 	
1334 1334
 	$source_name = $_POST['source_name'];
1335 1335
 	$source_latitude = $_POST['source_latitude'];
@@ -1343,8 +1343,8 @@  discard block
 block discarded – undo
1343 1343
 	
1344 1344
 	$sources = array();
1345 1345
 	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]);
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]);
1348 1348
 	}
1349 1349
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1350 1350
 
@@ -1353,16 +1353,16 @@  discard block
 block discarded – undo
1353 1353
 	$newstype = $_POST['newstype'];
1354 1354
 	
1355 1355
 	$newsfeeds = array();
1356
-	foreach($newsurl as $newskey => $url) {
1356
+	foreach ($newsurl as $newskey => $url) {
1357 1357
 	    if ($url != '') {
1358 1358
 		$type = $newstype[$newskey];
1359 1359
 		$lng = $newslng[$newskey];
1360 1360
 		if (isset($newsfeeds[$type][$lng])) {
1361
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1361
+		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng], array($url));
1362 1362
 		} else $newsfeeds[$type][$lng] = array($url);
1363 1363
 	    }
1364 1364
 	}
1365
-	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1365
+	$settings = array_merge($settings, array('globalNewsFeeds' => $newsfeeds));
1366 1366
 
1367 1367
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1368 1368
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1373,28 +1373,28 @@  discard block
 block discarded – undo
1373 1373
 	$sbsurl = $_POST['sbsurl'];
1374 1374
 	*/
1375 1375
 
1376
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1377
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1378
-	$globalvm = filter_input(INPUT_POST,'globalvm',FILTER_SANITIZE_STRING);
1379
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1380
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1381
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1382
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1383
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1384
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1376
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1377
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1378
+	$globalvm = filter_input(INPUT_POST, 'globalvm', FILTER_SANITIZE_STRING);
1379
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1380
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1381
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1382
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1383
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1384
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1385 1385
 
1386
-	$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'));
1389
-	$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'));
1392
-	$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'));
1395
-	$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'));
1386
+	$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'));
1389
+	$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'));
1392
+	$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'));
1395
+	$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'));
1398 1398
 
1399 1399
 /*	
1400 1400
 	$globalSBS1Hosts = array();
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	}
1411 1411
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1412 1412
 */
1413
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1413
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1414 1414
 	$host = $_POST['host'];
1415 1415
 	$port = $_POST['port'];
1416 1416
 	$name = $_POST['name'];
@@ -1427,115 +1427,115 @@  discard block
 block discarded – undo
1427 1427
 		else $cov = 'FALSE';
1428 1428
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1429 1429
 		else $arch = 'FALSE';
1430
-		if (strpos($format[$key],'_callback')) {
1431
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1430
+		if (strpos($format[$key], '_callback')) {
1431
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1432 1432
 		} elseif ($format[$key] != 'auto' || ($h != '' || $name[$key] != '')) {
1433
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1433
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1434 1434
 		}
1435 1435
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1436 1436
 	}
1437
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1437
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1438 1438
 
1439 1439
 /*
1440 1440
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1441 1441
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1442 1442
 */
1443
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1444
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1445
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1443
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1444
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1445
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1446 1446
 
1447
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1448
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1447
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1448
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1449 1449
 
1450
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1451
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1450
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1451
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1452 1452
 
1453
-	$map3dtile = filter_input(INPUT_POST,'map3dtileset',FILTER_SANITIZE_STRING);
1454
-	$settings = array_merge($settings,array('globalMap3DTiles' => $map3dtile));
1453
+	$map3dtile = filter_input(INPUT_POST, 'map3dtileset', FILTER_SANITIZE_STRING);
1454
+	$settings = array_merge($settings, array('globalMap3DTiles' => $map3dtile));
1455 1455
 
1456
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1457
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1458
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1459
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1456
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1457
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1458
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1459
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1460 1460
 
1461
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1462
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1463
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1461
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1462
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1463
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1464 1464
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1465
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1466
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1465
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1466
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1467 1467
 
1468
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1469
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1470
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1471
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1472
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1473
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1474
-	$minfetch = filter_input(INPUT_POST,'minfetch',FILTER_SANITIZE_NUMBER_INT);
1475
-	$settings = array_merge($settings,array('globalMinFetch' => $minfetch));
1476
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1477
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1468
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1469
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1470
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1471
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1472
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1473
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1474
+	$minfetch = filter_input(INPUT_POST, 'minfetch', FILTER_SANITIZE_NUMBER_INT);
1475
+	$settings = array_merge($settings, array('globalMinFetch' => $minfetch));
1476
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1477
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1478 1478
 
1479
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1480
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1479
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1480
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1481 1481
 
1482
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1483
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1482
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1483
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1484 1484
 	
1485
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1485
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1486 1486
 	if ($archiveyear == "archiveyear") {
1487
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1487
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1488 1488
 	} else {
1489
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1489
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1490 1490
 	}
1491
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1492
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1493
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1494
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1491
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1492
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1493
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1494
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1495 1495
 
1496
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1497
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1498
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1499
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1496
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1497
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1498
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1499
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1500 1500
 
1501
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1502
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1503
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1501
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1502
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1503
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1504 1504
 
1505 1505
 	// Create in settings.php keys not yet configurable if not already here
1506 1506
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1507
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1507
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1508 1508
 
1509
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1509
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1510 1510
 	if ($resetyearstats == 'resetyearstats') {
1511
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1511
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1512 1512
 	} else {
1513
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1513
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1514 1514
 	}
1515 1515
 
1516
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1516
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1517 1517
 	if ($archive == 'archive') {
1518
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1518
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1519 1519
 	} else {
1520
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1520
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1521 1521
 	}
1522
-	$archiveresults = filter_input(INPUT_POST,'archiveresults',FILTER_SANITIZE_STRING);
1522
+	$archiveresults = filter_input(INPUT_POST, 'archiveresults', FILTER_SANITIZE_STRING);
1523 1523
 	if ($archiveresults == 'archiveresults') {
1524
-		$settings = array_merge($settings,array('globalArchiveResults' => 'TRUE'));
1524
+		$settings = array_merge($settings, array('globalArchiveResults' => 'TRUE'));
1525 1525
 	} else {
1526
-		$settings = array_merge($settings,array('globalArchiveResults' => 'FALSE'));
1526
+		$settings = array_merge($settings, array('globalArchiveResults' => 'FALSE'));
1527 1527
 	}
1528
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1528
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1529 1529
 	if ($daemon == 'daemon') {
1530
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1530
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1531 1531
 	} else {
1532
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1532
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1533 1533
 	}
1534
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1534
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1535 1535
 	if ($schedules == 'schedules') {
1536
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1536
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1537 1537
 	} else {
1538
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1538
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1539 1539
 	}
1540 1540
 
1541 1541
 /*
@@ -1546,311 +1546,311 @@  discard block
 block discarded – undo
1546 1546
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1547 1547
 	}
1548 1548
 */
1549
-	$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'));
1549
+	$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'));
1554 1554
 	$va = false;
1555 1555
 	if ($globalivao == 'ivao') {
1556
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1556
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1557 1557
 		$va = true;
1558
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1558
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1559 1559
 	if ($globalvatsim == 'vatsim') {
1560
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1560
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1561 1561
 		$va = true;
1562
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1562
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1563 1563
 	if ($globalphpvms == 'phpvms') {
1564
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1564
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1565 1565
 		$va = true;
1566
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1566
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1567 1567
 	if ($globalvam == 'vam') {
1568
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1568
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1569 1569
 		$va = true;
1570
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1570
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1571 1571
 	if ($va) {
1572
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1573
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1572
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1573
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1574 1574
 	if ($globalva == 'va' || $va) {
1575
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1576
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1575
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1576
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1577 1577
 	} else {
1578
-		$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'));
1578
+		$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'));
1581 1581
 	}
1582 1582
 	if ($globalvm == 'vm') {
1583
-		$settings = array_merge($settings,array('globalVM' => 'TRUE'));
1583
+		$settings = array_merge($settings, array('globalVM' => 'TRUE'));
1584 1584
 	} else {
1585
-		$settings = array_merge($settings,array('globalVM' => 'FALSE'));
1585
+		$settings = array_merge($settings, array('globalVM' => 'FALSE'));
1586 1586
 	}
1587 1587
 	
1588
-	$mapoffline = filter_input(INPUT_POST,'mapoffline',FILTER_SANITIZE_STRING);
1588
+	$mapoffline = filter_input(INPUT_POST, 'mapoffline', FILTER_SANITIZE_STRING);
1589 1589
 	if ($mapoffline == 'mapoffline') {
1590
-		$settings = array_merge($settings,array('globalMapOffline' => 'TRUE'));
1590
+		$settings = array_merge($settings, array('globalMapOffline' => 'TRUE'));
1591 1591
 	} else {
1592
-		$settings = array_merge($settings,array('globalMapOffline' => 'FALSE'));
1592
+		$settings = array_merge($settings, array('globalMapOffline' => 'FALSE'));
1593 1593
 	}
1594
-	$globaloffline = filter_input(INPUT_POST,'globaloffline',FILTER_SANITIZE_STRING);
1594
+	$globaloffline = filter_input(INPUT_POST, 'globaloffline', FILTER_SANITIZE_STRING);
1595 1595
 	if ($globaloffline == 'globaloffline') {
1596
-		$settings = array_merge($settings,array('globalOffline' => 'TRUE'));
1596
+		$settings = array_merge($settings, array('globalOffline' => 'TRUE'));
1597 1597
 	} else {
1598
-		$settings = array_merge($settings,array('globalOffline' => 'FALSE'));
1598
+		$settings = array_merge($settings, array('globalOffline' => 'FALSE'));
1599 1599
 	}
1600 1600
 
1601
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1601
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1602 1602
 	if ($notam == 'notam') {
1603
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1603
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1604 1604
 	} else {
1605
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1605
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1606 1606
 	}
1607
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1607
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1608 1608
 	if ($owner == 'owner') {
1609
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1609
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1610 1610
 	} else {
1611
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1611
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1612 1612
 	}
1613
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1613
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1614 1614
 	if ($map3d == 'map3d') {
1615
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1615
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1616 1616
 	} else {
1617
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1617
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1618 1618
 	}
1619
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1619
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1620 1620
 	if ($crash == 'crash') {
1621
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1621
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1622 1622
 	} else {
1623
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1623
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1624 1624
 	}
1625
-	$fires = filter_input(INPUT_POST,'fires',FILTER_SANITIZE_STRING);
1625
+	$fires = filter_input(INPUT_POST, 'fires', FILTER_SANITIZE_STRING);
1626 1626
 	if ($fires == 'fires') {
1627
-		$settings = array_merge($settings,array('globalMapFires' => 'TRUE'));
1627
+		$settings = array_merge($settings, array('globalMapFires' => 'TRUE'));
1628 1628
 	} else {
1629
-		$settings = array_merge($settings,array('globalMapFires' => 'FALSE'));
1629
+		$settings = array_merge($settings, array('globalMapFires' => 'FALSE'));
1630 1630
 	}
1631
-	$firessupport = filter_input(INPUT_POST,'firessupport',FILTER_SANITIZE_STRING);
1631
+	$firessupport = filter_input(INPUT_POST, 'firessupport', FILTER_SANITIZE_STRING);
1632 1632
 	if ($firessupport == 'firessupport') {
1633
-		$settings = array_merge($settings,array('globalFires' => 'TRUE'));
1633
+		$settings = array_merge($settings, array('globalFires' => 'TRUE'));
1634 1634
 	} else {
1635
-		$settings = array_merge($settings,array('globalFires' => 'FALSE'));
1635
+		$settings = array_merge($settings, array('globalFires' => 'FALSE'));
1636 1636
 	}
1637
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1637
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1638 1638
 	if ($mapsatellites == 'mapsatellites') {
1639
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1639
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1640 1640
 	} else {
1641
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1641
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1642 1642
 	}
1643
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1643
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1644 1644
 	if ($map3ddefault == 'map3ddefault') {
1645
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1645
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1646 1646
 	} else {
1647
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1647
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1648 1648
 	}
1649
-	$one3dmodel = filter_input(INPUT_POST,'one3dmodel',FILTER_SANITIZE_STRING);
1649
+	$one3dmodel = filter_input(INPUT_POST, 'one3dmodel', FILTER_SANITIZE_STRING);
1650 1650
 	if ($one3dmodel == 'one3dmodel') {
1651
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'TRUE'));
1651
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'TRUE'));
1652 1652
 	} else {
1653
-		$settings = array_merge($settings,array('globalMap3DOneModel' => 'FALSE'));
1653
+		$settings = array_merge($settings, array('globalMap3DOneModel' => 'FALSE'));
1654 1654
 	}
1655
-	$map3dliveries = filter_input(INPUT_POST,'map3dliveries',FILTER_SANITIZE_STRING);
1655
+	$map3dliveries = filter_input(INPUT_POST, 'map3dliveries', FILTER_SANITIZE_STRING);
1656 1656
 	if ($map3dliveries == 'map3dliveries') {
1657
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'TRUE'));
1657
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'TRUE'));
1658 1658
 	} else {
1659
-		$settings = array_merge($settings,array('globalMap3DLiveries' => 'FALSE'));
1659
+		$settings = array_merge($settings, array('globalMap3DLiveries' => 'FALSE'));
1660 1660
 	}
1661
-	$map3dshadows = filter_input(INPUT_POST,'map3dshadows',FILTER_SANITIZE_STRING);
1661
+	$map3dshadows = filter_input(INPUT_POST, 'map3dshadows', FILTER_SANITIZE_STRING);
1662 1662
 	if ($map3dshadows == 'map3dshadows') {
1663
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'TRUE'));
1663
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'TRUE'));
1664 1664
 	} else {
1665
-		$settings = array_merge($settings,array('globalMap3DShadows' => 'FALSE'));
1665
+		$settings = array_merge($settings, array('globalMap3DShadows' => 'FALSE'));
1666 1666
 	}
1667
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1667
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1668 1668
 	if ($translate == 'translate') {
1669
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1669
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1670 1670
 	} else {
1671
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1671
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1672 1672
 	}
1673
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1673
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1674 1674
 	if ($realairlines == 'realairlines') {
1675
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1675
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1676 1676
 	} else {
1677
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1677
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1678 1678
 	}
1679
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1679
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1680 1680
 	if ($estimation == 'estimation') {
1681
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1681
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1682 1682
 	} else {
1683
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1683
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1684 1684
 	}
1685
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1685
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1686 1686
 	if ($metar == 'metar') {
1687
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1687
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1688 1688
 	} else {
1689
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1689
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1690 1690
 	}
1691
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1691
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1692 1692
 	if ($metarcycle == 'metarcycle') {
1693
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1693
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1694 1694
 	} else {
1695
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1695
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1696 1696
 	}
1697
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1697
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1698 1698
 	if ($fork == 'fork') {
1699
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1699
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1700 1700
 	} else {
1701
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1701
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1702 1702
 	}
1703 1703
 
1704
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1704
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1705 1705
 	if ($colormap == 'colormap') {
1706
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1706
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1707 1707
 	} else {
1708
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1708
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1709 1709
 	}
1710 1710
 	
1711 1711
 	if (isset($_POST['aircrafticoncolor'])) {
1712
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1713
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1712
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1713
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1714 1714
 	}
1715 1715
 	if (isset($_POST['marineiconcolor'])) {
1716
-		$marineiconcolor = filter_input(INPUT_POST,'marineiconcolor',FILTER_SANITIZE_STRING);
1717
-		$settings = array_merge($settings,array('globalMarineIconColor' => substr($marineiconcolor,1)));
1716
+		$marineiconcolor = filter_input(INPUT_POST, 'marineiconcolor', FILTER_SANITIZE_STRING);
1717
+		$settings = array_merge($settings, array('globalMarineIconColor' => substr($marineiconcolor, 1)));
1718 1718
 	}
1719 1719
 	if (isset($_POST['trackericoncolor'])) {
1720
-		$trackericoncolor = filter_input(INPUT_POST,'trackericoncolor',FILTER_SANITIZE_STRING);
1721
-		$settings = array_merge($settings,array('globalTrackerIconColor' => substr($trackericoncolor,1)));
1720
+		$trackericoncolor = filter_input(INPUT_POST, 'trackericoncolor', FILTER_SANITIZE_STRING);
1721
+		$settings = array_merge($settings, array('globalTrackerIconColor' => substr($trackericoncolor, 1)));
1722 1722
 	}
1723 1723
 	if (isset($_POST['satelliteiconcolor'])) {
1724
-		$satelliteiconcolor = filter_input(INPUT_POST,'satelliteiconcolor',FILTER_SANITIZE_STRING);
1725
-		$settings = array_merge($settings,array('globalSatelliteIconColor' => substr($satelliteiconcolor,1)));
1724
+		$satelliteiconcolor = filter_input(INPUT_POST, 'satelliteiconcolor', FILTER_SANITIZE_STRING);
1725
+		$settings = array_merge($settings, array('globalSatelliteIconColor' => substr($satelliteiconcolor, 1)));
1726 1726
 	}
1727 1727
 
1728
-	$corsproxy = filter_input(INPUT_POST,'corsproxy',FILTER_SANITIZE_STRING);
1729
-	$settings = array_merge($settings,array('globalCORSproxy' => $corsproxy));
1728
+	$corsproxy = filter_input(INPUT_POST, 'corsproxy', FILTER_SANITIZE_STRING);
1729
+	$settings = array_merge($settings, array('globalCORSproxy' => $corsproxy));
1730 1730
 
1731
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1732
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1731
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1732
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1733 1733
 
1734
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1735
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1736
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1737
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1738
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1739
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1734
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1735
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1736
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1737
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1738
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1739
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1740 1740
 
1741
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1741
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1742 1742
 	if ($mappopup == 'mappopup') {
1743
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1743
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1744 1744
 	} else {
1745
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1745
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1746 1746
 	}
1747
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1747
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1748 1748
 	if ($airportpopup == 'airportpopup') {
1749
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1749
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1750 1750
 	} else {
1751
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1751
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1752 1752
 	}
1753
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1753
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1754 1754
 	if ($maphistory == 'maphistory') {
1755
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1755
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1756 1756
 	} else {
1757
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1757
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1758 1758
 	}
1759
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1759
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1760 1760
 	if ($maptooltip == 'maptooltip') {
1761
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1761
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1762 1762
 	} else {
1763
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1763
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1764 1764
 	}
1765
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1765
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1766 1766
 	if ($flightroute == 'flightroute') {
1767
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1767
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1768 1768
 	} else {
1769
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1769
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1770 1770
 	}
1771
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1771
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1772 1772
 	if ($flightremainingroute == 'flightremainingroute') {
1773
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1773
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1774 1774
 	} else {
1775
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1775
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1776 1776
 	}
1777
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1777
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1778 1778
 	if ($allflights == 'allflights') {
1779
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1779
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1780 1780
 	} else {
1781
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1781
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1782 1782
 	}
1783
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1783
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1784 1784
 	if ($bbox == 'bbox') {
1785
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1785
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1786 1786
 	} else {
1787
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1787
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1788 1788
 	}
1789
-	$singlemodel = filter_input(INPUT_POST,'singlemodel',FILTER_SANITIZE_STRING);
1789
+	$singlemodel = filter_input(INPUT_POST, 'singlemodel', FILTER_SANITIZE_STRING);
1790 1790
 	if ($singlemodel == 'singlemodel') {
1791
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'TRUE'));
1791
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'TRUE'));
1792 1792
 	} else {
1793
-		$settings = array_merge($settings,array('globalMap3DSelected' => 'FALSE'));
1793
+		$settings = array_merge($settings, array('globalMap3DSelected' => 'FALSE'));
1794 1794
 	}
1795
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1795
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1796 1796
 	if ($groundaltitude == 'groundaltitude') {
1797
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1797
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1798 1798
 	} else {
1799
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1799
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1800 1800
 	}
1801
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1801
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1802 1802
 	if ($waypoints == 'waypoints') {
1803
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1803
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1804 1804
 	} else {
1805
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1805
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1806 1806
 	}
1807
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1807
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1808 1808
 	if ($geoid == 'geoid') {
1809
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1809
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1810 1810
 	} else {
1811
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1811
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1812 1812
 	}
1813
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1814
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1813
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1814
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1815 1815
 
1816
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1816
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1817 1817
 	if ($noairlines == 'noairlines') {
1818
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1818
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1819 1819
 	} else {
1820
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1820
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1821 1821
 	}
1822 1822
 
1823
-	$tsk = filter_input(INPUT_POST,'tsk',FILTER_SANITIZE_STRING);
1823
+	$tsk = filter_input(INPUT_POST, 'tsk', FILTER_SANITIZE_STRING);
1824 1824
 	if ($tsk == 'tsk') {
1825
-		$settings = array_merge($settings,array('globalTSK' => 'TRUE'));
1825
+		$settings = array_merge($settings, array('globalTSK' => 'TRUE'));
1826 1826
 	} else {
1827
-		$settings = array_merge($settings,array('globalTSK' => 'FALSE'));
1827
+		$settings = array_merge($settings, array('globalTSK' => 'FALSE'));
1828 1828
 	}
1829
-	$mapmatching = filter_input(INPUT_POST,'mapmatching',FILTER_SANITIZE_STRING);
1829
+	$mapmatching = filter_input(INPUT_POST, 'mapmatching', FILTER_SANITIZE_STRING);
1830 1830
 	if ($mapmatching == 'mapmatching') {
1831
-		$settings = array_merge($settings,array('globalMapMatching' => 'TRUE'));
1831
+		$settings = array_merge($settings, array('globalMapMatching' => 'TRUE'));
1832 1832
 	} else {
1833
-		$settings = array_merge($settings,array('globalMapMatching' => 'FALSE'));
1833
+		$settings = array_merge($settings, array('globalMapMatching' => 'FALSE'));
1834 1834
 	}
1835
-	$mapmatchingsource = filter_input(INPUT_POST,'mapmatchingsource',FILTER_SANITIZE_STRING);
1836
-	$settings = array_merge($settings,array('globalMapMatchingSource' => $mapmatchingsource));
1837
-	$graphhopper = filter_input(INPUT_POST,'graphhopper',FILTER_SANITIZE_STRING);
1838
-	$settings = array_merge($settings,array('globalGraphHopperKey' => $graphhopper));
1835
+	$mapmatchingsource = filter_input(INPUT_POST, 'mapmatchingsource', FILTER_SANITIZE_STRING);
1836
+	$settings = array_merge($settings, array('globalMapMatchingSource' => $mapmatchingsource));
1837
+	$graphhopper = filter_input(INPUT_POST, 'graphhopper', FILTER_SANITIZE_STRING);
1838
+	$settings = array_merge($settings, array('globalGraphHopperKey' => $graphhopper));
1839 1839
 
1840
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1840
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1841 1841
 
1842 1842
 	// Set some defaults values...
1843 1843
 	if (!isset($globalAircraftImageSources)) {
1844
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1845
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1844
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1845
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1846 1846
 	}
1847 1847
 
1848 1848
 	if (!isset($globalSchedulesSources)) {
1849
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1850
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1849
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1850
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1851 1851
     	}
1852 1852
 
1853
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1853
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1854 1854
 
1855 1855
 	if ($error == '') settings::modify_settings($settings);
1856 1856
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this 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 2 patches
Indentation   +1121 added lines, -1121 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -27,50 +27,50 @@  discard block
 block discarded – undo
27 27
 // Check if schema is at latest version
28 28
 $Connection = new Connection();
29 29
 if ($Connection->connectionExists() === false) {
30
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
31
-    exit();
30
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
31
+	exit();
32 32
 }
33 33
 if ($Connection->latest() === false) {
34
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
35
-    exit();
34
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
35
+	exit();
36 36
 }
37 37
 if (PHP_SAPI != 'cli') {
38
-    echo "This script MUST be called from console, not a web browser.";
38
+	echo "This script MUST be called from console, not a web browser.";
39 39
 //    exit();
40 40
 }
41 41
 if ($globalInstalled === FALSE) {
42
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
43
-    die();
42
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
43
+	die();
44 44
 }
45 45
 
46 46
 // This is to be compatible with old version of settings.php
47 47
 if (!isset($globalSources)) {
48
-    if (isset($globalSBS1Hosts)) {
49
-        //$hosts = $globalSBS1Hosts;
50
-        foreach ($globalSBS1Hosts as $host) {
51
-	    $globalSources[] = array('host' => $host);
52
-    	}
53
-    } else {
54
-        if (!isset($globalSBS1Host)) {
55
-	    echo '$globalSources MUST be defined !';
56
-	    die;
48
+	if (isset($globalSBS1Hosts)) {
49
+		//$hosts = $globalSBS1Hosts;
50
+		foreach ($globalSBS1Hosts as $host) {
51
+		$globalSources[] = array('host' => $host);
52
+		}
53
+	} else {
54
+		if (!isset($globalSBS1Host)) {
55
+		echo '$globalSources MUST be defined !';
56
+		die;
57 57
 	}
58 58
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
59 59
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
60
-    }
60
+	}
61 61
 }
62 62
 
63 63
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
64 64
 //if (isset($options['s'])) $hosts = array($options['s']);
65 65
 //elseif (isset($options['source'])) $hosts = array($options['source']);
66 66
 if (isset($options['s'])) {
67
-    $globalSources = array();
68
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
69
-    else $globalSources[] = array('host' => $options['s']);
67
+	$globalSources = array();
68
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
69
+	else $globalSources[] = array('host' => $options['s']);
70 70
 } elseif (isset($options['source'])) {
71
-    $globalSources = array();
72
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
73
-    else $globalSources[] = array('host' => $options['source']);
71
+	$globalSources = array();
72
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
73
+	else $globalSources[] = array('host' => $options['source']);
74 74
 }
75 75
 if (isset($options['aprsserverhost'])) {
76 76
 	$globalServerAPRS = TRUE;
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 if (isset($options['idsource'])) $id_source = $options['idsource'];
110 110
 else $id_source = 1;
111 111
 if (isset($globalServer) && $globalServer) {
112
-    if ($globalDebug) echo "Using Server Mode\n";
113
-    $SI=new SpotterServer();
112
+	if ($globalDebug) echo "Using Server Mode\n";
113
+	$SI=new SpotterServer();
114 114
 /*
115 115
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
116 116
     $SI = new adsb2aprs();
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 
121 121
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
122 122
 if (isset($globalMarine) && $globalMarine) {
123
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
124
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
123
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
124
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
125 125
 }
126 126
 
127 127
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
128 128
 if (isset($globalMarine) && $globalMarine) {
129
-    $AIS = new AIS();
130
-    $MI = new MarineImport($Connection->db);
129
+	$AIS = new AIS();
130
+	$MI = new MarineImport($Connection->db);
131 131
 }
132 132
 //$APRS=new APRS($Connection->db);
133 133
 $SBS=new SBS();
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 //$servertz = system('date +%Z');
141 141
 // signal handler - playing nice with sockets and dump1090
142 142
 if (function_exists('pcntl_fork')) {
143
-    pcntl_signal(SIGINT,  function() {
144
-        global $sockets;
145
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
146
-        die("Bye!\n");
147
-    });
148
-    pcntl_signal_dispatch();
143
+	pcntl_signal(SIGINT,  function() {
144
+		global $sockets;
145
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
146
+		die("Bye!\n");
147
+	});
148
+	pcntl_signal_dispatch();
149 149
 }
150 150
 
151 151
 // let's try and connect
@@ -155,46 +155,46 @@  discard block
 block discarded – undo
155 155
 $reset = 0;
156 156
 
157 157
 function connect_all($hosts) {
158
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
159
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
160
-    $reset++;
161
-    if ($globalDebug) echo 'Connect to all...'."\n";
162
-    foreach ($hosts as $id => $value) {
158
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
159
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
160
+	$reset++;
161
+	if ($globalDebug) echo 'Connect to all...'."\n";
162
+	foreach ($hosts as $id => $value) {
163 163
 	$host = $value['host'];
164 164
 	$globalSources[$id]['last_exec'] = 0;
165 165
 	// Here we check type of source(s)
166 166
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
167
-            if (preg_match('/deltadb.txt$/i',$host)) {
168
-        	//$formats[$id] = 'deltadbtxt';
169
-        	$globalSources[$id]['format'] = 'deltadbtxt';
170
-        	//$last_exec['deltadbtxt'] = 0;
171
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
172
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
173
-        	//$formats[$id] = 'vatsimtxt';
174
-        	$globalSources[$id]['format'] = 'vatsimtxt';
175
-        	//$last_exec['vatsimtxt'] = 0;
176
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
177
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
178
-        	//$formats[$id] = 'aircraftlistjson';
179
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
180
-        	//$last_exec['aircraftlistjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
182
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
183
-        	//$formats[$id] = 'aircraftjson';
184
-        	$globalSources[$id]['format'] = 'aircraftjson';
185
-        	//$last_exec['aircraftlistjson'] = 0;
186
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
187
-    	    } else if (preg_match('/aircraft$/i',$host)) {
188
-        	//$formats[$id] = 'planefinderclient';
189
-        	$globalSources[$id]['format'] = 'planefinderclient';
190
-        	//$last_exec['aircraftlistjson'] = 0;
191
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
192
-    	    } else if (preg_match('/opensky/i',$host)) {
193
-        	//$formats[$id] = 'aircraftlistjson';
194
-        	$globalSources[$id]['format'] = 'opensky';
195
-        	//$last_exec['aircraftlistjson'] = 0;
196
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
197
-    	    /*
167
+			if (preg_match('/deltadb.txt$/i',$host)) {
168
+			//$formats[$id] = 'deltadbtxt';
169
+			$globalSources[$id]['format'] = 'deltadbtxt';
170
+			//$last_exec['deltadbtxt'] = 0;
171
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
172
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
173
+			//$formats[$id] = 'vatsimtxt';
174
+			$globalSources[$id]['format'] = 'vatsimtxt';
175
+			//$last_exec['vatsimtxt'] = 0;
176
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
177
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
178
+			//$formats[$id] = 'aircraftlistjson';
179
+			$globalSources[$id]['format'] = 'aircraftlistjson';
180
+			//$last_exec['aircraftlistjson'] = 0;
181
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
182
+			} else if (preg_match('/aircraft.json$/i',$host)) {
183
+			//$formats[$id] = 'aircraftjson';
184
+			$globalSources[$id]['format'] = 'aircraftjson';
185
+			//$last_exec['aircraftlistjson'] = 0;
186
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
187
+			} else if (preg_match('/aircraft$/i',$host)) {
188
+			//$formats[$id] = 'planefinderclient';
189
+			$globalSources[$id]['format'] = 'planefinderclient';
190
+			//$last_exec['aircraftlistjson'] = 0;
191
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
192
+			} else if (preg_match('/opensky/i',$host)) {
193
+			//$formats[$id] = 'aircraftlistjson';
194
+			$globalSources[$id]['format'] = 'opensky';
195
+			//$last_exec['aircraftlistjson'] = 0;
196
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
197
+			/*
198 198
     	    // Disabled for now, site change source format
199 199
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
200 200
         	//$formats[$id] = 'radarvirtueljson';
@@ -206,128 +206,128 @@  discard block
 block discarded – undo
206 206
         	    exit(0);
207 207
         	}
208 208
     	    */
209
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
210
-        	//$formats[$id] = 'planeupdatefaa';
211
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
212
-        	//$last_exec['planeupdatefaa'] = 0;
213
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
214
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
215
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
216
-        	    exit(0);
217
-        	}
218
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
219
-        	//$formats[$id] = 'phpvmacars';
220
-        	$globalSources[$id]['format'] = 'phpvmacars';
221
-        	//$last_exec['phpvmacars'] = 0;
222
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
223
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
224
-        	//$formats[$id] = 'phpvmacars';
225
-        	$globalSources[$id]['format'] = 'vaos';
226
-        	//$last_exec['phpvmacars'] = 0;
227
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
228
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
229
-        	//$formats[$id] = 'phpvmacars';
230
-        	$globalSources[$id]['format'] = 'vam';
231
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
232
-            } else if (preg_match('/whazzup/i',$host)) {
233
-        	//$formats[$id] = 'whazzup';
234
-        	$globalSources[$id]['format'] = 'whazzup';
235
-        	//$last_exec['whazzup'] = 0;
236
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
237
-            } else if (preg_match('/blitzortung/i',$host)) {
238
-        	$globalSources[$id]['format'] = 'blitzortung';
239
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
240
-            } else if (preg_match('/airwhere/i',$host)) {
241
-        	$globalSources[$id]['format'] = 'airwhere';
242
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
243
-            } else if (preg_match('/recentpireps/i',$host)) {
244
-        	//$formats[$id] = 'pirepsjson';
245
-        	$globalSources[$id]['format'] = 'pirepsjson';
246
-        	//$last_exec['pirepsjson'] = 0;
247
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
248
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
249
-        	//$formats[$id] = 'fr24json';
250
-        	$globalSources[$id]['format'] = 'fr24json';
251
-        	//$last_exec['fr24json'] = 0;
252
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
253
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
254
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
255
-        	    exit(0);
256
-        	}
257
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
258
-        	//$formats[$id] = 'fr24json';
259
-        	$globalSources[$id]['format'] = 'myshiptracking';
260
-        	//$last_exec['fr24json'] = 0;
261
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
262
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
263
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
264
-        	    exit(0);
265
-        	}
266
-            //} else if (preg_match('/10001/',$host)) {
267
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
268
-        	//$formats[$id] = 'tsv';
269
-        	$globalSources[$id]['format'] = 'tsv';
270
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
271
-            }
272
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
273
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
274
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
275
-    		    if ($idf !== false) {
276
-    			$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";
281
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
282
-	    $hostport = explode(':',$host);
283
-	    if (isset($hostport[1])) {
209
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
210
+			//$formats[$id] = 'planeupdatefaa';
211
+			$globalSources[$id]['format'] = 'planeupdatefaa';
212
+			//$last_exec['planeupdatefaa'] = 0;
213
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
214
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
215
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
216
+				exit(0);
217
+			}
218
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
219
+			//$formats[$id] = 'phpvmacars';
220
+			$globalSources[$id]['format'] = 'phpvmacars';
221
+			//$last_exec['phpvmacars'] = 0;
222
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
223
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
224
+			//$formats[$id] = 'phpvmacars';
225
+			$globalSources[$id]['format'] = 'vaos';
226
+			//$last_exec['phpvmacars'] = 0;
227
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
228
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
229
+			//$formats[$id] = 'phpvmacars';
230
+			$globalSources[$id]['format'] = 'vam';
231
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
232
+			} else if (preg_match('/whazzup/i',$host)) {
233
+			//$formats[$id] = 'whazzup';
234
+			$globalSources[$id]['format'] = 'whazzup';
235
+			//$last_exec['whazzup'] = 0;
236
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
237
+			} else if (preg_match('/blitzortung/i',$host)) {
238
+			$globalSources[$id]['format'] = 'blitzortung';
239
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
240
+			} else if (preg_match('/airwhere/i',$host)) {
241
+			$globalSources[$id]['format'] = 'airwhere';
242
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
243
+			} else if (preg_match('/recentpireps/i',$host)) {
244
+			//$formats[$id] = 'pirepsjson';
245
+			$globalSources[$id]['format'] = 'pirepsjson';
246
+			//$last_exec['pirepsjson'] = 0;
247
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
248
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
249
+			//$formats[$id] = 'fr24json';
250
+			$globalSources[$id]['format'] = 'fr24json';
251
+			//$last_exec['fr24json'] = 0;
252
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
253
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
254
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
255
+				exit(0);
256
+			}
257
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
258
+			//$formats[$id] = 'fr24json';
259
+			$globalSources[$id]['format'] = 'myshiptracking';
260
+			//$last_exec['fr24json'] = 0;
261
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
262
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
263
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
264
+				exit(0);
265
+			}
266
+			//} else if (preg_match('/10001/',$host)) {
267
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
268
+			//$formats[$id] = 'tsv';
269
+			$globalSources[$id]['format'] = 'tsv';
270
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
271
+			}
272
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway')) {
273
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
274
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
275
+				if ($idf !== false) {
276
+				$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";
281
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
282
+		$hostport = explode(':',$host);
283
+		if (isset($hostport[1])) {
284 284
 		$port = $hostport[1];
285 285
 		$hostn = $hostport[0];
286
-	    } else {
286
+		} else {
287 287
 		$port = $globalSources[$id]['port'];
288 288
 		$hostn = $globalSources[$id]['host'];
289
-	    }
290
-	    $Common = new Common();
291
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
292
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
293
-    	    } else {
294
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
295
-	    }
296
-	    if ($s) {
297
-    	        $sockets[$id] = $s;
298
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
299
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
289
+		}
290
+		$Common = new Common();
291
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
292
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
293
+			} else {
294
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
295
+		}
296
+		if ($s) {
297
+				$sockets[$id] = $s;
298
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
299
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
300 300
 			//$formats[$id] = 'aprs';
301 301
 			$globalSources[$id]['format'] = 'aprs';
302 302
 			//$aprs_connect = 0;
303 303
 			//$use_aprs = true;
304
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
304
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
305 305
 			$globalSources[$id]['format'] = 'vrstcp';
306
-    		    } elseif ($port == '10001') {
307
-        		//$formats[$id] = 'tsv';
308
-        		$globalSources[$id]['format'] = 'tsv';
309
-		    } elseif ($port == '30002') {
310
-        		//$formats[$id] = 'raw';
311
-        		$globalSources[$id]['format'] = 'raw';
312
-		    } elseif ($port == '5001') {
313
-        		//$formats[$id] = 'raw';
314
-        		$globalSources[$id]['format'] = 'flightgearmp';
315
-		    } elseif ($port == '30005') {
306
+				} elseif ($port == '10001') {
307
+				//$formats[$id] = 'tsv';
308
+				$globalSources[$id]['format'] = 'tsv';
309
+			} elseif ($port == '30002') {
310
+				//$formats[$id] = 'raw';
311
+				$globalSources[$id]['format'] = 'raw';
312
+			} elseif ($port == '5001') {
313
+				//$formats[$id] = 'raw';
314
+				$globalSources[$id]['format'] = 'flightgearmp';
315
+			} elseif ($port == '30005') {
316 316
 			// Not yet supported
317
-        		//$formats[$id] = 'beast';
318
-        		$globalSources[$id]['format'] = 'beast';
319
-		    //} else $formats[$id] = 'sbs';
320
-		    } else $globalSources[$id]['format'] = 'sbs';
321
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
317
+				//$formats[$id] = 'beast';
318
+				$globalSources[$id]['format'] = 'beast';
319
+			//} else $formats[$id] = 'sbs';
320
+			} else $globalSources[$id]['format'] = 'sbs';
321
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
322 322
 		}
323 323
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
324
-            } else {
324
+			} else {
325 325
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
326 326
 		sleep(10);
327 327
 		connect_all($hosts);
328
-    	    }
329
-        }
330
-    }
328
+			}
329
+		}
330
+	}
331 331
 }
332 332
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
333 333
 
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 //connect_all($globalSources);
351 351
 
352 352
 if (isset($globalProxy) && $globalProxy) {
353
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
353
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
354 354
 } else {
355
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
355
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
356 356
 }
357 357
 
358 358
 // APRS Configuration
@@ -361,21 +361,21 @@  discard block
 block discarded – undo
361 361
 	die;
362 362
 }
363 363
 foreach ($globalSources as $key => $source) {
364
-    if (!isset($source['format'])) {
365
-        $globalSources[$key]['format'] = 'auto';
366
-    }
367
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
368
-        unset($globalSources[$key]);
369
-    }
364
+	if (!isset($source['format'])) {
365
+		$globalSources[$key]['format'] = 'auto';
366
+	}
367
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
368
+		unset($globalSources[$key]);
369
+	}
370 370
 }
371 371
 connect_all($globalSources);
372 372
 foreach ($globalSources as $key => $source) {
373
-    if (isset($source['format']) && $source['format'] == 'aprs') {
373
+	if (isset($source['format']) && $source['format'] == 'aprs') {
374 374
 	$aprs_connect = 0;
375 375
 	$use_aprs = true;
376 376
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
377 377
 	break;
378
-    }
378
+	}
379 379
 }
380 380
 
381 381
 if ($use_aprs) {
@@ -416,133 +416,133 @@  discard block
 block discarded – undo
416 416
 
417 417
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
418 418
 while ($i > 0) {
419
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
419
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
420 420
 
421
-    if (!$globalDaemon) $i = $endtime-time();
422
-    // Delete old ATC
423
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
421
+	if (!$globalDaemon) $i = $endtime-time();
422
+	// Delete old ATC
423
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
424 424
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
425
-        $ATC->deleteOldATC();
426
-    }
425
+		$ATC->deleteOldATC();
426
+	}
427 427
     
428
-    if (count($last_exec) == count($globalSources)) {
428
+	if (count($last_exec) == count($globalSources)) {
429 429
 	$max = $globalMinFetch;
430 430
 	foreach ($last_exec as $last) {
431
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
431
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
432 432
 	}
433 433
 	if ($max < $globalMinFetch) {
434
-	    if ($globalDebug) echo 'Sleeping...'."\n";
435
-	    sleep($globalMinFetch-$max+2);
434
+		if ($globalDebug) echo 'Sleeping...'."\n";
435
+		sleep($globalMinFetch-$max+2);
436
+	}
436 437
 	}
437
-    }
438 438
 
439 439
     
440
-    //foreach ($formats as $id => $value) {
441
-    foreach ($globalSources as $id => $value) {
440
+	//foreach ($formats as $id => $value) {
441
+	foreach ($globalSources as $id => $value) {
442 442
 	date_default_timezone_set('UTC');
443 443
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
444 444
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
445 445
 	if ($value['format'] === 'deltadbtxt' && 
446
-	    (
446
+		(
447 447
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
448 448
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
449
-	    )
449
+		)
450 450
 	) {
451
-	    //$buffer = $Common->getData($hosts[$id]);
452
-	    $buffer = $Common->getData($value['host']);
453
-	    if ($buffer != '') $reset = 0;
454
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455
-	    $buffer = explode('\n',$buffer);
456
-	    foreach ($buffer as $line) {
457
-    		if ($line != '' && count($line) > 7) {
458
-    		    $line = explode(',', $line);
459
-	            $data = array();
460
-	            $data['hex'] = $line[1]; // hex
461
-	            $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
467
-	            $data['verticalrate'] = ''; // vertical rate
468
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
469
-	            $data['emergency'] = ''; // emergency
470
-		    $data['datetime'] = date('Y-m-d H:i:s');
471
-		    $data['format_source'] = 'deltadbtxt';
472
-    		    $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'];
476
-    		    $SI->add($data);
477
-		    unset($data);
478
-    		}
479
-    	    }
480
-    	    $last_exec[$id]['last'] = time();
451
+		//$buffer = $Common->getData($hosts[$id]);
452
+		$buffer = $Common->getData($value['host']);
453
+		if ($buffer != '') $reset = 0;
454
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455
+		$buffer = explode('\n',$buffer);
456
+		foreach ($buffer as $line) {
457
+			if ($line != '' && count($line) > 7) {
458
+				$line = explode(',', $line);
459
+				$data = array();
460
+				$data['hex'] = $line[1]; // hex
461
+				$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
467
+				$data['verticalrate'] = ''; // vertical rate
468
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
469
+				$data['emergency'] = ''; // emergency
470
+			$data['datetime'] = date('Y-m-d H:i:s');
471
+			$data['format_source'] = 'deltadbtxt';
472
+				$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'];
476
+				$SI->add($data);
477
+			unset($data);
478
+			}
479
+			}
480
+			$last_exec[$id]['last'] = time();
481 481
 	} elseif ($value['format'] === 'aisnmeatxt' && 
482
-	    (
482
+		(
483 483
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
484 484
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
485
-	    )
485
+		)
486 486
 	) {
487
-	    date_default_timezone_set('CET');
488
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
489
-	    date_default_timezone_set('UTC');
490
-	    if ($buffer != '') $reset = 0;
491
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
492
-	    $buffer = explode('\n',$buffer);
493
-	    foreach ($buffer as $line) {
487
+		date_default_timezone_set('CET');
488
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
489
+		date_default_timezone_set('UTC');
490
+		if ($buffer != '') $reset = 0;
491
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
492
+		$buffer = explode('\n',$buffer);
493
+		foreach ($buffer as $line) {
494 494
 		if ($line != '') {
495
-		    //echo "'".$line."'\n";
496
-		    $add = false;
497
-		    $ais_data = $AIS->parse_line(trim($line));
498
-		    $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'];
511
-		    if (isset($ais_data['timestamp'])) {
495
+			//echo "'".$line."'\n";
496
+			$add = false;
497
+			$ais_data = $AIS->parse_line(trim($line));
498
+			$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'];
511
+			if (isset($ais_data['timestamp'])) {
512 512
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
513 513
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
514
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
515
-			    $add = true;
514
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
515
+				$add = true;
516 516
 			}
517
-		    } else {
517
+			} else {
518 518
 			$data['datetime'] = date('Y-m-d H:i:s');
519 519
 			$add = true;
520
-		    }
521
-		    $data['format_source'] = 'aisnmeatxt';
522
-    		    $data['id_source'] = $id_source;
523
-		    //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);
526
-		    unset($data);
520
+			}
521
+			$data['format_source'] = 'aisnmeatxt';
522
+				$data['id_source'] = $id_source;
523
+			//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);
526
+			unset($data);
527 527
 		}
528
-    	    }
529
-    	    $last_exec[$id]['last'] = time();
528
+			}
529
+			$last_exec[$id]['last'] = time();
530 530
 	} elseif ($value['format'] === 'aisnmeahttp') {
531
-	    $arr = $httpfeeds;
532
-	    $w = $e = null;
531
+		$arr = $httpfeeds;
532
+		$w = $e = null;
533 533
 	    
534
-	    if (isset($arr[$id])) {
534
+		if (isset($arr[$id])) {
535 535
 		$nn = stream_select($arr,$w,$e,$timeout);
536 536
 		if ($nn > 0) {
537
-		    foreach ($httpfeeds as $feed) {
537
+			foreach ($httpfeeds as $feed) {
538 538
 			$buffer = stream_get_line($feed,2000,"\n");
539 539
 			if ($buffer === FALSE) {
540
-			    connect_all($globalSources);
540
+				connect_all($globalSources);
541 541
 			}
542 542
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
543 543
 			$buffer = explode('\n',$buffer);
544 544
 			foreach ($buffer as $line) {
545
-			    if ($line != '') {
545
+				if ($line != '') {
546 546
 				$ais_data = $AIS->parse_line(trim($line));
547 547
 				$data = array();
548 548
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -560,117 +560,117 @@  discard block
 block discarded – undo
560 560
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
561 561
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
562 562
 				if (isset($ais_data['timestamp'])) {
563
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
563
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
564 564
 				} else {
565
-				    $data['datetime'] = date('Y-m-d H:i:s');
565
+					$data['datetime'] = date('Y-m-d H:i:s');
566 566
 				}
567 567
 				$data['format_source'] = 'aisnmeahttp';
568 568
 				$data['id_source'] = $id_source;
569 569
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
570 570
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
571 571
 				unset($data);
572
-			    }
572
+				}
573
+			}
573 574
 			}
574
-		    }
575 575
 		} else {
576
-		    $format = $value['format'];
577
-		    if (isset($tt[$format])) $tt[$format]++;
578
-		    else $tt[$format] = 0;
579
-		    if ($tt[$format] > 30) {
576
+			$format = $value['format'];
577
+			if (isset($tt[$format])) $tt[$format]++;
578
+			else $tt[$format] = 0;
579
+			if ($tt[$format] > 30) {
580 580
 			if ($globalDebug) echo 'Reconnect...'."\n";
581 581
 			sleep(2);
582 582
 			//$sourceeen[] = $value;
583 583
 			//connect_all($sourceeen);
584 584
 			//$sourceeen = array();
585 585
 			connect_all($globalSources);
586
-		    }
586
+			}
587
+		}
587 588
 		}
588
-	    }
589 589
 	} elseif ($value['format'] === 'myshiptracking' && 
590
-	    (
590
+		(
591 591
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
592 592
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
593
-	    )
593
+		)
594 594
 	) {
595
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
596
-	    if ($buffer != '') {
595
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
596
+		if ($buffer != '') {
597 597
 		//echo $buffer;
598 598
 		$all_data = json_decode($buffer,true);
599 599
 		//print_r($all_data);
600 600
 		if (isset($all_data[0]['DATA'])) {
601
-		    foreach ($all_data[0]['DATA'] as $line) {
601
+			foreach ($all_data[0]['DATA'] as $line) {
602 602
 			if ($line != '') {
603
-			    $data = array();
604
-			    $data['ident'] = $line['NAME'];
605
-			    $data['mmsi'] = $line['MMSI'];
606
-			    if (strlen($data['mmsi']) > 9) {
603
+				$data = array();
604
+				$data['ident'] = $line['NAME'];
605
+				$data['mmsi'] = $line['MMSI'];
606
+				if (strlen($data['mmsi']) > 9) {
607 607
 				$data['mmsi'] = substr($data['mmsi'],-9);
608
-			    }
609
-			    $data['speed'] = $line['SOG'];
610
-			    $data['heading'] = $line['COG'];
611
-			    $data['latitude'] = $line['LAT'];
612
-			    $data['longitude'] = $line['LNG'];
613
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
614
-			    //$data['type_id'] = $line['TYPE'];
615
-			    $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']));
618
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
619
-			    $data['format_source'] = 'myshiptracking';
620
-			    $data['id_source'] = $id_source;
621
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
-			    $MI->add($data);
623
-			    unset($data);
608
+				}
609
+				$data['speed'] = $line['SOG'];
610
+				$data['heading'] = $line['COG'];
611
+				$data['latitude'] = $line['LAT'];
612
+				$data['longitude'] = $line['LNG'];
613
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
614
+				//$data['type_id'] = $line['TYPE'];
615
+				$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']));
618
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
619
+				$data['format_source'] = 'myshiptracking';
620
+				$data['id_source'] = $id_source;
621
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
622
+				$MI->add($data);
623
+				unset($data);
624
+			}
624 625
 			}
625
-		    }
626 626
 		}
627
-	    }
628
-	    $last_exec[$id]['last'] = time();
627
+		}
628
+		$last_exec[$id]['last'] = time();
629 629
 	} elseif ($value['format'] === 'boatbeaconapp' && 
630
-	    (
630
+		(
631 631
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
632 632
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
633
-	    )
633
+		)
634 634
 	) {
635
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
636
-	    if ($buffer != '') {
635
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
636
+		if ($buffer != '') {
637 637
 		$all_data = json_decode($buffer,true);
638 638
 		if (isset($all_data[0]['mmsi'])) {
639
-		    foreach ($all_data as $line) {
639
+			foreach ($all_data as $line) {
640 640
 			if ($line != '') {
641
-			    $data = array();
642
-			    $data['ident'] = $line['shipname'];
643
-			    $data['callsign'] = $line['callsign'];
644
-			    $data['mmsi'] = substr($line['mmsi'],-9);
645
-			    $data['speed'] = $line['sog'];
646
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
647
-			    $data['latitude'] = $line['latitude'];
648
-			    $data['longitude'] = $line['longitude'];
649
-			    $data['type_id'] = $line['shiptype'];
650
-			    $data['arrival_code'] = $line['destination'];
651
-			    $data['datetime'] = $line['time'];
652
-			    $data['format_source'] = 'boatbeaconapp';
653
-			    $data['id_source'] = $id_source;
654
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
655
-			    $MI->add($data);
656
-			    unset($data);
641
+				$data = array();
642
+				$data['ident'] = $line['shipname'];
643
+				$data['callsign'] = $line['callsign'];
644
+				$data['mmsi'] = substr($line['mmsi'],-9);
645
+				$data['speed'] = $line['sog'];
646
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
647
+				$data['latitude'] = $line['latitude'];
648
+				$data['longitude'] = $line['longitude'];
649
+				$data['type_id'] = $line['shiptype'];
650
+				$data['arrival_code'] = $line['destination'];
651
+				$data['datetime'] = $line['time'];
652
+				$data['format_source'] = 'boatbeaconapp';
653
+				$data['id_source'] = $id_source;
654
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
655
+				$MI->add($data);
656
+				unset($data);
657
+			}
657 658
 			}
658
-		    }
659 659
 		}
660 660
 		
661
-	    }
662
-    	    $last_exec[$id]['last'] = time();
661
+		}
662
+			$last_exec[$id]['last'] = time();
663 663
 	} elseif ($value['format'] === 'boatnerd' && 
664
-	    (
664
+		(
665 665
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
666 666
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
667
-	    )
667
+		)
668 668
 	) {
669
-	    $buffer = $Common->getData($value['host']);
670
-	    if ($buffer != '') {
669
+		$buffer = $Common->getData($value['host']);
670
+		if ($buffer != '') {
671 671
 		$all_data = json_decode($buffer,true);
672 672
 		if (isset($all_data['features'][0]['id'])) {
673
-		    foreach ($all_data['features'] as $line) {
673
+			foreach ($all_data['features'] as $line) {
674 674
 			print_r($line);
675 675
 			$data = array();
676 676
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -690,76 +690,76 @@  discard block
 block discarded – undo
690 690
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
691 691
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
692 692
 			unset($data);
693
-		    }
693
+			}
694 694
 		}
695 695
 		
696
-	    }
697
-    	    $last_exec[$id]['last'] = time();
696
+		}
697
+			$last_exec[$id]['last'] = time();
698 698
 	} elseif ($value['format'] === 'shipplotter' && 
699
-	    (
699
+		(
700 700
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
701 701
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
702
-	    )
702
+		)
703 703
 	) {
704
-	    if ($globalDebug) echo 'download...';
705
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
706
-	    if ($globalDebug) echo 'done !'."\n";
707
-	    // FIXME: Need more work
708
-	    if ($buffer != '') $reset = 0;
709
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
710
-	    $buffer = explode('\n',$buffer);
711
-	    foreach ($buffer as $line) {
704
+		if ($globalDebug) echo 'download...';
705
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
706
+		if ($globalDebug) echo 'done !'."\n";
707
+		// FIXME: Need more work
708
+		if ($buffer != '') $reset = 0;
709
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
710
+		$buffer = explode('\n',$buffer);
711
+		foreach ($buffer as $line) {
712 712
 		if ($line != '') {
713
-		    $data = array();
714
-		    //echo $line."\n";
715
-		    $data['mmsi'] = (int)substr($line,0,9);
716
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
717
-		    $data['status_id'] = substr($line,21,2);
718
-		    $data['type_id'] = substr($line,24,3);
719
-		    $data['latitude'] = substr($line,29,9);
720
-		    $data['longitude'] = substr($line,41,9);
721
-		    $data['speed'] = round(substr($line,51,5));
722
-		    //$data['course'] = substr($line,57,5);
723
-		    $data['heading'] = round(substr($line,63,3));
724
-		    //$data['draft'] = substr($line,67,4);
725
-		    //$data['length'] = substr($line,72,3);
726
-		    //$data['beam'] = substr($line,76,2);
727
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
728
-		    //$data['callsign'] = trim(substr($line,100,7);
729
-		    $data['arrival_code'] = substr($line,108,20);
730
-		    //$data['etaDate'] = substr($line,129,5);
731
-		    //$data['etaTime'] = substr($line,135,5);
732
-		    $data['format_source'] = 'shipplotter';
733
-    		    $data['id_source'] = $id_source;
734
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
735
-		    //print_r($data);
736
-		    //echo 'Add...'."\n";
737
-		    $MI->add($data);
738
-		    unset($data);
713
+			$data = array();
714
+			//echo $line."\n";
715
+			$data['mmsi'] = (int)substr($line,0,9);
716
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
717
+			$data['status_id'] = substr($line,21,2);
718
+			$data['type_id'] = substr($line,24,3);
719
+			$data['latitude'] = substr($line,29,9);
720
+			$data['longitude'] = substr($line,41,9);
721
+			$data['speed'] = round(substr($line,51,5));
722
+			//$data['course'] = substr($line,57,5);
723
+			$data['heading'] = round(substr($line,63,3));
724
+			//$data['draft'] = substr($line,67,4);
725
+			//$data['length'] = substr($line,72,3);
726
+			//$data['beam'] = substr($line,76,2);
727
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
728
+			//$data['callsign'] = trim(substr($line,100,7);
729
+			$data['arrival_code'] = substr($line,108,20);
730
+			//$data['etaDate'] = substr($line,129,5);
731
+			//$data['etaTime'] = substr($line,135,5);
732
+			$data['format_source'] = 'shipplotter';
733
+				$data['id_source'] = $id_source;
734
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
735
+			//print_r($data);
736
+			//echo 'Add...'."\n";
737
+			$MI->add($data);
738
+			unset($data);
739 739
 		}
740
-    	    }
741
-    	    $last_exec[$id]['last'] = time();
740
+			}
741
+			$last_exec[$id]['last'] = time();
742 742
 	} elseif ($value['format'] === 'sailaway' && 
743
-	    (
743
+		(
744 744
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
745 745
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
746
-	    )
746
+		)
747 747
 	) {
748
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
748
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
749 749
 		$authsailaway = $Common->getData('https://sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
750 750
 		//echo $authsailaway;
751 751
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
752 752
 		if (isset($setcookie[1][0])) {
753
-		    $sailaway_authcookie = $setcookie[1][0];
753
+			$sailaway_authcookie = $setcookie[1][0];
754
+		}
754 755
 		}
755
-	    }
756 756
 
757
-	    if ($globalDebug) echo '! Download... ';
758
-	    for ($i =0; $i <= 1; $i++) {
757
+		if ($globalDebug) echo '! Download... ';
758
+		for ($i =0; $i <= 1; $i++) {
759 759
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
760 760
 		$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";
762
-	    if ($buffer != '') {
761
+		if ($globalDebug) echo 'done'."\n";
762
+		if ($buffer != '') {
763 763
 		$all_data = json_decode($buffer,true);
764 764
 		if (isset($all_data['missions'])) {
765 765
 			foreach ($all_data['missions'] as $mission) {
@@ -778,19 +778,19 @@  discard block
 block discarded – undo
778 778
 					//print_r($race_data);
779 779
 					unset($racebuffer);
780 780
 					if (isset($race_data['mission'])) {
781
-					    $datar = array();
782
-					    $datar['id'] = $mission['misnr'];
783
-					    $datar['desc'] = $race_data['mission']['misdescr'];
784
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
785
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
786
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
787
-					    $markers = array();
788
-					    foreach ($race_data['mission']['course'] as $course) {
781
+						$datar = array();
782
+						$datar['id'] = $mission['misnr'];
783
+						$datar['desc'] = $race_data['mission']['misdescr'];
784
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
785
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
786
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
787
+						$markers = array();
788
+						foreach ($race_data['mission']['course'] as $course) {
789 789
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
790
-					    }
791
-					    $datar['markers'] = json_encode($markers);
792
-					    //print_r($datar);
793
-					    $MI->race_add($datar);
790
+						}
791
+						$datar['markers'] = json_encode($markers);
792
+						//print_r($datar);
793
+						$MI->race_add($datar);
794 794
 					}
795 795
 				}
796 796
 				if ($bufferm != '') {
@@ -854,34 +854,34 @@  discard block
 block discarded – undo
854 854
 				}
855 855
 			}
856 856
 		}
857
-	    }
858
-	    }
859
-    	    $last_exec[$id]['last'] = time();
857
+		}
858
+		}
859
+			$last_exec[$id]['last'] = time();
860 860
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
861 861
 	} elseif (
862
-	    (
862
+		(
863 863
 		$value['format'] === 'whazzup' && 
864 864
 		(
865
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
866
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
865
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
866
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
867 867
 		)
868
-	    ) || (
868
+		) || (
869 869
 		$value['format'] === 'vatsimtxt' && 
870 870
 		(
871
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
872
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
871
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
872
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
873
+		)
873 874
 		)
874
-	    )
875 875
 	) {
876
-	    //$buffer = $Common->getData($hosts[$id]);
877
-	    $buffer = $Common->getData($value['host']);
878
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
879
-	    $buffer = explode('\n',$buffer);
880
-	    $reset = 0;
881
-	    foreach ($buffer as $line) {
882
-    		if ($line != '') {
883
-    		    $line = explode(':', $line);
884
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
876
+		//$buffer = $Common->getData($hosts[$id]);
877
+		$buffer = $Common->getData($value['host']);
878
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
879
+		$buffer = explode('\n',$buffer);
880
+		$reset = 0;
881
+		foreach ($buffer as $line) {
882
+			if ($line != '') {
883
+				$line = explode(':', $line);
884
+				if (count($line) > 30 && $line[0] != 'callsign') {
885 885
 			$data = array();
886 886
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
887 887
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -894,37 +894,37 @@  discard block
 block discarded – undo
894 894
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
895 895
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
896 896
 			$data['latitude'] = $line[5]; // lat
897
-	        	$data['longitude'] = $line[6]; // long
898
-	        	$data['verticalrate'] = ''; // vertical rate
899
-	        	$data['squawk'] = ''; // squawk
900
-	        	$data['emergency'] = ''; // emergency
901
-	        	$data['waypoints'] = $line[30];
897
+				$data['longitude'] = $line[6]; // long
898
+				$data['verticalrate'] = ''; // vertical rate
899
+				$data['squawk'] = ''; // squawk
900
+				$data['emergency'] = ''; // emergency
901
+				$data['waypoints'] = $line[30];
902 902
 			$data['datetime'] = date('Y-m-d H:i:s');
903 903
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
904 904
 			//if (isset($line[37])) $data['last_update'] = $line[37];
905
-		        $data['departure_airport_icao'] = $line[11];
906
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
907
-		        $data['arrival_airport_icao'] = $line[13];
905
+				$data['departure_airport_icao'] = $line[11];
906
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
907
+				$data['arrival_airport_icao'] = $line[13];
908 908
 			$data['frequency'] = $line[4];
909 909
 			$data['type'] = $line[18];
910 910
 			$data['range'] = $line[19];
911 911
 			if (isset($line[35])) $data['info'] = $line[35];
912
-    			$data['id_source'] = $id_source;
913
-	    		//$data['arrival_airport_time'] = ;
914
-	    		if ($line[9] != '') {
915
-	    		    $aircraft_data = explode('/',$line[9]);
916
-	    		    if (isset($aircraft_data[1])) {
917
-	    			$data['aircraft_icao'] = $aircraft_data[1];
918
-	    		    }
919
-        		}
920
-	    		/*
912
+				$data['id_source'] = $id_source;
913
+				//$data['arrival_airport_time'] = ;
914
+				if ($line[9] != '') {
915
+					$aircraft_data = explode('/',$line[9]);
916
+					if (isset($aircraft_data[1])) {
917
+					$data['aircraft_icao'] = $aircraft_data[1];
918
+					}
919
+				}
920
+				/*
921 921
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
922 922
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
923 923
 	    		*/
924
-	    		$data['format_source'] = $value['format'];
924
+				$data['format_source'] = $value['format'];
925 925
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
926 926
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
927
-    			if ($line[3] === 'PILOT') $SI->add($data);
927
+				if ($line[3] === 'PILOT') $SI->add($data);
928 928
 			elseif ($line[3] === 'ATC') {
929 929
 				//print_r($data);
930 930
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -945,21 +945,21 @@  discard block
 block discarded – undo
945 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']);
946 946
 				}
947 947
 			}
948
-    			unset($data);
949
-    		    }
950
-    		}
951
-    	    }
952
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
953
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
954
-    	    $last_exec[$id]['last'] = time();
955
-    	} elseif ($value['format'] === 'airwhere' && 
956
-    	    (
957
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
958
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
959
-    	    )
960
-    	) {
961
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
962
-	    if ($buffer != '') {
948
+				unset($data);
949
+				}
950
+			}
951
+			}
952
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
953
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
954
+			$last_exec[$id]['last'] = time();
955
+		} elseif ($value['format'] === 'airwhere' && 
956
+			(
957
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
958
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
959
+			)
960
+		) {
961
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
962
+		if ($buffer != '') {
963 963
 		$all_data = simplexml_load_string($buffer);
964 964
 		foreach($all_data->children() as $childdata) {
965 965
 			$data = array();
@@ -981,10 +981,10 @@  discard block
 block discarded – undo
981 981
 			$SI->add($data);
982 982
 			unset($data);
983 983
 		}
984
-	    }
985
-	    $Source->deleteOldLocationByType('gs');
986
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
987
-	    if ($buffer != '') {
984
+		}
985
+		$Source->deleteOldLocationByType('gs');
986
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
987
+		if ($buffer != '') {
988 988
 		$all_data = simplexml_load_string($buffer);
989 989
 		foreach($all_data->children() as $childdata) {
990 990
 			$data = array();
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 			}
1003 1003
 			unset($data);
1004 1004
 		}
1005
-	    }
1006
-	    $last_exec[$id]['last'] = time();
1005
+		}
1006
+		$last_exec[$id]['last'] = time();
1007 1007
 	/*
1008 1008
 	} if ($value['format'] === 'aircraftlistjson') {
1009 1009
 	    print_r($globalSources);
@@ -1011,17 +1011,17 @@  discard block
 block discarded – undo
1011 1011
 	    echo $globalMinFetch;
1012 1012
 	*/
1013 1013
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1014
-	    (
1014
+		(
1015 1015
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1016 1016
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1017
-	    )
1017
+		)
1018 1018
 	) {
1019
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1020
-	    if ($buffer != '') {
1021
-	        $all_data = json_decode($buffer,true);
1019
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1020
+		if ($buffer != '') {
1021
+			$all_data = json_decode($buffer,true);
1022 1022
 		if (isset($all_data['acList'])) {
1023
-		    $reset = 0;
1024
-		    foreach ($all_data['acList'] as $line) {
1023
+			$reset = 0;
1024
+			foreach ($all_data['acList'] as $line) {
1025 1025
 			$data = array();
1026 1026
 			$data['hex'] = $line['Icao']; // hex
1027 1027
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1044,10 +1044,10 @@  discard block
 block discarded – undo
1044 1044
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1045 1045
 			if (isset($data['latitude'])) $SI->add($data);
1046 1046
 			unset($data);
1047
-		    }
1047
+			}
1048 1048
 		} elseif (is_array($all_data)) {
1049
-		    $reset = 0;
1050
-		    foreach ($all_data as $line) {
1049
+			$reset = 0;
1050
+			foreach ($all_data as $line) {
1051 1051
 			$data = array();
1052 1052
 			$data['hex'] = $line['hex']; // hex
1053 1053
 			$data['ident'] = $line['flight']; // ident
@@ -1067,291 +1067,291 @@  discard block
 block discarded – undo
1067 1067
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1068 1068
 			$SI->add($data);
1069 1069
 			unset($data);
1070
-		    }
1070
+			}
1071 1071
 		}
1072
-	    } elseif ($globalDebug) echo 'No data'."\n";
1073
-    	    //$last_exec['aircraftlistjson'] = time();
1074
-    	    $last_exec[$id]['last'] = time();
1075
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1076
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1077
-    	    (
1078
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1079
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1080
-    	    )
1081
-    	) {
1082
-	    $buffer = $Common->getData($value['host']);
1083
-	    $all_data = json_decode($buffer,true);
1084
-	    if (isset($all_data['planes'])) {
1072
+		} elseif ($globalDebug) echo 'No data'."\n";
1073
+			//$last_exec['aircraftlistjson'] = time();
1074
+			$last_exec[$id]['last'] = time();
1075
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1076
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1077
+			(
1078
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1079
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1080
+			)
1081
+		) {
1082
+		$buffer = $Common->getData($value['host']);
1083
+		$all_data = json_decode($buffer,true);
1084
+		if (isset($all_data['planes'])) {
1085 1085
 		$reset = 0;
1086 1086
 		foreach ($all_data['planes'] as $key => $line) {
1087
-		    $data = array();
1088
-		    $data['hex'] = $key; // hex
1089
-		    $data['ident'] = $line[3]; // ident
1090
-		    $data['altitude'] = $line[6]; // altitude
1091
-		    $data['speed'] = $line[8]; // speed
1092
-		    $data['heading'] = $line[7]; // heading
1093
-		    $data['latitude'] = $line[4]; // lat
1094
-		    $data['longitude'] = $line[5]; // long
1095
-		    //$data['verticalrate'] = $line[]; // verticale rate
1096
-		    $data['squawk'] = $line[10]; // squawk
1097
-		    $data['emergency'] = ''; // emergency
1098
-		    $data['registration'] = $line[2];
1099
-		    $data['aircraft_icao'] = $line[0];
1100
-		    $deparr = explode('-',$line[1]);
1101
-		    if (count($deparr) === 2) {
1087
+			$data = array();
1088
+			$data['hex'] = $key; // hex
1089
+			$data['ident'] = $line[3]; // ident
1090
+			$data['altitude'] = $line[6]; // altitude
1091
+			$data['speed'] = $line[8]; // speed
1092
+			$data['heading'] = $line[7]; // heading
1093
+			$data['latitude'] = $line[4]; // lat
1094
+			$data['longitude'] = $line[5]; // long
1095
+			//$data['verticalrate'] = $line[]; // verticale rate
1096
+			$data['squawk'] = $line[10]; // squawk
1097
+			$data['emergency'] = ''; // emergency
1098
+			$data['registration'] = $line[2];
1099
+			$data['aircraft_icao'] = $line[0];
1100
+			$deparr = explode('-',$line[1]);
1101
+			if (count($deparr) === 2) {
1102 1102
 			$data['departure_airport_icao'] = $deparr[0];
1103 1103
 			$data['arrival_airport_icao'] = $deparr[1];
1104
-		    }
1105
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1106
-	    	    $data['format_source'] = 'planeupdatefaa';
1107
-    		    $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'];
1110
-		    $SI->add($data);
1111
-		    unset($data);
1104
+			}
1105
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1106
+				$data['format_source'] = 'planeupdatefaa';
1107
+				$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'];
1110
+			$SI->add($data);
1111
+			unset($data);
1112
+		}
1112 1113
 		}
1113
-	    }
1114
-	    //$last_exec['planeupdatefaa'] = time();
1115
-	    $last_exec[$id]['last'] = time();
1114
+		//$last_exec['planeupdatefaa'] = time();
1115
+		$last_exec[$id]['last'] = time();
1116 1116
 	} elseif ($value['format'] === 'opensky' && 
1117
-	    (
1117
+		(
1118 1118
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1119 1119
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1120
-	    )
1120
+		)
1121 1121
 	) {
1122
-	    $buffer = $Common->getData($value['host']);
1123
-	    $all_data = json_decode($buffer,true);
1124
-	    if (isset($all_data['states'])) {
1122
+		$buffer = $Common->getData($value['host']);
1123
+		$all_data = json_decode($buffer,true);
1124
+		if (isset($all_data['states'])) {
1125 1125
 		$reset = 0;
1126 1126
 		foreach ($all_data['states'] as $key => $line) {
1127
-		    $data = array();
1128
-		    $data['hex'] = $line[0]; // hex
1129
-		    $data['ident'] = trim($line[1]); // ident
1130
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1131
-		    $data['speed'] = round($line[9]*1.94384); // speed
1132
-		    $data['heading'] = round($line[10]); // heading
1133
-		    $data['latitude'] = $line[6]; // lat
1134
-		    $data['longitude'] = $line[5]; // long
1135
-		    $data['verticalrate'] = $line[11]; // verticale rate
1136
-		    //$data['squawk'] = $line[10]; // squawk
1137
-		    //$data['emergency'] = ''; // emergency
1138
-		    //$data['registration'] = $line[2];
1139
-		    //$data['aircraft_icao'] = $line[0];
1140
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1141
-		    $data['format_source'] = 'opensky';
1142
-		    $data['id_source'] = $id_source;
1143
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1144
-		    $SI->add($data);
1145
-		    unset($data);
1127
+			$data = array();
1128
+			$data['hex'] = $line[0]; // hex
1129
+			$data['ident'] = trim($line[1]); // ident
1130
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1131
+			$data['speed'] = round($line[9]*1.94384); // speed
1132
+			$data['heading'] = round($line[10]); // heading
1133
+			$data['latitude'] = $line[6]; // lat
1134
+			$data['longitude'] = $line[5]; // long
1135
+			$data['verticalrate'] = $line[11]; // verticale rate
1136
+			//$data['squawk'] = $line[10]; // squawk
1137
+			//$data['emergency'] = ''; // emergency
1138
+			//$data['registration'] = $line[2];
1139
+			//$data['aircraft_icao'] = $line[0];
1140
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1141
+			$data['format_source'] = 'opensky';
1142
+			$data['id_source'] = $id_source;
1143
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1144
+			$SI->add($data);
1145
+			unset($data);
1146 1146
 		}
1147
-	    }
1148
-	    //$last_exec['planeupdatefaa'] = time();
1149
-	    $last_exec[$id]['last'] = time();
1147
+		}
1148
+		//$last_exec['planeupdatefaa'] = time();
1149
+		$last_exec[$id]['last'] = time();
1150 1150
 	} elseif ($value['format'] === 'aircraftjson' && 
1151
-	    (
1151
+		(
1152 1152
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1153 1153
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1154
-	    )
1154
+		)
1155 1155
 	) {
1156
-	    $buffer = $Common->getData($value['host']);
1157
-	    $all_data = json_decode($buffer,true);
1158
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1156
+		$buffer = $Common->getData($value['host']);
1157
+		$all_data = json_decode($buffer,true);
1158
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1159 1159
 		$reset = 0;
1160 1160
 		foreach ($all_data['aircraft'] as $key => $line) {
1161
-		    $data = array();
1162
-		    // 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
1172
-		    //$data['emergency'] = ''; // emergency
1173
-		    //$data['registration'] = $line[2];
1174
-		    //$data['aircraft_icao'] = $line[0];
1175
-		    $data['datetime'] = date('Y-m-d H:i:s');
1176
-		    $data['format_source'] = 'aircraftjson';
1177
-		    $data['id_source'] = $id_source;
1178
-		    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;
1183
-		    $SI->add($data);
1184
-		    unset($data);
1161
+			$data = array();
1162
+			// 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
1172
+			//$data['emergency'] = ''; // emergency
1173
+			//$data['registration'] = $line[2];
1174
+			//$data['aircraft_icao'] = $line[0];
1175
+			$data['datetime'] = date('Y-m-d H:i:s');
1176
+			$data['format_source'] = 'aircraftjson';
1177
+			$data['id_source'] = $id_source;
1178
+			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;
1183
+			$SI->add($data);
1184
+			unset($data);
1185
+		}
1185 1186
 		}
1186
-	    }
1187
-	    //$last_exec['planeupdatefaa'] = time();
1188
-	    $last_exec[$id]['last'] = time();
1187
+		//$last_exec['planeupdatefaa'] = time();
1188
+		$last_exec[$id]['last'] = time();
1189 1189
 	} elseif ($value['format'] === 'planefinderclient' && 
1190
-	    (
1190
+		(
1191 1191
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1192 1192
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1193
-	    )
1193
+		)
1194 1194
 	) {
1195
-	    $buffer = $Common->getData($value['host']);
1196
-	    $all_data = json_decode($buffer,true);
1197
-	    if (isset($all_data['aircraft'])) {
1195
+		$buffer = $Common->getData($value['host']);
1196
+		$all_data = json_decode($buffer,true);
1197
+		if (isset($all_data['aircraft'])) {
1198 1198
 		$reset = 0;
1199 1199
 		foreach ($all_data['aircraft'] as $key => $line) {
1200
-		    $data = array();
1201
-		    $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
1210
-		    //$data['emergency'] = ''; // emergency
1211
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1212
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1213
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1214
-		    $data['format_source'] = 'planefinderclient';
1215
-		    $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;
1218
-		    $SI->add($data);
1219
-		    unset($data);
1200
+			$data = array();
1201
+			$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
1210
+			//$data['emergency'] = ''; // emergency
1211
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1212
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1213
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1214
+			$data['format_source'] = 'planefinderclient';
1215
+			$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;
1218
+			$SI->add($data);
1219
+			unset($data);
1220 1220
 		}
1221
-	    }
1222
-	    $last_exec[$id]['last'] = time();
1221
+		}
1222
+		$last_exec[$id]['last'] = time();
1223 1223
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1224 1224
 	} elseif ($value['format'] === 'fr24json' && 
1225
-	    (
1225
+		(
1226 1226
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1227 1227
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1228
-	    )
1228
+		)
1229 1229
 	) {
1230
-	    //$buffer = $Common->getData($hosts[$id]);
1231
-	    $buffer = $Common->getData($value['host']);
1232
-	    $all_data = json_decode($buffer,true);
1233
-	    if (!empty($all_data)) $reset = 0;
1234
-	    foreach ($all_data as $key => $line) {
1230
+		//$buffer = $Common->getData($hosts[$id]);
1231
+		$buffer = $Common->getData($value['host']);
1232
+		$all_data = json_decode($buffer,true);
1233
+		if (!empty($all_data)) $reset = 0;
1234
+		foreach ($all_data as $key => $line) {
1235 1235
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1236
-		    $data = array();
1237
-		    $data['hex'] = $line[0];
1238
-		    $data['ident'] = $line[16]; //$line[13]
1239
-	    	    $data['altitude'] = $line[4]; // altitude
1240
-	    	    $data['speed'] = $line[5]; // speed
1241
-	    	    $data['heading'] = $line[3]; // heading
1242
-	    	    $data['latitude'] = $line[1]; // lat
1243
-	    	    $data['longitude'] = $line[2]; // long
1244
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1245
-	    	    $data['squawk'] = $line[6]; // squawk
1246
-	    	    $data['aircraft_icao'] = $line[8];
1247
-	    	    $data['registration'] = $line[9];
1248
-		    $data['departure_airport_iata'] = $line[11];
1249
-		    $data['arrival_airport_iata'] = $line[12];
1250
-	    	    $data['emergency'] = ''; // emergency
1251
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1252
-	    	    $data['format_source'] = 'fr24json';
1253
-    		    $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'];
1256
-		    $SI->add($data);
1257
-		    unset($data);
1236
+			$data = array();
1237
+			$data['hex'] = $line[0];
1238
+			$data['ident'] = $line[16]; //$line[13]
1239
+				$data['altitude'] = $line[4]; // altitude
1240
+				$data['speed'] = $line[5]; // speed
1241
+				$data['heading'] = $line[3]; // heading
1242
+				$data['latitude'] = $line[1]; // lat
1243
+				$data['longitude'] = $line[2]; // long
1244
+				$data['verticalrate'] = $line[15]; // verticale rate
1245
+				$data['squawk'] = $line[6]; // squawk
1246
+				$data['aircraft_icao'] = $line[8];
1247
+				$data['registration'] = $line[9];
1248
+			$data['departure_airport_iata'] = $line[11];
1249
+			$data['arrival_airport_iata'] = $line[12];
1250
+				$data['emergency'] = ''; // emergency
1251
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1252
+				$data['format_source'] = 'fr24json';
1253
+				$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'];
1256
+			$SI->add($data);
1257
+			unset($data);
1258
+		}
1258 1259
 		}
1259
-	    }
1260
-	    //$last_exec['fr24json'] = time();
1261
-	    $last_exec[$id]['last'] = time();
1260
+		//$last_exec['fr24json'] = time();
1261
+		$last_exec[$id]['last'] = time();
1262 1262
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1263 1263
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1264
-	    (
1264
+		(
1265 1265
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1266 1266
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1267
-	    )
1267
+		)
1268 1268
 	) {
1269
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1270
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1271
-	    //echo $buffer;
1272
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1273
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1274
-	    $all_data = json_decode($buffer,true);
1275
-	    if (json_last_error() != JSON_ERROR_NONE) {
1269
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1270
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1271
+		//echo $buffer;
1272
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1273
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1274
+		$all_data = json_decode($buffer,true);
1275
+		if (json_last_error() != JSON_ERROR_NONE) {
1276 1276
 		die(json_last_error_msg());
1277
-	    }
1278
-	    if (isset($all_data['mrkrs'])) {
1277
+		}
1278
+		if (isset($all_data['mrkrs'])) {
1279 1279
 		$reset = 0;
1280 1280
 		foreach ($all_data['mrkrs'] as $key => $line) {
1281
-		    if (isset($line['inf'])) {
1281
+			if (isset($line['inf'])) {
1282 1282
 			$data = array();
1283 1283
 			$data['hex'] = $line['inf']['ia'];
1284 1284
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1285
-	    		$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
1288
-	    		$data['latitude'] = $line['pt'][0]; // lat
1289
-	    		$data['longitude'] = $line['pt'][1]; // long
1290
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1291
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1292
-	    		//$data['aircraft_icao'] = $line[8];
1293
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1285
+				$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
1288
+				$data['latitude'] = $line['pt'][0]; // lat
1289
+				$data['longitude'] = $line['pt'][1]; // long
1290
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1291
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1292
+				//$data['aircraft_icao'] = $line[8];
1293
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1294 1294
 			//$data['departure_airport_iata'] = $line[11];
1295 1295
 			//$data['arrival_airport_iata'] = $line[12];
1296
-	    		//$data['emergency'] = ''; // emergency
1296
+				//$data['emergency'] = ''; // emergency
1297 1297
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1298
-	    		$data['format_source'] = 'radarvirtueljson';
1299
-    			$data['id_source'] = $id_source;
1298
+				$data['format_source'] = 'radarvirtueljson';
1299
+				$data['id_source'] = $id_source;
1300 1300
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1301 1301
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1302 1302
 			$SI->add($data);
1303 1303
 			unset($data);
1304
-		    }
1304
+			}
1305 1305
 		}
1306
-	    }
1307
-	    //$last_exec['radarvirtueljson'] = time();
1308
-	    $last_exec[$id]['last'] = time();
1306
+		}
1307
+		//$last_exec['radarvirtueljson'] = time();
1308
+		$last_exec[$id]['last'] = time();
1309 1309
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1310 1310
 	} elseif ($value['format'] === 'pirepsjson' && 
1311
-	    (
1311
+		(
1312 1312
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1313 1313
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1314
-	    )
1314
+		)
1315 1315
 	) {
1316
-	    //$buffer = $Common->getData($hosts[$id]);
1317
-	    $buffer = $Common->getData($value['host'].'?'.time());
1318
-	    $all_data = json_decode(utf8_encode($buffer),true);
1316
+		//$buffer = $Common->getData($hosts[$id]);
1317
+		$buffer = $Common->getData($value['host'].'?'.time());
1318
+		$all_data = json_decode(utf8_encode($buffer),true);
1319 1319
 	    
1320
-	    if (isset($all_data['pireps'])) {
1320
+		if (isset($all_data['pireps'])) {
1321 1321
 		$reset = 0;
1322
-	        foreach ($all_data['pireps'] as $line) {
1323
-		    $data = array();
1324
-		    $data['id'] = $line['id'];
1325
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1326
-		    $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
1333
-		    $data['latitude'] = $line['lat']; // lat
1334
-		    $data['longitude'] = $line['lon']; // long
1335
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1336
-		    //$data['squawk'] = $line['squawk']; // squawk
1337
-		    //$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'];
1341
-		    //$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'] = '';
1346
-		    $data['format_source'] = 'pireps';
1347
-    		    $data['id_source'] = $id_source;
1348
-		    $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'];
1351
-		    if ($line['icon'] === 'plane') {
1322
+			foreach ($all_data['pireps'] as $line) {
1323
+			$data = array();
1324
+			$data['id'] = $line['id'];
1325
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1326
+			$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
1333
+			$data['latitude'] = $line['lat']; // lat
1334
+			$data['longitude'] = $line['lon']; // long
1335
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1336
+			//$data['squawk'] = $line['squawk']; // squawk
1337
+			//$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'];
1341
+			//$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'] = '';
1346
+			$data['format_source'] = 'pireps';
1347
+				$data['id_source'] = $id_source;
1348
+			$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'];
1351
+			if ($line['icon'] === 'plane') {
1352 1352
 			$SI->add($data);
1353
-		    //    print_r($data);
1354
-    		    } elseif ($line['icon'] === 'ct') {
1353
+			//    print_r($data);
1354
+				} elseif ($line['icon'] === 'ct') {
1355 1355
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1356 1356
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1357 1357
 			$typec = substr($data['ident'],-3);
@@ -1366,209 +1366,209 @@  discard block
 block discarded – undo
1366 1366
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1367 1367
 			else $data['type'] = 'Observer';
1368 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']);
1369
-		    }
1370
-		    unset($data);
1369
+			}
1370
+			unset($data);
1371 1371
 		}
1372
-	    }
1373
-	    //$last_exec['pirepsjson'] = time();
1374
-	    $last_exec[$id]['last'] = time();
1372
+		}
1373
+		//$last_exec['pirepsjson'] = time();
1374
+		$last_exec[$id]['last'] = time();
1375 1375
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1376 1376
 	} elseif ($value['format'] === 'phpvmacars' && 
1377
-	    (
1377
+		(
1378 1378
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1379 1379
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1380
-	    )
1380
+		)
1381 1381
 	) {
1382
-	    //$buffer = $Common->getData($hosts[$id]);
1383
-	    if ($globalDebug) echo 'Get Data...'."\n";
1384
-	    $buffer = $Common->getData($value['host']);
1385
-	    $all_data = json_decode($buffer,true);
1386
-	    if ($buffer != '' && is_array($all_data)) {
1382
+		//$buffer = $Common->getData($hosts[$id]);
1383
+		if ($globalDebug) echo 'Get Data...'."\n";
1384
+		$buffer = $Common->getData($value['host']);
1385
+		$all_data = json_decode($buffer,true);
1386
+		if ($buffer != '' && is_array($all_data)) {
1387 1387
 		$reset = 0;
1388 1388
 		foreach ($all_data as $line) {
1389
-	    	    $data = array();
1390
-	    	    //$data['id'] = $line['id']; // id not usable
1391
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1392
-	    	    $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'];
1395
-	    	    $data['ident'] = $line['flightnum']; // ident
1396
-	    	    $data['altitude'] = $line['alt']; // altitude
1397
-	    	    $data['speed'] = $line['gs']; // speed
1398
-	    	    $data['heading'] = $line['heading']; // heading
1399
-	    	    $data['latitude'] = $line['lat']; // lat
1400
-	    	    $data['longitude'] = $line['lng']; // long
1401
-	    	    $data['verticalrate'] = ''; // verticale rate
1402
-	    	    $data['squawk'] = ''; // squawk
1403
-	    	    $data['emergency'] = ''; // emergency
1404
-	    	    //$data['datetime'] = $line['lastupdate'];
1405
-	    	    //$data['last_update'] = $line['lastupdate'];
1406
-	    	    if (isset($value['timezone'])) {
1407
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1408
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1409
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1410
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1411
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1412
-	    	    $data['departure_airport_time'] = $line['deptime'];
1413
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1414
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1415
-    		    if (isset($line['registration'])) {
1416
-    			$data['registration'] = $line['registration'];
1417
-    			//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
1421
-		    if (isset($line['aircraftname'])) {
1389
+				$data = array();
1390
+				//$data['id'] = $line['id']; // id not usable
1391
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1392
+				$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'];
1395
+				$data['ident'] = $line['flightnum']; // ident
1396
+				$data['altitude'] = $line['alt']; // altitude
1397
+				$data['speed'] = $line['gs']; // speed
1398
+				$data['heading'] = $line['heading']; // heading
1399
+				$data['latitude'] = $line['lat']; // lat
1400
+				$data['longitude'] = $line['lng']; // long
1401
+				$data['verticalrate'] = ''; // verticale rate
1402
+				$data['squawk'] = ''; // squawk
1403
+				$data['emergency'] = ''; // emergency
1404
+				//$data['datetime'] = $line['lastupdate'];
1405
+				//$data['last_update'] = $line['lastupdate'];
1406
+				if (isset($value['timezone'])) {
1407
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1408
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1409
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1410
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1411
+				$data['departure_airport_icao'] = $line['depicao'];
1412
+				$data['departure_airport_time'] = $line['deptime'];
1413
+				$data['arrival_airport_icao'] = $line['arricao'];
1414
+				$data['arrival_airport_time'] = $line['arrtime'];
1415
+				if (isset($line['registration'])) {
1416
+				$data['registration'] = $line['registration'];
1417
+				//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
1421
+			if (isset($line['aircraftname'])) {
1422 1422
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1423 1423
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1424
-	    		$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 {
1428
-	    		    $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']);
1431
-	    		}
1432
-	    	    }
1433
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1434
-    		    $data['id_source'] = $id_source;
1435
-	    	    $data['format_source'] = 'phpvmacars';
1436
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1437
-		    $SI->add($data);
1438
-		    unset($data);
1424
+				$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 {
1428
+					$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']);
1431
+				}
1432
+				}
1433
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1434
+				$data['id_source'] = $id_source;
1435
+				$data['format_source'] = 'phpvmacars';
1436
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1437
+			$SI->add($data);
1438
+			unset($data);
1439 1439
 		}
1440 1440
 		if ($globalDebug) echo 'No more data...'."\n";
1441 1441
 		unset($buffer);
1442 1442
 		unset($all_data);
1443
-	    }
1444
-	    //$last_exec['phpvmacars'] = time();
1445
-	    $last_exec[$id]['last'] = time();
1443
+		}
1444
+		//$last_exec['phpvmacars'] = time();
1445
+		$last_exec[$id]['last'] = time();
1446 1446
 	} elseif ($value['format'] === 'vaos' && 
1447
-	    (
1447
+		(
1448 1448
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1449 1449
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1450
-	    )
1450
+		)
1451 1451
 	) {
1452
-	    //$buffer = $Common->getData($hosts[$id]);
1453
-	    if ($globalDebug) echo 'Get Data...'."\n";
1454
-	    $buffer = $Common->getData($value['host']);
1455
-	    $all_data = json_decode($buffer,true);
1456
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1452
+		//$buffer = $Common->getData($hosts[$id]);
1453
+		if ($globalDebug) echo 'Get Data...'."\n";
1454
+		$buffer = $Common->getData($value['host']);
1455
+		$all_data = json_decode($buffer,true);
1456
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1457 1457
 		$reset = 0;
1458 1458
 		foreach ($all_data['ACARSData'] as $line) {
1459
-		    //print_r($line);
1460
-	    	    $data = array();
1461
-	    	    //$data['id'] = $line['id']; // id not usable
1462
-	    	    $data['id'] = $line['id'];
1463
-	    	    //$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'];
1466
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1467
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1468
-	    	    $data['altitude'] = $line['altitude']; // altitude
1469
-	    	    $data['speed'] = $line['groundspeed']; // speed
1470
-	    	    $data['heading'] = $line['heading']; // heading
1471
-	    	    $data['latitude'] = $line['lat']; // lat
1472
-	    	    $data['longitude'] = $line['lon']; // long
1473
-	    	    //$data['verticalrate'] = ''; // verticale rate
1474
-	    	    //$data['squawk'] = ''; // squawk
1475
-	    	    //$data['emergency'] = ''; // emergency
1476
-	    	    if (isset($value['timezone'])) {
1477
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1478
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1479
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1480
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1459
+			//print_r($line);
1460
+				$data = array();
1461
+				//$data['id'] = $line['id']; // id not usable
1462
+				$data['id'] = $line['id'];
1463
+				//$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'];
1466
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1467
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1468
+				$data['altitude'] = $line['altitude']; // altitude
1469
+				$data['speed'] = $line['groundspeed']; // speed
1470
+				$data['heading'] = $line['heading']; // heading
1471
+				$data['latitude'] = $line['lat']; // lat
1472
+				$data['longitude'] = $line['lon']; // long
1473
+				//$data['verticalrate'] = ''; // verticale rate
1474
+				//$data['squawk'] = ''; // squawk
1475
+				//$data['emergency'] = ''; // emergency
1476
+				if (isset($value['timezone'])) {
1477
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1478
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1479
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1480
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1481 1481
 	    	    
1482
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1483
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1484
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1485
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1486
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1482
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1483
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1484
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1485
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1486
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1487 1487
 
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
1490
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
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
1490
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1491 1491
 
1492
-    		    $data['id_source'] = $id_source;
1493
-	    	    $data['format_source'] = 'vaos';
1494
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1495
-		    $SI->add($data);
1496
-		    unset($data);
1492
+				$data['id_source'] = $id_source;
1493
+				$data['format_source'] = 'vaos';
1494
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1495
+			$SI->add($data);
1496
+			unset($data);
1497 1497
 		}
1498 1498
 		if ($globalDebug) echo 'No more data...'."\n";
1499 1499
 		unset($buffer);
1500 1500
 		unset($all_data);
1501
-	    }
1502
-	    //$last_exec['phpvmacars'] = time();
1503
-	    $last_exec[$id]['last'] = time();
1501
+		}
1502
+		//$last_exec['phpvmacars'] = time();
1503
+		$last_exec[$id]['last'] = time();
1504 1504
 	} elseif ($value['format'] === 'vam' && 
1505
-	    (
1505
+		(
1506 1506
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1507 1507
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1508
-	    )
1508
+		)
1509 1509
 	) {
1510
-	    //$buffer = $Common->getData($hosts[$id]);
1511
-	    if ($globalDebug) echo 'Get Data...'."\n";
1512
-	    $buffer = $Common->getData($value['host']);
1513
-	    $all_data = json_decode($buffer,true);
1514
-	    if ($buffer != '' && is_array($all_data)) {
1510
+		//$buffer = $Common->getData($hosts[$id]);
1511
+		if ($globalDebug) echo 'Get Data...'."\n";
1512
+		$buffer = $Common->getData($value['host']);
1513
+		$all_data = json_decode($buffer,true);
1514
+		if ($buffer != '' && is_array($all_data)) {
1515 1515
 		$reset = 0;
1516 1516
 		foreach ($all_data as $line) {
1517
-	    	    $data = array();
1518
-	    	    //$data['id'] = $line['id']; // id not usable
1519
-	    	    $data['id'] = trim($line['flight_id']);
1520
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1521
-	    	    $data['pilot_name'] = $line['pilot_name'];
1522
-	    	    $data['pilot_id'] = $line['pilot_id'];
1523
-	    	    $data['ident'] = trim($line['callsign']); // ident
1524
-	    	    $data['altitude'] = $line['altitude']; // altitude
1525
-	    	    $data['speed'] = $line['gs']; // speed
1526
-	    	    $data['heading'] = $line['heading']; // heading
1527
-	    	    $data['latitude'] = $line['latitude']; // lat
1528
-	    	    $data['longitude'] = $line['longitude']; // long
1529
-	    	    $data['verticalrate'] = ''; // verticale rate
1530
-	    	    $data['squawk'] = ''; // squawk
1531
-	    	    $data['emergency'] = ''; // emergency
1532
-	    	    //$data['datetime'] = $line['lastupdate'];
1533
-	    	    $data['last_update'] = $line['last_update'];
1534
-		    $data['datetime'] = date('Y-m-d H:i:s');
1535
-	    	    $data['departure_airport_icao'] = $line['departure'];
1536
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1537
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1538
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1539
-    		    //$data['registration'] = $line['aircraft'];
1540
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1541
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1542
-    		    $data['id_source'] = $id_source;
1543
-	    	    $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'];
1546
-		    $SI->add($data);
1547
-		    unset($data);
1517
+				$data = array();
1518
+				//$data['id'] = $line['id']; // id not usable
1519
+				$data['id'] = trim($line['flight_id']);
1520
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1521
+				$data['pilot_name'] = $line['pilot_name'];
1522
+				$data['pilot_id'] = $line['pilot_id'];
1523
+				$data['ident'] = trim($line['callsign']); // ident
1524
+				$data['altitude'] = $line['altitude']; // altitude
1525
+				$data['speed'] = $line['gs']; // speed
1526
+				$data['heading'] = $line['heading']; // heading
1527
+				$data['latitude'] = $line['latitude']; // lat
1528
+				$data['longitude'] = $line['longitude']; // long
1529
+				$data['verticalrate'] = ''; // verticale rate
1530
+				$data['squawk'] = ''; // squawk
1531
+				$data['emergency'] = ''; // emergency
1532
+				//$data['datetime'] = $line['lastupdate'];
1533
+				$data['last_update'] = $line['last_update'];
1534
+			$data['datetime'] = date('Y-m-d H:i:s');
1535
+				$data['departure_airport_icao'] = $line['departure'];
1536
+				//$data['departure_airport_time'] = $line['departure_time'];
1537
+				$data['arrival_airport_icao'] = $line['arrival'];
1538
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1539
+				//$data['registration'] = $line['aircraft'];
1540
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1541
+				$data['aircraft_icao'] = $line['plane_type'];
1542
+				$data['id_source'] = $id_source;
1543
+				$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'];
1546
+			$SI->add($data);
1547
+			unset($data);
1548 1548
 		}
1549 1549
 		if ($globalDebug) echo 'No more data...'."\n";
1550 1550
 		unset($buffer);
1551 1551
 		unset($all_data);
1552
-	    }
1553
-	    //$last_exec['phpvmacars'] = time();
1554
-	    $last_exec[$id]['last'] = time();
1552
+		}
1553
+		//$last_exec['phpvmacars'] = time();
1554
+		$last_exec[$id]['last'] = time();
1555 1555
 	} elseif ($value['format'] === 'blitzortung' && 
1556
-	    (
1556
+		(
1557 1557
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1558 1558
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1559
-	    )
1559
+		)
1560 1560
 	) {
1561
-	    //$buffer = $Common->getData($hosts[$id]);
1562
-	    if ($globalDebug) echo 'Get Data...'."\n";
1563
-	    $buffer = $Common->getData($value['host']);
1564
-	    $all_data = json_decode($buffer,true);
1565
-	    if ($buffer != '') {
1561
+		//$buffer = $Common->getData($hosts[$id]);
1562
+		if ($globalDebug) echo 'Get Data...'."\n";
1563
+		$buffer = $Common->getData($value['host']);
1564
+		$all_data = json_decode($buffer,true);
1565
+		if ($buffer != '') {
1566 1566
 		$Source->deleteLocationBySource('blitzortung');
1567 1567
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1568 1568
 		$buffer = explode('\n',$buffer);
1569 1569
 		foreach ($buffer as $buffer_line) {
1570
-		    $line = json_decode($buffer_line,true);
1571
-		    if (isset($line['time'])) {
1570
+			$line = json_decode($buffer_line,true);
1571
+			if (isset($line['time'])) {
1572 1572
 			$data = array();
1573 1573
 			$data['altitude'] = $line['alt']; // altitude
1574 1574
 			$data['latitude'] = $line['lat']; // lat
@@ -1580,55 +1580,55 @@  discard block
 block discarded – undo
1580 1580
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1581 1581
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1582 1582
 			unset($data);
1583
-		    }
1583
+			}
1584 1584
 		}
1585 1585
 		if ($globalDebug) echo 'No more data...'."\n";
1586 1586
 		unset($buffer);
1587
-	    }
1588
-	    $last_exec[$id]['last'] = time();
1587
+		}
1588
+		$last_exec[$id]['last'] = time();
1589 1589
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1590 1590
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1591
-	    //$last_exec[$id]['last'] = time();
1592
-	    //$read = array( $sockets[$id] );
1593
-	    $read = $sockets;
1594
-	    $write = NULL;
1595
-	    $e = NULL;
1596
-	    $n = socket_select($read, $write, $e, $timeout);
1597
-	    if ($e != NULL) var_dump($e);
1598
-	    if ($n > 0) {
1591
+		//$last_exec[$id]['last'] = time();
1592
+		//$read = array( $sockets[$id] );
1593
+		$read = $sockets;
1594
+		$write = NULL;
1595
+		$e = NULL;
1596
+		$n = socket_select($read, $write, $e, $timeout);
1597
+		if ($e != NULL) var_dump($e);
1598
+		if ($n > 0) {
1599 1599
 		$reset = 0;
1600 1600
 		foreach ($read as $nb => $r) {
1601
-		    //$value = $formats[$nb];
1602
-		    $format = $globalSources[$nb]['format'];
1603
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1601
+			//$value = $formats[$nb];
1602
+			$format = $globalSources[$nb]['format'];
1603
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1604 1604
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1605
-		    } elseif ($format === 'vrstcp') {
1605
+			} elseif ($format === 'vrstcp') {
1606 1606
 			$buffer = @socket_read($r, 6000);
1607
-		    } else {
1607
+			} else {
1608 1608
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1609
-		    }
1610
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1611
-		    //echo $buffer."\n";
1612
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1613
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1614
-		    $error = false;
1615
-		    //$SI::del();
1616
-		    if ($buffer !== FALSE) {
1609
+			}
1610
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1611
+			//echo $buffer."\n";
1612
+			// lets play nice and handle signals such as ctrl-c/kill properly
1613
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1614
+			$error = false;
1615
+			//$SI::del();
1616
+			if ($buffer !== FALSE) {
1617 1617
 			if ($format === 'vrstcp') {
1618
-			    $buffer = explode('},{',$buffer);
1618
+				$buffer = explode('},{',$buffer);
1619 1619
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1620
-		    }
1621
-		    // SBS format is CSV format
1622
-		    if ($buffer !== FALSE && $buffer !== '') {
1620
+			}
1621
+			// SBS format is CSV format
1622
+			if ($buffer !== FALSE && $buffer !== '') {
1623 1623
 			$tt[$format] = 0;
1624 1624
 			if ($format === 'acarssbs3') {
1625
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1626
-			    $ACARS->add(trim($buffer));
1627
-			    $ACARS->deleteLiveAcarsData();
1625
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1626
+				$ACARS->add(trim($buffer));
1627
+				$ACARS->deleteLiveAcarsData();
1628 1628
 			} elseif ($format === 'raw') {
1629
-			    // AVR format
1630
-			    $data = $SBS->parse($buffer);
1631
-			    if (is_array($data)) {
1629
+				// AVR format
1630
+				$data = $SBS->parse($buffer);
1631
+				if (is_array($data)) {
1632 1632
 				//print_r($data);
1633 1633
 				$data['datetime'] = date('Y-m-d H:i:s');
1634 1634
 				$data['format_source'] = 'raw';
@@ -1637,39 +1637,39 @@  discard block
 block discarded – undo
1637 1637
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1638 1638
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1639 1639
 				$SI->add($data);
1640
-			    }
1640
+				}
1641 1641
 			} elseif ($format === 'ais') {
1642
-			    $ais_data = $AIS->parse_line(trim($buffer));
1643
-			    $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'];
1642
+				$ais_data = $AIS->parse_line(trim($buffer));
1643
+				$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'];
1660 1660
 
1661
-			    if (isset($ais_data['timestamp'])) {
1661
+				if (isset($ais_data['timestamp'])) {
1662 1662
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1663
-			    } else {
1663
+				} else {
1664 1664
 				$data['datetime'] = date('Y-m-d H:i:s');
1665
-			    }
1666
-			    $data['format_source'] = 'aisnmea';
1667
-    			    $data['id_source'] = $id_source;
1668
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1669
-			    unset($data);
1670
-                        } elseif ($format === 'flightgearsp') {
1671
-                    	    //echo $buffer."\n";
1672
-                    	    if (strlen($buffer) > 5) {
1665
+				}
1666
+				$data['format_source'] = 'aisnmea';
1667
+					$data['id_source'] = $id_source;
1668
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1669
+				unset($data);
1670
+						} elseif ($format === 'flightgearsp') {
1671
+							//echo $buffer."\n";
1672
+							if (strlen($buffer) > 5) {
1673 1673
 				$line = explode(',',$buffer);
1674 1674
 				$data = array();
1675 1675
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1686,38 +1686,38 @@  discard block
 block discarded – undo
1686 1686
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1687 1687
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1688 1688
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1689
-			    }
1690
-                        } elseif ($format === 'acars') {
1691
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1692
-			    $ACARS->add(trim($buffer));
1693
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1694
-			    $ACARS->deleteLiveAcarsData();
1689
+				}
1690
+						} elseif ($format === 'acars') {
1691
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1692
+				$ACARS->add(trim($buffer));
1693
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1694
+				$ACARS->deleteLiveAcarsData();
1695 1695
 			} elseif ($format === 'flightgearmp') {
1696
-			    if (substr($buffer,0,1) != '#') {
1696
+				if (substr($buffer,0,1) != '#') {
1697 1697
 				$data = array();
1698 1698
 				//echo $buffer."\n";
1699 1699
 				$line = explode(' ',$buffer);
1700 1700
 				if (count($line) === 11) {
1701
-				    $userserver = explode('@',$line[0]);
1702
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1703
-				    $data['ident'] = $userserver[0];
1704
-				    $data['registration'] = $userserver[0];
1705
-				    $data['latitude'] = $line[4];
1706
-				    $data['longitude'] = $line[5];
1707
-				    $data['altitude'] = $line[6];
1708
-				    $data['datetime'] = date('Y-m-d H:i:s');
1709
-				    $aircraft_type = $line[10];
1710
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1711
-				    $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);
1701
+					$userserver = explode('@',$line[0]);
1702
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1703
+					$data['ident'] = $userserver[0];
1704
+					$data['registration'] = $userserver[0];
1705
+					$data['latitude'] = $line[4];
1706
+					$data['longitude'] = $line[5];
1707
+					$data['altitude'] = $line[6];
1708
+					$data['datetime'] = date('Y-m-d H:i:s');
1709
+					$aircraft_type = $line[10];
1710
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1711
+					$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);
1714
+				}
1714 1715
 				}
1715
-			    }
1716 1716
 			} elseif ($format === 'beast') {
1717
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1718
-			    die;
1717
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1718
+				die;
1719 1719
 			} elseif ($format === 'vrstcp') {
1720
-			    foreach($buffer as $all_data) {
1720
+				foreach($buffer as $all_data) {
1721 1721
 				$line = json_decode('{'.$all_data.'}',true);
1722 1722
 				$data = array();
1723 1723
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1737,158 +1737,158 @@  discard block
 block discarded – undo
1737 1737
 				*/
1738 1738
 				$data['datetime'] = date('Y-m-d H:i:s');
1739 1739
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1740
-		    		$data['format_source'] = 'vrstcp';
1740
+					$data['format_source'] = 'vrstcp';
1741 1741
 				$data['id_source'] = $id_source;
1742 1742
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1743 1743
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1744 1744
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1745 1745
 				unset($data);
1746
-			    }
1746
+				}
1747 1747
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1748
-			    $line = explode("\t", $buffer);
1749
-			    for($k = 0; $k < count($line); $k=$k+2) {
1748
+				$line = explode("\t", $buffer);
1749
+				for($k = 0; $k < count($line); $k=$k+2) {
1750 1750
 				$key = $line[$k];
1751
-			        $lined[$key] = $line[$k+1];
1752
-			    }
1753
-    			    if (count($lined) > 3) {
1754
-    				$data['hex'] = $lined['hexid'];
1755
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1756
-    				$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'];
1764
-    				$data['id_source'] = $id_source;
1765
-    				$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'];
1751
+					$lined[$key] = $line[$k+1];
1752
+				}
1753
+					if (count($lined) > 3) {
1754
+					$data['hex'] = $lined['hexid'];
1755
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1756
+					$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'];
1764
+					$data['id_source'] = $id_source;
1765
+					$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 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);
1770
-    				unset($lined);
1771
-    				unset($data);
1772
-    			    } else $error = true;
1769
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1770
+					unset($lined);
1771
+					unset($data);
1772
+					} else $error = true;
1773 1773
 			} elseif ($format === 'aprs' && $use_aprs) {
1774
-			    if ($aprs_connect === 0) {
1774
+				if ($aprs_connect === 0) {
1775 1775
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1776 1776
 				$aprs_connect = 1;
1777
-			    }
1777
+				}
1778 1778
 			    
1779
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1779
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1780 1780
 				$aprs_last_tx = time();
1781 1781
 				$data_aprs = "# Keep alive";
1782 1782
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1783
-			    }
1783
+				}
1784 1784
 			    
1785
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1786
-			    //echo 'APRS data : '.$buffer."\n";
1787
-			    $buffer = str_replace('APRS <- ','',$buffer);
1788
-			    $buffer = str_replace('APRS -> ','',$buffer);
1789
-			    //echo $buffer."\n";
1790
-			    date_default_timezone_set('UTC');
1791
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1785
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1786
+				//echo 'APRS data : '.$buffer."\n";
1787
+				$buffer = str_replace('APRS <- ','',$buffer);
1788
+				$buffer = str_replace('APRS -> ','',$buffer);
1789
+				//echo $buffer."\n";
1790
+				date_default_timezone_set('UTC');
1791
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1792 1792
 				$line = $APRS->parse($buffer);
1793 1793
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1794 1794
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1795
-				    $aprs_last_tx = time();
1796
-				    $data = array();
1797
-				    //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');
1808
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1809
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1810
-				    $data['latitude'] = $line['latitude'];
1811
-				    $data['longitude'] = $line['longitude'];
1812
-				    //$data['verticalrate'] = $line[16];
1813
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1814
-				    //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'];
1818
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1795
+					$aprs_last_tx = time();
1796
+					$data = array();
1797
+					//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');
1808
+					//$data['datetime'] = date('Y-m-d H:i:s');
1809
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1810
+					$data['latitude'] = $line['latitude'];
1811
+					$data['longitude'] = $line['longitude'];
1812
+					//$data['verticalrate'] = $line[16];
1813
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1814
+					//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'];
1818
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1819 1819
 				    
1820
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1821
-				    //else echo 'No heading...'."\n";
1822
-				    //else $data['heading'] = 0;
1823
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1824
-				    //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;
1829
-    				    $data['id_source'] = $id_source;
1830
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1831
-				    else $data['format_source'] = 'aprs';
1832
-				    $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'];
1836
-				    $currentdate = date('Y-m-d H:i:s');
1837
-				    $aprsdate = strtotime($data['datetime']);
1838
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1839
-				    // Accept data if time <= system time + 20s
1840
-				    //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
-				    if (
1820
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1821
+					//else echo 'No heading...'."\n";
1822
+					//else $data['heading'] = 0;
1823
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1824
+					//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;
1829
+						$data['id_source'] = $id_source;
1830
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1831
+					else $data['format_source'] = 'aprs';
1832
+					$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'];
1836
+					$currentdate = date('Y-m-d H:i:s');
1837
+					$aprsdate = strtotime($data['datetime']);
1838
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1839
+					// Accept data if time <= system time + 20s
1840
+					//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
+					if (
1842 1842
 					($data['source_type'] === 'modes') || 
1843 1843
 					isset($line['stealth']) && 
1844 1844
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1845 1845
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1846 1846
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1847 1847
 					$send = $SI->add($data);
1848
-				    } elseif ($data['source_type'] === 'ais') {
1848
+					} elseif ($data['source_type'] === 'ais') {
1849 1849
 					$data['type'] = '';
1850 1850
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1851
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1851
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1852 1852
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1853
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1854
-					    //$line['symbol'] === 'Balloon' ||
1855
-					    $line['symbol'] === 'Glider' || 
1856
-					    $line['symbol'] === 'No. Plane' || 
1857
-					    $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';
1860
-					    $send = $SI->add($data);
1861
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1862
-					    $line['symbol'] === 'Yacht (Sail)' || 
1863
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1864
-					    $send = $MI->add($data);
1865
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1866
-					    $line['symbol'] === 'Car' || 
1867
-					    $line['symbol'] === 'Ambulance' || 
1868
-					    $line['symbol'] === 'Van' || 
1869
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1870
-					    $line['symbol'] === 'Motorcycle' || 
1871
-					    $line['symbol'] === 'Tractor' || 
1872
-					    $line['symbol'] === 'Police' || 
1873
-					    $line['symbol'] === 'Bike' || 
1874
-					    $line['symbol'] === 'Jogger' || 
1875
-					    $line['symbol'] === 'Horse' || 
1876
-					    $line['symbol'] === 'Bus' || 
1877
-					    $line['symbol'] === 'Jeep' || 
1878
-					    $line['symbol'] === 'Recreational Vehicle' || 
1879
-					    $line['symbol'] === 'Yacht (Sail)' || 
1880
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1881
-					    $line['symbol'] === 'Firetruck' || 
1882
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1883
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1884
-					    $line['symbol'] === 'SUV' ||
1885
-					    $line['symbol'] === 'Snowmobile' ||
1886
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1887
-				    //} 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') {
1853
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1854
+						//$line['symbol'] === 'Balloon' ||
1855
+						$line['symbol'] === 'Glider' || 
1856
+						$line['symbol'] === 'No. Plane' || 
1857
+						$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';
1860
+						$send = $SI->add($data);
1861
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1862
+						$line['symbol'] === 'Yacht (Sail)' || 
1863
+						$line['symbol'] === 'Ship (Power Boat)')) {
1864
+						$send = $MI->add($data);
1865
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1866
+						$line['symbol'] === 'Car' || 
1867
+						$line['symbol'] === 'Ambulance' || 
1868
+						$line['symbol'] === 'Van' || 
1869
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1870
+						$line['symbol'] === 'Motorcycle' || 
1871
+						$line['symbol'] === 'Tractor' || 
1872
+						$line['symbol'] === 'Police' || 
1873
+						$line['symbol'] === 'Bike' || 
1874
+						$line['symbol'] === 'Jogger' || 
1875
+						$line['symbol'] === 'Horse' || 
1876
+						$line['symbol'] === 'Bus' || 
1877
+						$line['symbol'] === 'Jeep' || 
1878
+						$line['symbol'] === 'Recreational Vehicle' || 
1879
+						$line['symbol'] === 'Yacht (Sail)' || 
1880
+						$line['symbol'] === 'Ship (Power Boat)' || 
1881
+						$line['symbol'] === 'Firetruck' || 
1882
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1883
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1884
+						$line['symbol'] === 'SUV' ||
1885
+						$line['symbol'] === 'Snowmobile' ||
1886
+						$line['symbol'] === 'Mobile Satellite Station')) {
1887
+					//} 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 1888
 				//    } 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 1889
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1890 1890
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1891
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1891
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1892 1892
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1893 1893
 					$Source->deleteOldLocationByType('gs');
1894 1894
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 					} else {
1897 1897
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1898 1898
 					}
1899
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1899
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1900 1900
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1901 1901
 					if ($globalDebug) echo '# Weather Station added'."\n";
1902 1902
 					$Source->deleteOldLocationByType('wx');
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
 					} else {
1907 1907
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1908 1908
 					}
1909
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1909
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
1910 1910
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1911 1911
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1912 1912
 					$Source->deleteOldLocationByType('lightning');
@@ -1915,11 +1915,11 @@  discard block
 block discarded – undo
1915 1915
 					} else {
1916 1916
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1917 1917
 					}
1918
-				    } elseif ($globalDebug) {
1919
-				    	echo '/!\ Not added: '.$buffer."\n";
1920
-				    	print_r($line);
1921
-				    }
1922
-				    unset($data);
1918
+					} elseif ($globalDebug) {
1919
+						echo '/!\ Not added: '.$buffer."\n";
1920
+						print_r($line);
1921
+					}
1922
+					unset($data);
1923 1923
 				}
1924 1924
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1925 1925
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1938,13 +1938,13 @@  discard block
 block discarded – undo
1938 1938
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1939 1939
 					$globalSources[$nb]['last_weather_clean'] = time();
1940 1940
 				}
1941
-			    }
1941
+				}
1942 1942
 			} else {
1943
-			    $line = explode(',', $buffer);
1944
-			    //print_r($line);
1945
-    			    if (count($line) > 20) {
1946
-    			    	$data['hex'] = $line[4];
1947
-    				/*
1943
+				$line = explode(',', $buffer);
1944
+				//print_r($line);
1945
+					if (count($line) > 20) {
1946
+						$data['hex'] = $line[4];
1947
+					/*
1948 1948
     				$data['datetime'] = $line[6].' '.$line[7];
1949 1949
     					date_default_timezone_set($globalTimezone);
1950 1950
     					$datetime = new DateTime($data['datetime']);
@@ -1952,31 +1952,31 @@  discard block
 block discarded – undo
1952 1952
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1953 1953
     					date_default_timezone_set('UTC');
1954 1954
     				*/
1955
-    				// Force datetime to current UTC datetime
1956
-    				date_default_timezone_set('UTC');
1957
-    				$data['datetime'] = date('Y-m-d H:i:s');
1958
-    				$data['ident'] = trim($line[10]);
1959
-    				$data['latitude'] = $line[14];
1960
-    				$data['longitude'] = $line[15];
1961
-    				$data['verticalrate'] = $line[16];
1962
-    				$data['emergency'] = $line[20];
1963
-    				$data['speed'] = $line[12];
1964
-    				$data['squawk'] = $line[17];
1965
-    				$data['altitude'] = $line[11];
1966
-    				$data['heading'] = $line[13];
1967
-    				$data['ground'] = $line[21];
1968
-    				$data['emergency'] = $line[19];
1969
-    				$data['format_source'] = 'sbs';
1955
+					// Force datetime to current UTC datetime
1956
+					date_default_timezone_set('UTC');
1957
+					$data['datetime'] = date('Y-m-d H:i:s');
1958
+					$data['ident'] = trim($line[10]);
1959
+					$data['latitude'] = $line[14];
1960
+					$data['longitude'] = $line[15];
1961
+					$data['verticalrate'] = $line[16];
1962
+					$data['emergency'] = $line[20];
1963
+					$data['speed'] = $line[12];
1964
+					$data['squawk'] = $line[17];
1965
+					$data['altitude'] = $line[11];
1966
+					$data['heading'] = $line[13];
1967
+					$data['ground'] = $line[21];
1968
+					$data['emergency'] = $line[19];
1969
+					$data['format_source'] = 'sbs';
1970 1970
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1971 1971
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
1972
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1972
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1973 1973
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1974
-    				$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;
1977
-    				unset($data);
1978
-    			    } else $error = true;
1979
-			    if ($error) {
1974
+					$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;
1977
+					unset($data);
1978
+					} else $error = true;
1979
+				if ($error) {
1980 1980
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
1981 1981
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1982 1982
 				} else {
@@ -1992,13 +1992,13 @@  discard block
 block discarded – undo
1992 1992
 					connect_all($sourceer);
1993 1993
 					$sourceer = array();
1994 1994
 				}
1995
-			    }
1995
+				}
1996 1996
 			}
1997 1997
 			// Sleep for xxx microseconds
1998 1998
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1999
-		    } else {
1999
+			} else {
2000 2000
 			if ($format === 'flightgearmp') {
2001
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2001
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2002 2002
 				//@socket_close($r);
2003 2003
 				sleep($globalMinFetch);
2004 2004
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2007,9 +2007,9 @@  discard block
 block discarded – undo
2007 2007
 				break;
2008 2008
 				
2009 2009
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2010
-			    if (isset($tt[$format])) $tt[$format]++;
2011
-			    else $tt[$format] = 0;
2012
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2010
+				if (isset($tt[$format])) $tt[$format]++;
2011
+				else $tt[$format] = 0;
2012
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2013 2013
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2014 2014
 				//@socket_close($r);
2015 2015
 				sleep(2);
@@ -2020,24 +2020,24 @@  discard block
 block discarded – undo
2020 2020
 				//connect_all($globalSources);
2021 2021
 				$tt[$format]=0;
2022 2022
 				break;
2023
-			    } 
2024
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2023
+				} 
2024
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2025
+			}
2025 2026
 			}
2026
-		    }
2027 2027
 		}
2028
-	    } else {
2028
+		} else {
2029 2029
 		$error = socket_strerror(socket_last_error());
2030 2030
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2031 2031
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2032 2032
 			if (isset($globalDebug)) echo "Restarting...\n";
2033 2033
 			// Restart the script if possible
2034 2034
 			if (is_array($sockets)) {
2035
-			    if ($globalDebug) echo "Shutdown all sockets...";
2035
+				if ($globalDebug) echo "Shutdown all sockets...";
2036 2036
 			    
2037
-			    foreach ($sockets as $sock) {
2037
+				foreach ($sockets as $sock) {
2038 2038
 				@socket_shutdown($sock,2);
2039 2039
 				@socket_close($sock);
2040
-			    }
2040
+				}
2041 2041
 			    
2042 2042
 			}
2043 2043
 			if ($globalDebug) echo "Waiting...";
@@ -2052,15 +2052,15 @@  discard block
 block discarded – undo
2052 2052
 			if ($globalDebug) echo "Restart all connections...";
2053 2053
 			connect_all($globalSources);
2054 2054
 		}
2055
-	    }
2055
+		}
2056 2056
 	}
2057 2057
 	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();
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();
2062
+	}
2062 2063
 	}
2063
-    }
2064 2064
 }
2065 2065
 
2066 2066
 ?>
Please login to merge, or discard this 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 3 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -11,27 +11,27 @@  discard block
 block discarded – undo
11 11
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
12 12
 $schema = new Connection();
13 13
 if ($schema->latest() === false) {
14
-    echo "You MUST update to latest schema. Run install/index.php";
15
-    exit();
14
+	echo "You MUST update to latest schema. Run install/index.php";
15
+	exit();
16 16
 }
17 17
 if ($globalInstalled === FALSE) {
18
-    echo "Install script MUST be run before this script. Use you web browser to run install/index.php";
19
-    die();
18
+	echo "Install script MUST be run before this script. Use you web browser to run install/index.php";
19
+	die();
20 20
 }
21 21
 if (!isset($globalACARSHost) || !isset($globalACARSPort) || $globalACARSHost == '' || $globalACARSPort == '') {
22
-    echo 'You MUST define $globalACARSHost and $globalACARSPort in require/settings.php';
23
-    die();
22
+	echo 'You MUST define $globalACARSHost and $globalACARSPort in require/settings.php';
23
+	die();
24 24
 }
25 25
 
26 26
 $ACARS=new ACARS(null,true);
27 27
 date_default_timezone_set('UTC');
28 28
 // signal handler - playing nice with sockets and dump1090
29 29
 pcntl_signal(SIGINT,  function($signo) {
30
-    global $sock;
31
-    echo "\n\nctrl-c or kill signal received. Tidying up ... ";
32
-    socket_shutdown($sock, 0);
33
-    socket_close($sock);
34
-    die("Bye!\n");
30
+	global $sock;
31
+	echo "\n\nctrl-c or kill signal received. Tidying up ... ";
32
+	socket_shutdown($sock, 0);
33
+	socket_close($sock);
34
+	die("Bye!\n");
35 35
 });
36 36
 pcntl_signal_dispatch();
37 37
 
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
 // Bind the source address
45 45
 if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) )
46 46
 {
47
-    $errorcode = socket_last_error();
48
-    $errormsg = socket_strerror($errorcode);
47
+	$errorcode = socket_last_error();
48
+	$errormsg = socket_strerror($errorcode);
49 49
      
50
-    die("Could not bind socket : [$errorcode] $errormsg \n");
50
+	die("Could not bind socket : [$errorcode] $errormsg \n");
51 51
 }
52 52
 
53 53
 if ($globalDebug) echo "LISTEN UDP MODE \n\n";
54 54
 while(1) {
55
-    $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port);
55
+	$r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port);
56 56
 
57
-    // lets play nice and handle signals such as ctrl-c/kill properly
58
-    pcntl_signal_dispatch();
59
-    $dataFound = false;
60
-    //  (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";
62
-    $ACARS->add(trim($buffer));
63
-    socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
64
-    $ACARS->deleteLiveAcarsData();
57
+	// lets play nice and handle signals such as ctrl-c/kill properly
58
+	pcntl_signal_dispatch();
59
+	$dataFound = false;
60
+	//  (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";
62
+	$ACARS->add(trim($buffer));
63
+	socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
64
+	$ACARS->deleteLiveAcarsData();
65 65
 }
66 66
 pcntl_exec($_,$argv);
67 67
 ?>
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@  discard block
 block discarded – undo
23 23
     die();
24 24
 }
25 25
 
26
-$ACARS=new ACARS(null,true);
26
+$ACARS = new ACARS(null, true);
27 27
 date_default_timezone_set('UTC');
28 28
 // signal handler - playing nice with sockets and dump1090
29
-pcntl_signal(SIGINT,  function($signo) {
29
+pcntl_signal(SIGINT, function($signo) {
30 30
     global $sock;
31 31
     echo "\n\nctrl-c or kill signal received. Tidying up ... ";
32 32
     socket_shutdown($sock, 0);
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 $sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Unable to create socket\n");
43 43
 
44 44
 // Bind the source address
45
-if( !socket_bind($sock, $globalACARSHost , $globalACARSPort) )
45
+if (!socket_bind($sock, $globalACARSHost, $globalACARSPort))
46 46
 {
47 47
     $errorcode = socket_last_error();
48 48
     $errormsg = socket_strerror($errorcode);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 }
52 52
 
53 53
 if ($globalDebug) echo "LISTEN UDP MODE \n\n";
54
-while(1) {
54
+while (1) {
55 55
     $r = socket_recvfrom($sock, $buffer, 512, 0, $remote_ip, $remote_port);
56 56
 
57 57
     // lets play nice and handle signals such as ctrl-c/kill properly
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
     //  (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 61
     if ($globalDebug) echo $buffer."\n";
62 62
     $ACARS->add(trim($buffer));
63
-    socket_sendto($sock, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
63
+    socket_sendto($sock, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
64 64
     $ACARS->deleteLiveAcarsData();
65 65
 }
66
-pcntl_exec($_,$argv);
66
+pcntl_exec($_, $argv);
67 67
 ?>
Please login to merge, or discard this 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.
scripts/update_db.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@
 block discarded – undo
12 12
 }
13 13
 // Check if script is not already running... (dirty)
14 14
 if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN' && (!isset($globalDisableUpdateCheck) || $globalDisableUpdateCheck === FALSE)) {
15
-	if(function_exists('exec')) {
15
+	if (function_exists('exec')) {
16 16
 		exec("ps ux", $output, $result);
17 17
 		$j = 0;
18
-		foreach ($output as $line) if(strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
18
+		foreach ($output as $line) if (strpos($line, dirname(__FILE__)."/update_db.php") && !strpos($line, "sh ") && !strpos($line, "sudo ")) $j++;
19 19
 		if ($j > 1) {
20 20
 			echo "Script is already runnning...";
21 21
 			die();
Please login to merge, or discard this patch.