Completed
Push — master ( 7332ae...d8eaa0 )
by Yannick
177:55 queued 153:21
created
date-statistics-arrival-airport.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,13 +3,13 @@  discard block
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 $Spotter = new Spotter();
6
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
7
-$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING);
8
-$spotter_array = $Spotter->getSpotterDataByDate($date,"0,1", $sort);
6
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
7
+$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING);
8
+$spotter_array = $Spotter->getSpotterDataByDate($date, "0,1", $sort);
9 9
 
10 10
 if (!empty($spotter_array))
11 11
 {
12
-	$title = sprintf(_("Most Common Arrival Airports on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
12
+	$title = sprintf(_("Most Common Arrival Airports on %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601'])));
13 13
 
14 14
 	require_once('header.php');
15 15
 	print '<div class="select-item">';
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>';
28 28
 	print '<br />';  
29 29
 	print '<div class="info column">';
30
-	print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
30
+	print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>';
31 31
 	print '</div>';
32 32
 
33 33
 	include('date-sub-menu.php');
34 34
 	print '<div class="column">';
35 35
 	print '<h2>'._("Most Common Arrival Airports").'</h2>';
36
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
36
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights on <strong>%s</strong>."), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>';
37 37
 	$airport_airport_array = $Spotter->countAllArrivalAirportsByDate($date);
38 38
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
39 39
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	print '<script>';
43 43
 	print 'var series = [';
44 44
 	$airport_data = '';
45
-	foreach($airport_airport_array as $airport_item)
45
+	foreach ($airport_airport_array as $airport_item)
46 46
 	{
47 47
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
48 48
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	print '</thead>';
98 98
 	print '<tbody>';
99 99
 	$i = 1;
100
-	foreach($airport_airport_array as $airport_item)
100
+	foreach ($airport_airport_array as $airport_item)
101 101
 	{
102 102
 		print '<tr>';
103 103
 		print '<td><strong>'.$i.'</strong></td>';
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	$title = _("Unknown Date");
123 123
 	require_once('header.php');
124 124
 	print '<h1>'._("Error").'</h1>';
125
-	print '<p>'._("Sorry, this date does not exist in this database. :(");'</p>';
125
+	print '<p>'._("Sorry, this date does not exist in this database. :("); '</p>';
126 126
 }
127 127
 
128 128
 require_once('footer.php');
Please login to merge, or discard this patch.
install/index.php 3 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
 				</tr>
318 318
 				<!--
319 319
 		<?php
320
-		    require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
-		    $Connection = new Connection();
320
+			require_once(dirname(__FILE__).'/../require/class.Connection.php');
321
+			$Connection = new Connection();
322 322
 		?>
323 323
 				-->
324 324
 		<?php
325
-		    if ($Connection->db != NULL) {
325
+			if ($Connection->db != NULL) {
326 326
 			if ($Connection->tableExists('source_location')) {
327
-			    require_once(dirname(__FILE__).'/../require/class.Source.php');
328
-			    $Source = new Source();
329
-			    //$alllocations = $Source->getAllLocationInfo();
330
-			    $alllocations = $Source->getLocationInfobyType('');
331
-			    foreach ($alllocations as $location) {
327
+				require_once(dirname(__FILE__).'/../require/class.Source.php');
328
+				$Source = new Source();
329
+				//$alllocations = $Source->getAllLocationInfo();
330
+				$alllocations = $Source->getLocationInfobyType('');
331
+				foreach ($alllocations as $location) {
332 332
 		?>
333 333
 				<tr>
334 334
 	    				<input type="hidden" name="source_id[]" value="<?php print $location['id']; ?>" />
@@ -342,9 +342,9 @@  discard block
 block discarded – undo
342 342
 				</tr>
343 343
 		
344 344
 		<?php
345
-			    }
345
+				}
346
+			}
346 347
 			}
347
-		    }
348 348
 		?>
349 349
 
350 350
 				<tr>
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 ?>
453 453
 							<tr>
454 454
 								<?php
455
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
455
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
456 456
 								?>
457 457
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
458 458
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
459 459
 								<?php
460
-								    } else {
460
+									} else {
461 461
 									$hostport = explode(':',$source['host']);
462 462
 									if (isset($hostport[1])) {
463 463
 										$host = $hostport[0];
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
471 471
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
472 472
 								<?php
473
-								    }
473
+									}
474 474
 								?>
475 475
 								<td>
476 476
 									<select name="format[]" id="format">
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 			<br />
881 881
 			<p>
882 882
 			<?php 
883
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
883
+				if (extension_loaded('gd') && function_exists('gd_info')) {
884 884
 			?>
885 885
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
886 886
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -890,11 +890,11 @@  discard block
 block discarded – undo
890 890
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
891 891
 			<?php
892 892
 				}
893
-			    } else {
893
+				} else {
894 894
 			?>
895 895
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
896 896
 			<?php
897
-			    }
897
+				}
898 898
 			?>
899 899
 			</p>
900 900
 			<br />
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 	</p>
919 919
 <?php
920 920
 	require('../footer.php');
921
-        exit;
921
+		exit;
922 922
 }
923 923
 // '	
924 924
 $settings = array();
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	
1010 1010
 	$sources = array();
1011 1011
 	foreach ($source_name as $keys => $name) {
1012
-	    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]);
1013
-	    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]);
1012
+		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]);
1013
+		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]);
1014 1014
 	}
1015 1015
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1016 1016
 
@@ -1392,14 +1392,14 @@  discard block
 block discarded – undo
1392 1392
 
1393 1393
 	// Set some defaults values...
1394 1394
 	if (!isset($globalAircraftImageSources)) {
1395
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1396
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1395
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1396
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1397 1397
 	}
1398 1398
 
1399 1399
 	if (!isset($globalSchedulesSources)) {
1400
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1401
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1402
-    	}
1400
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1401
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1402
+		}
1403 1403
 
1404 1404
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1405 1405
 
@@ -1446,21 +1446,21 @@  discard block
 block discarded – undo
1446 1446
 	$popi = false;
1447 1447
 	$popw = false;
1448 1448
 	foreach ($_SESSION['done'] as $done) {
1449
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1450
-	    if ($done == 'Create database') $pop = true;
1451
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1452
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1453
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1449
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1450
+		if ($done == 'Create database') $pop = true;
1451
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1452
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1453
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1454 1454
 	}
1455 1455
 	if ($pop) {
1456
-	    sleep(5);
1457
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1456
+		sleep(5);
1457
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1458 1458
 	} else if ($popi) {
1459
-	    sleep(5);
1460
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1459
+		sleep(5);
1460
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1461 1461
 	} else if ($popw) {
1462
-	    sleep(5);
1463
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1462
+		sleep(5);
1463
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1464 1464
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1465 1465
 	print '</div></ul>';
1466 1466
 	print '<div id="error"></div>';
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	unset($_COOKIE['install']);
1524 1524
 	print '<div class="info column"><ul>';
1525 1525
 	foreach ($_SESSION['done'] as $done) {
1526
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1526
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1527 1527
 	}
1528 1528
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1529 1529
 	print '</ul></div>';
Please login to merge, or discard this patch.
Spacing   +246 added lines, -246 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 require_once(dirname(__FILE__).'/class.create_db.php');
11 11
 require_once(dirname(__FILE__).'/class.update_schema.php');
12 12
 require_once(dirname(__FILE__).'/class.settings.php');
13
-$title="Install";
13
+$title = "Install";
14 14
 require(dirname(__FILE__).'/../require/settings.php');
15 15
 require(dirname(__FILE__).'/header.php');
16 16
 
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 if (!extension_loaded('curl')) {
70 70
 	$error[] = "Curl is not loaded.";
71 71
 }
72
-if(function_exists('apache_get_modules') ){
73
-	if(!in_array('mod_rewrite',apache_get_modules())) {
72
+if (function_exists('apache_get_modules')) {
73
+	if (!in_array('mod_rewrite', apache_get_modules())) {
74 74
 		$error[] = "mod_rewrite is not available.";
75 75
 	}
76 76
 /*
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 print '<div class="info column"><p><strong>If you use MySQL or MariaDB, check that <i>max_allowed_packet</i> >= 8M, else import of some table can fail.</strong></p></div>';
87 87
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
88 88
 	if (function_exists('get_headers')) {
89
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
90
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
89
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
90
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
91 91
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
92 92
 		}
93 93
 	}
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
 ?>
455 455
 							<tr>
456 456
 								<?php
457
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
457
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
458 458
 								?>
459 459
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
460 460
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
461 461
 								<?php
462 462
 								    } else {
463
-									$hostport = explode(':',$source['host']);
463
+									$hostport = explode(':', $source['host']);
464 464
 									if (isset($hostport[1])) {
465 465
 										$host = $hostport[0];
466 466
 										$port = $hostport[1];
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 									<select name="timezones[]" id="timezones">
508 508
 								<?php
509 509
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
510
-									foreach($timezonelist as $timezones){
510
+									foreach ($timezonelist as $timezones) {
511 511
 										if (isset($source['timezone']) && $source['timezone'] == $timezones) {
512 512
 											print '<option selected>'.$timezones.'</option>';
513 513
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 									<select name="timezones[]" id="timezones">
560 560
 								<?php
561 561
 									$timezonelist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
562
-									foreach($timezonelist as $timezones){
562
+									foreach ($timezonelist as $timezones) {
563 563
 										if ($timezones == 'UTC') {
564 564
 											print '<option selected>'.$timezones.'</option>';
565 565
 										} else print '<option>'.$timezones.'</option>';
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 			<br />
877 877
 			<p>
878 878
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
879
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
879
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
880 880
 			</p>
881 881
 			<br />
882 882
 			<p>
@@ -932,14 +932,14 @@  discard block
 block discarded – undo
932 932
 $error = '';
933 933
 
934 934
 if (isset($_POST['dbtype'])) {
935
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
936
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
937
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
938
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
939
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
940
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
941
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
942
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
935
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
936
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
937
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
938
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
939
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
940
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
941
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
942
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
943 943
 
944 944
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
945 945
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -959,49 +959,49 @@  discard block
 block discarded – undo
959 959
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
960 960
 	*/
961 961
 	
962
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
962
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
963 963
 
964
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
965
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
966
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
967
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
968
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
964
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
965
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
966
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
967
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
968
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
969 969
 
970
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
971
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
972
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
973
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
974
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
975
-	$openweathermapkey = filter_input(INPUT_POST,'openweathermapkey',FILTER_SANITIZE_STRING);
976
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
977
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
978
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
979
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey,'globalOpenWeatherMapKey' => $openweathermapkey));
970
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
971
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
972
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
973
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
974
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
975
+	$openweathermapkey = filter_input(INPUT_POST, 'openweathermapkey', FILTER_SANITIZE_STRING);
976
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
977
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
978
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
979
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey, 'globalOpenWeatherMapKey' => $openweathermapkey));
980 980
 	
981
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
982
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
983
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
984
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
985
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
986
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
981
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
982
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
983
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
984
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
985
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
986
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
987 987
 
988
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
989
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
988
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
989
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
990 990
 
991
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
992
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
993
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
991
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
992
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
993
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
994 994
 
995
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
995
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
996 996
 	if ($acars == 'acars') {
997
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
997
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
998 998
 	} else {
999
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
999
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
1000 1000
 	}
1001 1001
 
1002
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
1003
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
1004
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
1002
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
1003
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
1004
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
1005 1005
 	
1006 1006
 	$source_name = $_POST['source_name'];
1007 1007
 	$source_latitude = $_POST['source_latitude'];
@@ -1015,8 +1015,8 @@  discard block
 block discarded – undo
1015 1015
 	
1016 1016
 	$sources = array();
1017 1017
 	foreach ($source_name as $keys => $name) {
1018
-	    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]);
1019
-	    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]);
1018
+	    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]);
1019
+	    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]);
1020 1020
 	}
1021 1021
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1022 1022
 
@@ -1029,27 +1029,27 @@  discard block
 block discarded – undo
1029 1029
 	$sbsurl = $_POST['sbsurl'];
1030 1030
 	*/
1031 1031
 
1032
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
1033
-	$globalva = filter_input(INPUT_POST,'globalva',FILTER_SANITIZE_STRING);
1034
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
1035
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
1036
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
1037
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
1038
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
1039
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1032
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
1033
+	$globalva = filter_input(INPUT_POST, 'globalva', FILTER_SANITIZE_STRING);
1034
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
1035
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
1036
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
1037
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
1038
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
1039
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
1040 1040
 
1041
-	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1042
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1043
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1044
-	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1045
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1047
-	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1048
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1049
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1050
-	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1051
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1052
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1041
+	$globalaircraft = filter_input(INPUT_POST, 'globalaircraft', FILTER_SANITIZE_STRING);
1042
+	if ($globalaircraft == 'aircraft') $settings = array_merge($settings, array('globalAircraft' => 'TRUE'));
1043
+	else $settings = array_merge($settings, array('globalAircraft' => 'FALSE'));
1044
+	$globaltracker = filter_input(INPUT_POST, 'globaltracker', FILTER_SANITIZE_STRING);
1045
+	if ($globaltracker == 'tracker') $settings = array_merge($settings, array('globalTracker' => 'TRUE'));
1046
+	else $settings = array_merge($settings, array('globalTracker' => 'FALSE'));
1047
+	$globalmarine = filter_input(INPUT_POST, 'globalmarine', FILTER_SANITIZE_STRING);
1048
+	if ($globalmarine == 'marine') $settings = array_merge($settings, array('globalMarine' => 'TRUE'));
1049
+	else $settings = array_merge($settings, array('globalMarine' => 'FALSE'));
1050
+	$globalsatellite = filter_input(INPUT_POST, 'globalsatellite', FILTER_SANITIZE_STRING);
1051
+	if ($globalsatellite == 'satellite') $settings = array_merge($settings, array('globalSatellite' => 'TRUE'));
1052
+	else $settings = array_merge($settings, array('globalSatellite' => 'FALSE'));
1053 1053
 
1054 1054
 /*	
1055 1055
 	$globalSBS1Hosts = array();
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
 	}
1066 1066
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
1067 1067
 */
1068
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
1068
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
1069 1069
 	$host = $_POST['host'];
1070 1070
 	$port = $_POST['port'];
1071 1071
 	$name = $_POST['name'];
@@ -1082,104 +1082,104 @@  discard block
 block discarded – undo
1082 1082
 		else $cov = 'FALSE';
1083 1083
 		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1084 1084
 		else $arch = 'FALSE';
1085
-		if (strpos($format[$key],'_callback')) {
1086
-			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1085
+		if (strpos($format[$key], '_callback')) {
1086
+			$gSources[] = array('host' => $h, 'pass' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'TRUE');
1087 1087
 		} elseif ($h != '' || $name[$key] != '') {
1088
-			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1088
+			$gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov, 'noarchive' => $arch, 'timezone' => $timezones[$key], 'callback' => 'FALSE');
1089 1089
 		}
1090 1090
 		if ($format[$key] == 'airwhere') $forcepilots = true;
1091 1091
 	}
1092
-	$settings = array_merge($settings,array('globalSources' => $gSources));
1092
+	$settings = array_merge($settings, array('globalSources' => $gSources));
1093 1093
 
1094 1094
 /*
1095 1095
 	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
1096 1096
 	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
1097 1097
 */
1098
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
1099
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
1100
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
1098
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
1099
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
1100
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
1101 1101
 
1102
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
1103
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
1102
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
1103
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
1104 1104
 
1105
-	$customcss = filter_input(INPUT_POST,'customcss',FILTER_SANITIZE_STRING);
1106
-	$settings = array_merge($settings,array('globalCustomCSS' => $customcss));
1105
+	$customcss = filter_input(INPUT_POST, 'customcss', FILTER_SANITIZE_STRING);
1106
+	$settings = array_merge($settings, array('globalCustomCSS' => $customcss));
1107 1107
 
1108
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
1109
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
1110
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
1111
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
1108
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
1109
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
1110
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
1111
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
1112 1112
 
1113
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
1114
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
1115
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1113
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
1114
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
1115
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
1116 1116
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1117
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1118
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1117
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
1118
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
1119 1119
 
1120
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1121
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
1122
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
1123
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
1124
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
1125
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
1126
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
1127
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
1120
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
1121
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
1122
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
1123
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
1124
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
1125
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
1126
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
1127
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
1128 1128
 
1129
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
1130
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
1129
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
1130
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
1131 1131
 
1132
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
1133
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
1132
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
1133
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
1134 1134
 	
1135
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
1135
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
1136 1136
 	if ($archiveyear == "archiveyear") {
1137
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
1137
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
1138 1138
 	} else {
1139
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
1139
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
1140 1140
 	}
1141
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
1142
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
1143
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
1144
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1141
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
1142
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
1143
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
1144
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
1145 1145
 
1146
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
1147
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
1148
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
1149
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
1146
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
1147
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
1148
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
1149
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
1150 1150
 
1151
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
1152
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
1153
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
1151
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
1152
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
1153
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
1154 1154
 
1155 1155
 	// Create in settings.php keys not yet configurable if not already here
1156 1156
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1157
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1157
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
1158 1158
 
1159
-	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1159
+	$resetyearstats = filter_input(INPUT_POST, 'resetyearstats', FILTER_SANITIZE_STRING);
1160 1160
 	if ($resetyearstats == 'resetyearstats') {
1161
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'TRUE'));
1161
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'TRUE'));
1162 1162
 	} else {
1163
-		$settings = array_merge($settings,array('globalDeleteLastYearStats' => 'FALSE'));
1163
+		$settings = array_merge($settings, array('globalDeleteLastYearStats' => 'FALSE'));
1164 1164
 	}
1165 1165
 
1166
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
1166
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
1167 1167
 	if ($archive == 'archive') {
1168
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
1168
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
1169 1169
 	} else {
1170
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
1170
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
1171 1171
 	}
1172
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
1172
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
1173 1173
 	if ($daemon == 'daemon') {
1174
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
1174
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
1175 1175
 	} else {
1176
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
1176
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
1177 1177
 	}
1178
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
1178
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
1179 1179
 	if ($schedules == 'schedules') {
1180
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
1180
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
1181 1181
 	} else {
1182
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
1182
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
1183 1183
 	}
1184 1184
 
1185 1185
 /*
@@ -1190,227 +1190,227 @@  discard block
 block discarded – undo
1190 1190
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1191 1191
 	}
1192 1192
 */
1193
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1194
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1196
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1197
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1193
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1194
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1195
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1196
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1197
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1198 1198
 	$va = false;
1199 1199
 	if ($globalivao == 'ivao') {
1200
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1200
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1201 1201
 		$va = true;
1202
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1202
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1203 1203
 	if ($globalvatsim == 'vatsim') {
1204
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1204
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1205 1205
 		$va = true;
1206
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1206
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1207 1207
 	if ($globalphpvms == 'phpvms') {
1208
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1208
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1209 1209
 		$va = true;
1210
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1210
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1211 1211
 	if ($globalvam == 'vam') {
1212
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1212
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1213 1213
 		$va = true;
1214
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1214
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1215 1215
 	if ($va) {
1216
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1217
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1216
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1217
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1218 1218
 	if ($globalva == 'va' || $va) {
1219
-		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1220
-		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1219
+		$settings = array_merge($settings, array('globalVA' => 'TRUE'));
1220
+		$settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1221 1221
 	} else {
1222
-		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1223
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1224
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1222
+		$settings = array_merge($settings, array('globalVA' => 'FALSE'));
1223
+		if ($forcepilots) $settings = array_merge($settings, array('globalUsePilot' => 'TRUE', 'globalUseOwner' => 'FALSE'));
1224
+		else $settings = array_merge($settings, array('globalUsePilot' => 'FALSE', 'globalUseOwner' => 'TRUE'));
1225 1225
 	}
1226 1226
 	
1227 1227
 	
1228 1228
 
1229
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1229
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1230 1230
 	if ($notam == 'notam') {
1231
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1231
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1232 1232
 	} else {
1233
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1233
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1234 1234
 	}
1235
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1235
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1236 1236
 	if ($owner == 'owner') {
1237
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1237
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1238 1238
 	} else {
1239
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1239
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1240 1240
 	}
1241
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1241
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1242 1242
 	if ($map3d == 'map3d') {
1243
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1243
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1244 1244
 	} else {
1245
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1245
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1246 1246
 	}
1247
-	$crash = filter_input(INPUT_POST,'crash',FILTER_SANITIZE_STRING);
1247
+	$crash = filter_input(INPUT_POST, 'crash', FILTER_SANITIZE_STRING);
1248 1248
 	if ($crash == 'crash') {
1249
-		$settings = array_merge($settings,array('globalAccidents' => 'TRUE'));
1249
+		$settings = array_merge($settings, array('globalAccidents' => 'TRUE'));
1250 1250
 	} else {
1251
-		$settings = array_merge($settings,array('globalAccidents' => 'FALSE'));
1251
+		$settings = array_merge($settings, array('globalAccidents' => 'FALSE'));
1252 1252
 	}
1253
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1253
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1254 1254
 	if ($mapsatellites == 'mapsatellites') {
1255
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1255
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1256 1256
 	} else {
1257
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1257
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1258 1258
 	}
1259
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1259
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1260 1260
 	if ($map3ddefault == 'map3ddefault') {
1261
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1261
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1262 1262
 	} else {
1263
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1263
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1264 1264
 	}
1265
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1265
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1266 1266
 	if ($translate == 'translate') {
1267
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1267
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1268 1268
 	} else {
1269
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1269
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1270 1270
 	}
1271
-	$realairlines = filter_input(INPUT_POST,'realairlines',FILTER_SANITIZE_STRING);
1271
+	$realairlines = filter_input(INPUT_POST, 'realairlines', FILTER_SANITIZE_STRING);
1272 1272
 	if ($realairlines == 'realairlines') {
1273
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'TRUE'));
1273
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'TRUE'));
1274 1274
 	} else {
1275
-		$settings = array_merge($settings,array('globalUseRealAirlines' => 'FALSE'));
1275
+		$settings = array_merge($settings, array('globalUseRealAirlines' => 'FALSE'));
1276 1276
 	}
1277
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1277
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1278 1278
 	if ($estimation == 'estimation') {
1279
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1279
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1280 1280
 	} else {
1281
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1281
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1282 1282
 	}
1283
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1283
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1284 1284
 	if ($metar == 'metar') {
1285
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1285
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1286 1286
 	} else {
1287
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1287
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1288 1288
 	}
1289
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1289
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1290 1290
 	if ($metarcycle == 'metarcycle') {
1291
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1291
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1292 1292
 	} else {
1293
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1293
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1294 1294
 	}
1295
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1295
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1296 1296
 	if ($fork == 'fork') {
1297
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1297
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1298 1298
 	} else {
1299
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1299
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1300 1300
 	}
1301 1301
 
1302
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1302
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1303 1303
 	if ($colormap == 'colormap') {
1304
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1304
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1305 1305
 	} else {
1306
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1306
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1307 1307
 	}
1308 1308
 	
1309 1309
 	if (isset($_POST['aircrafticoncolor'])) {
1310
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1311
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1310
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1311
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1312 1312
 	}
1313 1313
 
1314
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1315
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1314
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1315
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1316 1316
 
1317
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1318
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1319
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1320
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1321
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1322
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1317
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1318
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1319
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1320
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1321
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1322
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1323 1323
 
1324
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1324
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1325 1325
 	if ($mappopup == 'mappopup') {
1326
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1326
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1327 1327
 	} else {
1328
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1328
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1329 1329
 	}
1330
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1330
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1331 1331
 	if ($airportpopup == 'airportpopup') {
1332
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1332
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1333 1333
 	} else {
1334
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1334
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1335 1335
 	}
1336
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1336
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1337 1337
 	if ($maphistory == 'maphistory') {
1338
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1338
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1339 1339
 	} else {
1340
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1340
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1341 1341
 	}
1342
-	$maptooltip = filter_input(INPUT_POST,'maptooltip',FILTER_SANITIZE_STRING);
1342
+	$maptooltip = filter_input(INPUT_POST, 'maptooltip', FILTER_SANITIZE_STRING);
1343 1343
 	if ($maptooltip == 'maptooltip') {
1344
-		$settings = array_merge($settings,array('globalMapTooltip' => 'TRUE'));
1344
+		$settings = array_merge($settings, array('globalMapTooltip' => 'TRUE'));
1345 1345
 	} else {
1346
-		$settings = array_merge($settings,array('globalMapTooltip' => 'FALSE'));
1346
+		$settings = array_merge($settings, array('globalMapTooltip' => 'FALSE'));
1347 1347
 	}
1348
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1348
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1349 1349
 	if ($flightroute == 'flightroute') {
1350
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1350
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1351 1351
 	} else {
1352
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1352
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1353 1353
 	}
1354
-	$flightremainingroute = filter_input(INPUT_POST,'flightremainingroute',FILTER_SANITIZE_STRING);
1354
+	$flightremainingroute = filter_input(INPUT_POST, 'flightremainingroute', FILTER_SANITIZE_STRING);
1355 1355
 	if ($flightremainingroute == 'flightremainingroute') {
1356
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'TRUE'));
1356
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'TRUE'));
1357 1357
 	} else {
1358
-		$settings = array_merge($settings,array('globalMapRemainingRoute' => 'FALSE'));
1358
+		$settings = array_merge($settings, array('globalMapRemainingRoute' => 'FALSE'));
1359 1359
 	}
1360
-	$allflights = filter_input(INPUT_POST,'allflights',FILTER_SANITIZE_STRING);
1360
+	$allflights = filter_input(INPUT_POST, 'allflights', FILTER_SANITIZE_STRING);
1361 1361
 	if ($allflights == 'allflights') {
1362
-		$settings = array_merge($settings,array('globalAllFlights' => 'TRUE'));
1362
+		$settings = array_merge($settings, array('globalAllFlights' => 'TRUE'));
1363 1363
 	} else {
1364
-		$settings = array_merge($settings,array('globalAllFlights' => 'FALSE'));
1364
+		$settings = array_merge($settings, array('globalAllFlights' => 'FALSE'));
1365 1365
 	}
1366
-	$bbox = filter_input(INPUT_POST,'bbox',FILTER_SANITIZE_STRING);
1366
+	$bbox = filter_input(INPUT_POST, 'bbox', FILTER_SANITIZE_STRING);
1367 1367
 	if ($bbox == 'bbox') {
1368
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'TRUE'));
1368
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'TRUE'));
1369 1369
 	} else {
1370
-		$settings = array_merge($settings,array('globalMapUseBbox' => 'FALSE'));
1370
+		$settings = array_merge($settings, array('globalMapUseBbox' => 'FALSE'));
1371 1371
 	}
1372
-	$groundaltitude = filter_input(INPUT_POST,'groundaltitude',FILTER_SANITIZE_STRING);
1372
+	$groundaltitude = filter_input(INPUT_POST, 'groundaltitude', FILTER_SANITIZE_STRING);
1373 1373
 	if ($groundaltitude == 'groundaltitude') {
1374
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'TRUE'));
1374
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'TRUE'));
1375 1375
 	} else {
1376
-		$settings = array_merge($settings,array('globalGroundAltitude' => 'FALSE'));
1376
+		$settings = array_merge($settings, array('globalGroundAltitude' => 'FALSE'));
1377 1377
 	}
1378
-	$waypoints = filter_input(INPUT_POST,'waypoints',FILTER_SANITIZE_STRING);
1378
+	$waypoints = filter_input(INPUT_POST, 'waypoints', FILTER_SANITIZE_STRING);
1379 1379
 	if ($waypoints == 'waypoints') {
1380
-		$settings = array_merge($settings,array('globalWaypoints' => 'TRUE'));
1380
+		$settings = array_merge($settings, array('globalWaypoints' => 'TRUE'));
1381 1381
 	} else {
1382
-		$settings = array_merge($settings,array('globalWaypoints' => 'FALSE'));
1382
+		$settings = array_merge($settings, array('globalWaypoints' => 'FALSE'));
1383 1383
 	}
1384
-	$geoid = filter_input(INPUT_POST,'geoid',FILTER_SANITIZE_STRING);
1384
+	$geoid = filter_input(INPUT_POST, 'geoid', FILTER_SANITIZE_STRING);
1385 1385
 	if ($geoid == 'geoid') {
1386
-		$settings = array_merge($settings,array('globalGeoid' => 'TRUE'));
1386
+		$settings = array_merge($settings, array('globalGeoid' => 'TRUE'));
1387 1387
 	} else {
1388
-		$settings = array_merge($settings,array('globalGeoid' => 'FALSE'));
1388
+		$settings = array_merge($settings, array('globalGeoid' => 'FALSE'));
1389 1389
 	}
1390
-	$geoid_source = filter_input(INPUT_POST,'geoid_source',FILTER_SANITIZE_STRING);
1391
-	$settings = array_merge($settings,array('globalGeoidSource' => $geoid_source));
1390
+	$geoid_source = filter_input(INPUT_POST, 'geoid_source', FILTER_SANITIZE_STRING);
1391
+	$settings = array_merge($settings, array('globalGeoidSource' => $geoid_source));
1392 1392
 
1393
-	$noairlines = filter_input(INPUT_POST,'noairlines',FILTER_SANITIZE_STRING);
1393
+	$noairlines = filter_input(INPUT_POST, 'noairlines', FILTER_SANITIZE_STRING);
1394 1394
 	if ($noairlines == 'noairlines') {
1395
-		$settings = array_merge($settings,array('globalNoAirlines' => 'TRUE'));
1395
+		$settings = array_merge($settings, array('globalNoAirlines' => 'TRUE'));
1396 1396
 	} else {
1397
-		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1397
+		$settings = array_merge($settings, array('globalNoAirlines' => 'FALSE'));
1398 1398
 	}
1399 1399
 
1400
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1400
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1401 1401
 
1402 1402
 	// Set some defaults values...
1403 1403
 	if (!isset($globalAircraftImageSources)) {
1404
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1405
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1404
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1405
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1406 1406
 	}
1407 1407
 
1408 1408
 	if (!isset($globalSchedulesSources)) {
1409
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1410
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1409
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1410
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1411 1411
     	}
1412 1412
 
1413
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1413
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1414 1414
 
1415 1415
 	if ($error == '') settings::modify_settings($settings);
1416 1416
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +506 added lines, -136 removed lines patch added patch discarded remove patch
@@ -131,45 +131,72 @@  discard block
 block discarded – undo
131 131
 			</div>
132 132
 			<p>
133 133
 				<label for="dbhost">Database hostname</label>
134
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
134
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
135
+	print $globalDBhost;
136
+}
137
+?>" />
135 138
 			</p>
136 139
 			<p>
137 140
 				<label for="dbport">Database port</label>
138
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
141
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
142
+	print $globalDBport;
143
+}
144
+?>" />
139 145
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
140 146
 			</p>
141 147
 			<p>
142 148
 				<label for="dbname">Database name</label>
143
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
149
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
150
+	print $globalDBname;
151
+}
152
+?>" />
144 153
 			</p>
145 154
 			<p>
146 155
 				<label for="dbuser">Database user</label>
147
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
156
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
157
+	print $globalDBuser;
158
+}
159
+?>" />
148 160
 			</p>
149 161
 			<p>
150 162
 				<label for="dbuserpass">Database user password</label>
151
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
163
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
164
+	print $globalDBpass;
165
+}
166
+?>" />
152 167
 			</p>
153 168
 		</fieldset>
154 169
 		<fieldset id="site">
155 170
 			<legend>Site configuration</legend>
156 171
 			<p>
157 172
 				<label for="sitename">Site name</label>
158
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
173
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
174
+	print $globalName;
175
+}
176
+?>" />
159 177
 			</p>
160 178
 			<p>
161 179
 				<label for="siteurl">Site directory</label>
162
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
180
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
181
+	print $globalURL;
182
+}
183
+?>" />
163 184
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
164 185
 			</p>
165 186
 			<p>
166 187
 				<label for="timezone">Timezone</label>
167
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
188
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
189
+	print $globalTimezone;
190
+}
191
+?>" />
168 192
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
169 193
 			</p>
170 194
 			<p>
171 195
 				<label for="language">Language</label>
172
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
196
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
197
+	print $globalLanguage;
198
+}
199
+?>" />
173 200
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
174 201
 			</p>
175 202
 		</fieldset>
@@ -190,11 +217,17 @@  discard block
 block discarded – undo
190 217
 			<div id="mapbox_data">
191 218
 				<p>
192 219
 					<label for="mapboxid">Mapbox id</label>
193
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
220
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
221
+	print $globalMapboxId;
222
+}
223
+?>" />
194 224
 				</p>
195 225
 				<p>
196 226
 					<label for="mapboxtoken">Mapbox token</label>
197
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
227
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
228
+	print $globalMapboxToken;
229
+}
230
+?>" />
198 231
 				</p>
199 232
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
200 233
 			</div>
@@ -202,7 +235,10 @@  discard block
 block discarded – undo
202 235
 			<div id="google_data">
203 236
 				<p>
204 237
 					<label for="googlekey">Google API key</label>
205
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
238
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
239
+	print $globalGoogleAPIKey;
240
+}
241
+?>" />
206 242
 					<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>
207 243
 				</p>
208 244
 			</div>
@@ -210,7 +246,10 @@  discard block
 block discarded – undo
210 246
 			<div id="bing_data">
211 247
 				<p>
212 248
 					<label for="bingkey">Bing Map key</label>
213
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
249
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
250
+	print $globalBingMapKey;
251
+}
252
+?>" />
214 253
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
215 254
 				</p>
216 255
 			</div>
@@ -218,7 +257,10 @@  discard block
 block discarded – undo
218 257
 			<div id="mapquest_data">
219 258
 				<p>
220 259
 					<label for="mapquestkey">MapQuest key</label>
221
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
260
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
261
+	print $globalMapQuestKey;
262
+}
263
+?>" />
222 264
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
223 265
 				</p>
224 266
 			</div>
@@ -226,11 +268,17 @@  discard block
 block discarded – undo
226 268
 			<div id="here_data">
227 269
 				<p>
228 270
 					<label for="hereappid">Here App_Id</label>
229
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
271
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
272
+	print $globalHereappId;
273
+}
274
+?>" />
230 275
 				</p>
231 276
 				<p>
232 277
 					<label for="hereappcode">Here App_Code</label>
233
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
278
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
279
+	print $globalHereappCode;
280
+}
281
+?>" />
234 282
 				</p>
235 283
 				<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>
236 284
 			</div>
@@ -238,7 +286,10 @@  discard block
 block discarded – undo
238 286
 			<div id="openweathermap_data">
239 287
 				<p>
240 288
 					<label for="openweathermapkey">OpenWeatherMap key (weather layer)</label>
241
-					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) print $globalOpenWeatherMapKey; ?>" />
289
+					<input type="text" name="openweathermapkey" id="openweathermapkey" value="<?php if (isset($globalOpenWeatherMapKey)) {
290
+	print $globalOpenWeatherMapKey;
291
+}
292
+?>" />
242 293
 					<p class="help-block">Get a key <a href="https://openweathermap.org/">here</a></p>
243 294
 				</p>
244 295
 			</div>
@@ -248,42 +299,86 @@  discard block
 block discarded – undo
248 299
 			<legend>Coverage area</legend>
249 300
 			<p>
250 301
 				<label for="latitudemax">The maximum latitude (north)</label>
251
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
302
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
303
+	print $globalLatitudeMax;
304
+}
305
+?>" />
252 306
 			</p>
253 307
 			<p>
254 308
 				<label for="latitudemin">The minimum latitude (south)</label>
255
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
309
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
310
+	print $globalLatitudeMin;
311
+}
312
+?>" />
256 313
 			</p>
257 314
 			<p>
258 315
 				<label for="longitudemax">The maximum longitude (west)</label>
259
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
316
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
317
+	print $globalLongitudeMax;
318
+}
319
+?>" />
260 320
 			</p>
261 321
 			<p>
262 322
 				<label for="longitudemin">The minimum longitude (east)</label>
263
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
323
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
324
+	print $globalLongitudeMin;
325
+}
326
+?>" />
264 327
 			</p>
265 328
 			<p>
266 329
 				<label for="latitudecenter">The latitude center</label>
267
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
330
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
331
+	print $globalCenterLatitude;
332
+}
333
+?>" />
268 334
 			</p>
269 335
 			<p>
270 336
 				<label for="longitudecenter">The longitude center</label>
271
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
337
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
338
+	print $globalCenterLongitude;
339
+}
340
+?>" />
272 341
 			</p>
273 342
 			<p>
274 343
 				<label for="livezoom">Default Zoom on live map</label>
275
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
344
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
345
+	print $globalLiveZoom;
346
+} else {
347
+	print '9';
348
+}
349
+?>" />
276 350
 			</p>
277 351
 			<p>
278 352
 				<label for="squawk_country">Country for squawk usage</label>
279 353
 				<select name="squawk_country" id="squawk_country">
280
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
281
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
282
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
283
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
284
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
285
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
286
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
354
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
355
+	print ' selected ';
356
+}
357
+?>>UK</option>
358
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
359
+	print ' selected ';
360
+}
361
+?>>NZ</option>
362
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
363
+	print ' selected ';
364
+}
365
+?>>US</option>
366
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
367
+	print ' selected ';
368
+}
369
+?>>AU</option>
370
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
371
+	print ' selected ';
372
+}
373
+?>>NL</option>
374
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
375
+	print ' selected ';
376
+}
377
+?>>FR</option>
378
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
379
+	print ' selected ';
380
+}
381
+?>>TR</option>
287 382
 				</select>
288 383
 			</p>
289 384
 		</fieldset>
@@ -292,15 +387,24 @@  discard block
 block discarded – undo
292 387
 			<p><i>Only put in DB flights that are inside a circle</i></p>
293 388
 			<p>
294 389
 				<label for="latitude">Center latitude</label>
295
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
390
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
391
+	echo $globalDistanceIgnore['latitude'];
392
+}
393
+?>" />
296 394
 			</p>
297 395
 			<p>
298 396
 				<label for="longitude">Center longitude</label>
299
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
397
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
398
+	echo $globalDistanceIgnore['longitude'];
399
+}
400
+?>" />
300 401
 			</p>
301 402
 			<p>
302 403
 				<label for="Distance">Distance (in km)</label>
303
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
404
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
405
+	echo $globalDistanceIgnore['distance'];
406
+}
407
+?>" />
304 408
 			</p>
305 409
 		</fieldset>
306 410
 		<fieldset id="sourceloc">
@@ -411,11 +515,17 @@  discard block
 block discarded – undo
411 515
 			<div id="flightaware_data">
412 516
 				<p>
413 517
 					<label for="flightawareusername">FlightAware username</label>
414
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
518
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
519
+	print $globalFlightAwareUsername;
520
+}
521
+?>" />
415 522
 				</p>
416 523
 				<p>
417 524
 					<label for="flightawarepassword">FlightAware password/API key</label>
418
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
525
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
526
+	print $globalFlightAwarePassword;
527
+}
528
+?>" />
419 529
 				</p>
420 530
 			</div>
421 531
 -->
@@ -457,7 +567,10 @@  discard block
 block discarded – undo
457 567
 								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
458 568
 								?>
459 569
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
460
-								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
570
+								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) {
571
+	print $source['port'];
572
+}
573
+?>" /></td>
461 574
 								<?php
462 575
 								    } else {
463 576
 									$hostport = explode(':',$source['host']);
@@ -476,33 +589,102 @@  discard block
 block discarded – undo
476 589
 								?>
477 590
 								<td>
478 591
 									<select name="format[]" id="format">
479
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
480
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
481
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
482
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
483
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
484
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
485
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
486
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server AircraftList.json</option>
487
-										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') print 'selected'; ?>>Virtual Radar Server TCP</option>
488
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
489
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airlines Manager</option>
490
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
491
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
492
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
493
-										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') print 'selected'; ?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
494
-										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') print 'selected'; ?>>ACARS SBS-3 over TCP</option>
495
-										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') print 'selected'; ?>>NMEA AIS over TCP</option>
496
-										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') print 'selected'; ?>>AirWhere website</option>
497
-										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') print 'selected'; ?>>HidnSeek Callback</option>
498
-										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') print 'selected'; ?>>Blitzortung</option>
592
+										<option value="auto" <?php if (!isset($source['format'])) {
593
+	print 'selected';
594
+}
595
+?>>Auto</option>
596
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
597
+	print 'selected';
598
+}
599
+?>>SBS</option>
600
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
601
+	print 'selected';
602
+}
603
+?>>TSV</option>
604
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
605
+	print 'selected';
606
+}
607
+?>>Raw</option>
608
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
609
+	print 'selected';
610
+}
611
+?>>APRS</option>
612
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
613
+	print 'selected';
614
+}
615
+?>>Radarcape deltadb.txt</option>
616
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
617
+	print 'selected';
618
+}
619
+?>>Vatsim</option>
620
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
621
+	print 'selected';
622
+}
623
+?>>Virtual Radar Server AircraftList.json</option>
624
+										<option value="vrstcp" <?php if (isset($source['format']) && $source['format'] == 'vrstcp') {
625
+	print 'selected';
626
+}
627
+?>>Virtual Radar Server TCP</option>
628
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
629
+	print 'selected';
630
+}
631
+?>>phpVMS</option>
632
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
633
+	print 'selected';
634
+}
635
+?>>Virtual Airlines Manager</option>
636
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
637
+	print 'selected';
638
+}
639
+?>>IVAO</option>
640
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
641
+	print 'selected';
642
+}
643
+?>>FlightGear Multiplayer</option>
644
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
645
+	print 'selected';
646
+}
647
+?>>FlightGear Singleplayer</option>
648
+										<option value="acars" <?php if (isset($source['format']) && $source['format'] == 'acars') {
649
+	print 'selected';
650
+}
651
+?>>ACARS from acarsdec/acarsdeco2 over UDP</option>
652
+										<option value="acarssbs3" <?php if (isset($source['format']) && $source['format'] == 'acarssbs3') {
653
+	print 'selected';
654
+}
655
+?>>ACARS SBS-3 over TCP</option>
656
+										<option value="ais" <?php if (isset($source['format']) && $source['format'] == 'ais') {
657
+	print 'selected';
658
+}
659
+?>>NMEA AIS over TCP</option>
660
+										<option value="airwhere" <?php if (isset($source['format']) && $source['format'] == 'airwhere') {
661
+	print 'selected';
662
+}
663
+?>>AirWhere website</option>
664
+										<option value="hidnseek_callback" <?php if (isset($source['format']) && $source['format'] == 'hidnseek_callback') {
665
+	print 'selected';
666
+}
667
+?>>HidnSeek Callback</option>
668
+										<option value="blitzortung" <?php if (isset($source['format']) && $source['format'] == 'blitzortung') {
669
+	print 'selected';
670
+}
671
+?>>Blitzortung</option>
499 672
 									</select>
500 673
 								</td>
501 674
 								<td>
502
-									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" />
675
+									<input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
676
+	print $source['name'];
677
+}
678
+?>" />
503 679
 								</td>
504
-								<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>
505
-								<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>
680
+								<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']) {
681
+	print 'checked';
682
+}
683
+?> /></td>
684
+								<td><input type="checkbox" name="noarchive[]" id="noarchive" title="Don't archive this source" value="1" <?php if (isset($source['noarchive']) && $source['noarchive']) {
685
+	print 'checked';
686
+}
687
+?> /></td>
506 688
 								<td>
507 689
 									<select name="timezones[]" id="timezones">
508 690
 								<?php
@@ -512,7 +694,9 @@  discard block
 block discarded – undo
512 694
 											print '<option selected>'.$timezones.'</option>';
513 695
 										} elseif (!isset($source['timezone']) && $timezones == 'UTC') {
514 696
 											print '<option selected>'.$timezones.'</option>';
515
-										} else print '<option>'.$timezones.'</option>';
697
+										} else {
698
+											print '<option>'.$timezones.'</option>';
699
+										}
516 700
 									}
517 701
 								?>
518 702
 									</select>
@@ -562,7 +746,9 @@  discard block
 block discarded – undo
562 746
 									foreach($timezonelist as $timezones){
563 747
 										if ($timezones == 'UTC') {
564 748
 											print '<option selected>'.$timezones.'</option>';
565
-										} else print '<option>'.$timezones.'</option>';
749
+										} else {
750
+											print '<option>'.$timezones.'</option>';
751
+										}
566 752
 									}
567 753
 								?>
568 754
 									</select>
@@ -585,11 +771,17 @@  discard block
 block discarded – undo
585 771
 					<p>Listen UDP server for acarsdec/acarsdeco2/... with <i>daemon-acars.php</i> script</p>
586 772
 					<p>
587 773
 						<label for="acarshost">ACARS UDP host</label>
588
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
774
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
775
+	print $globalACARSHost;
776
+}
777
+?>" />
589 778
 					</p>
590 779
 					<p>
591 780
 						<label for="acarsport">ACARS UDP port</label>
592
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
781
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
782
+	print $globalACARSPort;
783
+}
784
+?>" />
593 785
 					</p>
594 786
 				</fieldset>
595 787
 			</div>
@@ -671,13 +863,19 @@  discard block
 block discarded – undo
671 863
 			<div id="schedules_options">
672 864
 				<p>
673 865
 					<label for="britishairways">British Airways API Key</label>
674
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
866
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
867
+	print $globalBritishAirwaysKey;
868
+}
869
+?>" />
675 870
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
676 871
 				</p>
677 872
 				<!--
678 873
 				<p>
679 874
 					<label for="transavia">Transavia Test API Consumer Key</label>
680
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
875
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
876
+	print $globalTransaviaKey;
877
+}
878
+?>" />
681 879
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
682 880
 				</p>
683 881
 				-->
@@ -686,10 +884,16 @@  discard block
 block discarded – undo
686 884
 						<b>Lufthansa API Key</b>
687 885
 						<p>
688 886
 							<label for="lufthansakey">Key</label>
689
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
887
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
888
+	print $globalLufthansaKey['key'];
889
+}
890
+?>" />
690 891
 						</p><p>
691 892
 							<label for="lufthansasecret">Secret</label>
692
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
893
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
894
+	print $globalLufthansaKey['secret'];
895
+}
896
+?>" />
693 897
 						</p>
694 898
 					</div>
695 899
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -709,7 +913,10 @@  discard block
 block discarded – undo
709 913
 			</p>
710 914
 			<p>
711 915
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
712
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
916
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
917
+	print $globalNOTAMSource;
918
+}
919
+?>" />
713 920
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
714 921
 			</p>
715 922
 			<br />
@@ -725,14 +932,20 @@  discard block
 block discarded – undo
725 932
 			<div id="metarsrc">
726 933
 				<p>
727 934
 					<label for="metarsource">URL of your METAR source</label>
728
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
935
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
936
+	print $globalMETARurl;
937
+}
938
+?>" />
729 939
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
730 940
 				</p>
731 941
 			</div>
732 942
 			<br />
733 943
 			<p>
734 944
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
735
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
945
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
946
+	print $globalBitlyAccessToken;
947
+}
948
+?>" />
736 949
 			</p>
737 950
 			<br />
738 951
 			<p>
@@ -748,11 +961,26 @@  discard block
 block discarded – undo
748 961
 			<p>
749 962
 				<label for="geoid_source">Geoid Source</label>
750 963
 				<select name="geoid_source" id="geoid_source">
751
-					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') print ' selected="selected"'; ?>>EGM96 15' (2.1MB)</option>
752
-					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') print ' selected="selected"'; ?>>EGM96 5' (19MB)</option>
753
-					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') print ' selected="selected"'; ?>>EGM2008 5' (19MB)</option>
754
-					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') print ' selected="selected"'; ?>>EGM2008 2.5' (75MB)</option>
755
-					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') print ' selected="selected"'; ?>>EGM2008 1' (470MB)</option>
964
+					<option value="egm96-15"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-15') {
965
+	print ' selected="selected"';
966
+}
967
+?>>EGM96 15' (2.1MB)</option>
968
+					<option value="egm96-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm96-5') {
969
+	print ' selected="selected"';
970
+}
971
+?>>EGM96 5' (19MB)</option>
972
+					<option value="egm2008-5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-5') {
973
+	print ' selected="selected"';
974
+}
975
+?>>EGM2008 5' (19MB)</option>
976
+					<option value="egm2008-2_5"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-2_5') {
977
+	print ' selected="selected"';
978
+}
979
+?>>EGM2008 2.5' (75MB)</option>
980
+					<option value="egm2008-1"<?php if (isset($globalGeoidSource) && $globalGeoidSource == 'egm2008-1') {
981
+	print ' selected="selected"';
982
+}
983
+?>>EGM2008 1' (470MB)</option>
756 984
 				</select>
757 985
 				<p class="help-block">The geoid is approximated by an "earth gravity model" (EGM).</p>
758 986
 			</p>
@@ -770,7 +998,12 @@  discard block
 block discarded – undo
770 998
 			</p>
771 999
 			<p>
772 1000
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
773
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '1'; ?>" />
1001
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
1002
+	print $globalArchiveMonths;
1003
+} else {
1004
+	echo '1';
1005
+}
1006
+?>" />
774 1007
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
775 1008
 			</p>
776 1009
 			<p>
@@ -780,12 +1013,22 @@  discard block
 block discarded – undo
780 1013
 			</p>
781 1014
 			<p>
782 1015
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
783
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '1'; ?>" />
1016
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
1017
+	print $globalArchiveKeepMonths;
1018
+} else {
1019
+	echo '1';
1020
+}
1021
+?>" />
784 1022
 				<p class="help-block">0 to disable</p>
785 1023
 			</p>
786 1024
 			<p>
787 1025
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
788
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '1'; ?>" />
1026
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
1027
+	print $globalArchiveKeepTrackMonths;
1028
+} else {
1029
+	echo '1';
1030
+}
1031
+?>" />
789 1032
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
790 1033
 			</p>
791 1034
 			<br />
@@ -795,7 +1038,12 @@  discard block
 block discarded – undo
795 1038
 				<p class="help-block">Uncheck if the script is running as cron job</p>
796 1039
 				<div id="cronends"> 
797 1040
 					<label for="cronend">Run script for xx seconds</label>
798
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
1041
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
1042
+	print $globalCronEnd;
1043
+} else {
1044
+	print '0';
1045
+}
1046
+?>" />
799 1047
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
800 1048
 				</div>
801 1049
 			</p>
@@ -848,15 +1096,30 @@  discard block
 block discarded – undo
848 1096
 			<br />
849 1097
 			<p>
850 1098
 				<label for="refresh">Show flights detected since xxx seconds</label>
851
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
1099
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
1100
+	echo $globalLiveInterval;
1101
+} else {
1102
+	echo '200';
1103
+}
1104
+?>" />
852 1105
 			</p>
853 1106
 			<p>
854 1107
 				<label for="maprefresh">Live map refresh (in seconds)</label>
855
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
1108
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
1109
+	echo $globalMapRefresh;
1110
+} else {
1111
+	echo '30';
1112
+}
1113
+?>" />
856 1114
 			</p>
857 1115
 			<p>
858 1116
 				<label for="mapidle">Map idle timeout (in minutes)</label>
859
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
1117
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
1118
+	echo $globalMapIdleTimeout;
1119
+} else {
1120
+	echo '30';
1121
+}
1122
+?>" />
860 1123
 				<p class="help-block">0 to disable</p>
861 1124
 			</p>
862 1125
 			<p>
@@ -871,12 +1134,20 @@  discard block
 block discarded – undo
871 1134
 			<br />
872 1135
 			<p>
873 1136
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
874
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
1137
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
1138
+	echo $globalClosestMinDist;
1139
+} else {
1140
+	echo '50';
1141
+}
1142
+?>" />
875 1143
 			</p>
876 1144
 			<br />
877 1145
 			<p>
878 1146
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
879
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
1147
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
1148
+	echo $globalAircraftSize;
1149
+}
1150
+?>" />
880 1151
 			</p>
881 1152
 			<br />
882 1153
 			<p>
@@ -889,7 +1160,12 @@  discard block
 block discarded – undo
889 1160
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
890 1161
 			?>
891 1162
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
892
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
1163
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
1164
+	echo $globalAircraftIconColor;
1165
+} else {
1166
+	echo '1a3151';
1167
+}
1168
+?>" />
893 1169
 			<?php
894 1170
 				if (!is_writable('../cache')) {
895 1171
 			?>
@@ -907,14 +1183,27 @@  discard block
 block discarded – undo
907 1183
 			<p>
908 1184
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
909 1185
 				<div class="range">
910
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
911
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
1186
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
1187
+	echo $globalAirportZoom;
1188
+} else {
1189
+	echo '7';
1190
+}
1191
+?>" />
1192
+					<output id="range"><?php if (isset($globalAirportZoom)) {
1193
+	echo $globalAirportZoom;
1194
+} else {
1195
+	echo '7';
1196
+}
1197
+?></output>
912 1198
 				</div>
913 1199
 			</p>
914 1200
 			<br />
915 1201
 			<p>
916 1202
 				<label for="customcss">Custom CSS web path</label>
917
-				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) echo $globalCustomCSS; ?>" />
1203
+				<input type="text" name="customcss" id="customcss" value="<?php if (isset($globalCustomCSS)) {
1204
+	echo $globalCustomCSS;
1205
+}
1206
+?>" />
918 1207
 			</p>
919 1208
 		</fieldset>
920 1209
 		<input type="submit" name="submit" value="Create/Update database & write setup" />
@@ -941,8 +1230,12 @@  discard block
 block discarded – undo
941 1230
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
942 1231
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
943 1232
 
944
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
945
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1233
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1234
+		$error .= 'Mysql driver for PDO must be loaded';
1235
+	}
1236
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1237
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1238
+	}
946 1239
 	
947 1240
 	$_SESSION['database_root'] = $dbroot;
948 1241
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -1010,15 +1303,23 @@  discard block
 block discarded – undo
1010 1303
 	$source_city = $_POST['source_city'];
1011 1304
 	$source_country = $_POST['source_country'];
1012 1305
 	$source_ref = $_POST['source_ref'];
1013
-	if (isset($source_id)) $source_id = $_POST['source_id'];
1014
-	else $source_id = array();
1306
+	if (isset($source_id)) {
1307
+		$source_id = $_POST['source_id'];
1308
+	} else {
1309
+		$source_id = array();
1310
+	}
1015 1311
 	
1016 1312
 	$sources = array();
1017 1313
 	foreach ($source_name as $keys => $name) {
1018
-	    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]);
1019
-	    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]);
1314
+	    if (isset($source_id[$keys])) {
1315
+	    	$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]);
1316
+	    } else {
1317
+	    	$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]);
1318
+	    }
1319
+	}
1320
+	if (count($sources) > 0) {
1321
+		$_SESSION['sources'] = $sources;
1020 1322
 	}
1021
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1022 1323
 
1023 1324
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
1024 1325
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -1039,17 +1340,29 @@  discard block
 block discarded – undo
1039 1340
 	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
1040 1341
 
1041 1342
 	$globalaircraft = filter_input(INPUT_POST,'globalaircraft',FILTER_SANITIZE_STRING);
1042
-	if ($globalaircraft == 'aircraft') $settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1043
-	else $settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1343
+	if ($globalaircraft == 'aircraft') {
1344
+		$settings = array_merge($settings,array('globalAircraft' => 'TRUE'));
1345
+	} else {
1346
+		$settings = array_merge($settings,array('globalAircraft' => 'FALSE'));
1347
+	}
1044 1348
 	$globaltracker = filter_input(INPUT_POST,'globaltracker',FILTER_SANITIZE_STRING);
1045
-	if ($globaltracker == 'tracker') $settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1046
-	else $settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1349
+	if ($globaltracker == 'tracker') {
1350
+		$settings = array_merge($settings,array('globalTracker' => 'TRUE'));
1351
+	} else {
1352
+		$settings = array_merge($settings,array('globalTracker' => 'FALSE'));
1353
+	}
1047 1354
 	$globalmarine = filter_input(INPUT_POST,'globalmarine',FILTER_SANITIZE_STRING);
1048
-	if ($globalmarine == 'marine') $settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1049
-	else $settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1355
+	if ($globalmarine == 'marine') {
1356
+		$settings = array_merge($settings,array('globalMarine' => 'TRUE'));
1357
+	} else {
1358
+		$settings = array_merge($settings,array('globalMarine' => 'FALSE'));
1359
+	}
1050 1360
 	$globalsatellite = filter_input(INPUT_POST,'globalsatellite',FILTER_SANITIZE_STRING);
1051
-	if ($globalsatellite == 'satellite') $settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1052
-	else $settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1361
+	if ($globalsatellite == 'satellite') {
1362
+		$settings = array_merge($settings,array('globalSatellite' => 'TRUE'));
1363
+	} else {
1364
+		$settings = array_merge($settings,array('globalSatellite' => 'FALSE'));
1365
+	}
1053 1366
 
1054 1367
 /*	
1055 1368
 	$globalSBS1Hosts = array();
@@ -1071,23 +1384,37 @@  discard block
 block discarded – undo
1071 1384
 	$name = $_POST['name'];
1072 1385
 	$format = $_POST['format'];
1073 1386
 	$timezones = $_POST['timezones'];
1074
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
1075
-	else $sourcestats = array();
1076
-	if (isset($_POST['noarchive'])) $noarchive = $_POST['noarchive'];
1077
-	else $noarchive = array();
1387
+	if (isset($_POST['sourcestats'])) {
1388
+		$sourcestats = $_POST['sourcestats'];
1389
+	} else {
1390
+		$sourcestats = array();
1391
+	}
1392
+	if (isset($_POST['noarchive'])) {
1393
+		$noarchive = $_POST['noarchive'];
1394
+	} else {
1395
+		$noarchive = array();
1396
+	}
1078 1397
 	$gSources = array();
1079 1398
 	$forcepilots = false;
1080 1399
 	foreach ($host as $key => $h) {
1081
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
1082
-		else $cov = 'FALSE';
1083
-		if (isset($noarchive[$key]) && $noarchive[$key] == 1) $arch = 'TRUE';
1084
-		else $arch = 'FALSE';
1400
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1401
+			$cov = 'TRUE';
1402
+		} else {
1403
+			$cov = 'FALSE';
1404
+		}
1405
+		if (isset($noarchive[$key]) && $noarchive[$key] == 1) {
1406
+			$arch = 'TRUE';
1407
+		} else {
1408
+			$arch = 'FALSE';
1409
+		}
1085 1410
 		if (strpos($format[$key],'_callback')) {
1086 1411
 			$gSources[] = array('host' => $h, 'pass' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'TRUE');
1087 1412
 		} elseif ($h != '' || $name[$key] != '') {
1088 1413
 			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov,'noarchive' => $arch,'timezone' => $timezones[$key],'callback' => 'FALSE');
1089 1414
 		}
1090
-		if ($format[$key] == 'airwhere') $forcepilots = true;
1415
+		if ($format[$key] == 'airwhere') {
1416
+			$forcepilots = true;
1417
+		}
1091 1418
 	}
1092 1419
 	$settings = array_merge($settings,array('globalSources' => $gSources));
1093 1420
 
@@ -1115,7 +1442,9 @@  discard block
 block discarded – undo
1115 1442
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
1116 1443
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
1117 1444
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
1118
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1445
+	} else {
1446
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1447
+	}
1119 1448
 
1120 1449
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
1121 1450
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -1154,7 +1483,9 @@  discard block
 block discarded – undo
1154 1483
 
1155 1484
 	// Create in settings.php keys not yet configurable if not already here
1156 1485
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
1157
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1486
+	if (!isset($globalDebug)) {
1487
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1488
+	}
1158 1489
 
1159 1490
 	$resetyearstats = filter_input(INPUT_POST,'resetyearstats',FILTER_SANITIZE_STRING);
1160 1491
 	if ($resetyearstats == 'resetyearstats') {
@@ -1191,37 +1522,56 @@  discard block
 block discarded – undo
1191 1522
 	}
1192 1523
 */
1193 1524
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1194
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1195
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1196
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1197
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1525
+	if ($globalsbs == 'sbs') {
1526
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1527
+	} else {
1528
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1529
+	}
1530
+	if ($globalaprs == 'aprs') {
1531
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1532
+	} else {
1533
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1534
+	}
1198 1535
 	$va = false;
1199 1536
 	if ($globalivao == 'ivao') {
1200 1537
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1201 1538
 		$va = true;
1202
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1539
+	} else {
1540
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1541
+	}
1203 1542
 	if ($globalvatsim == 'vatsim') {
1204 1543
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1205 1544
 		$va = true;
1206
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1545
+	} else {
1546
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1547
+	}
1207 1548
 	if ($globalphpvms == 'phpvms') {
1208 1549
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1209 1550
 		$va = true;
1210
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1551
+	} else {
1552
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1553
+	}
1211 1554
 	if ($globalvam == 'vam') {
1212 1555
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1213 1556
 		$va = true;
1214
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1557
+	} else {
1558
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1559
+	}
1215 1560
 	if ($va) {
1216 1561
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1217
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1562
+	} else {
1563
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1564
+	}
1218 1565
 	if ($globalva == 'va' || $va) {
1219 1566
 		$settings = array_merge($settings,array('globalVA' => 'TRUE'));
1220 1567
 		$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1221 1568
 	} else {
1222 1569
 		$settings = array_merge($settings,array('globalVA' => 'FALSE'));
1223
-		if ($forcepilots) $settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1224
-		else $settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1570
+		if ($forcepilots) {
1571
+			$settings = array_merge($settings,array('globalUsePilot' => 'TRUE','globalUseOwner' => 'FALSE'));
1572
+		} else {
1573
+			$settings = array_merge($settings,array('globalUsePilot' => 'FALSE','globalUseOwner' => 'TRUE'));
1574
+		}
1225 1575
 	}
1226 1576
 	
1227 1577
 	
@@ -1397,7 +1747,9 @@  discard block
 block discarded – undo
1397 1747
 		$settings = array_merge($settings,array('globalNoAirlines' => 'FALSE'));
1398 1748
 	}
1399 1749
 
1400
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1750
+	if (!isset($globalTransaction)) {
1751
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1752
+	}
1401 1753
 
1402 1754
 	// Set some defaults values...
1403 1755
 	if (!isset($globalAircraftImageSources)) {
@@ -1412,15 +1764,23 @@  discard block
 block discarded – undo
1412 1764
 
1413 1765
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1414 1766
 
1415
-	if ($error == '') settings::modify_settings($settings);
1416
-	if ($error == '') settings::comment_settings($settings_comment);
1767
+	if ($error == '') {
1768
+		settings::modify_settings($settings);
1769
+	}
1770
+	if ($error == '') {
1771
+		settings::comment_settings($settings_comment);
1772
+	}
1417 1773
 	if ($error != '') {
1418 1774
 		print '<div class="info column">'.$error.'</div>';
1419 1775
 		require('../footer.php');
1420 1776
 		exit;
1421 1777
 	} else {
1422
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1423
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1778
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1779
+			$_SESSION['waypoints'] = 1;
1780
+		}
1781
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1782
+			$_SESSION['owner'] = 1;
1783
+		}
1424 1784
 		if (isset($_POST['createdb'])) {
1425 1785
 			$_SESSION['install'] = 'database_create';
1426 1786
 		} else {
@@ -1456,10 +1816,18 @@  discard block
 block discarded – undo
1456 1816
 	$popw = false;
1457 1817
 	foreach ($_SESSION['done'] as $done) {
1458 1818
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1459
-	    if ($done == 'Create database') $pop = true;
1460
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1461
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1462
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1819
+	    if ($done == 'Create database') {
1820
+	    	$pop = true;
1821
+	    }
1822
+	    if ($_SESSION['install'] == 'database_create') {
1823
+	    	$pop = true;
1824
+	    }
1825
+	    if ($_SESSION['install'] == 'database_import') {
1826
+	    	$popi = true;
1827
+	    }
1828
+	    if ($_SESSION['install'] == 'waypoints') {
1829
+	    	$popw = true;
1830
+	    }
1463 1831
 	}
1464 1832
 	if ($pop) {
1465 1833
 	    sleep(5);
@@ -1470,7 +1838,9 @@  discard block
 block discarded – undo
1470 1838
 	} else if ($popw) {
1471 1839
 	    sleep(5);
1472 1840
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1473
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1841
+	} else {
1842
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1843
+	}
1474 1844
 	print '</div></ul>';
1475 1845
 	print '<div id="error"></div>';
1476 1846
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
location-geojson.php 3 patches
Braces   +8 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,15 +45,18 @@
 block discarded – undo
45 45
 			$output .= '"city": "'.$spotter_item['city'].'",';
46 46
 			$output .= '"country": "'.$spotter_item['country'].'",';
47 47
 			$output .= '"altitude": "'.$spotter_item['altitude'].'",';
48
-			if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '')
49
-				$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
50
-			elseif ($spotter_item['location_id'] != '')
51
-				$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
48
+			if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '') {
49
+							$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
50
+			} elseif ($spotter_item['location_id'] != '') {
51
+							$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
52
+			}
52 53
 			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
53 54
 			$output .= '"type": "'.$spotter_item['type'].'",';
54 55
 			if ($spotter_item['type'] == 'wx') {
55 56
 				$weather = json_decode($spotter_item['description'],true);
56
-				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
57
+				if (isset($weather['temp'])) {
58
+					$output.= '"temp": "'.$weather['temp'].'",';
59
+				}
57 60
 			}
58 61
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
59 62
 		    $output .= '},';
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@  discard block
 block discarded – undo
14 14
 	{
15 15
 		$coords = explode(',',$_GET['coord']);
16 16
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
17
-		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
17
+			|| (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
18 18
 			//$spotter_array = $Source->getAllLocationInfo();
19 19
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
20 20
 		}
21 21
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
22
-		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
22
+			|| (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
23 23
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
24 24
 		}
25 25
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
26
-		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
26
+			|| (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
27 27
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
28 28
 		}
29 29
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
30 30
 	} else {
31 31
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
32
-		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
32
+			|| (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
33 33
 			//$spotter_array = $Source->getAllLocationInfo();
34 34
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
35 35
 		}
36 36
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
37
-		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
37
+			|| (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
38 38
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
39 39
 		}
40 40
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
41
-		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
41
+			|| (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
42 42
 			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
43 43
 		}
44 44
 		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		date_default_timezone_set('UTC');
54 54
 		//waypoint plotting
55 55
 		$output .= '{"type": "Feature",';
56
-		    $output .= '"properties": {';
56
+			$output .= '"properties": {';
57 57
 			$output .= '"id": "'.$spotter_item['id'].'",';
58 58
 			$output .= '"location_id": "'.$spotter_item['location_id'].'",';
59 59
 			$output .= '"name": "'.$spotter_item['name'].'",';
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
72 72
 			}
73 73
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
74
-		    $output .= '},';
75
-		    $output .= '"geometry": {';
74
+			$output .= '},';
75
+			$output .= '"geometry": {';
76 76
 			$output .= '"type": "Point",';
77 77
 			$output .= '"coordinates": [';
78
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
78
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
79 79
 			$output .= ']';
80
-		    $output .= '}';
80
+			$output .= '}';
81 81
 		$output .= '},';
82 82
 	}
83 83
 	$output  = substr($output, 0, -1);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,43 +12,43 @@  discard block
 block discarded – undo
12 12
 if (!isset($globalDemo)) {
13 13
 	if (isset($_GET['coord'])) 
14 14
 	{
15
-		$coords = explode(',',$_GET['coord']);
15
+		$coords = explode(',', $_GET['coord']);
16 16
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
17 17
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
18 18
 			//$spotter_array = $Source->getAllLocationInfo();
19
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
19
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
20 20
 		}
21 21
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
22 22
 		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
23
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
23
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
24 24
 		}
25 25
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
26 26
 		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
27
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
27
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
28 28
 		}
29
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
29
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
30 30
 	} else {
31 31
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
32 32
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
33 33
 			//$spotter_array = $Source->getAllLocationInfo();
34
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
34
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
35 35
 		}
36 36
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
37 37
 		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
38
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
38
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
39 39
 		}
40 40
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
41 41
 		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
42
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
42
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
43 43
 		}
44
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
44
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
45 45
 	}
46 46
 }
47 47
 
48 48
 $output = '{"type": "FeatureCollection","features": [';
49 49
 if (!empty($spotter_array) && count($spotter_array) > 0)
50 50
 {
51
-	foreach($spotter_array as $spotter_item)
51
+	foreach ($spotter_array as $spotter_item)
52 52
 	{
53 53
 		date_default_timezone_set('UTC');
54 54
 		//waypoint plotting
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
68 68
 			$output .= '"type": "'.$spotter_item['type'].'",';
69 69
 			if ($spotter_item['type'] == 'wx') {
70
-				$weather = json_decode($spotter_item['description'],true);
71
-				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
70
+				$weather = json_decode($spotter_item['description'], true);
71
+				if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",';
72 72
 			}
73 73
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
74 74
 		    $output .= '},';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		    $output .= '}';
81 81
 		$output .= '},';
82 82
 	}
83
-	$output  = substr($output, 0, -1);
83
+	$output = substr($output, 0, -1);
84 84
 }
85 85
 $output .= ']}';
86 86
 
Please login to merge, or discard this patch.
require/class.TrackerImport.php 3 patches
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.1)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
434
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
Braces   +190 added lines, -65 removed lines patch added patch discarded remove patch
@@ -42,7 +42,9 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function checkAll() {
44 44
 	global $globalDebug;
45
-	if ($globalDebug) echo "Update last seen tracked data...\n";
45
+	if ($globalDebug) {
46
+		echo "Update last seen tracked data...\n";
47
+	}
46 48
 	foreach ($this->all_tracked as $key => $flight) {
47 49
 	    if (isset($this->all_tracked[$key]['id'])) {
48 50
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -55,12 +57,16 @@  discard block
 block discarded – undo
55 57
     public function del() {
56 58
 	global $globalDebug;
57 59
 	// Delete old infos
58
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
60
+	if ($globalDebug) {
61
+		echo 'Delete old values and update latest data...'."\n";
62
+	}
59 63
 	foreach ($this->all_tracked as $key => $flight) {
60 64
     	    if (isset($flight['lastupdate'])) {
61 65
         	if ($flight['lastupdate'] < (time()-3000)) {
62 66
             	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
67
+            		if ($globalDebug) {
68
+            			echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
69
+            		}
64 70
 			/*
65 71
 			$TrackerLive = new TrackerLive();
66 72
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
@@ -70,7 +76,9 @@  discard block
 block discarded – undo
70 76
             		$Tracker = new Tracker($this->db);
71 77
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 78
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
79
+				if ($globalDebug && $result != 'success') {
80
+					echo '!!! ERROR : '.$result."\n";
81
+				}
74 82
 			}
75 83
 			// Put in archive
76 84
 //			$Tracker->db = null;
@@ -83,7 +91,9 @@  discard block
 block discarded – undo
83 91
 
84 92
     public function add($line) {
85 93
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86
-	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
94
+	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') {
95
+		$globalCoordMinChangeTracker = '0.015';
96
+	}
87 97
 	date_default_timezone_set('UTC');
88 98
 	$dataFound = false;
89 99
 	$send = false;
@@ -97,19 +107,29 @@  discard block
 block discarded – undo
97 107
 		// Increment message number
98 108
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99 109
 		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
110
+		    if (isset($line['source_name'])) {
111
+		    	$source = $line['source_name'];
112
+		    } else {
113
+		    	$source = '';
114
+		    }
115
+		    if ($source == '' || $line['format_source'] == 'aprs') {
116
+		    	$source = $line['format_source'];
117
+		    }
103 118
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104 119
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105 120
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
121
+		    } else {
122
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
123
+		    }
107 124
 		}
108 125
 		
109 126
 		
110 127
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
128
+	        if (!isset($line['id'])) {
129
+	        	$id = trim($line['ident']);
130
+	        } else {
131
+	        	$id = trim($line['id']);
132
+	        }
113 133
 		
114 134
 		if (!isset($this->all_tracked[$id])) {
115 135
 		    $this->all_tracked[$id] = array();
@@ -117,31 +137,46 @@  discard block
 block discarded – undo
117 137
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118 138
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119 139
 		    if (!isset($line['id'])) {
120
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
140
+			if (!isset($globalDaemon)) {
141
+				$globalDaemon = TRUE;
142
+			}
121 143
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
144
+		     } else {
145
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
146
+		     }
147
+		    if ($globalAllTracked !== FALSE) {
148
+		    	$dataFound = true;
149
+		    }
124 150
 		}
125 151
 		
126 152
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127 153
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 154
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129 155
 		    } else {
130
-				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131
-				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
156
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
157
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
158
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
159
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
160
+				}
132 161
 				return '';
133 162
 		    }
134 163
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
164
+			if ($globalDebug) {
165
+				echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
166
+			}
136 167
 			return '';
137 168
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
138
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
169
+			if ($globalDebug) {
170
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
171
+			}
139 172
 			return '';
140 173
 		} elseif (!isset($line['datetime'])) {
141 174
 			date_default_timezone_set('UTC');
142 175
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
143 176
 		} else {
144
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
177
+			if ($globalDebug) {
178
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
179
+			}
145 180
 			return '';
146 181
 		}
147 182
 		
@@ -153,11 +188,17 @@  discard block
 block discarded – undo
153 188
             		$Tracker = new Tracker($this->db);
154 189
             		$fromsource = NULL;
155 190
             		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
191
+			if ($globalDebug && $result != 'success') {
192
+				echo '!!! ERROR : '.$result."\n";
193
+			}
157 194
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
195
+			if ($globalDebugTimeElapsed) {
196
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
197
+			}
198
+		    }
199
+		    if (!isset($this->all_tracked[$id]['id'])) {
200
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159 201
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 202
 		}
162 203
 
163 204
 		if (isset($line['speed']) && $line['speed'] != '') {
@@ -168,14 +209,21 @@  discard block
 block discarded – undo
168 209
 		    if ($distance > 100 && $distance < 10000) {
169 210
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 211
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
212
+			if ($speed < 1000) {
213
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
214
+			}
215
+  			if ($globalDebug) {
216
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
217
+  			}
173 218
 		    }
174 219
 		}
175 220
 
176 221
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
222
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
223
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
224
+	    	    } else {
225
+	    	    	unset($timediff);
226
+	    	    }
179 227
 	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 228
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181 229
 			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
@@ -183,20 +231,30 @@  discard block
 block discarded – undo
183 231
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 232
 				$this->all_tracked[$id]['putinarchive'] = true;
185 233
 				
186
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
234
+				if ($globalDebug) {
235
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
236
+				}
187 237
 				$timeelapsed = microtime(true);
188 238
 				$Tracker = new Tracker($this->db);
189 239
 				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
190
-				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
240
+				if (!empty($all_country)) {
241
+					$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
242
+				}
191 243
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
244
+				if ($globalDebugTimeElapsed) {
245
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
246
+				}
193 247
 				$this->tmd = 0;
194
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
248
+				if ($globalDebug) {
249
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
250
+				}
195 251
 			    }
196 252
 			}
197 253
 
198 254
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
255
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
256
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
257
+				}
200 258
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 259
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 260
 				    $dataFound = true;
@@ -205,8 +263,12 @@  discard block
 block discarded – undo
205 263
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 264
 			}
207 265
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
266
+			    if ($line['longitude'] > 180) {
267
+			    	$line['longitude'] = $line['longitude'] - 360;
268
+			    }
269
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
270
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
271
+				}
210 272
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 273
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 274
 				    $dataFound = true;
@@ -226,7 +288,9 @@  discard block
 block discarded – undo
226 288
 		    }
227 289
 		}
228 290
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
291
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
292
+		    	$dataFound = true;
293
+		    }
230 294
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 295
 		}
232 296
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -246,7 +310,9 @@  discard block
 block discarded – undo
246 310
 
247 311
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 312
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
313
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) {
314
+				$this->all_tracked[$id]['putinarchive'] = true;
315
+			}
250 316
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 317
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 318
 			//$dataFound = true;
@@ -258,15 +324,21 @@  discard block
 block discarded – undo
258 324
 		}
259 325
 		
260 326
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
327
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
328
+		    	$this->all_tracked[$id]['putinarchive'] = true;
329
+		    }
262 330
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263 331
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264 332
 		    //$dataFound = true;
265 333
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266 334
   		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267 335
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
336
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
337
+		    	$this->all_tracked[$id]['putinarchive'] = true;
338
+		    }
339
+  		    if ($globalDebug) {
340
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
341
+  		    }
270 342
   		}
271 343
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 344
 
@@ -275,20 +347,31 @@  discard block
 block discarded – undo
275 347
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276 348
 		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 349
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
350
+				if ($globalDebug) {
351
+					echo "Check if aircraft is already in DB...";
352
+				}
279 353
 				$timeelapsed = microtime(true);
280 354
 				$TrackerLive = new TrackerLive($this->db);
281 355
 				if (isset($line['id'])) {
282 356
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
357
+				    if ($globalDebugTimeElapsed) {
358
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
359
+				    }
284 360
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 361
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
-				} else $recent_ident = '';
362
+				    if ($globalDebugTimeElapsed) {
363
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
364
+				    }
365
+				} else {
366
+					$recent_ident = '';
367
+				}
288 368
 				$TrackerLive->db=null;
289 369
 
290
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
370
+				if ($globalDebug && $recent_ident == '') {
371
+					echo " Not in DB.\n";
372
+				} elseif ($globalDebug && $recent_ident != '') {
373
+					echo " Already in DB.\n";
374
+				}
292 375
 			    } else {
293 376
 				$recent_ident = '';
294 377
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -296,27 +379,41 @@  discard block
 block discarded – undo
296 379
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297 380
 			    if($recent_ident == "")
298 381
 			    {
299
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
382
+				if ($globalDebug) {
383
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
384
+				}
300 385
 				//adds the spotter data for the archive
301 386
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
387
+				    if (!isset($this->all_tracked[$id]['id'])) {
388
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
389
+				    }
303 390
 				    $timeelapsed = microtime(true);
304 391
 				    $Tracker = new Tracker($this->db);
305 392
 				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306 393
 				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
394
+				    if ($globalDebug && isset($result)) {
395
+				    	echo $result."\n";
396
+				    }
397
+				    if ($globalDebugTimeElapsed) {
398
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+				    }
309 400
 				    
310 401
 				    
311 402
 				    // Add source stat in DB
312 403
 				    $Stats = new Stats($this->db);
313 404
 				    if (!empty($this->stats)) {
314
-					if ($globalDebug) echo 'Add source stats : ';
405
+					if ($globalDebug) {
406
+						echo 'Add source stats : ';
407
+					}
315 408
 				        foreach($this->stats as $date => $data) {
316 409
 					    foreach($data as $source => $sourced) {
317 410
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
411
+				    	        if (isset($sourced['polar'])) {
412
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
413
+				    	        }
414
+				    	        if (isset($sourced['hist'])) {
415
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
416
+				    	        }
320 417
 				    		if (isset($sourced['msg'])) {
321 418
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 419
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -329,7 +426,9 @@  discard block
 block discarded – undo
329 426
 			    			unset($this->stats[$date]);
330 427
 			    		    }
331 428
 				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
429
+				    	if ($globalDebug) {
430
+				    		echo 'Done'."\n";
431
+				    	}
333 432
 
334 433
 				    }
335 434
 				    $Stats->db = null;
@@ -339,12 +438,16 @@  discard block
 block discarded – undo
339 438
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 439
 				//print_r($this->all_tracked[$id]);
341 440
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
441
+				    if ($globalDebug) {
442
+				    	echo "---- Deleting Live Tracker data older than 9 hours...";
443
+				    }
343 444
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 445
 				    $TrackerLive = new TrackerLive($this->db);
345 446
 				    $TrackerLive->deleteLiveTrackerData();
346 447
 				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
448
+				    if ($globalDebug) {
449
+				    	echo " Done\n";
450
+				    }
348 451
 				    $this->last_delete = time();
349 452
 				}
350 453
 			    } else {
@@ -367,19 +470,25 @@  discard block
 block discarded – undo
367 470
 
368 471
 		    if (!$ignoreImport) {
369 472
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
473
+				if ($globalDebug) {
474
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
475
+				}
371 476
 				$timeelapsed = microtime(true);
372 477
 				$TrackerLive = new TrackerLive($this->db);
373 478
 				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
374 479
 				$TrackerLive->db = null;
375 480
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
481
+				if ($globalDebugTimeElapsed) {
482
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
483
+				}
377 484
 
378 485
 				// Put statistics in $this->stats variable
379 486
 				
380 487
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
381 488
 					$source = $this->all_tracked[$id]['source_name'];
382
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
489
+					if ($source == '') {
490
+						$source = $this->all_tracked[$id]['format_source'];
491
+					}
383 492
 					if (!isset($this->source_location[$source])) {
384 493
 						$Location = new Source();
385 494
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -400,7 +509,9 @@  discard block
 block discarded – undo
400 509
 					$stats_heading = round($stats_heading/22.5);
401 510
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
402 511
 					$current_date = date('Y-m-d');
403
-					if ($stats_heading == 16) $stats_heading = 0;
512
+					if ($stats_heading == 16) {
513
+						$stats_heading = 0;
514
+					}
404 515
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 516
 						for ($i=0;$i<=15;$i++) {
406 517
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -418,7 +529,9 @@  discard block
 block discarded – undo
418 529
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 530
 						    end($this->stats[$current_date][$source]['hist']);
420 531
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
421
-						} else $mini = 0;
532
+						} else {
533
+							$mini = 0;
534
+						}
422 535
 						for ($i=$mini;$i<=$distance;$i+=10) {
423 536
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 537
 						}
@@ -429,19 +542,29 @@  discard block
 block discarded – undo
429 542
 				}
430 543
 
431 544
 				$this->all_tracked[$id]['lastupdate'] = time();
432
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433
-				if ($globalDebug) echo $result."\n";
434
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
545
+				if ($this->all_tracked[$id]['putinarchive']) {
546
+					$send = true;
547
+				}
548
+				if ($globalDebug) {
549
+					echo $result."\n";
550
+				}
551
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
552
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
553
+			}
435 554
 			//$this->del();
436 555
 			
437 556
 			
438 557
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
558
+			    if ($globalDebug) {
559
+			    	echo "---- Deleting Live Tracker data Not updated since 2 hour...";
560
+			    }
440 561
 			    $TrackerLive = new TrackerLive($this->db);
441 562
 			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442 563
 			    $TrackerLive->db = null;
443 564
 			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
565
+			    if ($globalDebug) {
566
+			    	echo " Done\n";
567
+			    }
445 568
 			    $this->last_delete_hourly = time();
446 569
 			}
447 570
 			
@@ -449,7 +572,9 @@  discard block
 block discarded – undo
449 572
 		    //$ignoreImport = false;
450 573
 		}
451 574
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452
-		if ($send) return $this->all_tracked[$id];
575
+		if ($send) {
576
+			return $this->all_tracked[$id];
577
+		}
453 578
 	    }
454 579
 	}
455 580
     }
Please login to merge, or discard this patch.
location-data.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Source = new Source();
6 6
 
7 7
 if (isset($_GET['sourceid'])) {
8
-	$sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT);
8
+	$sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT);
9 9
 	$source_data = $Source->getLocationInfoById($sourceid);
10 10
 	if (isset($source_data[0])) {
11 11
  ?>
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 print '</div>';
35 35
 
36 36
 if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
37
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
37
+if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
39 39
 /*
40 40
 if ($spotter_item['atc_range'] > 0) {
41 41
     print '<div><span>'._("Range").'</span>';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 }
45 45
 */
46 46
 if ($spotter_item['type'] == 'wx') {
47
-	$weather = json_decode($spotter_item['description'],true);
47
+	$weather = json_decode($spotter_item['description'], true);
48 48
 	//print_r($weather);
49 49
 	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
50 50
 	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
Please login to merge, or discard this patch.
Braces   +38 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,11 +17,17 @@  discard block
 block discarded – undo
17 17
 date_default_timezone_set('UTC');
18 18
 
19 19
 print '<div class="top">';
20
-if ($spotter_item['name'] != '') print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
21
-elseif ($spotter_item['location_id'] != 0) print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
22
-elseif ($spotter_item['type'] == 'lightning') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
23
-elseif ($spotter_item['type'] == 'wx') print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
24
-else print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
20
+if ($spotter_item['name'] != '') {
21
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['name'].'</div>';
22
+} elseif ($spotter_item['location_id'] != 0) {
23
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['location_id'].'</div>';
24
+} elseif ($spotter_item['type'] == 'lightning') {
25
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Lightning").'</div>';
26
+} elseif ($spotter_item['type'] == 'wx') {
27
+	print '<div class="right"><div class="callsign-details"><div class="callsign">'._("Weather Station").'</div>';
28
+} else {
29
+	print '<div class="right"><div class="callsign-details"><div class="callsign"></div>';
30
+}
25 31
 print '</div>';
26 32
 
27 33
 print '</div></div>';
@@ -36,8 +42,12 @@  discard block
 block discarded – undo
36 42
 print $spotter_item['last_seen'].' UTC';
37 43
 print '</div>';
38 44
 
39
-if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
40
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
45
+if ($spotter_item['city'] != '') {
46
+	print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
47
+}
48
+if ($spotter_item['country'] !='') {
49
+	print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
50
+}
41 51
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
42 52
 /*
43 53
 if ($spotter_item['atc_range'] > 0) {
@@ -49,13 +59,27 @@  discard block
 block discarded – undo
49 59
 if ($spotter_item['type'] == 'wx') {
50 60
 	$weather = json_decode($spotter_item['description'],true);
51 61
 	//print_r($weather);
52
-	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
53
-	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
54
-	if (isset($weather['wind_gust'])) print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
55
-	if (isset($weather['humidity'])) print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
56
-	if (isset($weather['rain'])) print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
57
-	if (isset($weather['precipitation'])) print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
58
-	if (isset($weather['precipitation24h'])) print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
62
+	if (isset($weather['temp'])) {
63
+		print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
64
+	}
65
+	if (isset($weather['pressure'])) {
66
+		print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
67
+	}
68
+	if (isset($weather['wind_gust'])) {
69
+		print '<div><span>'._("Wind Gust").'</span>'.$weather['wind_gust'].' km/h</div>';
70
+	}
71
+	if (isset($weather['humidity'])) {
72
+		print '<div><span>'._("Humidity").'</span>'.$weather['humidity'].'%</div>';
73
+	}
74
+	if (isset($weather['rain'])) {
75
+		print '<div><span>'._("Rain").'</span>'.$weather['rain'].' mm</div>';
76
+	}
77
+	if (isset($weather['precipitation'])) {
78
+		print '<div><span>'._("Precipitation 24H").'</span>'.$weather['precipitation'].' mm</div>';
79
+	}
80
+	if (isset($weather['precipitation24h'])) {
81
+		print '<div><span>'._("Precipitation Today").'</span>'.$weather['precipitation24h'].' mm</div>';
82
+	}
59 83
 	$spotter_item['description'] = $weather['comment'];
60 84
 }
61 85
 print '</div>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Braces   +1028 added lines, -351 removed lines patch added patch discarded remove patch
@@ -14,13 +14,17 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Source.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17
+if (isset($globalTracker) && $globalTracker) {
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19
+}
18 20
 if (isset($globalMarine) && $globalMarine) {
19 21
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
20 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 23
 }
22 24
 
23
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
24 28
 
25 29
 // Check if schema is at latest version
26 30
 $Connection = new Connection();
@@ -55,35 +59,62 @@  discard block
 block discarded – undo
55 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 60
 if (isset($options['s'])) {
57 61
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
59
-    else $globalSources[] = array('host' => $options['s']);
60
-} elseif (isset($options['source'])) {
62
+    if (isset($options['format'])) {
63
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
64
+    } else {
65
+    	$globalSources[] = array('host' => $options['s']);
66
+    }
67
+    } elseif (isset($options['source'])) {
61 68
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['source']);
64
-}
69
+    if (isset($options['format'])) {
70
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
71
+    } else {
72
+    	$globalSources[] = array('host' => $options['source']);
73
+    }
74
+    }
65 75
 if (isset($options['aprsserverhost'])) {
66 76
 	$globalServerAPRS = TRUE;
67 77
 	$globalServerAPRShost = $options['aprsserverhost'];
68 78
 }
69
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
70
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
71
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
72
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
73
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
74
-if (isset($options['server'])) $globalServer = TRUE;
75
-if (isset($options['idsource'])) $id_source = $options['idsource'];
76
-else $id_source = 1;
79
+if (isset($options['aprsserverport'])) {
80
+	$globalServerAPRSport = $options['aprsserverport'];
81
+}
82
+if (isset($options['aprsserverssid'])) {
83
+	$globalServerAPRSssid = $options['aprsserverssid'];
84
+}
85
+if (isset($options['aprsserverpass'])) {
86
+	$globalServerAPRSpass = $options['aprsserverpass'];
87
+}
88
+if (isset($options['noaprsserver'])) {
89
+	$globalServerAPRS = FALSE;
90
+}
91
+if (isset($options['nodaemon'])) {
92
+	$globalDaemon = FALSE;
93
+}
94
+if (isset($options['server'])) {
95
+	$globalServer = TRUE;
96
+}
97
+if (isset($options['idsource'])) {
98
+	$id_source = $options['idsource'];
99
+} else {
100
+	$id_source = 1;
101
+}
77 102
 if (isset($globalServer) && $globalServer) {
78
-    if ($globalDebug) echo "Using Server Mode\n";
103
+    if ($globalDebug) {
104
+    	echo "Using Server Mode\n";
105
+    }
79 106
     $SI=new SpotterServer();
80 107
 /*
81 108
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 109
     $SI = new adsb2aprs();
83 110
     $SI->connect();
84 111
 */
85
-} else $SI=new SpotterImport($Connection->db);
86
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
112
+} else {
113
+	$SI=new SpotterImport($Connection->db);
114
+}
115
+if (isset($globalTracker) && $globalTracker) {
116
+	$TI = new TrackerImport($Connection->db);
117
+}
87 118
 if (isset($globalMarine) && $globalMarine) {
88 119
     $AIS = new AIS();
89 120
     $MI = new MarineImport($Connection->db);
@@ -106,7 +137,9 @@  discard block
 block discarded – undo
106 137
 }
107 138
 
108 139
 // let's try and connect
109
-if ($globalDebug) echo "Connecting...\n";
140
+if ($globalDebug) {
141
+	echo "Connecting...\n";
142
+}
110 143
 $use_aprs = false;
111 144
 $aprs_full = false;
112 145
 $reset = 0;
@@ -115,7 +148,9 @@  discard block
 block discarded – undo
115 148
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116 149
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
117 150
     $reset++;
118
-    if ($globalDebug) echo 'Connect to all...'."\n";
151
+    if ($globalDebug) {
152
+    	echo 'Connect to all...'."\n";
153
+    }
119 154
     foreach ($hosts as $id => $value) {
120 155
 	$host = $value['host'];
121 156
 	$globalSources[$id]['last_exec'] = 0;
@@ -125,22 +160,30 @@  discard block
 block discarded – undo
125 160
         	//$formats[$id] = 'deltadbtxt';
126 161
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 162
         	//$last_exec['deltadbtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
163
+        	if ($globalDebug) {
164
+        		echo "Connect to deltadb source (".$host.")...\n";
165
+        	}
129 166
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
130 167
         	//$formats[$id] = 'vatsimtxt';
131 168
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 169
         	//$last_exec['vatsimtxt'] = 0;
133
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
170
+        	if ($globalDebug) {
171
+        		echo "Connect to vatsim source (".$host.")...\n";
172
+        	}
134 173
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
135 174
         	//$formats[$id] = 'aircraftlistjson';
136 175
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 176
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	if ($globalDebug) {
178
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
179
+        	}
139 180
     	    } else if (preg_match('/opensky/i',$host)) {
140 181
         	//$formats[$id] = 'aircraftlistjson';
141 182
         	$globalSources[$id]['format'] = 'opensky';
142 183
         	//$last_exec['aircraftlistjson'] = 0;
143
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
184
+        	if ($globalDebug) {
185
+        		echo "Connect to opensky source (".$host.")...\n";
186
+        	}
144 187
     	    /*
145 188
     	    // Disabled for now, site change source format
146 189
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -157,7 +200,9 @@  discard block
 block discarded – undo
157 200
         	//$formats[$id] = 'planeupdatefaa';
158 201
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 202
         	//$last_exec['planeupdatefaa'] = 0;
160
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
205
+        	}
161 206
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
162 207
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 208
         	    exit(0);
@@ -166,32 +211,46 @@  discard block
 block discarded – undo
166 211
         	//$formats[$id] = 'phpvmacars';
167 212
         	$globalSources[$id]['format'] = 'phpvmacars';
168 213
         	//$last_exec['phpvmacars'] = 0;
169
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	if ($globalDebug) {
215
+        		echo "Connect to phpvmacars source (".$host.")...\n";
216
+        	}
170 217
             } else if (preg_match('/VAM-json.php$/i',$host)) {
171 218
         	//$formats[$id] = 'phpvmacars';
172 219
         	$globalSources[$id]['format'] = 'vam';
173
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
220
+        	if ($globalDebug) {
221
+        		echo "Connect to Vam source (".$host.")...\n";
222
+        	}
174 223
             } else if (preg_match('/whazzup/i',$host)) {
175 224
         	//$formats[$id] = 'whazzup';
176 225
         	$globalSources[$id]['format'] = 'whazzup';
177 226
         	//$last_exec['whazzup'] = 0;
178
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
227
+        	if ($globalDebug) {
228
+        		echo "Connect to whazzup source (".$host.")...\n";
229
+        	}
179 230
             } else if (preg_match('/blitzortung/i',$host)) {
180 231
         	$globalSources[$id]['format'] = 'blitzortung';
181
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to blitzortung source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match('/airwhere/i',$host)) {
183 236
         	$globalSources[$id]['format'] = 'airwhere';
184
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
237
+        	if ($globalDebug) {
238
+        		echo "Connect to airwhere source (".$host.")...\n";
239
+        	}
185 240
             } else if (preg_match('/recentpireps/i',$host)) {
186 241
         	//$formats[$id] = 'pirepsjson';
187 242
         	$globalSources[$id]['format'] = 'pirepsjson';
188 243
         	//$last_exec['pirepsjson'] = 0;
189
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
244
+        	if ($globalDebug) {
245
+        		echo "Connect to pirepsjson source (".$host.")...\n";
246
+        	}
190 247
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
191 248
         	//$formats[$id] = 'fr24json';
192 249
         	$globalSources[$id]['format'] = 'fr24json';
193 250
         	//$last_exec['fr24json'] = 0;
194
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
251
+        	if ($globalDebug) {
252
+        		echo "Connect to fr24 source (".$host.")...\n";
253
+        	}
195 254
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
196 255
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
197 256
         	    exit(0);
@@ -200,7 +259,9 @@  discard block
 block discarded – undo
200 259
         	//$formats[$id] = 'fr24json';
201 260
         	$globalSources[$id]['format'] = 'myshiptracking';
202 261
         	//$last_exec['fr24json'] = 0;
203
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
262
+        	if ($globalDebug) {
263
+        		echo "Connect to myshiptracking source (".$host.")...\n";
264
+        	}
204 265
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
205 266
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
206 267
         	    exit(0);
@@ -209,17 +270,24 @@  discard block
 block discarded – undo
209 270
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
210 271
         	//$formats[$id] = 'tsv';
211 272
         	$globalSources[$id]['format'] = 'tsv';
212
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
273
+        	if ($globalDebug) {
274
+        		echo "Connect to tsv source (".$host.")...\n";
275
+        	}
213 276
             }
214 277
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
215 278
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
216 279
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
217 280
     		    if ($idf !== false) {
218 281
     			$httpfeeds[$id] = $idf;
219
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+        		if ($globalDebug) {
283
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
284
+        		}
285
+    		    } elseif ($globalDebug) {
286
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
220 287
     		    }
221
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
222
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
288
+    		} elseif ($globalDebug) {
289
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
290
+    		}
223 291
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
224 292
 	    $hostport = explode(':',$host);
225 293
 	    if (isset($hostport[1])) {
@@ -259,17 +327,25 @@  discard block
 block discarded – undo
259 327
         		//$formats[$id] = 'beast';
260 328
         		$globalSources[$id]['format'] = 'beast';
261 329
 		    //} else $formats[$id] = 'sbs';
262
-		    } else $globalSources[$id]['format'] = 'sbs';
330
+		    } else {
331
+		    	$globalSources[$id]['format'] = 'sbs';
332
+		    }
263 333
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
264 334
 		}
265
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
335
+		if ($globalDebug) {
336
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
337
+		}
266 338
             } else {
267
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
339
+		if ($globalDebug) {
340
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
341
+		}
268 342
     	    }
269 343
         }
270 344
     }
271 345
 }
272
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
346
+if (!isset($globalMinFetch)) {
347
+	$globalMinFetch = 15;
348
+}
273 349
 
274 350
 // Initialize all
275 351
 $status = array();
@@ -278,13 +354,19 @@  discard block
 block discarded – undo
278 354
 $formats = array();
279 355
 $last_exec = array();
280 356
 $time = time();
281
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
282
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
283
-else $timeout = 20;
357
+if (isset($globalSourcesTimeout)) {
358
+	$timeout = $globalSourcesTimeOut;
359
+} else if (isset($globalSBS1TimeOut)) {
360
+	$timeout = $globalSBS1TimeOut;
361
+} else {
362
+	$timeout = 20;
363
+}
284 364
 $errno = '';
285 365
 $errstr='';
286 366
 
287
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
367
+if (!isset($globalDaemon)) {
368
+	$globalDaemon = TRUE;
369
+}
288 370
 /* Initiate connections to all the hosts simultaneously */
289 371
 //connect_all($hosts);
290 372
 //connect_all($globalSources);
@@ -313,7 +395,9 @@  discard block
 block discarded – undo
313 395
     if (isset($source['format']) && $source['format'] == 'aprs') {
314 396
 	$aprs_connect = 0;
315 397
 	$use_aprs = true;
316
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
398
+	if (isset($source['port']) && $source['port'] == '10152') {
399
+		$aprs_full = true;
400
+	}
317 401
 	break;
318 402
     }
319 403
 }
@@ -324,25 +408,48 @@  discard block
 block discarded – undo
324 408
 	$aprs_connect = 0;
325 409
 	$aprs_keep = 120;
326 410
 	$aprs_last_tx = time();
327
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
328
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
329
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
330
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
331
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
332
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
333
-	if ($aprs_full) $aprs_filter = '';
334
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
335
-	else $aprs_pass = '-1';
411
+	if (isset($globalAPRSversion)) {
412
+		$aprs_version = $globalAPRSversion;
413
+	} else {
414
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
415
+	}
416
+	if (isset($globalAPRSssid)) {
417
+		$aprs_ssid = $globalAPRSssid;
418
+	} else {
419
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
420
+	}
421
+	if (isset($globalAPRSfilter)) {
422
+		$aprs_filter = $globalAPRSfilter;
423
+	} else {
424
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
425
+	}
426
+	if ($aprs_full) {
427
+		$aprs_filter = '';
428
+	}
429
+	if (isset($globalAPRSpass)) {
430
+		$aprs_pass = $globalAPRSpass;
431
+	} else {
432
+		$aprs_pass = '-1';
433
+	}
336 434
 
337
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
338
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
339
-}
435
+	if ($aprs_filter != '') {
436
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
437
+	} else {
438
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
439
+	}
440
+	}
340 441
 
341 442
 // connected - lets do some work
342
-if ($globalDebug) echo "Connected!\n";
443
+if ($globalDebug) {
444
+	echo "Connected!\n";
445
+}
343 446
 sleep(1);
344
-if ($globalDebug) echo "SCAN MODE \n\n";
345
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
447
+if ($globalDebug) {
448
+	echo "SCAN MODE \n\n";
449
+}
450
+if (!isset($globalCronEnd)) {
451
+	$globalCronEnd = 60;
452
+}
346 453
 $endtime = time()+$globalCronEnd;
347 454
 $i = 1;
348 455
 $tt = array();
@@ -356,20 +463,28 @@  discard block
 block discarded – undo
356 463
 
357 464
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
358 465
 while ($i > 0) {
359
-    if (!$globalDaemon) $i = $endtime-time();
466
+    if (!$globalDaemon) {
467
+    	$i = $endtime-time();
468
+    }
360 469
     // Delete old ATC
361 470
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
362
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
471
+	if ($globalDebug) {
472
+		echo 'Delete old ATC...'."\n";
473
+	}
363 474
         $ATC->deleteOldATC();
364 475
     }
365 476
     
366 477
     if (count($last_exec) == count($globalSources)) {
367 478
 	$max = $globalMinFetch;
368 479
 	foreach ($last_exec as $last) {
369
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
480
+	    if ((time() - $last['last']) < $max) {
481
+	    	$max = time() - $last['last'];
482
+	    }
370 483
 	}
371 484
 	if ($max != $globalMinFetch) {
372
-	    if ($globalDebug) echo 'Sleeping...'."\n";
485
+	    if ($globalDebug) {
486
+	    	echo 'Sleeping...'."\n";
487
+	    }
373 488
 	    sleep($globalMinFetch-$max+2);
374 489
 	}
375 490
     }
@@ -379,7 +494,9 @@  discard block
 block discarded – undo
379 494
     foreach ($globalSources as $id => $value) {
380 495
 	date_default_timezone_set('UTC');
381 496
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
382
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
497
+	if (!isset($last_exec[$id]['last'])) {
498
+		$last_exec[$id]['last'] = 0;
499
+	}
383 500
 	if ($value['format'] == 'deltadbtxt' && 
384 501
 	    (
385 502
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -388,7 +505,9 @@  discard block
 block discarded – undo
388 505
 	) {
389 506
 	    //$buffer = $Common->getData($hosts[$id]);
390 507
 	    $buffer = $Common->getData($value['host']);
391
-	    if ($buffer != '') $reset = 0;
508
+	    if ($buffer != '') {
509
+	    	$reset = 0;
510
+	    }
392 511
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
393 512
 	    $buffer = explode('\n',$buffer);
394 513
 	    foreach ($buffer as $line) {
@@ -397,20 +516,41 @@  discard block
 block discarded – undo
397 516
 	            $data = array();
398 517
 	            $data['hex'] = $line[1]; // hex
399 518
 	            $data['ident'] = $line[2]; // ident
400
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
401
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
402
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
403
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
404
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
519
+	            if (isset($line[3])) {
520
+	            	$data['altitude'] = $line[3];
521
+	            }
522
+	            // altitude
523
+	            if (isset($line[4])) {
524
+	            	$data['speed'] = $line[4];
525
+	            }
526
+	            // speed
527
+	            if (isset($line[5])) {
528
+	            	$data['heading'] = $line[5];
529
+	            }
530
+	            // heading
531
+	            if (isset($line[6])) {
532
+	            	$data['latitude'] = $line[6];
533
+	            }
534
+	            // lat
535
+	            if (isset($line[7])) {
536
+	            	$data['longitude'] = $line[7];
537
+	            }
538
+	            // long
405 539
 	            $data['verticalrate'] = ''; // vertical rate
406 540
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
407 541
 	            $data['emergency'] = ''; // emergency
408 542
 		    $data['datetime'] = date('Y-m-d H:i:s');
409 543
 		    $data['format_source'] = 'deltadbtxt';
410 544
     		    $data['id_source'] = $id_source;
411
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
412
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
413
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
545
+		    if (isset($value['name']) && $value['name'] != '') {
546
+		    	$data['source_name'] = $value['name'];
547
+		    }
548
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
549
+		    	$data['noarchive'] = true;
550
+		    }
551
+		    if (isset($value['sourcestats'])) {
552
+		    	$data['sourcestats'] = $value['sourcestats'];
553
+		    }
414 554
     		    $SI->add($data);
415 555
 		    unset($data);
416 556
     		}
@@ -425,7 +565,9 @@  discard block
 block discarded – undo
425 565
 	    date_default_timezone_set('CET');
426 566
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
427 567
 	    date_default_timezone_set('UTC');
428
-	    if ($buffer != '') $reset = 0;
568
+	    if ($buffer != '') {
569
+	    	$reset = 0;
570
+	    }
429 571
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430 572
 	    $buffer = explode('\n',$buffer);
431 573
 	    foreach ($buffer as $line) {
@@ -434,16 +576,36 @@  discard block
 block discarded – undo
434 576
 		    $add = false;
435 577
 		    $ais_data = $AIS->parse_line(trim($line));
436 578
 		    $data = array();
437
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
438
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
439
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
440
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
441
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
442
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
443
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
444
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
445
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
446
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
579
+		    if (isset($ais_data['ident'])) {
580
+		    	$data['ident'] = $ais_data['ident'];
581
+		    }
582
+		    if (isset($ais_data['mmsi'])) {
583
+		    	$data['mmsi'] = $ais_data['mmsi'];
584
+		    }
585
+		    if (isset($ais_data['speed'])) {
586
+		    	$data['speed'] = $ais_data['speed'];
587
+		    }
588
+		    if (isset($ais_data['heading'])) {
589
+		    	$data['heading'] = $ais_data['heading'];
590
+		    }
591
+		    if (isset($ais_data['latitude'])) {
592
+		    	$data['latitude'] = $ais_data['latitude'];
593
+		    }
594
+		    if (isset($ais_data['longitude'])) {
595
+		    	$data['longitude'] = $ais_data['longitude'];
596
+		    }
597
+		    if (isset($ais_data['status'])) {
598
+		    	$data['status'] = $ais_data['status'];
599
+		    }
600
+		    if (isset($ais_data['type'])) {
601
+		    	$data['type'] = $ais_data['type'];
602
+		    }
603
+		    if (isset($ais_data['imo'])) {
604
+		    	$data['imo'] = $ais_data['imo'];
605
+		    }
606
+		    if (isset($ais_data['callsign'])) {
607
+		    	$data['callsign'] = $ais_data['callsign'];
608
+		    }
447 609
 		    if (isset($ais_data['timestamp'])) {
448 610
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
449 611
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -457,8 +619,12 @@  discard block
 block discarded – undo
457 619
 		    $data['format_source'] = 'aisnmeatxt';
458 620
     		    $data['id_source'] = $id_source;
459 621
 		    //print_r($data);
460
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
461
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
622
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
623
+		    	$data['noarchive'] = true;
624
+		    }
625
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
626
+		    	$MI->add($data);
627
+		    }
462 628
 		    unset($data);
463 629
 		}
464 630
     	    }
@@ -478,20 +644,48 @@  discard block
 block discarded – undo
478 644
 			    if ($line != '') {
479 645
 				$ais_data = $AIS->parse_line(trim($line));
480 646
 				$data = array();
481
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
482
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
483
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
484
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
485
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
486
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
487
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
488
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
489
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
490
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
491
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
492
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
493
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
494
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
647
+				if (isset($ais_data['ident'])) {
648
+					$data['ident'] = $ais_data['ident'];
649
+				}
650
+				if (isset($ais_data['mmsi'])) {
651
+					$data['mmsi'] = $ais_data['mmsi'];
652
+				}
653
+				if (isset($ais_data['speed'])) {
654
+					$data['speed'] = $ais_data['speed'];
655
+				}
656
+				if (isset($ais_data['heading'])) {
657
+					$data['heading'] = $ais_data['heading'];
658
+				}
659
+				if (isset($ais_data['latitude'])) {
660
+					$data['latitude'] = $ais_data['latitude'];
661
+				}
662
+				if (isset($ais_data['longitude'])) {
663
+					$data['longitude'] = $ais_data['longitude'];
664
+				}
665
+				if (isset($ais_data['status'])) {
666
+					$data['status'] = $ais_data['status'];
667
+				}
668
+				if (isset($ais_data['statusid'])) {
669
+					$data['status_id'] = $ais_data['statusid'];
670
+				}
671
+				if (isset($ais_data['type'])) {
672
+					$data['type'] = $ais_data['type'];
673
+				}
674
+				if (isset($ais_data['typeid'])) {
675
+					$data['type_id'] = $ais_data['typeid'];
676
+				}
677
+				if (isset($ais_data['imo'])) {
678
+					$data['imo'] = $ais_data['imo'];
679
+				}
680
+				if (isset($ais_data['callsign'])) {
681
+					$data['callsign'] = $ais_data['callsign'];
682
+				}
683
+				if (isset($ais_data['destination'])) {
684
+					$data['arrival_code'] = $ais_data['destination'];
685
+				}
686
+				if (isset($ais_data['eta_ts'])) {
687
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
688
+				}
495 689
 				if (isset($ais_data['timestamp'])) {
496 690
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
497 691
 				} else {
@@ -499,18 +693,27 @@  discard block
 block discarded – undo
499 693
 				}
500 694
 				$data['format_source'] = 'aisnmeahttp';
501 695
 				$data['id_source'] = $id_source;
502
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
503
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
696
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
697
+					$data['noarchive'] = true;
698
+				}
699
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
700
+					$MI->add($data);
701
+				}
504 702
 				unset($data);
505 703
 			    }
506 704
 			}
507 705
 		    }
508 706
 		} else {
509 707
 		    $format = $value['format'];
510
-		    if (isset($tt[$format])) $tt[$format]++;
511
-		    else $tt[$format] = 0;
708
+		    if (isset($tt[$format])) {
709
+		    	$tt[$format]++;
710
+		    } else {
711
+		    	$tt[$format] = 0;
712
+		    }
512 713
 		    if ($tt[$format] > 30) {
513
-			if ($globalDebug) echo 'Reconnect...'."\n";
714
+			if ($globalDebug) {
715
+				echo 'Reconnect...'."\n";
716
+			}
514 717
 			sleep(2);
515 718
 			$sourceeen[] = $value;
516 719
 			connect_all($sourceeen);
@@ -545,7 +748,9 @@  discard block
 block discarded – undo
545 748
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
546 749
 			    $data['format_source'] = 'myshiptracking';
547 750
 			    $data['id_source'] = $id_source;
548
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
751
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
752
+			    	$data['noarchive'] = true;
753
+			    }
549 754
 			    $MI->add($data);
550 755
 			    unset($data);
551 756
 			}
@@ -570,7 +775,9 @@  discard block
 block discarded – undo
570 775
 			    $data['callsign'] = $line['callsign'];
571 776
 			    $data['mmsi'] = $line['mmsi'];
572 777
 			    $data['speed'] = $line['sog'];
573
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
778
+			    if ($line['heading'] != '511') {
779
+			    	$data['heading'] = $line['heading'];
780
+			    }
574 781
 			    $data['latitude'] = $line['latitude'];
575 782
 			    $data['longitude'] = $line['longitude'];
576 783
 			    $data['type_id'] = $line['shiptype'];
@@ -578,7 +785,9 @@  discard block
 block discarded – undo
578 785
 			    $data['datetime'] = $line['time'];
579 786
 			    $data['format_source'] = 'boatbeaconapp';
580 787
 			    $data['id_source'] = $id_source;
581
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
788
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
789
+			    	$data['noarchive'] = true;
790
+			    }
582 791
 			    $MI->add($data);
583 792
 			    unset($data);
584 793
 			}
@@ -599,22 +808,44 @@  discard block
 block discarded – undo
599 808
 		if (isset($all_data['features'][0]['id'])) {
600 809
 		    foreach ($all_data['features'] as $line) {
601 810
 			$data = array();
602
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
603
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
604
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
605
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
606
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
607
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
811
+			if (isset($line['properties']['name'])) {
812
+				$data['ident'] = $line['properties']['name'];
813
+			}
814
+			if (isset($line['properties']['callsign'])) {
815
+				$data['callsign'] = $line['properties']['callsign'];
816
+			}
817
+			if (isset($line['properties']['mmsi'])) {
818
+				$data['mmsi'] = $line['properties']['mmsi'];
819
+			}
820
+			if (isset($line['properties']['imo'])) {
821
+				$data['mmsi'] = $line['properties']['imo'];
822
+			}
823
+			if (isset($line['properties']['speed'])) {
824
+				$data['speed'] = $line['properties']['speed'];
825
+			}
826
+			if (isset($line['properties']['heading'])) {
827
+				$data['heading'] = $line['properties']['heading'];
828
+			}
608 829
 			$data['latitude'] = $line['geometry']['coordinates'][1];
609 830
 			$data['longitude'] = $line['geometry']['coordinates'][0];
610
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
611
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
612
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
831
+			if (isset($line['properties']['vesselType'])) {
832
+				$data['type'] = $line['properties']['vesselType'];
833
+			}
834
+			if (isset($line['properties']['destination'])) {
835
+				$data['arrival_code'] = $line['properties']['destination'];
836
+			}
837
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
838
+				$data['arrival_date'] = $line['properties']['eta'];
839
+			}
613 840
 			$data['format_source'] = 'boatnerd';
614 841
 			$data['id_source'] = $id_source;
615 842
 			$data['datetime'] = date('Y-m-d H:i:s');
616
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
617
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
843
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
844
+				$data['noarchive'] = true;
845
+			}
846
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
847
+				$MI->add($data);
848
+			}
618 849
 			unset($data);
619 850
 		    }
620 851
 		}
@@ -630,7 +861,9 @@  discard block
 block discarded – undo
630 861
 	    echo 'download...';
631 862
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
632 863
 	    echo 'done !'."\n";
633
-	    if ($buffer != '') $reset = 0;
864
+	    if ($buffer != '') {
865
+	    	$reset = 0;
866
+	    }
634 867
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
635 868
 	    $buffer = explode('\n',$buffer);
636 869
 	    foreach ($buffer as $line) {
@@ -655,7 +888,9 @@  discard block
 block discarded – undo
655 888
 		    //$data['etaTime'] = substr($line,135,5);
656 889
 		    $data['format_source'] = 'shipplotter';
657 890
     		    $data['id_source'] = $id_source;
658
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
891
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
892
+		    	$data['noarchive'] = true;
893
+		    }
659 894
 		    //print_r($data);
660 895
 		    echo 'Add...'."\n";
661 896
 		    $MI->add($data);
@@ -689,16 +924,28 @@  discard block
 block discarded – undo
689 924
     		    $line = explode(':', $line);
690 925
     		    if (count($line) > 30 && $line[0] != 'callsign') {
691 926
 			$data = array();
692
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
693
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
927
+			if (isset($line[37]) && $line[37] != '') {
928
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
929
+			} else {
930
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
931
+			}
694 932
 			$data['pilot_id'] = $line[1];
695 933
 			$data['pilot_name'] = $line[2];
696 934
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
697 935
 			$data['ident'] = $line[0]; // ident
698
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
936
+			if ($line[7] != '' && $line[7] != 0) {
937
+				$data['altitude'] = $line[7];
938
+			}
939
+			// altitude
699 940
 			$data['speed'] = $line[8]; // speed
700
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
701
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
941
+			if (isset($line[45])) {
942
+				$data['heading'] = $line[45];
943
+			}
944
+			// heading
945
+			elseif (isset($line[38])) {
946
+				$data['heading'] = $line[38];
947
+			}
948
+			// heading
702 949
 			$data['latitude'] = $line[5]; // lat
703 950
 	        	$data['longitude'] = $line[6]; // long
704 951
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -714,7 +961,9 @@  discard block
 block discarded – undo
714 961
 			$data['frequency'] = $line[4];
715 962
 			$data['type'] = $line[18];
716 963
 			$data['range'] = $line[19];
717
-			if (isset($line[35])) $data['info'] = $line[35];
964
+			if (isset($line[35])) {
965
+				$data['info'] = $line[35];
966
+			}
718 967
     			$data['id_source'] = $id_source;
719 968
 	    		//$data['arrival_airport_time'] = ;
720 969
 	    		if ($line[9] != '') {
@@ -728,27 +977,47 @@  discard block
 block discarded – undo
728 977
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
729 978
 	    		*/
730 979
 	    		$data['format_source'] = $value['format'];
731
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
732
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
733
-    			if ($line[3] == 'PILOT') $SI->add($data);
734
-			elseif ($line[3] == 'ATC') {
980
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
981
+				$data['noarchive'] = true;
982
+			}
983
+			if (isset($value['name']) && $value['name'] != '') {
984
+				$data['source_name'] = $value['name'];
985
+			}
986
+    			if ($line[3] == 'PILOT') {
987
+    				$SI->add($data);
988
+    			} elseif ($line[3] == 'ATC') {
735 989
 				//print_r($data);
736 990
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
737 991
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
738 992
 				$typec = substr($data['ident'],-3);
739
-				if ($typec == 'APP') $data['type'] = 'Approach';
740
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
741
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
742
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
743
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
744
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
745
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
746
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
747
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
748
-				if (!isset($data['source_name'])) $data['source_name'] = '';
993
+				if ($typec == 'APP') {
994
+					$data['type'] = 'Approach';
995
+				} elseif ($typec == 'TWR') {
996
+					$data['type'] = 'Tower';
997
+				} elseif ($typec == 'OBS') {
998
+					$data['type'] = 'Observer';
999
+				} elseif ($typec == 'GND') {
1000
+					$data['type'] = 'Ground';
1001
+				} elseif ($typec == 'DEL') {
1002
+					$data['type'] = 'Delivery';
1003
+				} elseif ($typec == 'DEP') {
1004
+					$data['type'] = 'Departure';
1005
+				} elseif ($typec == 'FSS') {
1006
+					$data['type'] = 'Flight Service Station';
1007
+				} elseif ($typec == 'CTR') {
1008
+					$data['type'] = 'Control Radar or Centre';
1009
+				} elseif ($data['type'] == '') {
1010
+					$data['type'] = 'Observer';
1011
+				}
1012
+				if (!isset($data['source_name'])) {
1013
+					$data['source_name'] = '';
1014
+				}
749 1015
 				if (isset($ATC)) {
750
-					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']);
751
-					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']);
1016
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1017
+						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']);
1018
+					} else {
1019
+						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']);
1020
+					}
752 1021
 				}
753 1022
 			}
754 1023
     			unset($data);
@@ -775,14 +1044,20 @@  discard block
 block discarded – undo
775 1044
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
776 1045
 			$data['latitude'] = (float)$line['pktLatitude'];
777 1046
 			$data['longitude'] = (float)$line['pktLongitude'];
778
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
779
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1047
+			if ((float)$line['pktTrack'] != 0) {
1048
+				$data['heading'] = (float)$line['pktTrack'];
1049
+			}
1050
+			if ((int)$line['pktSpeed'] != 0) {
1051
+				$data['speed'] = (int)$line['pktSpeed'];
1052
+			}
780 1053
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
781 1054
 			$data['altitude_relative'] = 'AMSL';
782 1055
 			$data['pilot_id'] = (int)$line['pktPilotID'];
783 1056
 			$data['aircraft_icao'] = 'PARAGLIDER';
784 1057
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
785
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1058
+			if (isset($pilot_data[4])) {
1059
+				$data['pilot_name'] = $pilot_data[4];
1060
+			}
786 1061
 			$data['format_source'] = $value['format'];
787 1062
 			$SI->add($data);
788 1063
 			unset($data);
@@ -830,25 +1105,59 @@  discard block
 block discarded – undo
830 1105
 		    foreach ($all_data['acList'] as $line) {
831 1106
 			$data = array();
832 1107
 			$data['hex'] = $line['Icao']; // hex
833
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
834
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
835
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
836
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
837
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
838
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1108
+			if (isset($line['Call'])) {
1109
+				$data['ident'] = $line['Call'];
1110
+			}
1111
+			// ident
1112
+			if (isset($line['Alt'])) {
1113
+				$data['altitude'] = $line['Alt'];
1114
+			}
1115
+			// altitude
1116
+			if (isset($line['Spd'])) {
1117
+				$data['speed'] = $line['Spd'];
1118
+			}
1119
+			// speed
1120
+			if (isset($line['Trak'])) {
1121
+				$data['heading'] = $line['Trak'];
1122
+			}
1123
+			// heading
1124
+			if (isset($line['Lat'])) {
1125
+				$data['latitude'] = $line['Lat'];
1126
+			}
1127
+			// lat
1128
+			if (isset($line['Long'])) {
1129
+				$data['longitude'] = $line['Long'];
1130
+			}
1131
+			// long
839 1132
 			//$data['verticalrate'] = $line['']; // verticale rate
840
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1133
+			if (isset($line['Sqk'])) {
1134
+				$data['squawk'] = $line['Sqk'];
1135
+			}
1136
+			// squawk
841 1137
 			$data['emergency'] = ''; // emergency
842
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
843
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
844
-			else $data['datetime'] = date('Y-m-d H:i:s');
1138
+			if (isset($line['Reg'])) {
1139
+				$data['registration'] = $line['Reg'];
1140
+			}
1141
+			if (isset($line['PosTime'])) {
1142
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1143
+			} else {
1144
+				$data['datetime'] = date('Y-m-d H:i:s');
1145
+			}
845 1146
 			//$data['datetime'] = date('Y-m-d H:i:s');
846
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1147
+			if (isset($line['Type'])) {
1148
+				$data['aircraft_icao'] = $line['Type'];
1149
+			}
847 1150
 			$data['format_source'] = 'aircraftlistjson';
848 1151
 			$data['id_source'] = $id_source;
849
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
850
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
851
-			if (isset($data['latitude'])) $SI->add($data);
1152
+			if (isset($value['name']) && $value['name'] != '') {
1153
+				$data['source_name'] = $value['name'];
1154
+			}
1155
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1156
+				$data['noarchive'] = true;
1157
+			}
1158
+			if (isset($data['latitude'])) {
1159
+				$SI->add($data);
1160
+			}
852 1161
 			unset($data);
853 1162
 		    }
854 1163
 		} elseif (is_array($all_data)) {
@@ -865,17 +1174,26 @@  discard block
 block discarded – undo
865 1174
 			$data['verticalrate'] = $line['vrt']; // verticale rate
866 1175
 			$data['squawk'] = $line['squawk']; // squawk
867 1176
 			$data['emergency'] = ''; // emergency
868
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
869
-			else $data['datetime'] = date('Y-m-d H:i:s');
1177
+			if (isset($line['PosTime'])) {
1178
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1179
+			} else {
1180
+				$data['datetime'] = date('Y-m-d H:i:s');
1181
+			}
870 1182
 			$data['format_source'] = 'aircraftlistjson';
871 1183
 			$data['id_source'] = $id_source;
872
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
873
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1184
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1185
+				$data['noarchive'] = true;
1186
+			}
1187
+			if (isset($value['name']) && $value['name'] != '') {
1188
+				$data['source_name'] = $value['name'];
1189
+			}
874 1190
 			$SI->add($data);
875 1191
 			unset($data);
876 1192
 		    }
877 1193
 		}
878
-	    } elseif ($globalDebug) echo 'No data'."\n";
1194
+	    } elseif ($globalDebug) {
1195
+	    	echo 'No data'."\n";
1196
+	    }
879 1197
     	    //$last_exec['aircraftlistjson'] = time();
880 1198
     	    $last_exec[$id]['last'] = time();
881 1199
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -911,8 +1229,12 @@  discard block
 block discarded – undo
911 1229
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
912 1230
 	    	    $data['format_source'] = 'planeupdatefaa';
913 1231
     		    $data['id_source'] = $id_source;
914
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
915
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1232
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1233
+		    	$data['noarchive'] = true;
1234
+		    }
1235
+		    if (isset($value['name']) && $value['name'] != '') {
1236
+		    	$data['source_name'] = $value['name'];
1237
+		    }
916 1238
 		    $SI->add($data);
917 1239
 		    unset($data);
918 1240
 		}
@@ -946,7 +1268,9 @@  discard block
 block discarded – undo
946 1268
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
947 1269
 		    $data['format_source'] = 'opensky';
948 1270
 		    $data['id_source'] = $id_source;
949
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1271
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1272
+		    	$data['noarchive'] = true;
1273
+		    }
950 1274
 		    $SI->add($data);
951 1275
 		    unset($data);
952 1276
 		}
@@ -963,7 +1287,9 @@  discard block
 block discarded – undo
963 1287
 	    //$buffer = $Common->getData($hosts[$id]);
964 1288
 	    $buffer = $Common->getData($value['host']);
965 1289
 	    $all_data = json_decode($buffer,true);
966
-	    if (!empty($all_data)) $reset = 0;
1290
+	    if (!empty($all_data)) {
1291
+	    	$reset = 0;
1292
+	    }
967 1293
 	    foreach ($all_data as $key => $line) {
968 1294
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
969 1295
 		    $data = array();
@@ -984,8 +1310,12 @@  discard block
 block discarded – undo
984 1310
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
985 1311
 	    	    $data['format_source'] = 'fr24json';
986 1312
     		    $data['id_source'] = $id_source;
987
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
988
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1313
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1314
+		    	$data['noarchive'] = true;
1315
+		    }
1316
+		    if (isset($value['name']) && $value['name'] != '') {
1317
+		    	$data['source_name'] = $value['name'];
1318
+		    }
989 1319
 		    $SI->add($data);
990 1320
 		    unset($data);
991 1321
 		}
@@ -1014,24 +1344,42 @@  discard block
 block discarded – undo
1014 1344
 		    if (isset($line['inf'])) {
1015 1345
 			$data = array();
1016 1346
 			$data['hex'] = $line['inf']['ia'];
1017
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1347
+			if (isset($line['inf']['cs'])) {
1348
+				$data['ident'] = $line['inf']['cs'];
1349
+			}
1350
+			//$line[13]
1018 1351
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1019
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1020
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1352
+	    		if (isset($line['inf']['gs'])) {
1353
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1354
+	    		}
1355
+	    		// speed
1356
+	    		if (isset($line['inf']['tr'])) {
1357
+	    			$data['heading'] = $line['inf']['tr'];
1358
+	    		}
1359
+	    		// heading
1021 1360
 	    		$data['latitude'] = $line['pt'][0]; // lat
1022 1361
 	    		$data['longitude'] = $line['pt'][1]; // long
1023 1362
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1024
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1363
+	    		if (isset($line['inf']['sq'])) {
1364
+	    			$data['squawk'] = $line['inf']['sq'];
1365
+	    		}
1366
+	    		// squawk
1025 1367
 	    		//$data['aircraft_icao'] = $line[8];
1026
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1368
+	    		if (isset($line['inf']['rc'])) {
1369
+	    			$data['registration'] = $line['inf']['rc'];
1370
+	    		}
1027 1371
 			//$data['departure_airport_iata'] = $line[11];
1028 1372
 			//$data['arrival_airport_iata'] = $line[12];
1029 1373
 	    		//$data['emergency'] = ''; // emergency
1030 1374
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1031 1375
 	    		$data['format_source'] = 'radarvirtueljson';
1032 1376
     			$data['id_source'] = $id_source;
1033
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1034
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1377
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1378
+				$data['noarchive'] = true;
1379
+			}
1380
+			if (isset($value['name']) && $value['name'] != '') {
1381
+				$data['source_name'] = $value['name'];
1382
+			}
1035 1383
 			$SI->add($data);
1036 1384
 			unset($data);
1037 1385
 		    }
@@ -1057,30 +1405,65 @@  discard block
 block discarded – undo
1057 1405
 		    $data['id'] = $line['id'];
1058 1406
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1059 1407
 		    $data['ident'] = $line['callsign']; // ident
1060
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1061
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1062
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1063
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1064
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1065
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1408
+		    if (isset($line['pilotid'])) {
1409
+		    	$data['pilot_id'] = $line['pilotid'];
1410
+		    }
1411
+		    // pilot id
1412
+		    if (isset($line['name'])) {
1413
+		    	$data['pilot_name'] = $line['name'];
1414
+		    }
1415
+		    // pilot name
1416
+		    if (isset($line['alt'])) {
1417
+		    	$data['altitude'] = $line['alt'];
1418
+		    }
1419
+		    // altitude
1420
+		    if (isset($line['gs'])) {
1421
+		    	$data['speed'] = $line['gs'];
1422
+		    }
1423
+		    // speed
1424
+		    if (isset($line['heading'])) {
1425
+		    	$data['heading'] = $line['heading'];
1426
+		    }
1427
+		    // heading
1428
+		    if (isset($line['route'])) {
1429
+		    	$data['waypoints'] = $line['route'];
1430
+		    }
1431
+		    // route
1066 1432
 		    $data['latitude'] = $line['lat']; // lat
1067 1433
 		    $data['longitude'] = $line['lon']; // long
1068 1434
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1069 1435
 		    //$data['squawk'] = $line['squawk']; // squawk
1070 1436
 		    //$data['emergency'] = ''; // emergency
1071
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1072
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1073
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1437
+		    if (isset($line['depicao'])) {
1438
+		    	$data['departure_airport_icao'] = $line['depicao'];
1439
+		    }
1440
+		    if (isset($line['deptime'])) {
1441
+		    	$data['departure_airport_time'] = $line['deptime'];
1442
+		    }
1443
+		    if (isset($line['arricao'])) {
1444
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1445
+		    }
1074 1446
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1075
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1076
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1077
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1078
-		    else $data['info'] = '';
1447
+		    if (isset($line['aircraft'])) {
1448
+		    	$data['aircraft_icao'] = $line['aircraft'];
1449
+		    }
1450
+		    if (isset($line['transponder'])) {
1451
+		    	$data['squawk'] = $line['transponder'];
1452
+		    }
1453
+		    if (isset($line['atis'])) {
1454
+		    	$data['info'] = $line['atis'];
1455
+		    } else {
1456
+		    	$data['info'] = '';
1457
+		    }
1079 1458
 		    $data['format_source'] = 'pireps';
1080 1459
     		    $data['id_source'] = $id_source;
1081 1460
 		    $data['datetime'] = date('Y-m-d H:i:s');
1082
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1083
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1461
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1462
+		    	$data['noarchive'] = true;
1463
+		    }
1464
+		    if (isset($value['name']) && $value['name'] != '') {
1465
+		    	$data['source_name'] = $value['name'];
1466
+		    }
1084 1467
 		    if ($line['icon'] == 'plane') {
1085 1468
 			$SI->add($data);
1086 1469
 		    //    print_r($data);
@@ -1089,16 +1472,28 @@  discard block
 block discarded – undo
1089 1472
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1090 1473
 			$typec = substr($data['ident'],-3);
1091 1474
 			$data['type'] = '';
1092
-			if ($typec == 'APP') $data['type'] = 'Approach';
1093
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
1094
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
1095
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
1096
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
1097
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
1098
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1099
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1100
-			else $data['type'] = 'Observer';
1101
-			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']);
1475
+			if ($typec == 'APP') {
1476
+				$data['type'] = 'Approach';
1477
+			} elseif ($typec == 'TWR') {
1478
+				$data['type'] = 'Tower';
1479
+			} elseif ($typec == 'OBS') {
1480
+				$data['type'] = 'Observer';
1481
+			} elseif ($typec == 'GND') {
1482
+				$data['type'] = 'Ground';
1483
+			} elseif ($typec == 'DEL') {
1484
+				$data['type'] = 'Delivery';
1485
+			} elseif ($typec == 'DEP') {
1486
+				$data['type'] = 'Departure';
1487
+			} elseif ($typec == 'FSS') {
1488
+				$data['type'] = 'Flight Service Station';
1489
+			} elseif ($typec == 'CTR') {
1490
+				$data['type'] = 'Control Radar or Centre';
1491
+			} else {
1492
+				$data['type'] = 'Observer';
1493
+			}
1494
+			if (isset($ATC)) {
1495
+				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']);
1496
+			}
1102 1497
 		    }
1103 1498
 		    unset($data);
1104 1499
 		}
@@ -1113,7 +1508,9 @@  discard block
 block discarded – undo
1113 1508
 	    )
1114 1509
 	) {
1115 1510
 	    //$buffer = $Common->getData($hosts[$id]);
1116
-	    if ($globalDebug) echo 'Get Data...'."\n";
1511
+	    if ($globalDebug) {
1512
+	    	echo 'Get Data...'."\n";
1513
+	    }
1117 1514
 	    $buffer = $Common->getData($value['host']);
1118 1515
 	    $all_data = json_decode($buffer,true);
1119 1516
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1121,10 +1518,16 @@  discard block
 block discarded – undo
1121 1518
 		foreach ($all_data as $line) {
1122 1519
 	    	    $data = array();
1123 1520
 	    	    //$data['id'] = $line['id']; // id not usable
1124
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1521
+	    	    if (isset($line['pilotid'])) {
1522
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1523
+	    	    }
1125 1524
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1126
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1127
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1525
+	    	    if (isset($line['pilotname'])) {
1526
+	    	    	$data['pilot_name'] = $line['pilotname'];
1527
+	    	    }
1528
+	    	    if (isset($line['pilotid'])) {
1529
+	    	    	$data['pilot_id'] = $line['pilotid'];
1530
+	    	    }
1128 1531
 	    	    $data['ident'] = $line['flightnum']; // ident
1129 1532
 	    	    $data['altitude'] = $line['alt']; // altitude
1130 1533
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1140,34 +1543,52 @@  discard block
 block discarded – undo
1140 1543
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1141 1544
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1142 1545
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1143
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1546
+	    	    } else {
1547
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1548
+	    	    }
1144 1549
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1145 1550
 	    	    $data['departure_airport_time'] = $line['deptime'];
1146 1551
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
1147 1552
     		    $data['arrival_airport_time'] = $line['arrtime'];
1148 1553
     		    $data['registration'] = $line['aircraft'];
1149
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1150
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1554
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1555
+		    	$data['noarchive'] = true;
1556
+		    }
1557
+		    if (isset($line['route'])) {
1558
+		    	$data['waypoints'] = $line['route'];
1559
+		    }
1560
+		    // route
1151 1561
 		    if (isset($line['aircraftname'])) {
1152 1562
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1153 1563
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1154 1564
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1155
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1156
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1157
-	    		else {
1565
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1566
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1567
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1568
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1569
+	    		} else {
1158 1570
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1159
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1160
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1571
+	    		    if (isset($aircraft_data[1])) {
1572
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1573
+	    		    } else {
1574
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1575
+	    		    }
1161 1576
 	    		}
1162 1577
 	    	    }
1163
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1578
+    		    if (isset($line['route'])) {
1579
+    		    	$data['waypoints'] = $line['route'];
1580
+    		    }
1164 1581
     		    $data['id_source'] = $id_source;
1165 1582
 	    	    $data['format_source'] = 'phpvmacars';
1166
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1583
+		    if (isset($value['name']) && $value['name'] != '') {
1584
+		    	$data['source_name'] = $value['name'];
1585
+		    }
1167 1586
 		    $SI->add($data);
1168 1587
 		    unset($data);
1169 1588
 		}
1170
-		if ($globalDebug) echo 'No more data...'."\n";
1589
+		if ($globalDebug) {
1590
+			echo 'No more data...'."\n";
1591
+		}
1171 1592
 		unset($buffer);
1172 1593
 		unset($all_data);
1173 1594
 	    }
@@ -1180,7 +1601,9 @@  discard block
 block discarded – undo
1180 1601
 	    )
1181 1602
 	) {
1182 1603
 	    //$buffer = $Common->getData($hosts[$id]);
1183
-	    if ($globalDebug) echo 'Get Data...'."\n";
1604
+	    if ($globalDebug) {
1605
+	    	echo 'Get Data...'."\n";
1606
+	    }
1184 1607
 	    $buffer = $Common->getData($value['host']);
1185 1608
 	    $all_data = json_decode($buffer,true);
1186 1609
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1209,16 +1632,25 @@  discard block
 block discarded – undo
1209 1632
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1210 1633
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1211 1634
     		    //$data['registration'] = $line['aircraft'];
1212
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1635
+		    if (isset($line['route'])) {
1636
+		    	$data['waypoints'] = $line['route'];
1637
+		    }
1638
+		    // route
1213 1639
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1214 1640
     		    $data['id_source'] = $id_source;
1215 1641
 	    	    $data['format_source'] = 'vam';
1216
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1217
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1642
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1643
+		    	$data['noarchive'] = true;
1644
+		    }
1645
+		    if (isset($value['name']) && $value['name'] != '') {
1646
+		    	$data['source_name'] = $value['name'];
1647
+		    }
1218 1648
 		    $SI->add($data);
1219 1649
 		    unset($data);
1220 1650
 		}
1221
-		if ($globalDebug) echo 'No more data...'."\n";
1651
+		if ($globalDebug) {
1652
+			echo 'No more data...'."\n";
1653
+		}
1222 1654
 		unset($buffer);
1223 1655
 		unset($all_data);
1224 1656
 	    }
@@ -1231,7 +1663,9 @@  discard block
 block discarded – undo
1231 1663
 	    )
1232 1664
 	) {
1233 1665
 	    //$buffer = $Common->getData($hosts[$id]);
1234
-	    if ($globalDebug) echo 'Get Data...'."\n";
1666
+	    if ($globalDebug) {
1667
+	    	echo 'Get Data...'."\n";
1668
+	    }
1235 1669
 	    $buffer = $Common->getData($value['host']);
1236 1670
 	    $all_data = json_decode($buffer,true);
1237 1671
 	    if ($buffer != '') {
@@ -1249,18 +1683,24 @@  discard block
 block discarded – undo
1249 1683
 			$data['id_source'] = $id_source;
1250 1684
 			$data['format_source'] = 'blitzortung';
1251 1685
 			$SI->add($data);
1252
-			if ($globalDebug) echo '☈ Lightning added'."\n";
1686
+			if ($globalDebug) {
1687
+				echo '☈ Lightning added'."\n";
1688
+			}
1253 1689
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1254 1690
 			unset($data);
1255 1691
 		    }
1256 1692
 		}
1257
-		if ($globalDebug) echo 'No more data...'."\n";
1693
+		if ($globalDebug) {
1694
+			echo 'No more data...'."\n";
1695
+		}
1258 1696
 		unset($buffer);
1259 1697
 	    }
1260 1698
 	    $last_exec[$id]['last'] = time();
1261 1699
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1262 1700
 	} 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') {
1263
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1701
+	    if (function_exists('pcntl_fork')) {
1702
+	    	pcntl_signal_dispatch();
1703
+	    }
1264 1704
     	    //$last_exec[$id]['last'] = time();
1265 1705
 
1266 1706
 	    //$read = array( $sockets[$id] );
@@ -1268,7 +1708,9 @@  discard block
 block discarded – undo
1268 1708
 	    $write = NULL;
1269 1709
 	    $e = NULL;
1270 1710
 	    $n = socket_select($read, $write, $e, $timeout);
1271
-	    if ($e != NULL) var_dump($e);
1711
+	    if ($e != NULL) {
1712
+	    	var_dump($e);
1713
+	    }
1272 1714
 	    if ($n > 0) {
1273 1715
 		$reset = 0;
1274 1716
 		foreach ($read as $nb => $r) {
@@ -1289,12 +1731,16 @@  discard block
 block discarded – undo
1289 1731
 		    //$SI::del();
1290 1732
 		    if ($format == 'vrstcp') {
1291 1733
 			$buffer = explode('},{',$buffer);
1292
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1734
+		    } else {
1735
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1736
+		    }
1293 1737
 		    // SBS format is CSV format
1294 1738
 		    if ($buffer !== FALSE && $buffer != '') {
1295 1739
 			$tt[$format] = 0;
1296 1740
 			if ($format == 'acarssbs3') {
1297
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1741
+			    if ($globalDebug) {
1742
+			    	echo 'ACARS : '.$buffer."\n";
1743
+			    }
1298 1744
 			    $ACARS->add(trim($buffer));
1299 1745
 			    $ACARS->deleteLiveAcarsData();
1300 1746
 			} elseif ($format == 'raw') {
@@ -1303,30 +1749,70 @@  discard block
 block discarded – undo
1303 1749
 			    if (is_array($data)) {
1304 1750
 				$data['datetime'] = date('Y-m-d H:i:s');
1305 1751
 				$data['format_source'] = 'raw';
1306
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1307
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1308
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1309
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1752
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1753
+					$data['source_name'] = $globalSources[$nb]['name'];
1754
+				}
1755
+				if (isset($globalSources[$nb]['sourcestats'])) {
1756
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1757
+				}
1758
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1759
+					$data['noarchive'] = true;
1760
+				}
1761
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1762
+					$SI->add($data);
1763
+				}
1310 1764
 			    }
1311 1765
 			} elseif ($format == 'ais') {
1312 1766
 			    $ais_data = $AIS->parse_line(trim($buffer));
1313 1767
 			    $data = array();
1314
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1315
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1316
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1317
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1318
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1319
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1320
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1321
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1322
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1323
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1324
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1325
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1326
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1327
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1328
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1329
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1768
+			    if (isset($ais_data['ident'])) {
1769
+			    	$data['ident'] = $ais_data['ident'];
1770
+			    }
1771
+			    if (isset($ais_data['mmsi'])) {
1772
+			    	$data['mmsi'] = $ais_data['mmsi'];
1773
+			    }
1774
+			    if (isset($ais_data['speed'])) {
1775
+			    	$data['speed'] = $ais_data['speed'];
1776
+			    }
1777
+			    if (isset($ais_data['heading'])) {
1778
+			    	$data['heading'] = $ais_data['heading'];
1779
+			    }
1780
+			    if (isset($ais_data['latitude'])) {
1781
+			    	$data['latitude'] = $ais_data['latitude'];
1782
+			    }
1783
+			    if (isset($ais_data['longitude'])) {
1784
+			    	$data['longitude'] = $ais_data['longitude'];
1785
+			    }
1786
+			    if (isset($ais_data['status'])) {
1787
+			    	$data['status'] = $ais_data['status'];
1788
+			    }
1789
+			    if (isset($ais_data['statusid'])) {
1790
+			    	$data['status_id'] = $ais_data['statusid'];
1791
+			    }
1792
+			    if (isset($ais_data['type'])) {
1793
+			    	$data['type'] = $ais_data['type'];
1794
+			    }
1795
+			    if (isset($ais_data['imo'])) {
1796
+			    	$data['imo'] = $ais_data['imo'];
1797
+			    }
1798
+			    if (isset($ais_data['callsign'])) {
1799
+			    	$data['callsign'] = $ais_data['callsign'];
1800
+			    }
1801
+			    if (isset($ais_data['destination'])) {
1802
+			    	$data['arrival_code'] = $ais_data['destination'];
1803
+			    }
1804
+			    if (isset($ais_data['eta_ts'])) {
1805
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1806
+			    }
1807
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1808
+			    	$data['noarchive'] = true;
1809
+			    }
1810
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1811
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1812
+			    }
1813
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1814
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1815
+			    }
1330 1816
 
1331 1817
 			    if (isset($ais_data['timestamp'])) {
1332 1818
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1335,7 +1821,9 @@  discard block
 block discarded – undo
1335 1821
 			    }
1336 1822
 			    $data['format_source'] = 'aisnmea';
1337 1823
     			    $data['id_source'] = $id_source;
1338
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1824
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1825
+			    	$MI->add($data);
1826
+			    }
1339 1827
 			    unset($data);
1340 1828
                         } elseif ($format == 'flightgearsp') {
1341 1829
                     	    //echo $buffer."\n";
@@ -1353,12 +1841,18 @@  discard block
 block discarded – undo
1353 1841
 				$data['speed'] = round($line[5]*1.94384);
1354 1842
 				$data['datetime'] = date('Y-m-d H:i:s');
1355 1843
 				$data['format_source'] = 'flightgearsp';
1356
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1357
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1844
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1845
+					$data['noarchive'] = true;
1846
+				}
1847
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1848
+					$SI->add($data);
1849
+				}
1358 1850
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1359 1851
 			    }
1360 1852
                         } elseif ($format == 'acars') {
1361
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1853
+                    	    if ($globalDebug) {
1854
+                    	    	echo 'ACARS : '.$buffer."\n";
1855
+                    	    }
1362 1856
 			    $ACARS->add(trim($buffer));
1363 1857
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1364 1858
 			    $ACARS->deleteLiveAcarsData();
@@ -1379,8 +1873,12 @@  discard block
 block discarded – undo
1379 1873
 				    $aircraft_type = $line[10];
1380 1874
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1381 1875
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1382
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1383
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1876
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1877
+				    	$data['noarchive'] = true;
1878
+				    }
1879
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1880
+				    	$SI->add($data);
1881
+				    }
1384 1882
 				}
1385 1883
 			    }
1386 1884
 			} elseif ($format == 'beast') {
@@ -1390,28 +1888,62 @@  discard block
 block discarded – undo
1390 1888
 			    foreach($buffer as $all_data) {
1391 1889
 				$line = json_decode('{'.$all_data.'}',true);
1392 1890
 				$data = array();
1393
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1394
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1395
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1396
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1397
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1398
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1399
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1891
+				if (isset($line['Icao'])) {
1892
+					$data['hex'] = $line['Icao'];
1893
+				}
1894
+				// hex
1895
+				if (isset($line['Call'])) {
1896
+					$data['ident'] = $line['Call'];
1897
+				}
1898
+				// ident
1899
+				if (isset($line['Alt'])) {
1900
+					$data['altitude'] = $line['Alt'];
1901
+				}
1902
+				// altitude
1903
+				if (isset($line['Spd'])) {
1904
+					$data['speed'] = $line['Spd'];
1905
+				}
1906
+				// speed
1907
+				if (isset($line['Trak'])) {
1908
+					$data['heading'] = $line['Trak'];
1909
+				}
1910
+				// heading
1911
+				if (isset($line['Lat'])) {
1912
+					$data['latitude'] = $line['Lat'];
1913
+				}
1914
+				// lat
1915
+				if (isset($line['Long'])) {
1916
+					$data['longitude'] = $line['Long'];
1917
+				}
1918
+				// long
1400 1919
 				//$data['verticalrate'] = $line['']; // verticale rate
1401
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1920
+				if (isset($line['Sqk'])) {
1921
+					$data['squawk'] = $line['Sqk'];
1922
+				}
1923
+				// squawk
1402 1924
 				$data['emergency'] = ''; // emergency
1403
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1925
+				if (isset($line['Reg'])) {
1926
+					$data['registration'] = $line['Reg'];
1927
+				}
1404 1928
 				/*
1405 1929
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1406 1930
 				else $data['datetime'] = date('Y-m-d H:i:s');
1407 1931
 				*/
1408 1932
 				$data['datetime'] = date('Y-m-d H:i:s');
1409
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1933
+				if (isset($line['Type'])) {
1934
+					$data['aircraft_icao'] = $line['Type'];
1935
+				}
1410 1936
 		    		$data['format_source'] = 'vrstcp';
1411 1937
 				$data['id_source'] = $id_source;
1412
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1413
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1414
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1938
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1939
+					$data['noarchive'] = true;
1940
+				}
1941
+				if (isset($value['name']) && $value['name'] != '') {
1942
+					$data['source_name'] = $value['name'];
1943
+				}
1944
+				if (isset($data['latitude']) && isset($data['hex'])) {
1945
+					$SI->add($data);
1946
+				}
1415 1947
 				unset($data);
1416 1948
 			    }
1417 1949
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1424,22 +1956,46 @@  discard block
 block discarded – undo
1424 1956
     				$data['hex'] = $lined['hexid'];
1425 1957
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1426 1958
     				$data['datetime'] = date('Y-m-d H:i:s');;
1427
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1428
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1429
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1430
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1431
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1432
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1433
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1959
+    				if (isset($lined['ident'])) {
1960
+    					$data['ident'] = $lined['ident'];
1961
+    				}
1962
+    				if (isset($lined['lat'])) {
1963
+    					$data['latitude'] = $lined['lat'];
1964
+    				}
1965
+    				if (isset($lined['lon'])) {
1966
+    					$data['longitude'] = $lined['lon'];
1967
+    				}
1968
+    				if (isset($lined['speed'])) {
1969
+    					$data['speed'] = $lined['speed'];
1970
+    				}
1971
+    				if (isset($lined['squawk'])) {
1972
+    					$data['squawk'] = $lined['squawk'];
1973
+    				}
1974
+    				if (isset($lined['alt'])) {
1975
+    					$data['altitude'] = $lined['alt'];
1976
+    				}
1977
+    				if (isset($lined['heading'])) {
1978
+    					$data['heading'] = $lined['heading'];
1979
+    				}
1434 1980
     				$data['id_source'] = $id_source;
1435 1981
     				$data['format_source'] = 'tsv';
1436
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1437
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1438
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1439
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1982
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1983
+    					$data['source_name'] = $globalSources[$nb]['name'];
1984
+    				}
1985
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1986
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1987
+    				}
1988
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1989
+					$data['noarchive'] = true;
1990
+				}
1991
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1992
+    					$SI->add($data);
1993
+    				}
1440 1994
     				unset($lined);
1441 1995
     				unset($data);
1442
-    			    } else $error = true;
1996
+    			    } else {
1997
+    			    	$error = true;
1998
+    			    }
1443 1999
 			} elseif ($format == 'aprs' && $use_aprs) {
1444 2000
 			    if ($aprs_connect == 0) {
1445 2001
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1464,59 +2020,117 @@  discard block
 block discarded – undo
1464 2020
 				    $aprs_last_tx = time();
1465 2021
 				    $data = array();
1466 2022
 				    //print_r($line);
1467
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1468
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1469
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1470
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1471
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1472
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1473
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1474
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1475
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1476
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2023
+				    if (isset($line['address'])) {
2024
+				    	$data['hex'] = $line['address'];
2025
+				    }
2026
+				    if (isset($line['mmsi'])) {
2027
+				    	$data['mmsi'] = $line['mmsi'];
2028
+				    }
2029
+				    if (isset($line['imo'])) {
2030
+				    	$data['imo'] = $line['imo'];
2031
+				    }
2032
+				    if (isset($line['squawk'])) {
2033
+				    	$data['squawk'] = $line['squawk'];
2034
+				    }
2035
+				    if (isset($line['arrival_code'])) {
2036
+				    	$data['arrical_code'] = $line['arrival_code'];
2037
+				    }
2038
+				    if (isset($line['arrival_date'])) {
2039
+				    	$data['arrical_date'] = $line['arrival_date'];
2040
+				    }
2041
+				    if (isset($line['type_id'])) {
2042
+				    	$data['type_id'] = $line['typeid'];
2043
+				    }
2044
+				    if (isset($line['status_id'])) {
2045
+				    	$data['status_id'] = $line['statusid'];
2046
+				    }
2047
+				    if (isset($line['timestamp'])) {
2048
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2049
+				    } else {
2050
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2051
+				    }
1477 2052
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1478
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2053
+				    if (isset($line['ident'])) {
2054
+				    	$data['ident'] = $line['ident'];
2055
+				    }
1479 2056
 				    $data['latitude'] = $line['latitude'];
1480 2057
 				    $data['longitude'] = $line['longitude'];
1481 2058
 				    //$data['verticalrate'] = $line[16];
1482
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2059
+				    if (isset($line['speed'])) {
2060
+				    	$data['speed'] = $line['speed'];
2061
+				    }
1483 2062
 				    //else $data['speed'] = 0;
1484
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1485
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1486
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1487
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
2063
+				    if (isset($line['altitude'])) {
2064
+				    	$data['altitude'] = $line['altitude'];
2065
+				    }
2066
+				    if (isset($line['comment'])) {
2067
+				    	$data['comment'] = $line['comment'];
2068
+				    }
2069
+				    if (isset($line['symbol'])) {
2070
+				    	$data['type'] = $line['symbol'];
2071
+				    }
2072
+				    if (isset($line['heading'])) {
2073
+				    	$data['heading'] = $line['heading'];
2074
+				    }
1488 2075
 				    //else $data['heading'] = 0;
1489
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2076
+				    if (isset($line['stealth'])) {
2077
+				    	$data['aircraft_type'] = $line['stealth'];
2078
+				    }
1490 2079
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1491
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1492
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1493
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1494
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2080
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2081
+				    	$data['noarchive'] = true;
2082
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2083
+				    	$data['noarchive'] = false;
2084
+				    }
2085
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2086
+				    	$data['noarchive'] = true;
2087
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2088
+				    	$data['noarchive'] = false;
2089
+				    }
1495 2090
     				    $data['id_source'] = $id_source;
1496
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1497
-				    else $data['format_source'] = 'aprs';
2091
+    				    if (isset($line['format_source'])) {
2092
+    				    	$data['format_source'] = $line['format_source'];
2093
+    				    } else {
2094
+				    	$data['format_source'] = 'aprs';
2095
+				    }
1498 2096
 				    $data['source_name'] = $line['source'];
1499
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1500
-				    else $data['source_type'] = 'flarm';
1501
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2097
+				    if (isset($line['source_type'])) {
2098
+				    	$data['source_type'] = $line['source_type'];
2099
+				    } else {
2100
+				    	$data['source_type'] = 'flarm';
2101
+				    }
2102
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2103
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2104
+    				    }
1502 2105
 				    $currentdate = date('Y-m-d H:i:s');
1503 2106
 				    $aprsdate = strtotime($data['datetime']);
1504
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2107
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2108
+				    	$data['altitude_relative'] = 'AMSL';
2109
+				    }
1505 2110
 				    // Accept data if time <= system time + 20s
1506 2111
 				    //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'])))) {
1507 2112
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1508 2113
 					$send = $SI->add($data);
1509 2114
 				    } elseif ($data['source_type'] == 'ais') {
1510
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2115
+					if (isset($globalMarine) && $globalMarine) {
2116
+						$send = $MI->add($data);
2117
+					}
1511 2118
 				    } elseif (isset($line['stealth'])) {
1512
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1513
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2119
+					if ($line['stealth'] != 0) {
2120
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
2121
+					} else {
2122
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
2123
+					}
1514 2124
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1515 2125
 					    //$line['symbol'] == 'Balloon' ||
1516 2126
 					    $line['symbol'] == 'Glider' || 
1517 2127
 					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1518
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1519
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2128
+					    if ($line['symbol'] == 'Ballon') {
2129
+					    	$data['aircraft_icao'] = 'BALL';
2130
+					    }
2131
+					    if ($line['symbol'] == 'Glider') {
2132
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2133
+					    }
1520 2134
 					    $send = $SI->add($data);
1521 2135
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1522 2136
 					    $line['symbol'] == 'Yacht (Sail)' || 
@@ -1547,9 +2161,13 @@  discard block
 block discarded – undo
1547 2161
 				    //} 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') {
1548 2162
 				//    } 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') {
1549 2163
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1550
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2164
+					if (isset($globalTracker) && $globalTracker) {
2165
+						$send = $TI->add($data);
2166
+					}
1551 2167
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1552
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2168
+					if (!isset($data['altitude'])) {
2169
+						$data['altitude'] = 0;
2170
+					}
1553 2171
 					$Source->deleteOldLocationByType('gs');
1554 2172
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1555 2173
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1558,7 +2176,9 @@  discard block
 block discarded – undo
1558 2176
 					}
1559 2177
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1560 2178
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1561
-					if ($globalDebug) echo '# Weather Station added'."\n";
2179
+					if ($globalDebug) {
2180
+						echo '# Weather Station added'."\n";
2181
+					}
1562 2182
 					$Source->deleteOldLocationByType('wx');
1563 2183
 					$weather_data = json_encode($line);
1564 2184
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -1568,7 +2188,9 @@  discard block
 block discarded – undo
1568 2188
 					}
1569 2189
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1570 2190
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1571
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2191
+					if ($globalDebug) {
2192
+						echo '☈ Lightning added'."\n";
2193
+					}
1572 2194
 					$Source->deleteOldLocationByType('lightning');
1573 2195
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1574 2196
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -1580,8 +2202,7 @@  discard block
 block discarded – undo
1580 2202
 				    	print_r($line);
1581 2203
 				    }
1582 2204
 				    unset($data);
1583
-				}
1584
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2205
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1585 2206
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1586 2207
 				}
1587 2208
 				/*
@@ -1590,7 +2211,9 @@  discard block
 block discarded – undo
1590 2211
 				}
1591 2212
 				*/
1592 2213
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1593
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2214
+				elseif ($line == true && $globalDebug) {
2215
+					echo '!! Failed : '.$buffer."!!\n";
2216
+				}
1594 2217
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1595 2218
 					$Source->deleteOldLocationByType('lightning');
1596 2219
 					$Source->deleteOldLocationByType('wx');
@@ -1626,26 +2249,45 @@  discard block
 block discarded – undo
1626 2249
     				$data['ground'] = $line[21];
1627 2250
     				$data['emergency'] = $line[19];
1628 2251
     				$data['format_source'] = 'sbs';
1629
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1630
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1631
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2252
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2253
+					$data['source_name'] = $globalSources[$nb]['name'];
2254
+				}
2255
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2256
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2257
+    				}
2258
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2259
+					$data['noarchive'] = true;
2260
+				}
1632 2261
     				$data['id_source'] = $id_source;
1633
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1634
-    				else $error = true;
2262
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2263
+    					$send = $SI->add($data);
2264
+    				} else {
2265
+    					$error = true;
2266
+    				}
1635 2267
     				unset($data);
1636
-    			    } else $error = true;
2268
+    			    } else {
2269
+    			    	$error = true;
2270
+    			    }
1637 2271
 			    if ($error) {
1638 2272
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1639
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2273
+					if ($globalDebug) {
2274
+						echo "Not a message. Ignoring... \n";
2275
+					}
1640 2276
 				} else {
1641
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2277
+					if ($globalDebug) {
2278
+						echo "Wrong line format. Ignoring... \n";
2279
+					}
1642 2280
 					if ($globalDebug) {
1643 2281
 						echo $buffer;
1644 2282
 						//print_r($line);
1645 2283
 					}
1646 2284
 					//socket_close($r);
1647
-					if ($globalDebug) echo "Reconnect after an error...\n";
1648
-					if ($format == 'aprs') $aprs_connect = 0;
2285
+					if ($globalDebug) {
2286
+						echo "Reconnect after an error...\n";
2287
+					}
2288
+					if ($format == 'aprs') {
2289
+						$aprs_connect = 0;
2290
+					}
1649 2291
 					$sourceer[$nb] = $globalSources[$nb];
1650 2292
 					connect_all($sourceer);
1651 2293
 					$sourceer = array();
@@ -1653,10 +2295,14 @@  discard block
 block discarded – undo
1653 2295
 			    }
1654 2296
 			}
1655 2297
 			// Sleep for xxx microseconds
1656
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2298
+			if (isset($globalSBSSleep)) {
2299
+				usleep($globalSBSSleep);
2300
+			}
1657 2301
 		    } else {
1658 2302
 			if ($format == 'flightgearmp') {
1659
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2303
+			    	if ($globalDebug) {
2304
+			    		echo "Reconnect FlightGear MP...";
2305
+			    	}
1660 2306
 				//@socket_close($r);
1661 2307
 				sleep($globalMinFetch);
1662 2308
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1665,10 +2311,15 @@  discard block
 block discarded – undo
1665 2311
 				break;
1666 2312
 				
1667 2313
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1668
-			    if (isset($tt[$format])) $tt[$format]++;
1669
-			    else $tt[$format] = 0;
2314
+			    if (isset($tt[$format])) {
2315
+			    	$tt[$format]++;
2316
+			    } else {
2317
+			    	$tt[$format] = 0;
2318
+			    }
1670 2319
 			    if ($tt[$format] > 30) {
1671
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2320
+				if ($globalDebug) {
2321
+					echo "ERROR : Reconnect ".$format."...";
2322
+				}
1672 2323
 				//@socket_close($r);
1673 2324
 				sleep(2);
1674 2325
 				$aprs_connect = 0;
@@ -1685,11 +2336,17 @@  discard block
 block discarded – undo
1685 2336
 	    } else {
1686 2337
 		$error = socket_strerror(socket_last_error());
1687 2338
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1688
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1689
-			if (isset($globalDebug)) echo "Restarting...\n";
2339
+			if ($globalDebug) {
2340
+				echo "ERROR : socket_select give this error ".$error . "\n";
2341
+			}
2342
+			if (isset($globalDebug)) {
2343
+				echo "Restarting...\n";
2344
+			}
1690 2345
 			// Restart the script if possible
1691 2346
 			if (is_array($sockets)) {
1692
-			    if ($globalDebug) echo "Shutdown all sockets...";
2347
+			    if ($globalDebug) {
2348
+			    	echo "Shutdown all sockets...";
2349
+			    }
1693 2350
 			    
1694 2351
 			    foreach ($sockets as $sock) {
1695 2352
 				@socket_shutdown($sock,2);
@@ -1697,25 +2354,45 @@  discard block
 block discarded – undo
1697 2354
 			    }
1698 2355
 			    
1699 2356
 			}
1700
-			if ($globalDebug) echo "Waiting...";
2357
+			if ($globalDebug) {
2358
+				echo "Waiting...";
2359
+			}
1701 2360
 			sleep(2);
1702 2361
 			$time = time();
1703 2362
 			//connect_all($hosts);
1704 2363
 			$aprs_connect = 0;
1705
-			if ($reset%5 == 0) sleep(20);
1706
-			if ($reset%10 == 0) sleep(100);
1707
-			if ($reset%20 == 0) sleep(200);
1708
-			if ($reset > 100) exit('Too many attempts...');
1709
-			if ($globalDebug) echo "Restart all connections...";
2364
+			if ($reset%5 == 0) {
2365
+				sleep(20);
2366
+			}
2367
+			if ($reset%10 == 0) {
2368
+				sleep(100);
2369
+			}
2370
+			if ($reset%20 == 0) {
2371
+				sleep(200);
2372
+			}
2373
+			if ($reset > 100) {
2374
+				exit('Too many attempts...');
2375
+			}
2376
+			if ($globalDebug) {
2377
+				echo "Restart all connections...";
2378
+			}
1710 2379
 			connect_all($globalSources);
1711 2380
 		}
1712 2381
 	    }
1713 2382
 	}
1714 2383
 	if ($globalDaemon === false) {
1715
-	    if ($globalDebug) echo 'Check all...'."\n";
1716
-	    if (isset($SI)) $SI->checkAll();
1717
-	    if (isset($TI)) $TI->checkAll();
1718
-	    if (isset($MI)) $MI->checkAll();
2384
+	    if ($globalDebug) {
2385
+	    	echo 'Check all...'."\n";
2386
+	    }
2387
+	    if (isset($SI)) {
2388
+	    	$SI->checkAll();
2389
+	    }
2390
+	    if (isset($TI)) {
2391
+	    	$TI->checkAll();
2392
+	    }
2393
+	    if (isset($MI)) {
2394
+	    	$MI->checkAll();
2395
+	    }
1719 2396
 	}
1720 2397
     }
1721 2398
 }
Please login to merge, or discard this patch.
Indentation   +954 added lines, -954 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@  discard block
 block discarded – undo
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18 18
 if (isset($globalMarine) && $globalMarine) {
19
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
19
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
20
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21 21
 }
22 22
 
23 23
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -25,46 +25,46 @@  discard block
 block discarded – undo
25 25
 // Check if schema is at latest version
26 26
 $Connection = new Connection();
27 27
 if ($Connection->connectionExists() === false) {
28
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
-    exit();
28
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
29
+	exit();
30 30
 }
31 31
 if ($Connection->latest() === false) {
32
-    echo "You MUST update to latest schema. Run install/index.php";
33
-    exit();
32
+	echo "You MUST update to latest schema. Run install/index.php";
33
+	exit();
34 34
 }
35 35
 if (PHP_SAPI != 'cli') {
36
-    echo "This script MUST be called from console, not a web browser.";
36
+	echo "This script MUST be called from console, not a web browser.";
37 37
 //    exit();
38 38
 }
39 39
 
40 40
 // This is to be compatible with old version of settings.php
41 41
 if (!isset($globalSources)) {
42
-    if (isset($globalSBS1Hosts)) {
43
-        //$hosts = $globalSBS1Hosts;
44
-        foreach ($globalSBS1Hosts as $host) {
45
-	    $globalSources[] = array('host' => $host);
46
-    	}
47
-    } else {
48
-        if (!isset($globalSBS1Host)) {
49
-	    echo '$globalSources MUST be defined !';
50
-	    die;
42
+	if (isset($globalSBS1Hosts)) {
43
+		//$hosts = $globalSBS1Hosts;
44
+		foreach ($globalSBS1Hosts as $host) {
45
+		$globalSources[] = array('host' => $host);
46
+		}
47
+	} else {
48
+		if (!isset($globalSBS1Host)) {
49
+		echo '$globalSources MUST be defined !';
50
+		die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53 53
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
54
-    }
54
+	}
55 55
 }
56 56
 
57 57
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61
-    $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
-    else $globalSources[] = array('host' => $options['s']);
61
+	$globalSources = array();
62
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+	else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65
-    $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
-    else $globalSources[] = array('host' => $options['source']);
65
+	$globalSources = array();
66
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
67
+	else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
70 70
 	$globalServerAPRS = TRUE;
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 if (isset($options['idsource'])) $id_source = $options['idsource'];
80 80
 else $id_source = 1;
81 81
 if (isset($globalServer) && $globalServer) {
82
-    if ($globalDebug) echo "Using Server Mode\n";
83
-    $SI=new SpotterServer();
82
+	if ($globalDebug) echo "Using Server Mode\n";
83
+	$SI=new SpotterServer();
84 84
 /*
85 85
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
86 86
     $SI = new adsb2aprs();
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 } else $SI=new SpotterImport($Connection->db);
90 90
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
91 91
 if (isset($globalMarine) && $globalMarine) {
92
-    $AIS = new AIS();
93
-    $MI = new MarineImport($Connection->db);
92
+	$AIS = new AIS();
93
+	$MI = new MarineImport($Connection->db);
94 94
 }
95 95
 //$APRS=new APRS($Connection->db);
96 96
 $SBS=new SBS();
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 //$servertz = system('date +%Z');
102 102
 // signal handler - playing nice with sockets and dump1090
103 103
 if (function_exists('pcntl_fork')) {
104
-    pcntl_signal(SIGINT,  function() {
105
-        global $sockets;
106
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
-        die("Bye!\n");
108
-    });
109
-    pcntl_signal_dispatch();
104
+	pcntl_signal(SIGINT,  function() {
105
+		global $sockets;
106
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107
+		die("Bye!\n");
108
+	});
109
+	pcntl_signal_dispatch();
110 110
 }
111 111
 
112 112
 // let's try and connect
@@ -116,36 +116,36 @@  discard block
 block discarded – undo
116 116
 $reset = 0;
117 117
 
118 118
 function connect_all($hosts) {
119
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
-    $reset++;
122
-    if ($globalDebug) echo 'Connect to all...'."\n";
123
-    foreach ($hosts as $id => $value) {
119
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
121
+	$reset++;
122
+	if ($globalDebug) echo 'Connect to all...'."\n";
123
+	foreach ($hosts as $id => $value) {
124 124
 	$host = $value['host'];
125 125
 	$globalSources[$id]['last_exec'] = 0;
126 126
 	// Here we check type of source(s)
127 127
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
128
-            if (preg_match('/deltadb.txt$/i',$host)) {
129
-        	//$formats[$id] = 'deltadbtxt';
130
-        	$globalSources[$id]['format'] = 'deltadbtxt';
131
-        	//$last_exec['deltadbtxt'] = 0;
132
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
-        	//$formats[$id] = 'vatsimtxt';
135
-        	$globalSources[$id]['format'] = 'vatsimtxt';
136
-        	//$last_exec['vatsimtxt'] = 0;
137
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
139
-        	//$formats[$id] = 'aircraftlistjson';
140
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
141
-        	//$last_exec['aircraftlistjson'] = 0;
142
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
-    	    } else if (preg_match('/opensky/i',$host)) {
144
-        	//$formats[$id] = 'aircraftlistjson';
145
-        	$globalSources[$id]['format'] = 'opensky';
146
-        	//$last_exec['aircraftlistjson'] = 0;
147
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
-    	    /*
128
+			if (preg_match('/deltadb.txt$/i',$host)) {
129
+			//$formats[$id] = 'deltadbtxt';
130
+			$globalSources[$id]['format'] = 'deltadbtxt';
131
+			//$last_exec['deltadbtxt'] = 0;
132
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
134
+			//$formats[$id] = 'vatsimtxt';
135
+			$globalSources[$id]['format'] = 'vatsimtxt';
136
+			//$last_exec['vatsimtxt'] = 0;
137
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
139
+			//$formats[$id] = 'aircraftlistjson';
140
+			$globalSources[$id]['format'] = 'aircraftlistjson';
141
+			//$last_exec['aircraftlistjson'] = 0;
142
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
+			} else if (preg_match('/opensky/i',$host)) {
144
+			//$formats[$id] = 'aircraftlistjson';
145
+			$globalSources[$id]['format'] = 'opensky';
146
+			//$last_exec['aircraftlistjson'] = 0;
147
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
148
+			/*
149 149
     	    // Disabled for now, site change source format
150 150
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
151 151
         	//$formats[$id] = 'radarvirtueljson';
@@ -157,121 +157,121 @@  discard block
 block discarded – undo
157 157
         	    exit(0);
158 158
         	}
159 159
     	    */
160
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
-        	//$formats[$id] = 'planeupdatefaa';
162
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
163
-        	//$last_exec['planeupdatefaa'] = 0;
164
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
-        	    exit(0);
168
-        	}
169
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
-        	//$formats[$id] = 'phpvmacars';
171
-        	$globalSources[$id]['format'] = 'phpvmacars';
172
-        	//$last_exec['phpvmacars'] = 0;
173
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
175
-        	//$formats[$id] = 'phpvmacars';
176
-        	$globalSources[$id]['format'] = 'vam';
177
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
-            } else if (preg_match('/whazzup/i',$host)) {
179
-        	//$formats[$id] = 'whazzup';
180
-        	$globalSources[$id]['format'] = 'whazzup';
181
-        	//$last_exec['whazzup'] = 0;
182
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
-            } else if (preg_match('/blitzortung/i',$host)) {
184
-        	$globalSources[$id]['format'] = 'blitzortung';
185
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
-            } else if (preg_match('/airwhere/i',$host)) {
187
-        	$globalSources[$id]['format'] = 'airwhere';
188
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
-            } else if (preg_match('/recentpireps/i',$host)) {
190
-        	//$formats[$id] = 'pirepsjson';
191
-        	$globalSources[$id]['format'] = 'pirepsjson';
192
-        	//$last_exec['pirepsjson'] = 0;
193
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
-        	//$formats[$id] = 'fr24json';
196
-        	$globalSources[$id]['format'] = 'fr24json';
197
-        	//$last_exec['fr24json'] = 0;
198
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
-        	    exit(0);
202
-        	}
203
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
204
-        	//$formats[$id] = 'fr24json';
205
-        	$globalSources[$id]['format'] = 'myshiptracking';
206
-        	//$last_exec['fr24json'] = 0;
207
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
-        	    exit(0);
211
-        	}
212
-            //} else if (preg_match('/10001/',$host)) {
213
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
-        	//$formats[$id] = 'tsv';
215
-        	$globalSources[$id]['format'] = 'tsv';
216
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
-            }
218
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
-    		    if ($idf !== false) {
222
-    			$httpfeeds[$id] = $idf;
223
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
-    		    }
225
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
-	    $hostport = explode(':',$host);
229
-	    if (isset($hostport[1])) {
160
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
161
+			//$formats[$id] = 'planeupdatefaa';
162
+			$globalSources[$id]['format'] = 'planeupdatefaa';
163
+			//$last_exec['planeupdatefaa'] = 0;
164
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
165
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
166
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167
+				exit(0);
168
+			}
169
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
170
+			//$formats[$id] = 'phpvmacars';
171
+			$globalSources[$id]['format'] = 'phpvmacars';
172
+			//$last_exec['phpvmacars'] = 0;
173
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
175
+			//$formats[$id] = 'phpvmacars';
176
+			$globalSources[$id]['format'] = 'vam';
177
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
+			} else if (preg_match('/whazzup/i',$host)) {
179
+			//$formats[$id] = 'whazzup';
180
+			$globalSources[$id]['format'] = 'whazzup';
181
+			//$last_exec['whazzup'] = 0;
182
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
+			} else if (preg_match('/blitzortung/i',$host)) {
184
+			$globalSources[$id]['format'] = 'blitzortung';
185
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
+			} else if (preg_match('/airwhere/i',$host)) {
187
+			$globalSources[$id]['format'] = 'airwhere';
188
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
+			} else if (preg_match('/recentpireps/i',$host)) {
190
+			//$formats[$id] = 'pirepsjson';
191
+			$globalSources[$id]['format'] = 'pirepsjson';
192
+			//$last_exec['pirepsjson'] = 0;
193
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
195
+			//$formats[$id] = 'fr24json';
196
+			$globalSources[$id]['format'] = 'fr24json';
197
+			//$last_exec['fr24json'] = 0;
198
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
199
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
200
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201
+				exit(0);
202
+			}
203
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
204
+			//$formats[$id] = 'fr24json';
205
+			$globalSources[$id]['format'] = 'myshiptracking';
206
+			//$last_exec['fr24json'] = 0;
207
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
208
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
209
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
210
+				exit(0);
211
+			}
212
+			//} else if (preg_match('/10001/',$host)) {
213
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214
+			//$formats[$id] = 'tsv';
215
+			$globalSources[$id]['format'] = 'tsv';
216
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217
+			}
218
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
219
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
221
+				if ($idf !== false) {
222
+				$httpfeeds[$id] = $idf;
223
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224
+				}
225
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
+		$hostport = explode(':',$host);
229
+		if (isset($hostport[1])) {
230 230
 		$port = $hostport[1];
231 231
 		$hostn = $hostport[0];
232
-	    } else {
232
+		} else {
233 233
 		$port = $globalSources[$id]['port'];
234 234
 		$hostn = $globalSources[$id]['host'];
235
-	    }
236
-	    $Common = new Common();
237
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
-    	    } else {
240
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
-	    }
242
-	    if ($s) {
243
-    	        $sockets[$id] = $s;
244
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
235
+		}
236
+		$Common = new Common();
237
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
239
+			} else {
240
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
241
+		}
242
+		if ($s) {
243
+				$sockets[$id] = $s;
244
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
246 246
 			//$formats[$id] = 'aprs';
247 247
 			$globalSources[$id]['format'] = 'aprs';
248 248
 			//$aprs_connect = 0;
249 249
 			//$use_aprs = true;
250
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
250
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
251 251
 			$globalSources[$id]['format'] = 'vrstcp';
252
-    		    } elseif ($port == '10001') {
253
-        		//$formats[$id] = 'tsv';
254
-        		$globalSources[$id]['format'] = 'tsv';
255
-		    } elseif ($port == '30002') {
256
-        		//$formats[$id] = 'raw';
257
-        		$globalSources[$id]['format'] = 'raw';
258
-		    } elseif ($port == '5001') {
259
-        		//$formats[$id] = 'raw';
260
-        		$globalSources[$id]['format'] = 'flightgearmp';
261
-		    } elseif ($port == '30005') {
252
+				} elseif ($port == '10001') {
253
+				//$formats[$id] = 'tsv';
254
+				$globalSources[$id]['format'] = 'tsv';
255
+			} elseif ($port == '30002') {
256
+				//$formats[$id] = 'raw';
257
+				$globalSources[$id]['format'] = 'raw';
258
+			} elseif ($port == '5001') {
259
+				//$formats[$id] = 'raw';
260
+				$globalSources[$id]['format'] = 'flightgearmp';
261
+			} elseif ($port == '30005') {
262 262
 			// Not yet supported
263
-        		//$formats[$id] = 'beast';
264
-        		$globalSources[$id]['format'] = 'beast';
265
-		    //} else $formats[$id] = 'sbs';
266
-		    } else $globalSources[$id]['format'] = 'sbs';
267
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
263
+				//$formats[$id] = 'beast';
264
+				$globalSources[$id]['format'] = 'beast';
265
+			//} else $formats[$id] = 'sbs';
266
+			} else $globalSources[$id]['format'] = 'sbs';
267
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
268 268
 		}
269 269
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
270
-            } else {
270
+			} else {
271 271
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
272
-    	    }
273
-        }
274
-    }
272
+			}
273
+		}
274
+	}
275 275
 }
276 276
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
277 277
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 //connect_all($globalSources);
295 295
 
296 296
 if (isset($globalProxy) && $globalProxy) {
297
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
297
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
298 298
 } else {
299
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
299
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
300 300
 }
301 301
 
302 302
 // APRS Configuration
@@ -305,21 +305,21 @@  discard block
 block discarded – undo
305 305
 	die;
306 306
 }
307 307
 foreach ($globalSources as $key => $source) {
308
-    if (!isset($source['format'])) {
309
-        $globalSources[$key]['format'] = 'auto';
310
-    }
311
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
312
-        unset($globalSources[$key]);
313
-    }
308
+	if (!isset($source['format'])) {
309
+		$globalSources[$key]['format'] = 'auto';
310
+	}
311
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
312
+		unset($globalSources[$key]);
313
+	}
314 314
 }
315 315
 connect_all($globalSources);
316 316
 foreach ($globalSources as $key => $source) {
317
-    if (isset($source['format']) && $source['format'] == 'aprs') {
317
+	if (isset($source['format']) && $source['format'] == 'aprs') {
318 318
 	$aprs_connect = 0;
319 319
 	$use_aprs = true;
320 320
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
321 321
 	break;
322
-    }
322
+	}
323 323
 }
324 324
 
325 325
 if ($use_aprs) {
@@ -360,126 +360,126 @@  discard block
 block discarded – undo
360 360
 
361 361
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
362 362
 while ($i > 0) {
363
-    if (!$globalDaemon) $i = $endtime-time();
364
-    // Delete old ATC
365
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
363
+	if (!$globalDaemon) $i = $endtime-time();
364
+	// Delete old ATC
365
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
366 366
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
367
-        $ATC->deleteOldATC();
368
-    }
367
+		$ATC->deleteOldATC();
368
+	}
369 369
     
370
-    if (count($last_exec) == count($globalSources)) {
370
+	if (count($last_exec) == count($globalSources)) {
371 371
 	$max = $globalMinFetch;
372 372
 	foreach ($last_exec as $last) {
373
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
373
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
374 374
 	}
375 375
 	if ($max != $globalMinFetch) {
376
-	    if ($globalDebug) echo 'Sleeping...'."\n";
377
-	    sleep($globalMinFetch-$max+2);
376
+		if ($globalDebug) echo 'Sleeping...'."\n";
377
+		sleep($globalMinFetch-$max+2);
378
+	}
378 379
 	}
379
-    }
380 380
 
381 381
     
382
-    //foreach ($formats as $id => $value) {
383
-    foreach ($globalSources as $id => $value) {
382
+	//foreach ($formats as $id => $value) {
383
+	foreach ($globalSources as $id => $value) {
384 384
 	date_default_timezone_set('UTC');
385 385
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
386 386
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
387 387
 	if ($value['format'] == 'deltadbtxt' && 
388
-	    (
388
+		(
389 389
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
390 390
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
391
-	    )
391
+		)
392 392
 	) {
393
-	    //$buffer = $Common->getData($hosts[$id]);
394
-	    $buffer = $Common->getData($value['host']);
395
-	    if ($buffer != '') $reset = 0;
396
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
-	    $buffer = explode('\n',$buffer);
398
-	    foreach ($buffer as $line) {
399
-    		if ($line != '' && count($line) > 7) {
400
-    		    $line = explode(',', $line);
401
-	            $data = array();
402
-	            $data['hex'] = $line[1]; // hex
403
-	            $data['ident'] = $line[2]; // ident
404
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
-	            $data['verticalrate'] = ''; // vertical rate
410
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
-	            $data['emergency'] = ''; // emergency
412
-		    $data['datetime'] = date('Y-m-d H:i:s');
413
-		    $data['format_source'] = 'deltadbtxt';
414
-    		    $data['id_source'] = $id_source;
415
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
-    		    $SI->add($data);
419
-		    unset($data);
420
-    		}
421
-    	    }
422
-    	    $last_exec[$id]['last'] = time();
393
+		//$buffer = $Common->getData($hosts[$id]);
394
+		$buffer = $Common->getData($value['host']);
395
+		if ($buffer != '') $reset = 0;
396
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
+		$buffer = explode('\n',$buffer);
398
+		foreach ($buffer as $line) {
399
+			if ($line != '' && count($line) > 7) {
400
+				$line = explode(',', $line);
401
+				$data = array();
402
+				$data['hex'] = $line[1]; // hex
403
+				$data['ident'] = $line[2]; // ident
404
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
405
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
406
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
407
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
408
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
409
+				$data['verticalrate'] = ''; // vertical rate
410
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
411
+				$data['emergency'] = ''; // emergency
412
+			$data['datetime'] = date('Y-m-d H:i:s');
413
+			$data['format_source'] = 'deltadbtxt';
414
+				$data['id_source'] = $id_source;
415
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
417
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
418
+				$SI->add($data);
419
+			unset($data);
420
+			}
421
+			}
422
+			$last_exec[$id]['last'] = time();
423 423
 	} elseif ($value['format'] == 'aisnmeatxt' && 
424
-	    (
424
+		(
425 425
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
426 426
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
427
-	    )
427
+		)
428 428
 	) {
429
-	    date_default_timezone_set('CET');
430
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
-	    date_default_timezone_set('UTC');
432
-	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
435
-	    foreach ($buffer as $line) {
429
+		date_default_timezone_set('CET');
430
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
431
+		date_default_timezone_set('UTC');
432
+		if ($buffer != '') $reset = 0;
433
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
+		$buffer = explode('\n',$buffer);
435
+		foreach ($buffer as $line) {
436 436
 		if ($line != '') {
437
-		    //echo "'".$line."'\n";
438
-		    $add = false;
439
-		    $ais_data = $AIS->parse_line(trim($line));
440
-		    $data = array();
441
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
-		    if (isset($ais_data['timestamp'])) {
437
+			//echo "'".$line."'\n";
438
+			$add = false;
439
+			$ais_data = $AIS->parse_line(trim($line));
440
+			$data = array();
441
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
442
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
443
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
444
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
445
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
446
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
447
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
448
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
449
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451
+			if (isset($ais_data['timestamp'])) {
452 452
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
453 453
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
454
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
-			    $add = true;
454
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455
+				$add = true;
456 456
 			}
457
-		    } else {
457
+			} else {
458 458
 			$data['datetime'] = date('Y-m-d H:i:s');
459 459
 			$add = true;
460
-		    }
461
-		    $data['format_source'] = 'aisnmeatxt';
462
-    		    $data['id_source'] = $id_source;
463
-		    //print_r($data);
464
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
-		    unset($data);
460
+			}
461
+			$data['format_source'] = 'aisnmeatxt';
462
+				$data['id_source'] = $id_source;
463
+			//print_r($data);
464
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
465
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
466
+			unset($data);
467 467
 		}
468
-    	    }
469
-    	    $last_exec[$id]['last'] = time();
468
+			}
469
+			$last_exec[$id]['last'] = time();
470 470
 	} elseif ($value['format'] == 'aisnmeahttp') {
471
-	    $arr = $httpfeeds;
472
-	    $w = $e = null;
471
+		$arr = $httpfeeds;
472
+		$w = $e = null;
473 473
 	    
474
-	    if (isset($arr[$id])) {
474
+		if (isset($arr[$id])) {
475 475
 		$nn = stream_select($arr,$w,$e,$timeout);
476 476
 		if ($nn > 0) {
477
-		    foreach ($httpfeeds as $feed) {
477
+			foreach ($httpfeeds as $feed) {
478 478
 			$buffer = stream_get_line($feed,2000,"\n");
479 479
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480 480
 			$buffer = explode('\n',$buffer);
481 481
 			foreach ($buffer as $line) {
482
-			    if ($line != '') {
482
+				if ($line != '') {
483 483
 				$ais_data = $AIS->parse_line(trim($line));
484 484
 				$data = array();
485 485
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -497,111 +497,111 @@  discard block
 block discarded – undo
497 497
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
498 498
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
499 499
 				if (isset($ais_data['timestamp'])) {
500
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
500
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
501 501
 				} else {
502
-				    $data['datetime'] = date('Y-m-d H:i:s');
502
+					$data['datetime'] = date('Y-m-d H:i:s');
503 503
 				}
504 504
 				$data['format_source'] = 'aisnmeahttp';
505 505
 				$data['id_source'] = $id_source;
506 506
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
507 507
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
508 508
 				unset($data);
509
-			    }
509
+				}
510
+			}
510 511
 			}
511
-		    }
512 512
 		} else {
513
-		    $format = $value['format'];
514
-		    if (isset($tt[$format])) $tt[$format]++;
515
-		    else $tt[$format] = 0;
516
-		    if ($tt[$format] > 30) {
513
+			$format = $value['format'];
514
+			if (isset($tt[$format])) $tt[$format]++;
515
+			else $tt[$format] = 0;
516
+			if ($tt[$format] > 30) {
517 517
 			if ($globalDebug) echo 'Reconnect...'."\n";
518 518
 			sleep(2);
519 519
 			$sourceeen[] = $value;
520 520
 			connect_all($sourceeen);
521 521
 			$sourceeen = array();
522
-		    }
522
+			}
523
+		}
523 524
 		}
524
-	    }
525 525
 	} elseif ($value['format'] == 'myshiptracking' && 
526
-	    (
526
+		(
527 527
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
528 528
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
529
-	    )
529
+		)
530 530
 	) {
531
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
532
-	    if ($buffer != '') {
531
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
532
+		if ($buffer != '') {
533 533
 		//echo $buffer;
534 534
 		$all_data = json_decode($buffer,true);
535 535
 		//print_r($all_data);
536 536
 		if (isset($all_data[0]['DATA'])) {
537
-		    foreach ($all_data[0]['DATA'] as $line) {
537
+			foreach ($all_data[0]['DATA'] as $line) {
538 538
 			if ($line != '') {
539
-			    $data = array();
540
-			    $data['ident'] = $line['NAME'];
541
-			    $data['mmsi'] = $line['MMSI'];
542
-			    $data['speed'] = $line['SOG'];
543
-			    $data['heading'] = $line['COG'];
544
-			    $data['latitude'] = $line['LAT'];
545
-			    $data['longitude'] = $line['LNG'];
546
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
-			    $data['imo'] = $line['IMO'];
548
-			    //$data['arrival_code'] = $ais_data['destination'];
549
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
-			    $data['format_source'] = 'myshiptracking';
551
-			    $data['id_source'] = $id_source;
552
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
-			    $MI->add($data);
554
-			    unset($data);
539
+				$data = array();
540
+				$data['ident'] = $line['NAME'];
541
+				$data['mmsi'] = $line['MMSI'];
542
+				$data['speed'] = $line['SOG'];
543
+				$data['heading'] = $line['COG'];
544
+				$data['latitude'] = $line['LAT'];
545
+				$data['longitude'] = $line['LNG'];
546
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547
+				$data['imo'] = $line['IMO'];
548
+				//$data['arrival_code'] = $ais_data['destination'];
549
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
550
+				$data['format_source'] = 'myshiptracking';
551
+				$data['id_source'] = $id_source;
552
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
553
+				$MI->add($data);
554
+				unset($data);
555
+			}
555 556
 			}
556
-		    }
557 557
 		}
558
-	    }
559
-	    $last_exec[$id]['last'] = time();
558
+		}
559
+		$last_exec[$id]['last'] = time();
560 560
 	} elseif ($value['format'] == 'boatbeaconapp' && 
561
-	    (
561
+		(
562 562
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
563 563
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
564
-	    )
564
+		)
565 565
 	) {
566
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
-	    if ($buffer != '') {
566
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
567
+		if ($buffer != '') {
568 568
 		$all_data = json_decode($buffer,true);
569 569
 		if (isset($all_data[0]['mmsi'])) {
570
-		    foreach ($all_data as $line) {
570
+			foreach ($all_data as $line) {
571 571
 			if ($line != '') {
572
-			    $data = array();
573
-			    $data['ident'] = $line['shipname'];
574
-			    $data['callsign'] = $line['callsign'];
575
-			    $data['mmsi'] = $line['mmsi'];
576
-			    $data['speed'] = $line['sog'];
577
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
-			    $data['latitude'] = $line['latitude'];
579
-			    $data['longitude'] = $line['longitude'];
580
-			    $data['type_id'] = $line['shiptype'];
581
-			    $data['arrival_code'] = $line['destination'];
582
-			    $data['datetime'] = $line['time'];
583
-			    $data['format_source'] = 'boatbeaconapp';
584
-			    $data['id_source'] = $id_source;
585
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
-			    $MI->add($data);
587
-			    unset($data);
572
+				$data = array();
573
+				$data['ident'] = $line['shipname'];
574
+				$data['callsign'] = $line['callsign'];
575
+				$data['mmsi'] = $line['mmsi'];
576
+				$data['speed'] = $line['sog'];
577
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
578
+				$data['latitude'] = $line['latitude'];
579
+				$data['longitude'] = $line['longitude'];
580
+				$data['type_id'] = $line['shiptype'];
581
+				$data['arrival_code'] = $line['destination'];
582
+				$data['datetime'] = $line['time'];
583
+				$data['format_source'] = 'boatbeaconapp';
584
+				$data['id_source'] = $id_source;
585
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
586
+				$MI->add($data);
587
+				unset($data);
588
+			}
588 589
 			}
589
-		    }
590 590
 		}
591 591
 		
592
-	    }
593
-    	    $last_exec[$id]['last'] = time();
592
+		}
593
+			$last_exec[$id]['last'] = time();
594 594
 	} elseif ($value['format'] == 'boatnerd' && 
595
-	    (
595
+		(
596 596
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
597 597
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
598
-	    )
598
+		)
599 599
 	) {
600
-	    $buffer = $Common->getData($value['host']);
601
-	    if ($buffer != '') {
600
+		$buffer = $Common->getData($value['host']);
601
+		if ($buffer != '') {
602 602
 		$all_data = json_decode($buffer,true);
603 603
 		if (isset($all_data['features'][0]['id'])) {
604
-		    foreach ($all_data['features'] as $line) {
604
+			foreach ($all_data['features'] as $line) {
605 605
 			$data = array();
606 606
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
607 607
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -620,78 +620,78 @@  discard block
 block discarded – undo
620 620
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
621 621
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
622 622
 			unset($data);
623
-		    }
623
+			}
624 624
 		}
625 625
 		
626
-	    }
627
-    	    $last_exec[$id]['last'] = time();
626
+		}
627
+			$last_exec[$id]['last'] = time();
628 628
 	} elseif ($value['format'] == 'shipplotter' && 
629
-	    (
629
+		(
630 630
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
631 631
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
632
-	    )
632
+		)
633 633
 	) {
634
-	    echo 'download...';
635
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
-	    echo 'done !'."\n";
637
-	    if ($buffer != '') $reset = 0;
638
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
-	    $buffer = explode('\n',$buffer);
640
-	    foreach ($buffer as $line) {
634
+		echo 'download...';
635
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
636
+		echo 'done !'."\n";
637
+		if ($buffer != '') $reset = 0;
638
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
+		$buffer = explode('\n',$buffer);
640
+		foreach ($buffer as $line) {
641 641
 		if ($line != '') {
642
-		    $data = array();
643
-		    $data['mmsi'] = (int)substr($line,0,9);
644
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
-		    //$data['status'] = substr($line,21,2);
646
-		    //$data['type'] = substr($line,24,3);
647
-		    $data['latitude'] = substr($line,29,9);
648
-		    $data['longitude'] = substr($line,41,9);
649
-		    $data['speed'] = round(substr($line,51,5));
650
-		    //$data['course'] = substr($line,57,5);
651
-		    $data['heading'] = round(substr($line,63,3));
652
-		    //$data['draft'] = substr($line,67,4);
653
-		    //$data['length'] = substr($line,72,3);
654
-		    //$data['beam'] = substr($line,76,2);
655
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
-		    //$data['callsign'] = trim(substr($line,100,7);
657
-		    //$data['dest'] = substr($line,108,20);
658
-		    //$data['etaDate'] = substr($line,129,5);
659
-		    //$data['etaTime'] = substr($line,135,5);
660
-		    $data['format_source'] = 'shipplotter';
661
-    		    $data['id_source'] = $id_source;
662
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
-		    //print_r($data);
664
-		    echo 'Add...'."\n";
665
-		    $MI->add($data);
666
-		    unset($data);
642
+			$data = array();
643
+			$data['mmsi'] = (int)substr($line,0,9);
644
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
645
+			//$data['status'] = substr($line,21,2);
646
+			//$data['type'] = substr($line,24,3);
647
+			$data['latitude'] = substr($line,29,9);
648
+			$data['longitude'] = substr($line,41,9);
649
+			$data['speed'] = round(substr($line,51,5));
650
+			//$data['course'] = substr($line,57,5);
651
+			$data['heading'] = round(substr($line,63,3));
652
+			//$data['draft'] = substr($line,67,4);
653
+			//$data['length'] = substr($line,72,3);
654
+			//$data['beam'] = substr($line,76,2);
655
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
656
+			//$data['callsign'] = trim(substr($line,100,7);
657
+			//$data['dest'] = substr($line,108,20);
658
+			//$data['etaDate'] = substr($line,129,5);
659
+			//$data['etaTime'] = substr($line,135,5);
660
+			$data['format_source'] = 'shipplotter';
661
+				$data['id_source'] = $id_source;
662
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
663
+			//print_r($data);
664
+			echo 'Add...'."\n";
665
+			$MI->add($data);
666
+			unset($data);
667 667
 		}
668
-    	    }
669
-    	    $last_exec[$id]['last'] = time();
668
+			}
669
+			$last_exec[$id]['last'] = time();
670 670
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
671 671
 	} elseif (
672
-	    (
672
+		(
673 673
 		$value['format'] == 'whazzup' && 
674 674
 		(
675
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
675
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
676
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
677 677
 		)
678
-	    ) || (
678
+		) || (
679 679
 		$value['format'] == 'vatsimtxt' && 
680 680
 		(
681
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
681
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
682
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
683
+		)
683 684
 		)
684
-	    )
685 685
 	) {
686
-	    //$buffer = $Common->getData($hosts[$id]);
687
-	    $buffer = $Common->getData($value['host']);
688
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
-	    $buffer = explode('\n',$buffer);
690
-	    $reset = 0;
691
-	    foreach ($buffer as $line) {
692
-    		if ($line != '') {
693
-    		    $line = explode(':', $line);
694
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
686
+		//$buffer = $Common->getData($hosts[$id]);
687
+		$buffer = $Common->getData($value['host']);
688
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
+		$buffer = explode('\n',$buffer);
690
+		$reset = 0;
691
+		foreach ($buffer as $line) {
692
+			if ($line != '') {
693
+				$line = explode(':', $line);
694
+				if (count($line) > 30 && $line[0] != 'callsign') {
695 695
 			$data = array();
696 696
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
697 697
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -704,37 +704,37 @@  discard block
 block discarded – undo
704 704
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
705 705
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
706 706
 			$data['latitude'] = $line[5]; // lat
707
-	        	$data['longitude'] = $line[6]; // long
708
-	        	$data['verticalrate'] = ''; // vertical rate
709
-	        	$data['squawk'] = ''; // squawk
710
-	        	$data['emergency'] = ''; // emergency
711
-	        	$data['waypoints'] = $line[30];
707
+				$data['longitude'] = $line[6]; // long
708
+				$data['verticalrate'] = ''; // vertical rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				$data['waypoints'] = $line[30];
712 712
 			$data['datetime'] = date('Y-m-d H:i:s');
713 713
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
714 714
 			//if (isset($line[37])) $data['last_update'] = $line[37];
715
-		        $data['departure_airport_icao'] = $line[11];
716
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
-		        $data['arrival_airport_icao'] = $line[13];
715
+				$data['departure_airport_icao'] = $line[11];
716
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
717
+				$data['arrival_airport_icao'] = $line[13];
718 718
 			$data['frequency'] = $line[4];
719 719
 			$data['type'] = $line[18];
720 720
 			$data['range'] = $line[19];
721 721
 			if (isset($line[35])) $data['info'] = $line[35];
722
-    			$data['id_source'] = $id_source;
723
-	    		//$data['arrival_airport_time'] = ;
724
-	    		if ($line[9] != '') {
725
-	    		    $aircraft_data = explode('/',$line[9]);
726
-	    		    if (isset($aircraft_data[1])) {
727
-	    			$data['aircraft_icao'] = $aircraft_data[1];
728
-	    		    }
729
-        		}
730
-	    		/*
722
+				$data['id_source'] = $id_source;
723
+				//$data['arrival_airport_time'] = ;
724
+				if ($line[9] != '') {
725
+					$aircraft_data = explode('/',$line[9]);
726
+					if (isset($aircraft_data[1])) {
727
+					$data['aircraft_icao'] = $aircraft_data[1];
728
+					}
729
+				}
730
+				/*
731 731
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
732 732
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
733 733
 	    		*/
734
-	    		$data['format_source'] = $value['format'];
734
+				$data['format_source'] = $value['format'];
735 735
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736 736
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
737
-    			if ($line[3] == 'PILOT') $SI->add($data);
737
+				if ($line[3] == 'PILOT') $SI->add($data);
738 738
 			elseif ($line[3] == 'ATC') {
739 739
 				//print_r($data);
740 740
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -755,21 +755,21 @@  discard block
 block discarded – undo
755 755
 					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']);
756 756
 				}
757 757
 			}
758
-    			unset($data);
759
-    		    }
760
-    		}
761
-    	    }
762
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
-    	    $last_exec[$id]['last'] = time();
765
-    	} elseif ($value['format'] == 'airwhere' && 
766
-    	    (
767
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
-    	    )
770
-    	) {
771
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
-	    if ($buffer != '') {
758
+				unset($data);
759
+				}
760
+			}
761
+			}
762
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
763
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
764
+			$last_exec[$id]['last'] = time();
765
+		} elseif ($value['format'] == 'airwhere' && 
766
+			(
767
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
768
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769
+			)
770
+		) {
771
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
772
+		if ($buffer != '') {
773 773
 		$all_data = simplexml_load_string($buffer);
774 774
 		foreach($all_data->children() as $childdata) {
775 775
 			$data = array();
@@ -791,10 +791,10 @@  discard block
 block discarded – undo
791 791
 			$SI->add($data);
792 792
 			unset($data);
793 793
 		}
794
-	    }
795
-	    $Source->deleteOldLocationByType('gs');
796
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
-	    if ($buffer != '') {
794
+		}
795
+		$Source->deleteOldLocationByType('gs');
796
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
797
+		if ($buffer != '') {
798 798
 		$all_data = simplexml_load_string($buffer);
799 799
 		foreach($all_data->children() as $childdata) {
800 800
 			$data = array();
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			}
813 813
 			unset($data);
814 814
 		}
815
-	    }
816
-	    $last_exec[$id]['last'] = time();
815
+		}
816
+		$last_exec[$id]['last'] = time();
817 817
 	/*
818 818
 	} if ($value['format'] == 'aircraftlistjson') {
819 819
 	    print_r($globalSources);
@@ -821,17 +821,17 @@  discard block
 block discarded – undo
821 821
 	    echo $globalMinFetch;
822 822
 	*/
823 823
 	} elseif ($value['format'] == 'aircraftlistjson' && 
824
-	    (
824
+		(
825 825
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
826 826
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827
-	    )
827
+		)
828 828
 	) {
829
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
830
-	    if ($buffer != '') {
831
-	        $all_data = json_decode($buffer,true);
829
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
830
+		if ($buffer != '') {
831
+			$all_data = json_decode($buffer,true);
832 832
 		if (isset($all_data['acList'])) {
833
-		    $reset = 0;
834
-		    foreach ($all_data['acList'] as $line) {
833
+			$reset = 0;
834
+			foreach ($all_data['acList'] as $line) {
835 835
 			$data = array();
836 836
 			$data['hex'] = $line['Icao']; // hex
837 837
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -854,10 +854,10 @@  discard block
 block discarded – undo
854 854
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
855 855
 			if (isset($data['latitude'])) $SI->add($data);
856 856
 			unset($data);
857
-		    }
857
+			}
858 858
 		} elseif (is_array($all_data)) {
859
-		    $reset = 0;
860
-		    foreach ($all_data as $line) {
859
+			$reset = 0;
860
+			foreach ($all_data as $line) {
861 861
 			$data = array();
862 862
 			$data['hex'] = $line['hex']; // hex
863 863
 			$data['ident'] = $line['flight']; // ident
@@ -877,218 +877,218 @@  discard block
 block discarded – undo
877 877
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
878 878
 			$SI->add($data);
879 879
 			unset($data);
880
-		    }
880
+			}
881 881
 		}
882
-	    } elseif ($globalDebug) echo 'No data'."\n";
883
-    	    //$last_exec['aircraftlistjson'] = time();
884
-    	    $last_exec[$id]['last'] = time();
885
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
-    	} elseif ($value['format'] == 'planeupdatefaa' && 
887
-    	    (
888
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
-    	    )
891
-    	) {
892
-	    $buffer = $Common->getData($value['host']);
893
-	    $all_data = json_decode($buffer,true);
894
-	    if (isset($all_data['planes'])) {
882
+		} elseif ($globalDebug) echo 'No data'."\n";
883
+			//$last_exec['aircraftlistjson'] = time();
884
+			$last_exec[$id]['last'] = time();
885
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
886
+		} elseif ($value['format'] == 'planeupdatefaa' && 
887
+			(
888
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
889
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
890
+			)
891
+		) {
892
+		$buffer = $Common->getData($value['host']);
893
+		$all_data = json_decode($buffer,true);
894
+		if (isset($all_data['planes'])) {
895 895
 		$reset = 0;
896 896
 		foreach ($all_data['planes'] as $key => $line) {
897
-		    $data = array();
898
-		    $data['hex'] = $key; // hex
899
-		    $data['ident'] = $line[3]; // ident
900
-		    $data['altitude'] = $line[6]; // altitude
901
-		    $data['speed'] = $line[8]; // speed
902
-		    $data['heading'] = $line[7]; // heading
903
-		    $data['latitude'] = $line[4]; // lat
904
-		    $data['longitude'] = $line[5]; // long
905
-		    //$data['verticalrate'] = $line[]; // verticale rate
906
-		    $data['squawk'] = $line[10]; // squawk
907
-		    $data['emergency'] = ''; // emergency
908
-		    $data['registration'] = $line[2];
909
-		    $data['aircraft_icao'] = $line[0];
910
-		    $deparr = explode('-',$line[1]);
911
-		    if (count($deparr) == 2) {
897
+			$data = array();
898
+			$data['hex'] = $key; // hex
899
+			$data['ident'] = $line[3]; // ident
900
+			$data['altitude'] = $line[6]; // altitude
901
+			$data['speed'] = $line[8]; // speed
902
+			$data['heading'] = $line[7]; // heading
903
+			$data['latitude'] = $line[4]; // lat
904
+			$data['longitude'] = $line[5]; // long
905
+			//$data['verticalrate'] = $line[]; // verticale rate
906
+			$data['squawk'] = $line[10]; // squawk
907
+			$data['emergency'] = ''; // emergency
908
+			$data['registration'] = $line[2];
909
+			$data['aircraft_icao'] = $line[0];
910
+			$deparr = explode('-',$line[1]);
911
+			if (count($deparr) == 2) {
912 912
 			$data['departure_airport_icao'] = $deparr[0];
913 913
 			$data['arrival_airport_icao'] = $deparr[1];
914
-		    }
915
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
-	    	    $data['format_source'] = 'planeupdatefaa';
917
-    		    $data['id_source'] = $id_source;
918
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
-		    $SI->add($data);
921
-		    unset($data);
914
+			}
915
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
916
+				$data['format_source'] = 'planeupdatefaa';
917
+				$data['id_source'] = $id_source;
918
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
919
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
920
+			$SI->add($data);
921
+			unset($data);
922
+		}
922 923
 		}
923
-	    }
924
-	    //$last_exec['planeupdatefaa'] = time();
925
-	    $last_exec[$id]['last'] = time();
924
+		//$last_exec['planeupdatefaa'] = time();
925
+		$last_exec[$id]['last'] = time();
926 926
 	} elseif ($value['format'] == 'opensky' && 
927
-	    (
927
+		(
928 928
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
929 929
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
930
-	    )
930
+		)
931 931
 	) {
932
-	    $buffer = $Common->getData($value['host']);
933
-	    $all_data = json_decode($buffer,true);
934
-	    if (isset($all_data['states'])) {
932
+		$buffer = $Common->getData($value['host']);
933
+		$all_data = json_decode($buffer,true);
934
+		if (isset($all_data['states'])) {
935 935
 		$reset = 0;
936 936
 		foreach ($all_data['states'] as $key => $line) {
937
-		    $data = array();
938
-		    $data['hex'] = $line[0]; // hex
939
-		    $data['ident'] = trim($line[1]); // ident
940
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
941
-		    $data['speed'] = round($line[9]*1.94384); // speed
942
-		    $data['heading'] = round($line[10]); // heading
943
-		    $data['latitude'] = $line[6]; // lat
944
-		    $data['longitude'] = $line[5]; // long
945
-		    $data['verticalrate'] = $line[11]; // verticale rate
946
-		    //$data['squawk'] = $line[10]; // squawk
947
-		    //$data['emergency'] = ''; // emergency
948
-		    //$data['registration'] = $line[2];
949
-		    //$data['aircraft_icao'] = $line[0];
950
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
-		    $data['format_source'] = 'opensky';
952
-		    $data['id_source'] = $id_source;
953
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
-		    $SI->add($data);
955
-		    unset($data);
937
+			$data = array();
938
+			$data['hex'] = $line[0]; // hex
939
+			$data['ident'] = trim($line[1]); // ident
940
+			$data['altitude'] = round($line[7]*3.28084); // altitude
941
+			$data['speed'] = round($line[9]*1.94384); // speed
942
+			$data['heading'] = round($line[10]); // heading
943
+			$data['latitude'] = $line[6]; // lat
944
+			$data['longitude'] = $line[5]; // long
945
+			$data['verticalrate'] = $line[11]; // verticale rate
946
+			//$data['squawk'] = $line[10]; // squawk
947
+			//$data['emergency'] = ''; // emergency
948
+			//$data['registration'] = $line[2];
949
+			//$data['aircraft_icao'] = $line[0];
950
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
951
+			$data['format_source'] = 'opensky';
952
+			$data['id_source'] = $id_source;
953
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
954
+			$SI->add($data);
955
+			unset($data);
956 956
 		}
957
-	    }
958
-	    //$last_exec['planeupdatefaa'] = time();
959
-	    $last_exec[$id]['last'] = time();
957
+		}
958
+		//$last_exec['planeupdatefaa'] = time();
959
+		$last_exec[$id]['last'] = time();
960 960
 	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
961 961
 	} elseif ($value['format'] == 'fr24json' && 
962
-	    (
962
+		(
963 963
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
964 964
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
965
-	    )
965
+		)
966 966
 	) {
967
-	    //$buffer = $Common->getData($hosts[$id]);
968
-	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
970
-	    if (!empty($all_data)) $reset = 0;
971
-	    foreach ($all_data as $key => $line) {
967
+		//$buffer = $Common->getData($hosts[$id]);
968
+		$buffer = $Common->getData($value['host']);
969
+		$all_data = json_decode($buffer,true);
970
+		if (!empty($all_data)) $reset = 0;
971
+		foreach ($all_data as $key => $line) {
972 972
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
973
-		    $data = array();
974
-		    $data['hex'] = $line[0];
975
-		    $data['ident'] = $line[16]; //$line[13]
976
-	    	    $data['altitude'] = $line[4]; // altitude
977
-	    	    $data['speed'] = $line[5]; // speed
978
-	    	    $data['heading'] = $line[3]; // heading
979
-	    	    $data['latitude'] = $line[1]; // lat
980
-	    	    $data['longitude'] = $line[2]; // long
981
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
982
-	    	    $data['squawk'] = $line[6]; // squawk
983
-	    	    $data['aircraft_icao'] = $line[8];
984
-	    	    $data['registration'] = $line[9];
985
-		    $data['departure_airport_iata'] = $line[11];
986
-		    $data['arrival_airport_iata'] = $line[12];
987
-	    	    $data['emergency'] = ''; // emergency
988
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
-	    	    $data['format_source'] = 'fr24json';
990
-    		    $data['id_source'] = $id_source;
991
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
-		    $SI->add($data);
994
-		    unset($data);
973
+			$data = array();
974
+			$data['hex'] = $line[0];
975
+			$data['ident'] = $line[16]; //$line[13]
976
+				$data['altitude'] = $line[4]; // altitude
977
+				$data['speed'] = $line[5]; // speed
978
+				$data['heading'] = $line[3]; // heading
979
+				$data['latitude'] = $line[1]; // lat
980
+				$data['longitude'] = $line[2]; // long
981
+				$data['verticalrate'] = $line[15]; // verticale rate
982
+				$data['squawk'] = $line[6]; // squawk
983
+				$data['aircraft_icao'] = $line[8];
984
+				$data['registration'] = $line[9];
985
+			$data['departure_airport_iata'] = $line[11];
986
+			$data['arrival_airport_iata'] = $line[12];
987
+				$data['emergency'] = ''; // emergency
988
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
989
+				$data['format_source'] = 'fr24json';
990
+				$data['id_source'] = $id_source;
991
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
992
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
993
+			$SI->add($data);
994
+			unset($data);
995 995
 		}
996
-	    }
997
-	    //$last_exec['fr24json'] = time();
998
-	    $last_exec[$id]['last'] = time();
996
+		}
997
+		//$last_exec['fr24json'] = time();
998
+		$last_exec[$id]['last'] = time();
999 999
 	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1000 1000
 	} elseif ($value['format'] == 'radarvirtueljson' && 
1001
-	    (
1001
+		(
1002 1002
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1003 1003
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1004
-	    )
1004
+		)
1005 1005
 	) {
1006
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1008
-	    //echo $buffer;
1009
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1010
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
-	    $all_data = json_decode($buffer,true);
1012
-	    if (json_last_error() != JSON_ERROR_NONE) {
1006
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1008
+		//echo $buffer;
1009
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1010
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
+		$all_data = json_decode($buffer,true);
1012
+		if (json_last_error() != JSON_ERROR_NONE) {
1013 1013
 		die(json_last_error_msg());
1014
-	    }
1015
-	    if (isset($all_data['mrkrs'])) {
1014
+		}
1015
+		if (isset($all_data['mrkrs'])) {
1016 1016
 		$reset = 0;
1017 1017
 		foreach ($all_data['mrkrs'] as $key => $line) {
1018
-		    if (isset($line['inf'])) {
1018
+			if (isset($line['inf'])) {
1019 1019
 			$data = array();
1020 1020
 			$data['hex'] = $line['inf']['ia'];
1021 1021
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1022
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
-	    		$data['latitude'] = $line['pt'][0]; // lat
1026
-	    		$data['longitude'] = $line['pt'][1]; // long
1027
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
-	    		//$data['aircraft_icao'] = $line[8];
1030
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1022
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1023
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1024
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1025
+				$data['latitude'] = $line['pt'][0]; // lat
1026
+				$data['longitude'] = $line['pt'][1]; // long
1027
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1028
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1029
+				//$data['aircraft_icao'] = $line[8];
1030
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1031 1031
 			//$data['departure_airport_iata'] = $line[11];
1032 1032
 			//$data['arrival_airport_iata'] = $line[12];
1033
-	    		//$data['emergency'] = ''; // emergency
1033
+				//$data['emergency'] = ''; // emergency
1034 1034
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1035
-	    		$data['format_source'] = 'radarvirtueljson';
1036
-    			$data['id_source'] = $id_source;
1035
+				$data['format_source'] = 'radarvirtueljson';
1036
+				$data['id_source'] = $id_source;
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1038 1038
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1039 1039
 			$SI->add($data);
1040 1040
 			unset($data);
1041
-		    }
1041
+			}
1042
+		}
1042 1043
 		}
1043
-	    }
1044
-	    //$last_exec['radarvirtueljson'] = time();
1045
-	    $last_exec[$id]['last'] = time();
1044
+		//$last_exec['radarvirtueljson'] = time();
1045
+		$last_exec[$id]['last'] = time();
1046 1046
 	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1047 1047
 	} elseif ($value['format'] == 'pirepsjson' && 
1048
-	    (
1048
+		(
1049 1049
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1050 1050
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1051
-	    )
1051
+		)
1052 1052
 	) {
1053
-	    //$buffer = $Common->getData($hosts[$id]);
1054
-	    $buffer = $Common->getData($value['host'].'?'.time());
1055
-	    $all_data = json_decode(utf8_encode($buffer),true);
1053
+		//$buffer = $Common->getData($hosts[$id]);
1054
+		$buffer = $Common->getData($value['host'].'?'.time());
1055
+		$all_data = json_decode(utf8_encode($buffer),true);
1056 1056
 	    
1057
-	    if (isset($all_data['pireps'])) {
1057
+		if (isset($all_data['pireps'])) {
1058 1058
 		$reset = 0;
1059
-	        foreach ($all_data['pireps'] as $line) {
1060
-		    $data = array();
1061
-		    $data['id'] = $line['id'];
1062
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
-		    $data['ident'] = $line['callsign']; // ident
1064
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
-		    $data['latitude'] = $line['lat']; // lat
1071
-		    $data['longitude'] = $line['lon']; // long
1072
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1073
-		    //$data['squawk'] = $line['squawk']; // squawk
1074
-		    //$data['emergency'] = ''; // emergency
1075
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1079
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
-		    else $data['info'] = '';
1083
-		    $data['format_source'] = 'pireps';
1084
-    		    $data['id_source'] = $id_source;
1085
-		    $data['datetime'] = date('Y-m-d H:i:s');
1086
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
-		    if ($line['icon'] == 'plane') {
1059
+			foreach ($all_data['pireps'] as $line) {
1060
+			$data = array();
1061
+			$data['id'] = $line['id'];
1062
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1063
+			$data['ident'] = $line['callsign']; // ident
1064
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1066
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1067
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1068
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1069
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1070
+			$data['latitude'] = $line['lat']; // lat
1071
+			$data['longitude'] = $line['lon']; // long
1072
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1073
+			//$data['squawk'] = $line['squawk']; // squawk
1074
+			//$data['emergency'] = ''; // emergency
1075
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1076
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1077
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1078
+			//$data['arrival_airport_time'] = $line['arrtime'];
1079
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1080
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1081
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1082
+			else $data['info'] = '';
1083
+			$data['format_source'] = 'pireps';
1084
+				$data['id_source'] = $id_source;
1085
+			$data['datetime'] = date('Y-m-d H:i:s');
1086
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1087
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1088
+			if ($line['icon'] == 'plane') {
1089 1089
 			$SI->add($data);
1090
-		    //    print_r($data);
1091
-    		    } elseif ($line['icon'] == 'ct') {
1090
+			//    print_r($data);
1091
+				} elseif ($line['icon'] == 'ct') {
1092 1092
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1093 1093
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1094 1094
 			$typec = substr($data['ident'],-3);
@@ -1103,148 +1103,148 @@  discard block
 block discarded – undo
1103 1103
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1104 1104
 			else $data['type'] = 'Observer';
1105 1105
 			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']);
1106
-		    }
1107
-		    unset($data);
1106
+			}
1107
+			unset($data);
1108
+		}
1108 1109
 		}
1109
-	    }
1110
-	    //$last_exec['pirepsjson'] = time();
1111
-	    $last_exec[$id]['last'] = time();
1110
+		//$last_exec['pirepsjson'] = time();
1111
+		$last_exec[$id]['last'] = time();
1112 1112
 	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1113 1113
 	} elseif ($value['format'] == 'phpvmacars' && 
1114
-	    (
1114
+		(
1115 1115
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1116 1116
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1117
-	    )
1117
+		)
1118 1118
 	) {
1119
-	    //$buffer = $Common->getData($hosts[$id]);
1120
-	    if ($globalDebug) echo 'Get Data...'."\n";
1121
-	    $buffer = $Common->getData($value['host']);
1122
-	    $all_data = json_decode($buffer,true);
1123
-	    if ($buffer != '' && is_array($all_data)) {
1119
+		//$buffer = $Common->getData($hosts[$id]);
1120
+		if ($globalDebug) echo 'Get Data...'."\n";
1121
+		$buffer = $Common->getData($value['host']);
1122
+		$all_data = json_decode($buffer,true);
1123
+		if ($buffer != '' && is_array($all_data)) {
1124 1124
 		$reset = 0;
1125 1125
 		foreach ($all_data as $line) {
1126
-	    	    $data = array();
1127
-	    	    //$data['id'] = $line['id']; // id not usable
1128
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
-	    	    $data['ident'] = $line['flightnum']; // ident
1133
-	    	    $data['altitude'] = $line['alt']; // altitude
1134
-	    	    $data['speed'] = $line['gs']; // speed
1135
-	    	    $data['heading'] = $line['heading']; // heading
1136
-	    	    $data['latitude'] = $line['lat']; // lat
1137
-	    	    $data['longitude'] = $line['lng']; // long
1138
-	    	    $data['verticalrate'] = ''; // verticale rate
1139
-	    	    $data['squawk'] = ''; // squawk
1140
-	    	    $data['emergency'] = ''; // emergency
1141
-	    	    //$data['datetime'] = $line['lastupdate'];
1142
-	    	    //$data['last_update'] = $line['lastupdate'];
1143
-	    	    if (isset($value['timezone'])) {
1144
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1148
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1149
-	    	    $data['departure_airport_time'] = $line['deptime'];
1150
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1151
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1152
-    		    $data['registration'] = $line['aircraft'];
1153
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
-		    if (isset($line['aircraftname'])) {
1126
+				$data = array();
1127
+				//$data['id'] = $line['id']; // id not usable
1128
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1130
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132
+				$data['ident'] = $line['flightnum']; // ident
1133
+				$data['altitude'] = $line['alt']; // altitude
1134
+				$data['speed'] = $line['gs']; // speed
1135
+				$data['heading'] = $line['heading']; // heading
1136
+				$data['latitude'] = $line['lat']; // lat
1137
+				$data['longitude'] = $line['lng']; // long
1138
+				$data['verticalrate'] = ''; // verticale rate
1139
+				$data['squawk'] = ''; // squawk
1140
+				$data['emergency'] = ''; // emergency
1141
+				//$data['datetime'] = $line['lastupdate'];
1142
+				//$data['last_update'] = $line['lastupdate'];
1143
+				if (isset($value['timezone'])) {
1144
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1145
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1146
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1148
+				$data['departure_airport_icao'] = $line['depicao'];
1149
+				$data['departure_airport_time'] = $line['deptime'];
1150
+				$data['arrival_airport_icao'] = $line['arricao'];
1151
+				$data['arrival_airport_time'] = $line['arrtime'];
1152
+				$data['registration'] = $line['aircraft'];
1153
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1154
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155
+			if (isset($line['aircraftname'])) {
1156 1156
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1157 1157
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1158
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1159
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
-	    		else {
1162
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1163
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
-	    		}
1166
-	    	    }
1167
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
-    		    $data['id_source'] = $id_source;
1169
-	    	    $data['format_source'] = 'phpvmacars';
1170
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
-		    $SI->add($data);
1172
-		    unset($data);
1158
+				$aircraft_data = explode('-',$line['aircraftname']);
1159
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161
+				else {
1162
+					$aircraft_data = explode(' ',$line['aircraftname']);
1163
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1165
+				}
1166
+				}
1167
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1168
+				$data['id_source'] = $id_source;
1169
+				$data['format_source'] = 'phpvmacars';
1170
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
+			$SI->add($data);
1172
+			unset($data);
1173 1173
 		}
1174 1174
 		if ($globalDebug) echo 'No more data...'."\n";
1175 1175
 		unset($buffer);
1176 1176
 		unset($all_data);
1177
-	    }
1178
-	    //$last_exec['phpvmacars'] = time();
1179
-	    $last_exec[$id]['last'] = time();
1177
+		}
1178
+		//$last_exec['phpvmacars'] = time();
1179
+		$last_exec[$id]['last'] = time();
1180 1180
 	} elseif ($value['format'] == 'vam' && 
1181
-	    (
1181
+		(
1182 1182
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1183 1183
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1184
-	    )
1184
+		)
1185 1185
 	) {
1186
-	    //$buffer = $Common->getData($hosts[$id]);
1187
-	    if ($globalDebug) echo 'Get Data...'."\n";
1188
-	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1190
-	    if ($buffer != '' && is_array($all_data)) {
1186
+		//$buffer = $Common->getData($hosts[$id]);
1187
+		if ($globalDebug) echo 'Get Data...'."\n";
1188
+		$buffer = $Common->getData($value['host']);
1189
+		$all_data = json_decode($buffer,true);
1190
+		if ($buffer != '' && is_array($all_data)) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data as $line) {
1193
-	    	    $data = array();
1194
-	    	    //$data['id'] = $line['id']; // id not usable
1195
-	    	    $data['id'] = trim($line['flight_id']);
1196
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
-	    	    $data['pilot_name'] = $line['pilot_name'];
1198
-	    	    $data['pilot_id'] = $line['pilot_id'];
1199
-	    	    $data['ident'] = trim($line['callsign']); // ident
1200
-	    	    $data['altitude'] = $line['altitude']; // altitude
1201
-	    	    $data['speed'] = $line['gs']; // speed
1202
-	    	    $data['heading'] = $line['heading']; // heading
1203
-	    	    $data['latitude'] = $line['latitude']; // lat
1204
-	    	    $data['longitude'] = $line['longitude']; // long
1205
-	    	    $data['verticalrate'] = ''; // verticale rate
1206
-	    	    $data['squawk'] = ''; // squawk
1207
-	    	    $data['emergency'] = ''; // emergency
1208
-	    	    //$data['datetime'] = $line['lastupdate'];
1209
-	    	    $data['last_update'] = $line['last_update'];
1210
-		    $data['datetime'] = date('Y-m-d H:i:s');
1211
-	    	    $data['departure_airport_icao'] = $line['departure'];
1212
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1213
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1214
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1215
-    		    //$data['registration'] = $line['aircraft'];
1216
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1218
-    		    $data['id_source'] = $id_source;
1219
-	    	    $data['format_source'] = 'vam';
1220
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
-		    $SI->add($data);
1223
-		    unset($data);
1193
+				$data = array();
1194
+				//$data['id'] = $line['id']; // id not usable
1195
+				$data['id'] = trim($line['flight_id']);
1196
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1197
+				$data['pilot_name'] = $line['pilot_name'];
1198
+				$data['pilot_id'] = $line['pilot_id'];
1199
+				$data['ident'] = trim($line['callsign']); // ident
1200
+				$data['altitude'] = $line['altitude']; // altitude
1201
+				$data['speed'] = $line['gs']; // speed
1202
+				$data['heading'] = $line['heading']; // heading
1203
+				$data['latitude'] = $line['latitude']; // lat
1204
+				$data['longitude'] = $line['longitude']; // long
1205
+				$data['verticalrate'] = ''; // verticale rate
1206
+				$data['squawk'] = ''; // squawk
1207
+				$data['emergency'] = ''; // emergency
1208
+				//$data['datetime'] = $line['lastupdate'];
1209
+				$data['last_update'] = $line['last_update'];
1210
+			$data['datetime'] = date('Y-m-d H:i:s');
1211
+				$data['departure_airport_icao'] = $line['departure'];
1212
+				//$data['departure_airport_time'] = $line['departure_time'];
1213
+				$data['arrival_airport_icao'] = $line['arrival'];
1214
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1215
+				//$data['registration'] = $line['aircraft'];
1216
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1217
+				$data['aircraft_icao'] = $line['plane_type'];
1218
+				$data['id_source'] = $id_source;
1219
+				$data['format_source'] = 'vam';
1220
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1221
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1222
+			$SI->add($data);
1223
+			unset($data);
1224 1224
 		}
1225 1225
 		if ($globalDebug) echo 'No more data...'."\n";
1226 1226
 		unset($buffer);
1227 1227
 		unset($all_data);
1228
-	    }
1229
-	    //$last_exec['phpvmacars'] = time();
1230
-	    $last_exec[$id]['last'] = time();
1228
+		}
1229
+		//$last_exec['phpvmacars'] = time();
1230
+		$last_exec[$id]['last'] = time();
1231 1231
 	} elseif ($value['format'] == 'blitzortung' && 
1232
-	    (
1232
+		(
1233 1233
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1234 1234
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1235
-	    )
1235
+		)
1236 1236
 	) {
1237
-	    //$buffer = $Common->getData($hosts[$id]);
1238
-	    if ($globalDebug) echo 'Get Data...'."\n";
1239
-	    $buffer = $Common->getData($value['host']);
1240
-	    $all_data = json_decode($buffer,true);
1241
-	    if ($buffer != '') {
1237
+		//$buffer = $Common->getData($hosts[$id]);
1238
+		if ($globalDebug) echo 'Get Data...'."\n";
1239
+		$buffer = $Common->getData($value['host']);
1240
+		$all_data = json_decode($buffer,true);
1241
+		if ($buffer != '') {
1242 1242
 		$Source->deleteLocationBySource('blitzortung');
1243 1243
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1244 1244
 		$buffer = explode('\n',$buffer);
1245 1245
 		foreach ($buffer as $buffer_line) {
1246
-		    $line = json_decode($buffer_line,true);
1247
-		    if (isset($line['time'])) {
1246
+			$line = json_decode($buffer_line,true);
1247
+			if (isset($line['time'])) {
1248 1248
 			$data = array();
1249 1249
 			$data['altitude'] = $line['alt']; // altitude
1250 1250
 			$data['latitude'] = $line['lat']; // lat
@@ -1256,94 +1256,94 @@  discard block
 block discarded – undo
1256 1256
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1257 1257
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1258 1258
 			unset($data);
1259
-		    }
1259
+			}
1260 1260
 		}
1261 1261
 		if ($globalDebug) echo 'No more data...'."\n";
1262 1262
 		unset($buffer);
1263
-	    }
1264
-	    $last_exec[$id]['last'] = time();
1263
+		}
1264
+		$last_exec[$id]['last'] = time();
1265 1265
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1266 1266
 	} 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') {
1267
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
-    	    //$last_exec[$id]['last'] = time();
1267
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1268
+			//$last_exec[$id]['last'] = time();
1269 1269
 
1270
-	    //$read = array( $sockets[$id] );
1271
-	    $read = $sockets;
1272
-	    $write = NULL;
1273
-	    $e = NULL;
1274
-	    $n = socket_select($read, $write, $e, $timeout);
1275
-	    if ($e != NULL) var_dump($e);
1276
-	    if ($n > 0) {
1270
+		//$read = array( $sockets[$id] );
1271
+		$read = $sockets;
1272
+		$write = NULL;
1273
+		$e = NULL;
1274
+		$n = socket_select($read, $write, $e, $timeout);
1275
+		if ($e != NULL) var_dump($e);
1276
+		if ($n > 0) {
1277 1277
 		$reset = 0;
1278 1278
 		foreach ($read as $nb => $r) {
1279
-		    //$value = $formats[$nb];
1280
-		    $format = $globalSources[$nb]['format'];
1281
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1279
+			//$value = $formats[$nb];
1280
+			$format = $globalSources[$nb]['format'];
1281
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1282 1282
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1283
-		    } elseif ($format == 'vrstcp') {
1283
+			} elseif ($format == 'vrstcp') {
1284 1284
 			$buffer = @socket_read($r, 6000);
1285
-		    } else {
1285
+			} else {
1286 1286
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1287
-		    }
1288
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
-		    //echo $buffer."\n";
1290
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1291
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
-		    $error = false;
1293
-		    //$SI::del();
1294
-		    if ($format == 'vrstcp') {
1287
+			}
1288
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289
+			//echo $buffer."\n";
1290
+			// lets play nice and handle signals such as ctrl-c/kill properly
1291
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1292
+			$error = false;
1293
+			//$SI::del();
1294
+			if ($format == 'vrstcp') {
1295 1295
 			$buffer = explode('},{',$buffer);
1296
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
-		    // SBS format is CSV format
1298
-		    if ($buffer !== FALSE && $buffer != '') {
1296
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1297
+			// SBS format is CSV format
1298
+			if ($buffer !== FALSE && $buffer != '') {
1299 1299
 			$tt[$format] = 0;
1300 1300
 			if ($format == 'acarssbs3') {
1301
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
-			    $ACARS->add(trim($buffer));
1303
-			    $ACARS->deleteLiveAcarsData();
1301
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1302
+				$ACARS->add(trim($buffer));
1303
+				$ACARS->deleteLiveAcarsData();
1304 1304
 			} elseif ($format == 'raw') {
1305
-			    // AVR format
1306
-			    $data = $SBS->parse($buffer);
1307
-			    if (is_array($data)) {
1305
+				// AVR format
1306
+				$data = $SBS->parse($buffer);
1307
+				if (is_array($data)) {
1308 1308
 				$data['datetime'] = date('Y-m-d H:i:s');
1309 1309
 				$data['format_source'] = 'raw';
1310 1310
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1311 1311
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1312 1312
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1313 1313
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1314
-			    }
1314
+				}
1315 1315
 			} elseif ($format == 'ais') {
1316
-			    $ais_data = $AIS->parse_line(trim($buffer));
1317
-			    $data = array();
1318
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1316
+				$ais_data = $AIS->parse_line(trim($buffer));
1317
+				$data = array();
1318
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1319
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1320
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1321
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1322
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1323
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1324
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1325
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1326
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1327
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1331
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1334 1334
 
1335
-			    if (isset($ais_data['timestamp'])) {
1335
+				if (isset($ais_data['timestamp'])) {
1336 1336
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1337
-			    } else {
1337
+				} else {
1338 1338
 				$data['datetime'] = date('Y-m-d H:i:s');
1339
-			    }
1340
-			    $data['format_source'] = 'aisnmea';
1341
-    			    $data['id_source'] = $id_source;
1342
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
-			    unset($data);
1344
-                        } elseif ($format == 'flightgearsp') {
1345
-                    	    //echo $buffer."\n";
1346
-                    	    if (strlen($buffer) > 5) {
1339
+				}
1340
+				$data['format_source'] = 'aisnmea';
1341
+					$data['id_source'] = $id_source;
1342
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1343
+				unset($data);
1344
+						} elseif ($format == 'flightgearsp') {
1345
+							//echo $buffer."\n";
1346
+							if (strlen($buffer) > 5) {
1347 1347
 				$line = explode(',',$buffer);
1348 1348
 				$data = array();
1349 1349
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1360,38 +1360,38 @@  discard block
 block discarded – undo
1360 1360
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1361 1361
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1362 1362
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1363
-			    }
1364
-                        } elseif ($format == 'acars') {
1365
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
-			    $ACARS->add(trim($buffer));
1367
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
-			    $ACARS->deleteLiveAcarsData();
1363
+				}
1364
+						} elseif ($format == 'acars') {
1365
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366
+				$ACARS->add(trim($buffer));
1367
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1368
+				$ACARS->deleteLiveAcarsData();
1369 1369
 			} elseif ($format == 'flightgearmp') {
1370
-			    if (substr($buffer,0,1) != '#') {
1370
+				if (substr($buffer,0,1) != '#') {
1371 1371
 				$data = array();
1372 1372
 				//echo $buffer."\n";
1373 1373
 				$line = explode(' ',$buffer);
1374 1374
 				if (count($line) == 11) {
1375
-				    $userserver = explode('@',$line[0]);
1376
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
-				    $data['ident'] = $userserver[0];
1378
-				    $data['registration'] = $userserver[0];
1379
-				    $data['latitude'] = $line[4];
1380
-				    $data['longitude'] = $line[5];
1381
-				    $data['altitude'] = $line[6];
1382
-				    $data['datetime'] = date('Y-m-d H:i:s');
1383
-				    $aircraft_type = $line[10];
1384
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1385
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1375
+					$userserver = explode('@',$line[0]);
1376
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1377
+					$data['ident'] = $userserver[0];
1378
+					$data['registration'] = $userserver[0];
1379
+					$data['latitude'] = $line[4];
1380
+					$data['longitude'] = $line[5];
1381
+					$data['altitude'] = $line[6];
1382
+					$data['datetime'] = date('Y-m-d H:i:s');
1383
+					$aircraft_type = $line[10];
1384
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1385
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1386
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388
+				}
1388 1389
 				}
1389
-			    }
1390 1390
 			} elseif ($format == 'beast') {
1391
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
-			    die;
1391
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392
+				die;
1393 1393
 			} elseif ($format == 'vrstcp') {
1394
-			    foreach($buffer as $all_data) {
1394
+				foreach($buffer as $all_data) {
1395 1395
 				$line = json_decode('{'.$all_data.'}',true);
1396 1396
 				$data = array();
1397 1397
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1411,148 +1411,148 @@  discard block
 block discarded – undo
1411 1411
 				*/
1412 1412
 				$data['datetime'] = date('Y-m-d H:i:s');
1413 1413
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1414
-		    		$data['format_source'] = 'vrstcp';
1414
+					$data['format_source'] = 'vrstcp';
1415 1415
 				$data['id_source'] = $id_source;
1416 1416
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1417 1417
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1418 1418
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1419 1419
 				unset($data);
1420
-			    }
1420
+				}
1421 1421
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1422
-			    $line = explode("\t", $buffer);
1423
-			    for($k = 0; $k < count($line); $k=$k+2) {
1422
+				$line = explode("\t", $buffer);
1423
+				for($k = 0; $k < count($line); $k=$k+2) {
1424 1424
 				$key = $line[$k];
1425
-			        $lined[$key] = $line[$k+1];
1426
-			    }
1427
-    			    if (count($lined) > 3) {
1428
-    				$data['hex'] = $lined['hexid'];
1429
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1431
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
-    				$data['id_source'] = $id_source;
1439
-    				$data['format_source'] = 'tsv';
1440
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1425
+					$lined[$key] = $line[$k+1];
1426
+				}
1427
+					if (count($lined) > 3) {
1428
+					$data['hex'] = $lined['hexid'];
1429
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
+					$data['datetime'] = date('Y-m-d H:i:s');;
1431
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1434
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1435
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1436
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1437
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1438
+					$data['id_source'] = $id_source;
1439
+					$data['format_source'] = 'tsv';
1440
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1441
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1442 1442
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1443
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
-    				unset($lined);
1445
-    				unset($data);
1446
-    			    } else $error = true;
1443
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1444
+					unset($lined);
1445
+					unset($data);
1446
+					} else $error = true;
1447 1447
 			} elseif ($format == 'aprs' && $use_aprs) {
1448
-			    if ($aprs_connect == 0) {
1448
+				if ($aprs_connect == 0) {
1449 1449
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1450 1450
 				$aprs_connect = 1;
1451
-			    }
1451
+				}
1452 1452
 			    
1453
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1453
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1454 1454
 				$aprs_last_tx = time();
1455 1455
 				$data_aprs = "# Keep alive";
1456 1456
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1457
-			    }
1457
+				}
1458 1458
 			    
1459
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
-			    //echo 'APRS data : '.$buffer."\n";
1461
-			    $buffer = str_replace('APRS <- ','',$buffer);
1462
-			    $buffer = str_replace('APRS -> ','',$buffer);
1463
-			    //echo $buffer."\n";
1464
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1459
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460
+				//echo 'APRS data : '.$buffer."\n";
1461
+				$buffer = str_replace('APRS <- ','',$buffer);
1462
+				$buffer = str_replace('APRS -> ','',$buffer);
1463
+				//echo $buffer."\n";
1464
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1465 1465
 				$line = $APRS->parse($buffer);
1466 1466
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1467 1467
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1468
-				    $aprs_last_tx = time();
1469
-				    $data = array();
1470
-				    //print_r($line);
1471
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1472
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1481
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1482
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
-				    $data['latitude'] = $line['latitude'];
1484
-				    $data['longitude'] = $line['longitude'];
1485
-				    //$data['verticalrate'] = $line[16];
1486
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
-				    //else $data['speed'] = 0;
1488
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
-				    //else $data['heading'] = 0;
1493
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
-    				    $data['id_source'] = $id_source;
1500
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
-				    else $data['format_source'] = 'aprs';
1502
-				    $data['source_name'] = $line['source'];
1503
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
-				    else $data['source_type'] = 'flarm';
1505
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
-				    $currentdate = date('Y-m-d H:i:s');
1507
-				    $aprsdate = strtotime($data['datetime']);
1508
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
-				    // Accept data if time <= system time + 20s
1510
-				    //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'])))) {
1511
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1468
+					$aprs_last_tx = time();
1469
+					$data = array();
1470
+					//print_r($line);
1471
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1472
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1473
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1474
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1475
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1476
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1480
+					else $data['datetime'] = date('Y-m-d H:i:s');
1481
+					//$data['datetime'] = date('Y-m-d H:i:s');
1482
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1483
+					$data['latitude'] = $line['latitude'];
1484
+					$data['longitude'] = $line['longitude'];
1485
+					//$data['verticalrate'] = $line[16];
1486
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1487
+					//else $data['speed'] = 0;
1488
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1489
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1490
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1491
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1492
+					//else $data['heading'] = 0;
1493
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1494
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1495
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1496
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1497
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1498
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1499
+						$data['id_source'] = $id_source;
1500
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1501
+					else $data['format_source'] = 'aprs';
1502
+					$data['source_name'] = $line['source'];
1503
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1504
+					else $data['source_type'] = 'flarm';
1505
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1506
+					$currentdate = date('Y-m-d H:i:s');
1507
+					$aprsdate = strtotime($data['datetime']);
1508
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1509
+					// Accept data if time <= system time + 20s
1510
+					//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'])))) {
1511
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1512 1512
 					$send = $SI->add($data);
1513
-				    } elseif ($data['source_type'] == 'ais') {
1513
+					} elseif ($data['source_type'] == 'ais') {
1514 1514
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1515
-				    } elseif (isset($line['stealth'])) {
1515
+					} elseif (isset($line['stealth'])) {
1516 1516
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1517 1517
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1518
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
-					    //$line['symbol'] == 'Balloon' ||
1520
-					    $line['symbol'] == 'Glider' || 
1521
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
-					    if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
-					    if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
-					    $send = $SI->add($data);
1525
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
-					    $line['symbol'] == 'Yacht (Sail)' || 
1527
-					    $line['symbol'] == 'Ship (Power Boat)')) {
1528
-					    $send = $MI->add($data);
1529
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
-					    $line['symbol'] == 'Car' || 
1531
-					    $line['symbol'] == 'Ambulance' || 
1532
-					    $line['symbol'] == 'Van' || 
1533
-					    $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
-					    $line['symbol'] == 'Motorcycle' || 
1535
-					    $line['symbol'] == 'Tractor' || 
1536
-					    $line['symbol'] == 'Police' || 
1537
-					    $line['symbol'] == 'Bike' || 
1538
-					    $line['symbol'] == 'Jogger' || 
1539
-					    $line['symbol'] == 'Horse' || 
1540
-					    $line['symbol'] == 'Bus' || 
1541
-					    $line['symbol'] == 'Jeep' || 
1542
-					    $line['symbol'] == 'Recreational Vehicle' || 
1543
-					    $line['symbol'] == 'Yacht (Sail)' || 
1544
-					    $line['symbol'] == 'Ship (Power Boat)' || 
1545
-					    $line['symbol'] == 'Firetruck' || 
1546
-					    $line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
-					    $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
-					    $line['symbol'] == 'SUV' ||
1549
-					    $line['symbol'] == 'Snowmobile' ||
1550
-					    $line['symbol'] == 'Mobile Satellite Station')) {
1551
-				    //} 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') {
1518
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1519
+						//$line['symbol'] == 'Balloon' ||
1520
+						$line['symbol'] == 'Glider' || 
1521
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1522
+						if ($line['symbol'] == 'Ballon') $data['aircraft_icao'] = 'BALL';
1523
+						if ($line['symbol'] == 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1524
+						$send = $SI->add($data);
1525
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1526
+						$line['symbol'] == 'Yacht (Sail)' || 
1527
+						$line['symbol'] == 'Ship (Power Boat)')) {
1528
+						$send = $MI->add($data);
1529
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1530
+						$line['symbol'] == 'Car' || 
1531
+						$line['symbol'] == 'Ambulance' || 
1532
+						$line['symbol'] == 'Van' || 
1533
+						$line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || 
1534
+						$line['symbol'] == 'Motorcycle' || 
1535
+						$line['symbol'] == 'Tractor' || 
1536
+						$line['symbol'] == 'Police' || 
1537
+						$line['symbol'] == 'Bike' || 
1538
+						$line['symbol'] == 'Jogger' || 
1539
+						$line['symbol'] == 'Horse' || 
1540
+						$line['symbol'] == 'Bus' || 
1541
+						$line['symbol'] == 'Jeep' || 
1542
+						$line['symbol'] == 'Recreational Vehicle' || 
1543
+						$line['symbol'] == 'Yacht (Sail)' || 
1544
+						$line['symbol'] == 'Ship (Power Boat)' || 
1545
+						$line['symbol'] == 'Firetruck' || 
1546
+						$line['symbol'] == 'Balloon' || $line['symbol'] == 'Glider' || 
1547
+						$line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter' || 
1548
+						$line['symbol'] == 'SUV' ||
1549
+						$line['symbol'] == 'Snowmobile' ||
1550
+						$line['symbol'] == 'Mobile Satellite Station')) {
1551
+					//} 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') {
1552 1552
 				//    } 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') {
1553 1553
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1554 1554
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1555
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1555
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1556 1556
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1557 1557
 					$Source->deleteOldLocationByType('gs');
1558 1558
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1560,7 +1560,7 @@  discard block
 block discarded – undo
1560 1560
 					} else {
1561 1561
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1562 1562
 					}
1563
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1563
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1564 1564
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1565 1565
 					if ($globalDebug) echo '# Weather Station added'."\n";
1566 1566
 					$Source->deleteOldLocationByType('wx');
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
 					} else {
1571 1571
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1572 1572
 					}
1573
-				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1573
+					} elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1574 1574
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1575 1575
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1576 1576
 					$Source->deleteOldLocationByType('lightning');
@@ -1579,11 +1579,11 @@  discard block
 block discarded – undo
1579 1579
 					} else {
1580 1580
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1581 1581
 					}
1582
-				    } elseif ($globalDebug) {
1583
-				    	echo '/!\ Not added: '.$buffer."\n";
1584
-				    	print_r($line);
1585
-				    }
1586
-				    unset($data);
1582
+					} elseif ($globalDebug) {
1583
+						echo '/!\ Not added: '.$buffer."\n";
1584
+						print_r($line);
1585
+					}
1586
+					unset($data);
1587 1587
 				}
1588 1588
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1589 1589
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -1602,12 +1602,12 @@  discard block
 block discarded – undo
1602 1602
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
1603 1603
 					$globalSources[$nb]['last_weather_clean'] = time();
1604 1604
 				}
1605
-			    }
1605
+				}
1606 1606
 			} else {
1607
-			    $line = explode(',', $buffer);
1608
-    			    if (count($line) > 20) {
1609
-    			    	$data['hex'] = $line[4];
1610
-    				/*
1607
+				$line = explode(',', $buffer);
1608
+					if (count($line) > 20) {
1609
+						$data['hex'] = $line[4];
1610
+					/*
1611 1611
     				$data['datetime'] = $line[6].' '.$line[7];
1612 1612
     					date_default_timezone_set($globalTimezone);
1613 1613
     					$datetime = new DateTime($data['datetime']);
@@ -1615,30 +1615,30 @@  discard block
 block discarded – undo
1615 1615
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1616 1616
     					date_default_timezone_set('UTC');
1617 1617
     				*/
1618
-    				// Force datetime to current UTC datetime
1619
-    				date_default_timezone_set('UTC');
1620
-    				$data['datetime'] = date('Y-m-d H:i:s');
1621
-    				$data['ident'] = trim($line[10]);
1622
-    				$data['latitude'] = $line[14];
1623
-    				$data['longitude'] = $line[15];
1624
-    				$data['verticalrate'] = $line[16];
1625
-    				$data['emergency'] = $line[20];
1626
-    				$data['speed'] = $line[12];
1627
-    				$data['squawk'] = $line[17];
1628
-    				$data['altitude'] = $line[11];
1629
-    				$data['heading'] = $line[13];
1630
-    				$data['ground'] = $line[21];
1631
-    				$data['emergency'] = $line[19];
1632
-    				$data['format_source'] = 'sbs';
1618
+					// Force datetime to current UTC datetime
1619
+					date_default_timezone_set('UTC');
1620
+					$data['datetime'] = date('Y-m-d H:i:s');
1621
+					$data['ident'] = trim($line[10]);
1622
+					$data['latitude'] = $line[14];
1623
+					$data['longitude'] = $line[15];
1624
+					$data['verticalrate'] = $line[16];
1625
+					$data['emergency'] = $line[20];
1626
+					$data['speed'] = $line[12];
1627
+					$data['squawk'] = $line[17];
1628
+					$data['altitude'] = $line[11];
1629
+					$data['heading'] = $line[13];
1630
+					$data['ground'] = $line[21];
1631
+					$data['emergency'] = $line[19];
1632
+					$data['format_source'] = 'sbs';
1633 1633
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1634
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1634
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1635 1635
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1636
-    				$data['id_source'] = $id_source;
1637
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
-    				else $error = true;
1639
-    				unset($data);
1640
-    			    } else $error = true;
1641
-			    if ($error) {
1636
+					$data['id_source'] = $id_source;
1637
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1638
+					else $error = true;
1639
+					unset($data);
1640
+					} else $error = true;
1641
+				if ($error) {
1642 1642
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1643 1643
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1644 1644
 				} else {
@@ -1654,13 +1654,13 @@  discard block
 block discarded – undo
1654 1654
 					connect_all($sourceer);
1655 1655
 					$sourceer = array();
1656 1656
 				}
1657
-			    }
1657
+				}
1658 1658
 			}
1659 1659
 			// Sleep for xxx microseconds
1660 1660
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1661
-		    } else {
1661
+			} else {
1662 1662
 			if ($format == 'flightgearmp') {
1663
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1663
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1664 1664
 				//@socket_close($r);
1665 1665
 				sleep($globalMinFetch);
1666 1666
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1669,9 +1669,9 @@  discard block
 block discarded – undo
1669 1669
 				break;
1670 1670
 				
1671 1671
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1672
-			    if (isset($tt[$format])) $tt[$format]++;
1673
-			    else $tt[$format] = 0;
1674
-			    if ($tt[$format] > 30) {
1672
+				if (isset($tt[$format])) $tt[$format]++;
1673
+				else $tt[$format] = 0;
1674
+				if ($tt[$format] > 30) {
1675 1675
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1676 1676
 				//@socket_close($r);
1677 1677
 				sleep(2);
@@ -1682,23 +1682,23 @@  discard block
 block discarded – undo
1682 1682
 				//connect_all($globalSources);
1683 1683
 				$tt[$format]=0;
1684 1684
 				break;
1685
-			    }
1685
+				}
1686
+			}
1686 1687
 			}
1687
-		    }
1688 1688
 		}
1689
-	    } else {
1689
+		} else {
1690 1690
 		$error = socket_strerror(socket_last_error());
1691 1691
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1692 1692
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1693 1693
 			if (isset($globalDebug)) echo "Restarting...\n";
1694 1694
 			// Restart the script if possible
1695 1695
 			if (is_array($sockets)) {
1696
-			    if ($globalDebug) echo "Shutdown all sockets...";
1696
+				if ($globalDebug) echo "Shutdown all sockets...";
1697 1697
 			    
1698
-			    foreach ($sockets as $sock) {
1698
+				foreach ($sockets as $sock) {
1699 1699
 				@socket_shutdown($sock,2);
1700 1700
 				@socket_close($sock);
1701
-			    }
1701
+				}
1702 1702
 			    
1703 1703
 			}
1704 1704
 			if ($globalDebug) echo "Waiting...";
@@ -1713,15 +1713,15 @@  discard block
 block discarded – undo
1713 1713
 			if ($globalDebug) echo "Restart all connections...";
1714 1714
 			connect_all($globalSources);
1715 1715
 		}
1716
-	    }
1716
+		}
1717 1717
 	}
1718 1718
 	if ($globalDaemon === false) {
1719
-	    if ($globalDebug) echo 'Check all...'."\n";
1720
-	    if (isset($SI)) $SI->checkAll();
1721
-	    if (isset($TI)) $TI->checkAll();
1722
-	    if (isset($MI)) $MI->checkAll();
1719
+		if ($globalDebug) echo 'Check all...'."\n";
1720
+		if (isset($SI)) $SI->checkAll();
1721
+		if (isset($TI)) $TI->checkAll();
1722
+		if (isset($MI)) $MI->checkAll();
1723
+	}
1723 1724
 	}
1724
-    }
1725 1725
 }
1726 1726
 
1727 1727
 ?>
Please login to merge, or discard this patch.
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	    die;
51 51
 	}
52 52
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
53
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
53
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
54 54
     }
55 55
 }
56 56
 
57
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
57
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
58 58
 //if (isset($options['s'])) $hosts = array($options['s']);
59 59
 //elseif (isset($options['source'])) $hosts = array($options['source']);
60 60
 if (isset($options['s'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['s']);
64 64
 } elseif (isset($options['source'])) {
65 65
     $globalSources = array();
66
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
66
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
67 67
     else $globalSources[] = array('host' => $options['source']);
68 68
 }
69 69
 if (isset($options['aprsserverhost'])) {
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
 else $id_source = 1;
81 81
 if (isset($globalServer) && $globalServer) {
82 82
     if ($globalDebug) echo "Using Server Mode\n";
83
-    $SI=new SpotterServer();
83
+    $SI = new SpotterServer();
84 84
 /*
85 85
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
86 86
     $SI = new adsb2aprs();
87 87
     $SI->connect();
88 88
 */
89
-} else $SI=new SpotterImport($Connection->db);
89
+} else $SI = new SpotterImport($Connection->db);
90 90
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
91 91
 if (isset($globalMarine) && $globalMarine) {
92 92
     $AIS = new AIS();
93 93
     $MI = new MarineImport($Connection->db);
94 94
 }
95 95
 //$APRS=new APRS($Connection->db);
96
-$SBS=new SBS();
97
-$ACARS=new ACARS($Connection->db,true);
98
-$Source=new Source($Connection->db);
99
-$Common=new Common();
96
+$SBS = new SBS();
97
+$ACARS = new ACARS($Connection->db, true);
98
+$Source = new Source($Connection->db);
99
+$Common = new Common();
100 100
 date_default_timezone_set('UTC');
101 101
 //$servertz = system('date +%Z');
102 102
 // signal handler - playing nice with sockets and dump1090
103 103
 if (function_exists('pcntl_fork')) {
104
-    pcntl_signal(SIGINT,  function() {
104
+    pcntl_signal(SIGINT, function() {
105 105
         global $sockets;
106 106
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
107 107
         die("Bye!\n");
@@ -117,30 +117,30 @@  discard block
 block discarded – undo
117 117
 
118 118
 function connect_all($hosts) {
119 119
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
120
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
120
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
121 121
     $reset++;
122 122
     if ($globalDebug) echo 'Connect to all...'."\n";
123 123
     foreach ($hosts as $id => $value) {
124 124
 	$host = $value['host'];
125 125
 	$globalSources[$id]['last_exec'] = 0;
126 126
 	// Here we check type of source(s)
127
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
128
-            if (preg_match('/deltadb.txt$/i',$host)) {
127
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
128
+            if (preg_match('/deltadb.txt$/i', $host)) {
129 129
         	//$formats[$id] = 'deltadbtxt';
130 130
         	$globalSources[$id]['format'] = 'deltadbtxt';
131 131
         	//$last_exec['deltadbtxt'] = 0;
132 132
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
133
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
133
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
134 134
         	//$formats[$id] = 'vatsimtxt';
135 135
         	$globalSources[$id]['format'] = 'vatsimtxt';
136 136
         	//$last_exec['vatsimtxt'] = 0;
137 137
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
138
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
138
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
139 139
         	//$formats[$id] = 'aircraftlistjson';
140 140
         	$globalSources[$id]['format'] = 'aircraftlistjson';
141 141
         	//$last_exec['aircraftlistjson'] = 0;
142 142
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
143
-    	    } else if (preg_match('/opensky/i',$host)) {
143
+    	    } else if (preg_match('/opensky/i', $host)) {
144 144
         	//$formats[$id] = 'aircraftlistjson';
145 145
         	$globalSources[$id]['format'] = 'opensky';
146 146
         	//$last_exec['aircraftlistjson'] = 0;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         	    exit(0);
158 158
         	}
159 159
     	    */
160
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
160
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
161 161
         	//$formats[$id] = 'planeupdatefaa';
162 162
         	$globalSources[$id]['format'] = 'planeupdatefaa';
163 163
         	//$last_exec['planeupdatefaa'] = 0;
@@ -166,32 +166,32 @@  discard block
 block discarded – undo
166 166
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
167 167
         	    exit(0);
168 168
         	}
169
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
169
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
170 170
         	//$formats[$id] = 'phpvmacars';
171 171
         	$globalSources[$id]['format'] = 'phpvmacars';
172 172
         	//$last_exec['phpvmacars'] = 0;
173 173
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
174
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
174
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
175 175
         	//$formats[$id] = 'phpvmacars';
176 176
         	$globalSources[$id]['format'] = 'vam';
177 177
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
178
-            } else if (preg_match('/whazzup/i',$host)) {
178
+            } else if (preg_match('/whazzup/i', $host)) {
179 179
         	//$formats[$id] = 'whazzup';
180 180
         	$globalSources[$id]['format'] = 'whazzup';
181 181
         	//$last_exec['whazzup'] = 0;
182 182
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
183
-            } else if (preg_match('/blitzortung/i',$host)) {
183
+            } else if (preg_match('/blitzortung/i', $host)) {
184 184
         	$globalSources[$id]['format'] = 'blitzortung';
185 185
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
186
-            } else if (preg_match('/airwhere/i',$host)) {
186
+            } else if (preg_match('/airwhere/i', $host)) {
187 187
         	$globalSources[$id]['format'] = 'airwhere';
188 188
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
189
-            } else if (preg_match('/recentpireps/i',$host)) {
189
+            } else if (preg_match('/recentpireps/i', $host)) {
190 190
         	//$formats[$id] = 'pirepsjson';
191 191
         	$globalSources[$id]['format'] = 'pirepsjson';
192 192
         	//$last_exec['pirepsjson'] = 0;
193 193
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
194
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
194
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
195 195
         	//$formats[$id] = 'fr24json';
196 196
         	$globalSources[$id]['format'] = 'fr24json';
197 197
         	//$last_exec['fr24json'] = 0;
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
201 201
         	    exit(0);
202 202
         	}
203
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
203
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
204 204
         	//$formats[$id] = 'fr24json';
205 205
         	$globalSources[$id]['format'] = 'myshiptracking';
206 206
         	//$last_exec['fr24json'] = 0;
@@ -210,22 +210,22 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
             //} else if (preg_match('/10001/',$host)) {
213
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
213
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
214 214
         	//$formats[$id] = 'tsv';
215 215
         	$globalSources[$id]['format'] = 'tsv';
216 216
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
217 217
             }
218
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
218
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
219 219
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
220
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
220
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
221 221
     		    if ($idf !== false) {
222 222
     			$httpfeeds[$id] = $idf;
223 223
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
224 224
     		    }
225 225
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
226 226
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
227
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
228
-	    $hostport = explode(':',$host);
227
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
228
+	    $hostport = explode(':', $host);
229 229
 	    if (isset($hostport[1])) {
230 230
 		$port = $hostport[1];
231 231
 		$hostn = $hostport[0];
@@ -235,19 +235,19 @@  discard block
 block discarded – undo
235 235
 	    }
236 236
 	    $Common = new Common();
237 237
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
238
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
238
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
239 239
     	    } else {
240
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
240
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
241 241
 	    }
242 242
 	    if ($s) {
243 243
     	        $sockets[$id] = $s;
244 244
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
245
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
245
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
246 246
 			//$formats[$id] = 'aprs';
247 247
 			$globalSources[$id]['format'] = 'aprs';
248 248
 			//$aprs_connect = 0;
249 249
 			//$use_aprs = true;
250
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
250
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
251 251
 			$globalSources[$id]['format'] = 'vrstcp';
252 252
     		    } elseif ($port == '10001') {
253 253
         		//$formats[$id] = 'tsv';
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
287 287
 else $timeout = 20;
288 288
 $errno = '';
289
-$errstr='';
289
+$errstr = '';
290 290
 
291 291
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
292 292
 /* Initiate connections to all the hosts simultaneously */
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 //connect_all($globalSources);
295 295
 
296 296
 if (isset($globalProxy) && $globalProxy) {
297
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
297
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
298 298
 } else {
299 299
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
300 300
 }
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
 
325 325
 if ($use_aprs) {
326 326
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
327
-	$APRS=new APRS();
327
+	$APRS = new APRS();
328 328
 	$aprs_connect = 0;
329 329
 	$aprs_keep = 120;
330 330
 	$aprs_last_tx = time();
331 331
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
332
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
332
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
333 333
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
334
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
334
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
335 335
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
336
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
336
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
337 337
 	if ($aprs_full) $aprs_filter = '';
338 338
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
339 339
 	else $aprs_pass = '-1';
@@ -347,12 +347,12 @@  discard block
 block discarded – undo
347 347
 sleep(1);
348 348
 if ($globalDebug) echo "SCAN MODE \n\n";
349 349
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
350
-$endtime = time()+$globalCronEnd;
350
+$endtime = time() + $globalCronEnd;
351 351
 $i = 1;
352 352
 $tt = array();
353 353
 // Delete all ATC
354 354
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
355
-	$ATC=new ATC($Connection->db);
355
+	$ATC = new ATC($Connection->db);
356 356
 }
357 357
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
358 358
 	$ATC->deleteAll();
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
362 362
 while ($i > 0) {
363
-    if (!$globalDaemon) $i = $endtime-time();
363
+    if (!$globalDaemon) $i = $endtime - time();
364 364
     // Delete old ATC
365 365
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
366 366
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	}
375 375
 	if ($max != $globalMinFetch) {
376 376
 	    if ($globalDebug) echo 'Sleeping...'."\n";
377
-	    sleep($globalMinFetch-$max+2);
377
+	    sleep($globalMinFetch - $max + 2);
378 378
 	}
379 379
     }
380 380
 
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	    //$buffer = $Common->getData($hosts[$id]);
394 394
 	    $buffer = $Common->getData($value['host']);
395 395
 	    if ($buffer != '') $reset = 0;
396
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
397
-	    $buffer = explode('\n',$buffer);
396
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
397
+	    $buffer = explode('\n', $buffer);
398 398
 	    foreach ($buffer as $line) {
399 399
     		if ($line != '' && count($line) > 7) {
400 400
     		    $line = explode(',', $line);
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
 	    )
428 428
 	) {
429 429
 	    date_default_timezone_set('CET');
430
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
430
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
431 431
 	    date_default_timezone_set('UTC');
432 432
 	    if ($buffer != '') $reset = 0;
433
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
434
-	    $buffer = explode('\n',$buffer);
433
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
434
+	    $buffer = explode('\n', $buffer);
435 435
 	    foreach ($buffer as $line) {
436 436
 		if ($line != '') {
437 437
 		    //echo "'".$line."'\n";
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
450 450
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
451 451
 		    if (isset($ais_data['timestamp'])) {
452
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
452
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
453 453
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
454 454
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
455 455
 			    $add = true;
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
 	    $w = $e = null;
473 473
 	    
474 474
 	    if (isset($arr[$id])) {
475
-		$nn = stream_select($arr,$w,$e,$timeout);
475
+		$nn = stream_select($arr, $w, $e, $timeout);
476 476
 		if ($nn > 0) {
477 477
 		    foreach ($httpfeeds as $feed) {
478
-			$buffer = stream_get_line($feed,2000,"\n");
479
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
480
-			$buffer = explode('\n',$buffer);
478
+			$buffer = stream_get_line($feed, 2000, "\n");
479
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
480
+			$buffer = explode('\n', $buffer);
481 481
 			foreach ($buffer as $line) {
482 482
 			    if ($line != '') {
483 483
 				$ais_data = $AIS->parse_line(trim($line));
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
496 496
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
497 497
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
498
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
498
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
499 499
 				if (isset($ais_data['timestamp'])) {
500
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
500
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
501 501
 				} else {
502 502
 				    $data['datetime'] = date('Y-m-d H:i:s');
503 503
 				}
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
529 529
 	    )
530 530
 	) {
531
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
531
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
532 532
 	    if ($buffer != '') {
533 533
 		//echo $buffer;
534
-		$all_data = json_decode($buffer,true);
534
+		$all_data = json_decode($buffer, true);
535 535
 		//print_r($all_data);
536 536
 		if (isset($all_data[0]['DATA'])) {
537 537
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
547 547
 			    $data['imo'] = $line['IMO'];
548 548
 			    //$data['arrival_code'] = $ais_data['destination'];
549
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
549
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
550 550
 			    $data['format_source'] = 'myshiptracking';
551 551
 			    $data['id_source'] = $id_source;
552 552
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
564 564
 	    )
565 565
 	) {
566
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
566
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
567 567
 	    if ($buffer != '') {
568
-		$all_data = json_decode($buffer,true);
568
+		$all_data = json_decode($buffer, true);
569 569
 		if (isset($all_data[0]['mmsi'])) {
570 570
 		    foreach ($all_data as $line) {
571 571
 			if ($line != '') {
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	) {
600 600
 	    $buffer = $Common->getData($value['host']);
601 601
 	    if ($buffer != '') {
602
-		$all_data = json_decode($buffer,true);
602
+		$all_data = json_decode($buffer, true);
603 603
 		if (isset($all_data['features'][0]['id'])) {
604 604
 		    foreach ($all_data['features'] as $line) {
605 605
 			$data = array();
@@ -632,27 +632,27 @@  discard block
 block discarded – undo
632 632
 	    )
633 633
 	) {
634 634
 	    echo 'download...';
635
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
635
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
636 636
 	    echo 'done !'."\n";
637 637
 	    if ($buffer != '') $reset = 0;
638
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
639
-	    $buffer = explode('\n',$buffer);
638
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
639
+	    $buffer = explode('\n', $buffer);
640 640
 	    foreach ($buffer as $line) {
641 641
 		if ($line != '') {
642 642
 		    $data = array();
643
-		    $data['mmsi'] = (int)substr($line,0,9);
644
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
643
+		    $data['mmsi'] = (int) substr($line, 0, 9);
644
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
645 645
 		    //$data['status'] = substr($line,21,2);
646 646
 		    //$data['type'] = substr($line,24,3);
647
-		    $data['latitude'] = substr($line,29,9);
648
-		    $data['longitude'] = substr($line,41,9);
649
-		    $data['speed'] = round(substr($line,51,5));
647
+		    $data['latitude'] = substr($line, 29, 9);
648
+		    $data['longitude'] = substr($line, 41, 9);
649
+		    $data['speed'] = round(substr($line, 51, 5));
650 650
 		    //$data['course'] = substr($line,57,5);
651
-		    $data['heading'] = round(substr($line,63,3));
651
+		    $data['heading'] = round(substr($line, 63, 3));
652 652
 		    //$data['draft'] = substr($line,67,4);
653 653
 		    //$data['length'] = substr($line,72,3);
654 654
 		    //$data['beam'] = substr($line,76,2);
655
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
655
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
656 656
 		    //$data['callsign'] = trim(substr($line,100,7);
657 657
 		    //$data['dest'] = substr($line,108,20);
658 658
 		    //$data['etaDate'] = substr($line,129,5);
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
 	) {
686 686
 	    //$buffer = $Common->getData($hosts[$id]);
687 687
 	    $buffer = $Common->getData($value['host']);
688
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
689
-	    $buffer = explode('\n',$buffer);
688
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
689
+	    $buffer = explode('\n', $buffer);
690 690
 	    $reset = 0;
691 691
 	    foreach ($buffer as $line) {
692 692
     		if ($line != '') {
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
698 698
 			$data['pilot_id'] = $line[1];
699 699
 			$data['pilot_name'] = $line[2];
700
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
700
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
701 701
 			$data['ident'] = $line[0]; // ident
702 702
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
703 703
 			$data['speed'] = $line[8]; // speed
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
714 714
 			//if (isset($line[37])) $data['last_update'] = $line[37];
715 715
 		        $data['departure_airport_icao'] = $line[11];
716
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
716
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
717 717
 		        $data['arrival_airport_icao'] = $line[13];
718 718
 			$data['frequency'] = $line[4];
719 719
 			$data['type'] = $line[18];
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
     			$data['id_source'] = $id_source;
723 723
 	    		//$data['arrival_airport_time'] = ;
724 724
 	    		if ($line[9] != '') {
725
-	    		    $aircraft_data = explode('/',$line[9]);
725
+	    		    $aircraft_data = explode('/', $line[9]);
726 726
 	    		    if (isset($aircraft_data[1])) {
727 727
 	    			$data['aircraft_icao'] = $aircraft_data[1];
728 728
 	    		    }
@@ -737,9 +737,9 @@  discard block
 block discarded – undo
737 737
     			if ($line[3] == 'PILOT') $SI->add($data);
738 738
 			elseif ($line[3] == 'ATC') {
739 739
 				//print_r($data);
740
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
741
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
742
-				$typec = substr($data['ident'],-3);
740
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
741
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
742
+				$typec = substr($data['ident'], -3);
743 743
 				if ($typec == 'APP') $data['type'] = 'Approach';
744 744
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
745 745
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
752 752
 				if (!isset($data['source_name'])) $data['source_name'] = '';
753 753
 				if (isset($ATC)) {
754
-					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']);
755
-					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']);
754
+					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']);
755
+					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']);
756 756
 				}
757 757
 			}
758 758
     			unset($data);
@@ -768,24 +768,24 @@  discard block
 block discarded – undo
768 768
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
769 769
     	    )
770 770
     	) {
771
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
771
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
772 772
 	    if ($buffer != '') {
773 773
 		$all_data = simplexml_load_string($buffer);
774
-		foreach($all_data->children() as $childdata) {
774
+		foreach ($all_data->children() as $childdata) {
775 775
 			$data = array();
776 776
 			$line = $childdata;
777 777
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
778
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
779
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
780
-			$data['latitude'] = (float)$line['pktLatitude'];
781
-			$data['longitude'] = (float)$line['pktLongitude'];
782
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
783
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
784
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
778
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
779
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
780
+			$data['latitude'] = (float) $line['pktLatitude'];
781
+			$data['longitude'] = (float) $line['pktLongitude'];
782
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
783
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
784
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
785 785
 			$data['altitude_relative'] = 'AMSL';
786
-			$data['pilot_id'] = (int)$line['pktPilotID'];
786
+			$data['pilot_id'] = (int) $line['pktPilotID'];
787 787
 			$data['aircraft_icao'] = 'PARAGLIDER';
788
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
788
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
789 789
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
790 790
 			$data['format_source'] = $value['format'];
791 791
 			$SI->add($data);
@@ -793,22 +793,22 @@  discard block
 block discarded – undo
793 793
 		}
794 794
 	    }
795 795
 	    $Source->deleteOldLocationByType('gs');
796
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
796
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
797 797
 	    if ($buffer != '') {
798 798
 		$all_data = simplexml_load_string($buffer);
799
-		foreach($all_data->children() as $childdata) {
799
+		foreach ($all_data->children() as $childdata) {
800 800
 			$data = array();
801 801
 			$line = $childdata;
802
-			$data['id'] = (int)$line['gsID'];
803
-			$data['latitude'] = (float)$line['gsLatitude'];
804
-			$data['longitude'] = (float)$line['gsLongitude'];
805
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
802
+			$data['id'] = (int) $line['gsID'];
803
+			$data['latitude'] = (float) $line['gsLatitude'];
804
+			$data['longitude'] = (float) $line['gsLongitude'];
805
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
806 806
 			$data['altitude_relative'] = 'AMSL';
807
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
807
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
808 808
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
809
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
809
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
810 810
 			} else {
811
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
811
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
812 812
 			}
813 813
 			unset($data);
814 814
 		}
@@ -826,9 +826,9 @@  discard block
 block discarded – undo
826 826
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
827 827
 	    )
828 828
 	) {
829
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
829
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
830 830
 	    if ($buffer != '') {
831
-	        $all_data = json_decode($buffer,true);
831
+	        $all_data = json_decode($buffer, true);
832 832
 		if (isset($all_data['acList'])) {
833 833
 		    $reset = 0;
834 834
 		    foreach ($all_data['acList'] as $line) {
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
845 845
 			$data['emergency'] = ''; // emergency
846 846
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
847
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
847
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
848 848
 			else $data['datetime'] = date('Y-m-d H:i:s');
849 849
 			//$data['datetime'] = date('Y-m-d H:i:s');
850 850
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
 			$data['verticalrate'] = $line['vrt']; // verticale rate
870 870
 			$data['squawk'] = $line['squawk']; // squawk
871 871
 			$data['emergency'] = ''; // emergency
872
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
872
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
873 873
 			else $data['datetime'] = date('Y-m-d H:i:s');
874 874
 			$data['format_source'] = 'aircraftlistjson';
875 875
 			$data['id_source'] = $id_source;
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
     	    )
891 891
     	) {
892 892
 	    $buffer = $Common->getData($value['host']);
893
-	    $all_data = json_decode($buffer,true);
893
+	    $all_data = json_decode($buffer, true);
894 894
 	    if (isset($all_data['planes'])) {
895 895
 		$reset = 0;
896 896
 		foreach ($all_data['planes'] as $key => $line) {
@@ -907,12 +907,12 @@  discard block
 block discarded – undo
907 907
 		    $data['emergency'] = ''; // emergency
908 908
 		    $data['registration'] = $line[2];
909 909
 		    $data['aircraft_icao'] = $line[0];
910
-		    $deparr = explode('-',$line[1]);
910
+		    $deparr = explode('-', $line[1]);
911 911
 		    if (count($deparr) == 2) {
912 912
 			$data['departure_airport_icao'] = $deparr[0];
913 913
 			$data['arrival_airport_icao'] = $deparr[1];
914 914
 		    }
915
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
915
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
916 916
 	    	    $data['format_source'] = 'planeupdatefaa';
917 917
     		    $data['id_source'] = $id_source;
918 918
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 	    )
931 931
 	) {
932 932
 	    $buffer = $Common->getData($value['host']);
933
-	    $all_data = json_decode($buffer,true);
933
+	    $all_data = json_decode($buffer, true);
934 934
 	    if (isset($all_data['states'])) {
935 935
 		$reset = 0;
936 936
 		foreach ($all_data['states'] as $key => $line) {
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 		    //$data['emergency'] = ''; // emergency
948 948
 		    //$data['registration'] = $line[2];
949 949
 		    //$data['aircraft_icao'] = $line[0];
950
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
950
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
951 951
 		    $data['format_source'] = 'opensky';
952 952
 		    $data['id_source'] = $id_source;
953 953
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 	) {
967 967
 	    //$buffer = $Common->getData($hosts[$id]);
968 968
 	    $buffer = $Common->getData($value['host']);
969
-	    $all_data = json_decode($buffer,true);
969
+	    $all_data = json_decode($buffer, true);
970 970
 	    if (!empty($all_data)) $reset = 0;
971 971
 	    foreach ($all_data as $key => $line) {
972 972
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1004,11 +1004,11 @@  discard block
 block discarded – undo
1004 1004
 	    )
1005 1005
 	) {
1006 1006
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1007
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1007
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1008 1008
 	    //echo $buffer;
1009
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1010
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1011
-	    $all_data = json_decode($buffer,true);
1009
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1010
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1011
+	    $all_data = json_decode($buffer, true);
1012 1012
 	    if (json_last_error() != JSON_ERROR_NONE) {
1013 1013
 		die(json_last_error_msg());
1014 1014
 	    }
@@ -1031,7 +1031,7 @@  discard block
 block discarded – undo
1031 1031
 			//$data['departure_airport_iata'] = $line[11];
1032 1032
 			//$data['arrival_airport_iata'] = $line[12];
1033 1033
 	    		//$data['emergency'] = ''; // emergency
1034
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1034
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1035 1035
 	    		$data['format_source'] = 'radarvirtueljson';
1036 1036
     			$data['id_source'] = $id_source;
1037 1037
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1052,14 +1052,14 @@  discard block
 block discarded – undo
1052 1052
 	) {
1053 1053
 	    //$buffer = $Common->getData($hosts[$id]);
1054 1054
 	    $buffer = $Common->getData($value['host'].'?'.time());
1055
-	    $all_data = json_decode(utf8_encode($buffer),true);
1055
+	    $all_data = json_decode(utf8_encode($buffer), true);
1056 1056
 	    
1057 1057
 	    if (isset($all_data['pireps'])) {
1058 1058
 		$reset = 0;
1059 1059
 	        foreach ($all_data['pireps'] as $line) {
1060 1060
 		    $data = array();
1061 1061
 		    $data['id'] = $line['id'];
1062
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1062
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1063 1063
 		    $data['ident'] = $line['callsign']; // ident
1064 1064
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1065 1065
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1089,9 +1089,9 @@  discard block
 block discarded – undo
1089 1089
 			$SI->add($data);
1090 1090
 		    //    print_r($data);
1091 1091
     		    } elseif ($line['icon'] == 'ct') {
1092
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1093
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1094
-			$typec = substr($data['ident'],-3);
1092
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1093
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1094
+			$typec = substr($data['ident'], -3);
1095 1095
 			$data['type'] = '';
1096 1096
 			if ($typec == 'APP') $data['type'] = 'Approach';
1097 1097
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1103 1103
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1104 1104
 			else $data['type'] = 'Observer';
1105
-			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']);
1105
+			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']);
1106 1106
 		    }
1107 1107
 		    unset($data);
1108 1108
 		}
@@ -1119,14 +1119,14 @@  discard block
 block discarded – undo
1119 1119
 	    //$buffer = $Common->getData($hosts[$id]);
1120 1120
 	    if ($globalDebug) echo 'Get Data...'."\n";
1121 1121
 	    $buffer = $Common->getData($value['host']);
1122
-	    $all_data = json_decode($buffer,true);
1122
+	    $all_data = json_decode($buffer, true);
1123 1123
 	    if ($buffer != '' && is_array($all_data)) {
1124 1124
 		$reset = 0;
1125 1125
 		foreach ($all_data as $line) {
1126 1126
 	    	    $data = array();
1127 1127
 	    	    //$data['id'] = $line['id']; // id not usable
1128 1128
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1129
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1129
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1130 1130
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1131 1131
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1132 1132
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1141,7 +1141,7 @@  discard block
 block discarded – undo
1141 1141
 	    	    //$data['datetime'] = $line['lastupdate'];
1142 1142
 	    	    //$data['last_update'] = $line['lastupdate'];
1143 1143
 	    	    if (isset($value['timezone'])) {
1144
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1144
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1145 1145
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1146 1146
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1147 1147
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1154,14 +1154,14 @@  discard block
 block discarded – undo
1154 1154
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1155 1155
 		    if (isset($line['aircraftname'])) {
1156 1156
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1157
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1158
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1157
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1158
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1159 1159
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1160 1160
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1161 1161
 	    		else {
1162
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1163
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1164
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1162
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1163
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1164
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1165 1165
 	    		}
1166 1166
 	    	    }
1167 1167
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1186,14 +1186,14 @@  discard block
 block discarded – undo
1186 1186
 	    //$buffer = $Common->getData($hosts[$id]);
1187 1187
 	    if ($globalDebug) echo 'Get Data...'."\n";
1188 1188
 	    $buffer = $Common->getData($value['host']);
1189
-	    $all_data = json_decode($buffer,true);
1189
+	    $all_data = json_decode($buffer, true);
1190 1190
 	    if ($buffer != '' && is_array($all_data)) {
1191 1191
 		$reset = 0;
1192 1192
 		foreach ($all_data as $line) {
1193 1193
 	    	    $data = array();
1194 1194
 	    	    //$data['id'] = $line['id']; // id not usable
1195 1195
 	    	    $data['id'] = trim($line['flight_id']);
1196
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1196
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1197 1197
 	    	    $data['pilot_name'] = $line['pilot_name'];
1198 1198
 	    	    $data['pilot_id'] = $line['pilot_id'];
1199 1199
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1237,24 +1237,24 @@  discard block
 block discarded – undo
1237 1237
 	    //$buffer = $Common->getData($hosts[$id]);
1238 1238
 	    if ($globalDebug) echo 'Get Data...'."\n";
1239 1239
 	    $buffer = $Common->getData($value['host']);
1240
-	    $all_data = json_decode($buffer,true);
1240
+	    $all_data = json_decode($buffer, true);
1241 1241
 	    if ($buffer != '') {
1242 1242
 		$Source->deleteLocationBySource('blitzortung');
1243
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1244
-		$buffer = explode('\n',$buffer);
1243
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1244
+		$buffer = explode('\n', $buffer);
1245 1245
 		foreach ($buffer as $buffer_line) {
1246
-		    $line = json_decode($buffer_line,true);
1246
+		    $line = json_decode($buffer_line, true);
1247 1247
 		    if (isset($line['time'])) {
1248 1248
 			$data = array();
1249 1249
 			$data['altitude'] = $line['alt']; // altitude
1250 1250
 			$data['latitude'] = $line['lat']; // lat
1251 1251
 			$data['longitude'] = $line['lon']; // long
1252
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1252
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1253 1253
 			$data['id_source'] = $id_source;
1254 1254
 			$data['format_source'] = 'blitzortung';
1255 1255
 			$SI->add($data);
1256 1256
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1257
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1257
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1258 1258
 			unset($data);
1259 1259
 		    }
1260 1260
 		}
@@ -1279,11 +1279,11 @@  discard block
 block discarded – undo
1279 1279
 		    //$value = $formats[$nb];
1280 1280
 		    $format = $globalSources[$nb]['format'];
1281 1281
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1282
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1282
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1283 1283
 		    } elseif ($format == 'vrstcp') {
1284 1284
 			$buffer = @socket_read($r, 6000);
1285 1285
 		    } else {
1286
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1286
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1287 1287
 		    }
1288 1288
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1289 1289
 		    //echo $buffer."\n";
@@ -1292,8 +1292,8 @@  discard block
 block discarded – undo
1292 1292
 		    $error = false;
1293 1293
 		    //$SI::del();
1294 1294
 		    if ($format == 'vrstcp') {
1295
-			$buffer = explode('},{',$buffer);
1296
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1295
+			$buffer = explode('},{', $buffer);
1296
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1297 1297
 		    // SBS format is CSV format
1298 1298
 		    if ($buffer !== FALSE && $buffer != '') {
1299 1299
 			$tt[$format] = 0;
@@ -1327,13 +1327,13 @@  discard block
 block discarded – undo
1327 1327
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1328 1328
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1329 1329
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1330
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1330
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1331 1331
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1332 1332
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1333 1333
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1334 1334
 
1335 1335
 			    if (isset($ais_data['timestamp'])) {
1336
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1336
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1337 1337
 			    } else {
1338 1338
 				$data['datetime'] = date('Y-m-d H:i:s');
1339 1339
 			    }
@@ -1344,10 +1344,10 @@  discard block
 block discarded – undo
1344 1344
                         } elseif ($format == 'flightgearsp') {
1345 1345
                     	    //echo $buffer."\n";
1346 1346
                     	    if (strlen($buffer) > 5) {
1347
-				$line = explode(',',$buffer);
1347
+				$line = explode(',', $buffer);
1348 1348
 				$data = array();
1349 1349
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1350
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1350
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1351 1351
 				$data['ident'] = $line[6];
1352 1352
 				$data['aircraft_name'] = $line[7];
1353 1353
 				$data['longitude'] = $line[1];
@@ -1364,16 +1364,16 @@  discard block
 block discarded – undo
1364 1364
                         } elseif ($format == 'acars') {
1365 1365
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1366 1366
 			    $ACARS->add(trim($buffer));
1367
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1367
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1368 1368
 			    $ACARS->deleteLiveAcarsData();
1369 1369
 			} elseif ($format == 'flightgearmp') {
1370
-			    if (substr($buffer,0,1) != '#') {
1370
+			    if (substr($buffer, 0, 1) != '#') {
1371 1371
 				$data = array();
1372 1372
 				//echo $buffer."\n";
1373
-				$line = explode(' ',$buffer);
1373
+				$line = explode(' ', $buffer);
1374 1374
 				if (count($line) == 11) {
1375
-				    $userserver = explode('@',$line[0]);
1376
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1375
+				    $userserver = explode('@', $line[0]);
1376
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1377 1377
 				    $data['ident'] = $userserver[0];
1378 1378
 				    $data['registration'] = $userserver[0];
1379 1379
 				    $data['latitude'] = $line[4];
@@ -1381,8 +1381,8 @@  discard block
 block discarded – undo
1381 1381
 				    $data['altitude'] = $line[6];
1382 1382
 				    $data['datetime'] = date('Y-m-d H:i:s');
1383 1383
 				    $aircraft_type = $line[10];
1384
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1385
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1384
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1385
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1386 1386
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1387 1387
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1388 1388
 				}
@@ -1391,8 +1391,8 @@  discard block
 block discarded – undo
1391 1391
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1392 1392
 			    die;
1393 1393
 			} elseif ($format == 'vrstcp') {
1394
-			    foreach($buffer as $all_data) {
1395
-				$line = json_decode('{'.$all_data.'}',true);
1394
+			    foreach ($buffer as $all_data) {
1395
+				$line = json_decode('{'.$all_data.'}', true);
1396 1396
 				$data = array();
1397 1397
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1398 1398
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1418,16 +1418,16 @@  discard block
 block discarded – undo
1418 1418
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1419 1419
 				unset($data);
1420 1420
 			    }
1421
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1421
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1422 1422
 			    $line = explode("\t", $buffer);
1423
-			    for($k = 0; $k < count($line); $k=$k+2) {
1423
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1424 1424
 				$key = $line[$k];
1425
-			        $lined[$key] = $line[$k+1];
1425
+			        $lined[$key] = $line[$k + 1];
1426 1426
 			    }
1427 1427
     			    if (count($lined) > 3) {
1428 1428
     				$data['hex'] = $lined['hexid'];
1429 1429
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1430
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1430
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1431 1431
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1432 1432
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1433 1433
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1446,22 +1446,22 @@  discard block
 block discarded – undo
1446 1446
     			    } else $error = true;
1447 1447
 			} elseif ($format == 'aprs' && $use_aprs) {
1448 1448
 			    if ($aprs_connect == 0) {
1449
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1449
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1450 1450
 				$aprs_connect = 1;
1451 1451
 			    }
1452 1452
 			    
1453
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1453
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1454 1454
 				$aprs_last_tx = time();
1455 1455
 				$data_aprs = "# Keep alive";
1456
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1456
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1457 1457
 			    }
1458 1458
 			    
1459 1459
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1460 1460
 			    //echo 'APRS data : '.$buffer."\n";
1461
-			    $buffer = str_replace('APRS <- ','',$buffer);
1462
-			    $buffer = str_replace('APRS -> ','',$buffer);
1461
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1462
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1463 1463
 			    //echo $buffer."\n";
1464
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1464
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1465 1465
 				$line = $APRS->parse($buffer);
1466 1466
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1467 1467
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1477 1477
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1478 1478
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1479
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1479
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1480 1480
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1481 1481
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1482 1482
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1555,29 +1555,29 @@  discard block
 block discarded – undo
1555 1555
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1556 1556
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1557 1557
 					$Source->deleteOldLocationByType('gs');
1558
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1559
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1558
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1559
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1560 1560
 					} else {
1561
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1561
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1562 1562
 					}
1563 1563
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1564 1564
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1565 1565
 					if ($globalDebug) echo '# Weather Station added'."\n";
1566 1566
 					$Source->deleteOldLocationByType('wx');
1567 1567
 					$weather_data = json_encode($line);
1568
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1569
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1568
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1569
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1570 1570
 					} else {
1571
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1571
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1572 1572
 					}
1573 1573
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1574 1574
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1575 1575
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1576 1576
 					$Source->deleteOldLocationByType('lightning');
1577
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1578
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1577
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1578
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1579 1579
 					} else {
1580
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1580
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1581 1581
 					}
1582 1582
 				    } elseif ($globalDebug) {
1583 1583
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 				    unset($data);
1587 1587
 				}
1588 1588
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1589
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1589
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1590 1590
 				}
1591 1591
 				/*
1592 1592
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
 				*/
1596 1596
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1597 1597
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1598
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1598
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1599 1599
 					$Source->deleteOldLocationByType('lightning');
1600 1600
 					$Source->deleteOldLocationByType('wx');
1601 1601
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1680,7 +1680,7 @@  discard block
 block discarded – undo
1680 1680
 				connect_all($sourceee);
1681 1681
 				$sourceee = array();
1682 1682
 				//connect_all($globalSources);
1683
-				$tt[$format]=0;
1683
+				$tt[$format] = 0;
1684 1684
 				break;
1685 1685
 			    }
1686 1686
 			}
@@ -1689,14 +1689,14 @@  discard block
 block discarded – undo
1689 1689
 	    } else {
1690 1690
 		$error = socket_strerror(socket_last_error());
1691 1691
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1692
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1692
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1693 1693
 			if (isset($globalDebug)) echo "Restarting...\n";
1694 1694
 			// Restart the script if possible
1695 1695
 			if (is_array($sockets)) {
1696 1696
 			    if ($globalDebug) echo "Shutdown all sockets...";
1697 1697
 			    
1698 1698
 			    foreach ($sockets as $sock) {
1699
-				@socket_shutdown($sock,2);
1699
+				@socket_shutdown($sock, 2);
1700 1700
 				@socket_close($sock);
1701 1701
 			    }
1702 1702
 			    
Please login to merge, or discard this patch.
require/class.Translation.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -58,6 +58,10 @@  discard block
 block discarded – undo
58 58
 		} else return $ident;
59 59
 	}
60 60
 
61
+	/**
62
+	 * @param string $correct_ident
63
+	 * @param string $source
64
+	 */
61 65
 	public function addOperator($ident,$correct_ident,$source) {
62 66
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63 67
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
@@ -69,6 +73,10 @@  discard block
 block discarded – undo
69 73
 		}
70 74
 	}
71 75
 
76
+	/**
77
+	 * @param string $correct_ident
78
+	 * @param string $source
79
+	 */
72 80
 	public function updateOperator($ident,$correct_ident,$source) {
73 81
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74 82
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 
16 16
 
17 17
 	/**
18
-	* Change IATA to ICAO value for ident
19
-	* 
20
-	* @param String $ident ident
21
-	* @return String the icao
22
-	*/
18
+	 * Change IATA to ICAO value for ident
19
+	 * 
20
+	 * @param String $ident ident
21
+	 * @return String the icao
22
+	 */
23 23
 	public function ident2icao($ident) {
24 24
 		$Spotter = new Spotter();
25 25
 		if (!is_numeric(substr($ident, 0, 3))) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 			} else return $ident;
32 32
 		} else return $ident;
33 33
 		if ($airline_icao == 'AF') {
34
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
34
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
36 36
 		} else {
37 37
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
38 38
 			if (isset($identicao[0])) {
39
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
39
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
40 40
 			} else $icao = $ident;
41 41
 		}
42 42
 		return $icao;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		try {
49 49
 			$sth = $this->db->prepare($query);
50 50
 			$sth->execute($query_values);
51
-		} catch(PDOException $e) {
51
+		} catch (PDOException $e) {
52 52
 			return "error : ".$e->getMessage();
53 53
 		}
54 54
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -58,29 +58,29 @@  discard block
 block discarded – undo
58 58
 		} else return $ident;
59 59
 	}
60 60
 
61
-	public function addOperator($ident,$correct_ident,$source) {
61
+	public function addOperator($ident, $correct_ident, $source) {
62 62
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
63
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
64 64
 		try {
65 65
 			$sth = $this->db->prepare($query);
66 66
 			$sth->execute($query_values);
67
-		} catch(PDOException $e) {
67
+		} catch (PDOException $e) {
68 68
 			return "error : ".$e->getMessage();
69 69
 		}
70 70
 	}
71 71
 
72
-	public function updateOperator($ident,$correct_ident,$source) {
72
+	public function updateOperator($ident, $correct_ident, $source) {
73 73
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
74
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
75 75
 		try {
76 76
 			$sth = $this->db->prepare($query);
77 77
 			$sth->execute($query_values);
78
-		} catch(PDOException $e) {
78
+		} catch (PDOException $e) {
79 79
 			return "error : ".$e->getMessage();
80 80
 		}
81 81
 	}
82 82
 
83
-	public function checkTranslation($ident,$web = false) {
83
+	public function checkTranslation($ident, $web = false) {
84 84
 		global $globalTranslationSources, $globalTranslationFetch;
85 85
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86 86
 		$globalTranslationSources = array();
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,16 +28,25 @@  discard block
 block discarded – undo
28 28
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
29 29
 				//$airline_icao = substr($ident, 0, 3);
30 30
 				return $ident;
31
-			} else return $ident;
32
-		} else return $ident;
31
+			} else {
32
+				return $ident;
33
+			}
34
+		} else {
35
+			return $ident;
36
+		}
33 37
 		if ($airline_icao == 'AF') {
34
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
38
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
39
+				$icao = $ident;
40
+			} else {
41
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
42
+			}
36 43
 		} else {
37 44
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
38 45
 			if (isset($identicao[0])) {
39 46
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
40
-			} else $icao = $ident;
47
+			} else {
48
+				$icao = $ident;
49
+			}
41 50
 		}
42 51
 		return $icao;
43 52
 	}
@@ -55,7 +64,9 @@  discard block
 block discarded – undo
55 64
 		$sth->closeCursor();
56 65
 		if (count($row) > 0) {
57 66
 			return $row['operator_correct'];
58
-		} else return $ident;
67
+		} else {
68
+			return $ident;
69
+		}
59 70
 	}
60 71
 
61 72
 	public function addOperator($ident,$correct_ident,$source) {
@@ -84,7 +95,9 @@  discard block
 block discarded – undo
84 95
 		global $globalTranslationSources, $globalTranslationFetch;
85 96
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86 97
 		$globalTranslationSources = array();
87
-		if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
98
+		if (!isset($globalTranslationFetch)) {
99
+			$globalTranslationFetch = TRUE;
100
+		}
88 101
 		//echo "Check Translation for ".$ident."...";
89 102
 		$correct = $this->getOperator($ident);
90 103
 		if ($correct != '' && $correct != $ident) {
Please login to merge, or discard this patch.
require/class.SpotterServer.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 
12 12
 	function __construct($dbs = null) {
13 13
 		if ($dbs === null) {
14
-			$Connection = new Connection(null,'server');
14
+			$Connection = new Connection(null, 'server');
15 15
 			$this->dbs = $Connection->dbs;
16 16
 			$query = "CREATE TABLE IF NOT EXISTS `spotter_temp` ( `id_data` INT NOT NULL AUTO_INCREMENT , `id_user` INT NOT NULL , `datetime` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , `hex` VARCHAR(20) NOT NULL , `ident` VARCHAR(20) NULL , `latitude` FLOAT NULL , `longitude` FLOAT NULL , `verticalrate` INT NULL , `speed` INT NULL , `squawk` INT NULL , `altitude` INT NULL , `heading` INT NULL , `registration` VARCHAR(10) NULL , `aircraft_icao` VARCHAR(10) NULL , `waypoints` VARCHAR(255) NULL , `noarchive` BOOLEAN NOT NULL DEFAULT FALSE, `id_source` INT NOT NULL DEFAULT '1', `format_source` VARCHAR(25) NULL, `source_name` VARCHAR(25) NULL, `over_country` VARCHAR(255) NULL, PRIMARY KEY (`id_data`) ) ENGINE = MEMORY;";
17 17
 			try {
18 18
 				$sth = $this->dbs['server']->exec($query);
19
-			} catch(PDOException $e) {
19
+			} catch (PDOException $e) {
20 20
 				return "error : ".$e->getMessage();
21 21
 			}
22 22
 		}
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
 		date_default_timezone_set('UTC');
32 32
 		//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'aprs')) {
33 33
 		if (isset($line['format_source'])) {
34
-			if(is_array($line) && isset($line['hex'])) {
34
+			if (is_array($line) && isset($line['hex'])) {
35 35
 				if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
36 36
 					$data['hex'] = trim($line['hex']);
37
-					if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
37
+					if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
38 38
 						$data['datetime'] = $line['datetime'];
39 39
 					} else $data['datetime'] = date('Y-m-d H:i:s');
40 40
 					if (!isset($line['aircraft_icao'])) {
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 					if ($id_user == NULL) $id_user = 1;
111 111
 					if (!isset($id_source)) $id_source = 1;
112 112
 					$query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
113
-					$query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
113
+					$query_values = array(':id_user' => $id_user, ':datetime' => $data['datetime'], ':hex' => $data['hex'], ':ident' => $data['ident'], ':latitude' => $data['latitude'], ':longitude' => $data['longitude'], ':verticalrate' => $data['verticalrate'], ':speed' => $data['speed'], ':squawk' => $data['squawk'], ':altitude' => $data['altitude'], ':heading' => $data['heading'], ':registration' => $data['registration'], ':aircraft_icao' => $data['aircraft_icao'], ':waypoints' => $data['waypoints'], ':id_source' => $id_source, ':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'], ':over_country' => $data['over_country']);
114 114
 					try {
115 115
 						$sth = $this->dbs['server']->prepare($query);
116 116
 						$sth->execute($query_values);
117
-					} catch(PDOException $e) {
117
+					} catch (PDOException $e) {
118 118
 						return "error : ".$e->getMessage();
119 119
 					}
120 120
 				}
Please login to merge, or discard this patch.
Braces   +72 added lines, -25 removed lines patch added patch discarded remove patch
@@ -36,79 +36,126 @@
 block discarded – undo
36 36
 					$data['hex'] = trim($line['hex']);
37 37
 					if (preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
38 38
 						$data['datetime'] = $line['datetime'];
39
-					} else $data['datetime'] = date('Y-m-d H:i:s');
39
+					} else {
40
+						$data['datetime'] = date('Y-m-d H:i:s');
41
+					}
40 42
 					if (!isset($line['aircraft_icao'])) {
41 43
 						$Spotter = new Spotter();
42 44
 						$aircraft_icao = $Spotter->getAllAircraftType($data['hex']);
43 45
 						$Spotter->db = null;
44 46
 						if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
45
-							if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
46
-							elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
47
-							elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
48
-							elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
47
+							if ($line['aircraft_type'] == 'PARA_GLIDER') {
48
+								$aircraft_icao = 'GLID';
49
+							} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
50
+								$aircraft_icao = 'UHEL';
51
+							} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
52
+								$aircraft_icao = 'TOWPLANE';
53
+							} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
54
+								$aircraft_icao = 'POWAIRC';
55
+							}
49 56
 						}
50 57
 						$data['aircraft_icao'] = $aircraft_icao;
51
-					} else $data['aircraft_icao'] = $line['aircraft_icao'];
58
+					} else {
59
+						$data['aircraft_icao'] = $line['aircraft_icao'];
60
+					}
52 61
 					//if ($globalDebug) echo "*********** New aircraft hex : ".$data['hex']." ***********\n";
53 62
 				}
54 63
 				if (isset($line['registration']) && $line['registration'] != '') {
55 64
 					$data['registration'] = $line['registration'];
56
-				} else $data['registration'] = null;
65
+				} else {
66
+					$data['registration'] = null;
67
+				}
57 68
 				if (isset($line['waypoints']) && $line['waypoints'] != '') {
58 69
 					$data['waypoints'] = $line['waypoints'];
59
-				} else $data['waypoints'] = null;
70
+				} else {
71
+					$data['waypoints'] = null;
72
+				}
60 73
 				if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
61 74
 					$data['ident'] = trim($line['ident']);
62
-				} else $data['ident'] = null;
75
+				} else {
76
+					$data['ident'] = null;
77
+				}
63 78
 				if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '') {
64 79
 					if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
65 80
 						$data['latitude'] = $line['latitude'];
66
-					} else $data['latitude'] = null;
81
+					} else {
82
+						$data['latitude'] = null;
83
+					}
67 84
 					if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
68
-						if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
85
+						if ($line['longitude'] > 180) {
86
+							$line['longitude'] = $line['longitude'] - 360;
87
+						}
69 88
 						$data['longitude'] = $line['longitude'];
70
-					} else $data['longitude'] = null;
89
+					} else {
90
+						$data['longitude'] = null;
91
+					}
71 92
 				} else {
72 93
 					$data['latitude'] = null;
73 94
 					$data['longitude'] = null;
74 95
 				}
75 96
 				if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
76 97
 					$data['verticalrate'] = $line['verticalrate'];
77
-				} else $data['verticalrate'] = null;
98
+				} else {
99
+					$data['verticalrate'] = null;
100
+				}
78 101
 				if (isset($line['emergency']) && $line['emergency'] != '') {
79 102
 					$data['emergency'] = $line['emergency'];
80
-				} else $data['emergency'] = null;
103
+				} else {
104
+					$data['emergency'] = null;
105
+				}
81 106
 				if (isset($line['ground']) && $line['ground'] != '') {
82 107
 					$data['ground'] = $line['ground'];
83
-				} else $data['ground'] = null;
108
+				} else {
109
+					$data['ground'] = null;
110
+				}
84 111
 				if (isset($line['speed']) && $line['speed'] != '') {
85 112
 					$data['speed'] = round($line['speed']);
86
-				} else $data['speed'] = null;
113
+				} else {
114
+					$data['speed'] = null;
115
+				}
87 116
 				if (isset($line['squawk']) && $line['squawk'] != '') {
88 117
 					$data['squawk'] = $line['squawk'];
89
-				} else $data['squawk'] = null;
118
+				} else {
119
+					$data['squawk'] = null;
120
+				}
90 121
 				if (isset($line['altitude']) && $line['altitude'] != '') {
91 122
 					$data['altitude'] = round($line['altitude']);
92
-		  		} else $data['altitude'] = null;
123
+		  		} else {
124
+		  			$data['altitude'] = null;
125
+		  		}
93 126
 				if (isset($line['heading']) && $line['heading'] != '') {
94 127
 					$data['heading'] = round($line['heading']);
95
-		 		} else $data['heading'] = null;
128
+		 		} else {
129
+		 			$data['heading'] = null;
130
+		 		}
96 131
 				if (isset($line['source_name']) && $line['source_name'] != '') {
97 132
 					$data['source_name'] = $line['source_name'];
98
-				} else $data['source_name'] = null;
133
+				} else {
134
+					$data['source_name'] = null;
135
+				}
99 136
 				if (isset($line['over_country']) && $line['over_country'] != '') {
100 137
 					$data['over_country'] = $line['over_country'];
101
-		 		} else $data['over_country'] = null;
138
+		 		} else {
139
+		 			$data['over_country'] = null;
140
+		 		}
102 141
 				if (isset($line['noarchive']) && $line['noarchive']) {
103 142
 					$data['noarchive'] = true;
104
-				} else $data['noarchive'] = false;
143
+				} else {
144
+					$data['noarchive'] = false;
145
+				}
105 146
 				$data['format_source'] = $line['format_source'];
106
-				if (isset($line['id_source'])) $id_source = $line['id_source'];
147
+				if (isset($line['id_source'])) {
148
+					$id_source = $line['id_source'];
149
+				}
107 150
 				if (isset($data['hex'])) {
108 151
 					echo '.';
109 152
 					$id_user = $globalServerUserID;
110
-					if ($id_user == NULL) $id_user = 1;
111
-					if (!isset($id_source)) $id_source = 1;
153
+					if ($id_user == NULL) {
154
+						$id_user = 1;
155
+					}
156
+					if (!isset($id_source)) {
157
+						$id_source = 1;
158
+					}
112 159
 					$query = 'INSERT INTO spotter_temp (id_user,datetime,hex,ident,latitude,longitude,verticalrate,speed,squawk,altitude,heading,registration,aircraft_icao,waypoints,id_source,noarchive,format_source,source_name,over_country) VALUES (:id_user,:datetime,:hex,:ident,:latitude,:longitude,:verticalrate,:speed,:squawk,:altitude,:heading,:registration,:aircraft_icao,:waypoints,:id_source,:noarchive, :format_source, :source_name, :over_country)';
113 160
 					$query_values = array(':id_user' => $id_user,':datetime' => $data['datetime'],':hex' => $data['hex'],':ident' => $data['ident'],':latitude' => $data['latitude'],':longitude' => $data['longitude'],':verticalrate' => $data['verticalrate'],':speed' => $data['speed'],':squawk' => $data['squawk'],':altitude' => $data['altitude'],':heading' => $data['heading'],':registration' => $data['registration'],':aircraft_icao' => $data['aircraft_icao'],':waypoints' => $data['waypoints'],':id_source' => $id_source,':noarchive' => $data['noarchive'], ':format_source' => $data['format_source'], ':source_name' => $data['source_name'],':over_country' => $data['over_country']);
114 161
 					try {
Please login to merge, or discard this patch.
ident-statistics-time.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
 	die();
8 8
 }
9 9
 $Spotter = new Spotter();
10
-$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
-$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
-$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort);
10
+$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
11
+$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
12
+$spotter_array = $Spotter->getSpotterDataByIdent($ident, "0,1", $sort);
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['ident']);
16
+	$title = sprintf(_("Most Common Time of Day of %s"), $spotter_array[0]['ident']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="info column">';
19 19
 	print '<h1>'.$spotter_array[0]['ident'].'</h1>';
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	include('ident-sub-menu.php');
25 25
 	print '<div class="column">';
26 26
 	print '<h2>'._("Most Common Time of Day").'</h2>';
27
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
27
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights with the ident/callsign <strong>%s</strong>."), $spotter_array[0]['ident']).'</p>';
28 28
 	$hour_array = $Spotter->countAllHoursByIdent($ident);
29 29
 	print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
30 30
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	$hour_data = '';
34 34
 	$hour_cnt = '';
35 35
 	$last = 0;
36
-	foreach($hour_array as $hour_item)
36
+	foreach ($hour_array as $hour_item)
37 37
 	{
38
-		while($last != $hour_item['hour_name']) {
38
+		while ($last != $hour_item['hour_name']) {
39 39
 			$hour_data .= '"'.$last.':00",';
40 40
 			$hour_cnt .= '0,';
41 41
 			$last++;
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$hour_cnt .= $hour_item['hour_count'].',';
46 46
 	}
47 47
 	$hour_data = "['x',".substr($hour_data, 0, -1)."]";
48
-	$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
48
+	$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
49 49
 	print 'c3.generate({
50 50
 	    bindto: "#chartHour",
51 51
 	    data: {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		print '</thead>';
71 71
 		print '<tbody>';
72 72
 		$i = 1;
73
-		foreach($hour_array as $hour_item)
73
+		foreach ($hour_array as $hour_item)
74 74
 		{
75 75
 			print '<tr>';
76 76
 			print '<td>'.$hour_item['hour_name'].':00</td>';
Please login to merge, or discard this patch.