Completed
Push — master ( f7315f...c6f0b9 )
by Yannick
08:38
created
install/index.php 2 patches
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.create_db.php');
10 10
 require_once(dirname(__FILE__).'/class.update_schema.php');
11 11
 require_once(dirname(__FILE__).'/class.settings.php');
12
-$title="Install";
12
+$title = "Install";
13 13
 require(dirname(__FILE__).'/../require/settings.php');
14 14
 require(dirname(__FILE__).'/header.php');
15 15
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 if (!extension_loaded('curl')) {
64 64
 	$error[] = "Curl is not loaded.";
65 65
 }
66
-if(function_exists('apache_get_modules') ){
67
-	if(!in_array('mod_rewrite',apache_get_modules())) {
66
+if (function_exists('apache_get_modules')) {
67
+	if (!in_array('mod_rewrite', apache_get_modules())) {
68 68
 		$error[] = "mod_rewrite is not available.";
69 69
 	}
70 70
 /*
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 }
80 80
 if (isset($_SERVER['REQUEST_SCHEME']) && isset($_SERVER['SERVER_NAME']) && isset($_SERVER['SERVER_PORT']) && isset($_SERVER['REQUEST_URI'])) {
81 81
 	if (function_exists('get_headers')) {
82
-		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/','search',str_replace('index.php',$_SERVER["REQUEST_URI"])));
83
-		if (isset($check_header[0]) && !stripos($check_header[0],"200 OK")) {
82
+		$check_header = @get_headers($_SERVER['REQUEST_SCHEME'].'://'.$_SERVER["SERVER_NAME"].':'.$_SERVER["SERVER_PORT"].str_replace('install/', 'search', str_replace('index.php', $_SERVER["REQUEST_URI"])));
83
+		if (isset($check_header[0]) && !stripos($check_header[0], "200 OK")) {
84 84
 			print '<div class="info column"><p><strong>Check your configuration, rewrite don\'t seems to work.</strong></p></div>';
85 85
 		}
86 86
 	}
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 ?>
421 421
 							<tr>
422 422
 								<?php
423
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
423
+								    if (filter_var($source['host'], FILTER_VALIDATE_URL)) {
424 424
 								?>
425 425
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
426 426
 								<td><input type="number" name="port[]" id="port" value="<?php print $source['port']; ?>" /></td>
427 427
 								<?php
428 428
 								    } else {
429
-									$hostport = explode(':',$source['host']);
429
+									$hostport = explode(':', $source['host']);
430 430
 									if (isset($hostport[1])) {
431 431
 										$host = $hostport[0];
432 432
 										$port = $hostport[1];
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 			<br />
735 735
 			<p>
736 736
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
737
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
737
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize; ?>" />
738 738
 			</p>
739 739
 			<br />
740 740
 			<p>
@@ -780,14 +780,14 @@  discard block
 block discarded – undo
780 780
 $error = '';
781 781
 
782 782
 if (isset($_POST['dbtype'])) {
783
-	$dbtype = filter_input(INPUT_POST,'dbtype',FILTER_SANITIZE_STRING);
784
-	$dbroot = filter_input(INPUT_POST,'dbroot',FILTER_SANITIZE_STRING);
785
-	$dbrootpass = filter_input(INPUT_POST,'dbrootpass',FILTER_SANITIZE_STRING);
786
-	$dbname = filter_input(INPUT_POST,'dbname',FILTER_SANITIZE_STRING);
787
-	$dbuser = filter_input(INPUT_POST,'dbuser',FILTER_SANITIZE_STRING);
788
-	$dbuserpass = filter_input(INPUT_POST,'dbuserpass',FILTER_SANITIZE_STRING);
789
-	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
790
-	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
783
+	$dbtype = filter_input(INPUT_POST, 'dbtype', FILTER_SANITIZE_STRING);
784
+	$dbroot = filter_input(INPUT_POST, 'dbroot', FILTER_SANITIZE_STRING);
785
+	$dbrootpass = filter_input(INPUT_POST, 'dbrootpass', FILTER_SANITIZE_STRING);
786
+	$dbname = filter_input(INPUT_POST, 'dbname', FILTER_SANITIZE_STRING);
787
+	$dbuser = filter_input(INPUT_POST, 'dbuser', FILTER_SANITIZE_STRING);
788
+	$dbuserpass = filter_input(INPUT_POST, 'dbuserpass', FILTER_SANITIZE_STRING);
789
+	$dbhost = filter_input(INPUT_POST, 'dbhost', FILTER_SANITIZE_STRING);
790
+	$dbport = filter_input(INPUT_POST, 'dbport', FILTER_SANITIZE_STRING);
791 791
 
792 792
 	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
793 793
 	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
@@ -807,48 +807,48 @@  discard block
 block discarded – undo
807 807
 	} else $settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
808 808
 	*/
809 809
 	
810
-	$settings = array_merge($settings,array('globalDBdriver' => $dbtype,'globalDBhost' => $dbhost,'globalDBuser' => $dbuser,'globalDBport' => $dbport,'globalDBpass' => $dbuserpass,'globalDBname' => $dbname));
810
+	$settings = array_merge($settings, array('globalDBdriver' => $dbtype, 'globalDBhost' => $dbhost, 'globalDBuser' => $dbuser, 'globalDBport' => $dbport, 'globalDBpass' => $dbuserpass, 'globalDBname' => $dbname));
811 811
 
812
-	$sitename = filter_input(INPUT_POST,'sitename',FILTER_SANITIZE_STRING);
813
-	$siteurl = filter_input(INPUT_POST,'siteurl',FILTER_SANITIZE_STRING);
814
-	$timezone = filter_input(INPUT_POST,'timezone',FILTER_SANITIZE_STRING);
815
-	$language = filter_input(INPUT_POST,'language',FILTER_SANITIZE_STRING);
816
-	$settings = array_merge($settings,array('globalName' => $sitename,'globalURL' => $siteurl, 'globalTimezone' => $timezone,'globalLanguage' => $language));
812
+	$sitename = filter_input(INPUT_POST, 'sitename', FILTER_SANITIZE_STRING);
813
+	$siteurl = filter_input(INPUT_POST, 'siteurl', FILTER_SANITIZE_STRING);
814
+	$timezone = filter_input(INPUT_POST, 'timezone', FILTER_SANITIZE_STRING);
815
+	$language = filter_input(INPUT_POST, 'language', FILTER_SANITIZE_STRING);
816
+	$settings = array_merge($settings, array('globalName' => $sitename, 'globalURL' => $siteurl, 'globalTimezone' => $timezone, 'globalLanguage' => $language));
817 817
 
818
-	$mapprovider = filter_input(INPUT_POST,'mapprovider',FILTER_SANITIZE_STRING);
819
-	$mapboxid = filter_input(INPUT_POST,'mapboxid',FILTER_SANITIZE_STRING);
820
-	$mapboxtoken = filter_input(INPUT_POST,'mapboxtoken',FILTER_SANITIZE_STRING);
821
-	$googlekey = filter_input(INPUT_POST,'googlekey',FILTER_SANITIZE_STRING);
822
-	$bingkey = filter_input(INPUT_POST,'bingkey',FILTER_SANITIZE_STRING);
823
-	$mapquestkey = filter_input(INPUT_POST,'mapquestkey',FILTER_SANITIZE_STRING);
824
-	$hereappid = filter_input(INPUT_POST,'hereappid',FILTER_SANITIZE_STRING);
825
-	$hereappcode = filter_input(INPUT_POST,'hereappcode',FILTER_SANITIZE_STRING);
826
-	$settings = array_merge($settings,array('globalMapProvider' => $mapprovider,'globalMapboxId' => $mapboxid,'globalMapboxToken' => $mapboxtoken,'globalGoogleAPIKey' => $googlekey,'globalBingMapKey' => $bingkey,'globalHereappID' => $hereappid,'globalHereappCode' => $hereappcode,'globalMapQuestKey' => $mapquestkey));
818
+	$mapprovider = filter_input(INPUT_POST, 'mapprovider', FILTER_SANITIZE_STRING);
819
+	$mapboxid = filter_input(INPUT_POST, 'mapboxid', FILTER_SANITIZE_STRING);
820
+	$mapboxtoken = filter_input(INPUT_POST, 'mapboxtoken', FILTER_SANITIZE_STRING);
821
+	$googlekey = filter_input(INPUT_POST, 'googlekey', FILTER_SANITIZE_STRING);
822
+	$bingkey = filter_input(INPUT_POST, 'bingkey', FILTER_SANITIZE_STRING);
823
+	$mapquestkey = filter_input(INPUT_POST, 'mapquestkey', FILTER_SANITIZE_STRING);
824
+	$hereappid = filter_input(INPUT_POST, 'hereappid', FILTER_SANITIZE_STRING);
825
+	$hereappcode = filter_input(INPUT_POST, 'hereappcode', FILTER_SANITIZE_STRING);
826
+	$settings = array_merge($settings, array('globalMapProvider' => $mapprovider, 'globalMapboxId' => $mapboxid, 'globalMapboxToken' => $mapboxtoken, 'globalGoogleAPIKey' => $googlekey, 'globalBingMapKey' => $bingkey, 'globalHereappID' => $hereappid, 'globalHereappCode' => $hereappcode, 'globalMapQuestKey' => $mapquestkey));
827 827
 	
828
-	$latitudemax = filter_input(INPUT_POST,'latitudemax',FILTER_SANITIZE_STRING);
829
-	$latitudemin = filter_input(INPUT_POST,'latitudemin',FILTER_SANITIZE_STRING);
830
-	$longitudemax = filter_input(INPUT_POST,'longitudemax',FILTER_SANITIZE_STRING);
831
-	$longitudemin = filter_input(INPUT_POST,'longitudemin',FILTER_SANITIZE_STRING);
832
-	$livezoom = filter_input(INPUT_POST,'livezoom',FILTER_SANITIZE_NUMBER_INT);
833
-	$settings = array_merge($settings,array('globalLatitudeMax' => $latitudemax,'globalLatitudeMin' => $latitudemin,'globalLongitudeMax' => $longitudemax,'globalLongitudeMin' => $longitudemin,'globalLiveZoom' => $livezoom));
828
+	$latitudemax = filter_input(INPUT_POST, 'latitudemax', FILTER_SANITIZE_STRING);
829
+	$latitudemin = filter_input(INPUT_POST, 'latitudemin', FILTER_SANITIZE_STRING);
830
+	$longitudemax = filter_input(INPUT_POST, 'longitudemax', FILTER_SANITIZE_STRING);
831
+	$longitudemin = filter_input(INPUT_POST, 'longitudemin', FILTER_SANITIZE_STRING);
832
+	$livezoom = filter_input(INPUT_POST, 'livezoom', FILTER_SANITIZE_NUMBER_INT);
833
+	$settings = array_merge($settings, array('globalLatitudeMax' => $latitudemax, 'globalLatitudeMin' => $latitudemin, 'globalLongitudeMax' => $longitudemax, 'globalLongitudeMin' => $longitudemin, 'globalLiveZoom' => $livezoom));
834 834
 
835
-	$squawk_country = filter_input(INPUT_POST,'squawk_country',FILTER_SANITIZE_STRING);
836
-	$settings = array_merge($settings,array('globalSquawkCountry' => $squawk_country));
835
+	$squawk_country = filter_input(INPUT_POST, 'squawk_country', FILTER_SANITIZE_STRING);
836
+	$settings = array_merge($settings, array('globalSquawkCountry' => $squawk_country));
837 837
 
838
-	$latitudecenter = filter_input(INPUT_POST,'latitudecenter',FILTER_SANITIZE_STRING);
839
-	$longitudecenter = filter_input(INPUT_POST,'longitudecenter',FILTER_SANITIZE_STRING);
840
-	$settings = array_merge($settings,array('globalCenterLatitude' => $latitudecenter,'globalCenterLongitude' => $longitudecenter));
838
+	$latitudecenter = filter_input(INPUT_POST, 'latitudecenter', FILTER_SANITIZE_STRING);
839
+	$longitudecenter = filter_input(INPUT_POST, 'longitudecenter', FILTER_SANITIZE_STRING);
840
+	$settings = array_merge($settings, array('globalCenterLatitude' => $latitudecenter, 'globalCenterLongitude' => $longitudecenter));
841 841
 
842
-	$acars = filter_input(INPUT_POST,'acars',FILTER_SANITIZE_STRING);
842
+	$acars = filter_input(INPUT_POST, 'acars', FILTER_SANITIZE_STRING);
843 843
 	if ($acars == 'acars') {
844
-		$settings = array_merge($settings,array('globalACARS' => 'TRUE'));
844
+		$settings = array_merge($settings, array('globalACARS' => 'TRUE'));
845 845
 	} else {
846
-		$settings = array_merge($settings,array('globalACARS' => 'FALSE'));
846
+		$settings = array_merge($settings, array('globalACARS' => 'FALSE'));
847 847
 	}
848 848
 
849
-	$flightawareusername = filter_input(INPUT_POST,'flightawareusername',FILTER_SANITIZE_STRING);
850
-	$flightawarepassword = filter_input(INPUT_POST,'flightawarepassword',FILTER_SANITIZE_STRING);
851
-	$settings = array_merge($settings,array('globalFlightAwareUsername' => $flightawareusername,'globalFlightAwarePassword' => $flightawarepassword));
849
+	$flightawareusername = filter_input(INPUT_POST, 'flightawareusername', FILTER_SANITIZE_STRING);
850
+	$flightawarepassword = filter_input(INPUT_POST, 'flightawarepassword', FILTER_SANITIZE_STRING);
851
+	$settings = array_merge($settings, array('globalFlightAwareUsername' => $flightawareusername, 'globalFlightAwarePassword' => $flightawarepassword));
852 852
 	
853 853
 	$source_name = $_POST['source_name'];
854 854
 	$source_latitude = $_POST['source_latitude'];
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 	
863 863
 	$sources = array();
864 864
 	foreach ($source_name as $keys => $name) {
865
-	    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]);
866
-	    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]);
865
+	    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]);
866
+	    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]);
867 867
 	}
868 868
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
869 869
 
@@ -876,13 +876,13 @@  discard block
 block discarded – undo
876 876
 	$sbsurl = $_POST['sbsurl'];
877 877
 	*/
878 878
 
879
-	$globalvatsim = filter_input(INPUT_POST,'globalvatsim',FILTER_SANITIZE_STRING);
880
-	$globalivao = filter_input(INPUT_POST,'globalivao',FILTER_SANITIZE_STRING);
881
-	$globalphpvms = filter_input(INPUT_POST,'globalphpvms',FILTER_SANITIZE_STRING);
882
-	$globalvam = filter_input(INPUT_POST,'globalvam',FILTER_SANITIZE_STRING);
883
-	$globalsbs = filter_input(INPUT_POST,'globalsbs',FILTER_SANITIZE_STRING);
884
-	$globalaprs = filter_input(INPUT_POST,'globalaprs',FILTER_SANITIZE_STRING);
885
-	$datasource = filter_input(INPUT_POST,'datasource',FILTER_SANITIZE_STRING);
879
+	$globalvatsim = filter_input(INPUT_POST, 'globalvatsim', FILTER_SANITIZE_STRING);
880
+	$globalivao = filter_input(INPUT_POST, 'globalivao', FILTER_SANITIZE_STRING);
881
+	$globalphpvms = filter_input(INPUT_POST, 'globalphpvms', FILTER_SANITIZE_STRING);
882
+	$globalvam = filter_input(INPUT_POST, 'globalvam', FILTER_SANITIZE_STRING);
883
+	$globalsbs = filter_input(INPUT_POST, 'globalsbs', FILTER_SANITIZE_STRING);
884
+	$globalaprs = filter_input(INPUT_POST, 'globalaprs', FILTER_SANITIZE_STRING);
885
+	$datasource = filter_input(INPUT_POST, 'datasource', FILTER_SANITIZE_STRING);
886 886
 
887 887
 /*	
888 888
 	$globalSBS1Hosts = array();
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 	}
899 899
 	$settings = array_merge($settings,array('globalSBS1Hosts' => $globalSBS1Hosts));
900 900
 */
901
-	$settings_comment = array_merge($settings_comment,array('globalSBS1Hosts'));
901
+	$settings_comment = array_merge($settings_comment, array('globalSBS1Hosts'));
902 902
 	$host = $_POST['host'];
903 903
 	$port = $_POST['port'];
904 904
 	$name = $_POST['name'];
@@ -909,88 +909,88 @@  discard block
 block discarded – undo
909 909
 	foreach ($host as $key => $h) {
910 910
 		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
911 911
 		else $cov = 'FALSE';
912
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
912
+		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key], 'name' => $name[$key], 'format' => $format[$key], 'sourcestats' => $cov);
913 913
 	}
914
-	$settings = array_merge($settings,array('globalSources' => $gSources));
914
+	$settings = array_merge($settings, array('globalSources' => $gSources));
915 915
 
916
-	$sbstimeout = filter_input(INPUT_POST,'sbstimeout',FILTER_SANITIZE_NUMBER_INT);
917
-	$settings = array_merge($settings,array('globalSourcesTimeOut' => $sbstimeout));
916
+	$sbstimeout = filter_input(INPUT_POST, 'sbstimeout', FILTER_SANITIZE_NUMBER_INT);
917
+	$settings = array_merge($settings, array('globalSourcesTimeOut' => $sbstimeout));
918 918
 
919
-	$acarshost = filter_input(INPUT_POST,'acarshost',FILTER_SANITIZE_STRING);
920
-	$acarsport = filter_input(INPUT_POST,'acarsport',FILTER_SANITIZE_NUMBER_INT);
921
-	$settings = array_merge($settings,array('globalACARSHost' => $acarshost,'globalACARSPort' => $acarsport));
919
+	$acarshost = filter_input(INPUT_POST, 'acarshost', FILTER_SANITIZE_STRING);
920
+	$acarsport = filter_input(INPUT_POST, 'acarsport', FILTER_SANITIZE_NUMBER_INT);
921
+	$settings = array_merge($settings, array('globalACARSHost' => $acarshost, 'globalACARSPort' => $acarsport));
922 922
 
923
-	$bitly = filter_input(INPUT_POST,'bitly',FILTER_SANITIZE_STRING);
924
-	$settings = array_merge($settings,array('globalBitlyAccessToken' => $bitly));
923
+	$bitly = filter_input(INPUT_POST, 'bitly', FILTER_SANITIZE_STRING);
924
+	$settings = array_merge($settings, array('globalBitlyAccessToken' => $bitly));
925 925
 
926
-	$notamsource = filter_input(INPUT_POST,'notamsource',FILTER_SANITIZE_STRING);
927
-	$settings = array_merge($settings,array('globalNOTAMSource' => $notamsource));
928
-	$metarsource = filter_input(INPUT_POST,'metarsource',FILTER_SANITIZE_STRING);
929
-	$settings = array_merge($settings,array('globalMETARurl' => $metarsource));
926
+	$notamsource = filter_input(INPUT_POST, 'notamsource', FILTER_SANITIZE_STRING);
927
+	$settings = array_merge($settings, array('globalNOTAMSource' => $notamsource));
928
+	$metarsource = filter_input(INPUT_POST, 'metarsource', FILTER_SANITIZE_STRING);
929
+	$settings = array_merge($settings, array('globalMETARurl' => $metarsource));
930 930
 
931
-	$zoilatitude = filter_input(INPUT_POST,'zoilatitude',FILTER_SANITIZE_STRING);
932
-	$zoilongitude = filter_input(INPUT_POST,'zoilongitude',FILTER_SANITIZE_STRING);
933
-	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
931
+	$zoilatitude = filter_input(INPUT_POST, 'zoilatitude', FILTER_SANITIZE_STRING);
932
+	$zoilongitude = filter_input(INPUT_POST, 'zoilongitude', FILTER_SANITIZE_STRING);
933
+	$zoidistance = filter_input(INPUT_POST, 'zoidistance', FILTER_SANITIZE_NUMBER_INT);
934 934
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
935
-		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
936
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
935
+		$settings = array_merge($settings, array('globalDistanceIgnore' => array('latitude' => $zoilatitude, 'longitude' => $zoilongitude, 'distance' => $zoidistance)));
936
+	} else $settings = array_merge($settings, array('globalDistanceIgnore' => array()));
937 937
 
938
-	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
939
-	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
940
-	$maprefresh = filter_input(INPUT_POST,'maprefresh',FILTER_SANITIZE_NUMBER_INT);
941
-	$settings = array_merge($settings,array('globalMapRefresh' => $maprefresh));
942
-	$mapidle = filter_input(INPUT_POST,'mapidle',FILTER_SANITIZE_NUMBER_INT);
943
-	$settings = array_merge($settings,array('globalMapIdleTimeout' => $mapidle));
944
-	$closestmindist = filter_input(INPUT_POST,'closestmindist',FILTER_SANITIZE_NUMBER_INT);
945
-	$settings = array_merge($settings,array('globalClosestMinDist' => $closestmindist));
938
+	$refresh = filter_input(INPUT_POST, 'refresh', FILTER_SANITIZE_NUMBER_INT);
939
+	$settings = array_merge($settings, array('globalLiveInterval' => $refresh));
940
+	$maprefresh = filter_input(INPUT_POST, 'maprefresh', FILTER_SANITIZE_NUMBER_INT);
941
+	$settings = array_merge($settings, array('globalMapRefresh' => $maprefresh));
942
+	$mapidle = filter_input(INPUT_POST, 'mapidle', FILTER_SANITIZE_NUMBER_INT);
943
+	$settings = array_merge($settings, array('globalMapIdleTimeout' => $mapidle));
944
+	$closestmindist = filter_input(INPUT_POST, 'closestmindist', FILTER_SANITIZE_NUMBER_INT);
945
+	$settings = array_merge($settings, array('globalClosestMinDist' => $closestmindist));
946 946
 
947
-	$aircraftsize = filter_input(INPUT_POST,'aircraftsize',FILTER_SANITIZE_NUMBER_INT);
948
-	$settings = array_merge($settings,array('globalAircraftSize' => $aircraftsize));
947
+	$aircraftsize = filter_input(INPUT_POST, 'aircraftsize', FILTER_SANITIZE_NUMBER_INT);
948
+	$settings = array_merge($settings, array('globalAircraftSize' => $aircraftsize));
949 949
 
950
-	$archivemonths = filter_input(INPUT_POST,'archivemonths',FILTER_SANITIZE_NUMBER_INT);
951
-	$settings = array_merge($settings,array('globalArchiveMonths' => $archivemonths));
950
+	$archivemonths = filter_input(INPUT_POST, 'archivemonths', FILTER_SANITIZE_NUMBER_INT);
951
+	$settings = array_merge($settings, array('globalArchiveMonths' => $archivemonths));
952 952
 	
953
-	$archiveyear = filter_input(INPUT_POST,'archiveyear',FILTER_SANITIZE_STRING);
953
+	$archiveyear = filter_input(INPUT_POST, 'archiveyear', FILTER_SANITIZE_STRING);
954 954
 	if ($archiveyear == "archiveyear") {
955
-		$settings = array_merge($settings,array('globalArchiveYear' => 'TRUE'));
955
+		$settings = array_merge($settings, array('globalArchiveYear' => 'TRUE'));
956 956
 	} else {
957
-		$settings = array_merge($settings,array('globalArchiveYear' => 'FALSE'));
957
+		$settings = array_merge($settings, array('globalArchiveYear' => 'FALSE'));
958 958
 	}
959
-	$archivekeepmonths = filter_input(INPUT_POST,'archivekeepmonths',FILTER_SANITIZE_NUMBER_INT);
960
-	$settings = array_merge($settings,array('globalArchiveKeepMonths' => $archivekeepmonths));
961
-	$archivekeeptrackmonths = filter_input(INPUT_POST,'archivekeeptrackmonths',FILTER_SANITIZE_NUMBER_INT);
962
-	$settings = array_merge($settings,array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
959
+	$archivekeepmonths = filter_input(INPUT_POST, 'archivekeepmonths', FILTER_SANITIZE_NUMBER_INT);
960
+	$settings = array_merge($settings, array('globalArchiveKeepMonths' => $archivekeepmonths));
961
+	$archivekeeptrackmonths = filter_input(INPUT_POST, 'archivekeeptrackmonths', FILTER_SANITIZE_NUMBER_INT);
962
+	$settings = array_merge($settings, array('globalArchiveKeepTrackMonths' => $archivekeeptrackmonths));
963 963
 
964
-	$britishairways = filter_input(INPUT_POST,'britishairways',FILTER_SANITIZE_STRING);
965
-	$settings = array_merge($settings,array('globalBritishAirwaysKey' => $britishairways));
966
-	$transavia = filter_input(INPUT_POST,'transavia',FILTER_SANITIZE_STRING);
967
-	$settings = array_merge($settings,array('globalTransaviaKey' => $transavia));
964
+	$britishairways = filter_input(INPUT_POST, 'britishairways', FILTER_SANITIZE_STRING);
965
+	$settings = array_merge($settings, array('globalBritishAirwaysKey' => $britishairways));
966
+	$transavia = filter_input(INPUT_POST, 'transavia', FILTER_SANITIZE_STRING);
967
+	$settings = array_merge($settings, array('globalTransaviaKey' => $transavia));
968 968
 
969
-	$lufthansakey = filter_input(INPUT_POST,'lufthansakey',FILTER_SANITIZE_STRING);
970
-	$lufthansasecret = filter_input(INPUT_POST,'lufthansasecret',FILTER_SANITIZE_STRING);
971
-	$settings = array_merge($settings,array('globalLufthansaKey' => array('key' => $lufthansakey,'secret' => $lufthansasecret)));
969
+	$lufthansakey = filter_input(INPUT_POST, 'lufthansakey', FILTER_SANITIZE_STRING);
970
+	$lufthansasecret = filter_input(INPUT_POST, 'lufthansasecret', FILTER_SANITIZE_STRING);
971
+	$settings = array_merge($settings, array('globalLufthansaKey' => array('key' => $lufthansakey, 'secret' => $lufthansasecret)));
972 972
 
973 973
 	// Create in settings.php keys not yet configurable if not already here
974 974
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
975
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
975
+	if (!isset($globalDebug)) $settings = array_merge($settings, array('globalDebug' => 'TRUE'));
976 976
 
977
-	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
977
+	$archive = filter_input(INPUT_POST, 'archive', FILTER_SANITIZE_STRING);
978 978
 	if ($archive == 'archive') {
979
-		$settings = array_merge($settings,array('globalArchive' => 'TRUE'));
979
+		$settings = array_merge($settings, array('globalArchive' => 'TRUE'));
980 980
 	} else {
981
-		$settings = array_merge($settings,array('globalArchive' => 'FALSE'));
981
+		$settings = array_merge($settings, array('globalArchive' => 'FALSE'));
982 982
 	}
983
-	$daemon = filter_input(INPUT_POST,'daemon',FILTER_SANITIZE_STRING);
983
+	$daemon = filter_input(INPUT_POST, 'daemon', FILTER_SANITIZE_STRING);
984 984
 	if ($daemon == 'daemon') {
985
-		$settings = array_merge($settings,array('globalDaemon' => 'TRUE'));
985
+		$settings = array_merge($settings, array('globalDaemon' => 'TRUE'));
986 986
 	} else {
987
-		$settings = array_merge($settings,array('globalDaemon' => 'FALSE'));
987
+		$settings = array_merge($settings, array('globalDaemon' => 'FALSE'));
988 988
 	}
989
-	$schedules = filter_input(INPUT_POST,'schedules',FILTER_SANITIZE_STRING);
989
+	$schedules = filter_input(INPUT_POST, 'schedules', FILTER_SANITIZE_STRING);
990 990
 	if ($schedules == 'schedules') {
991
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE'));
991
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE'));
992 992
 	} else {
993
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE'));
993
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE'));
994 994
 	}
995 995
 
996 996
 /*
@@ -1001,153 +1001,153 @@  discard block
 block discarded – undo
1001 1001
 		$settings = array_merge($settings,array('globalFlightAware' => 'FALSE','globalSBS1' => 'TRUE'));
1002 1002
 	}
1003 1003
 */
1004
-	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1005
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1006
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1007
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1008
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1004
+	$settings = array_merge($settings, array('globalFlightAware' => 'FALSE'));
1005
+	if ($globalsbs == 'sbs') $settings = array_merge($settings, array('globalSBS1' => 'TRUE'));
1006
+	else $settings = array_merge($settings, array('globalSBS1' => 'FALSE'));
1007
+	if ($globalaprs == 'aprs') $settings = array_merge($settings, array('globalAPRS' => 'TRUE'));
1008
+	else $settings = array_merge($settings, array('globalAPRS' => 'FALSE'));
1009 1009
 	if ($globalivao == 'ivao') {
1010 1010
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1011
-		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1012
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1011
+		$settings = array_merge($settings, array('globalIVAO' => 'TRUE'));
1012
+	} else $settings = array_merge($settings, array('globalIVAO' => 'FALSE'));
1013 1013
 	if ($globalvatsim == 'vatsim') {
1014 1014
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1015
-		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1016
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1015
+		$settings = array_merge($settings, array('globalVATSIM' => 'TRUE'));
1016
+	} else $settings = array_merge($settings, array('globalVATSIM' => 'FALSE'));
1017 1017
 	if ($globalphpvms == 'phpvms') {
1018
-		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1019
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1018
+		$settings = array_merge($settings, array('globalphpVMS' => 'TRUE'));
1019
+	} else $settings = array_merge($settings, array('globalphpVMS' => 'FALSE'));
1020 1020
 	if ($globalvam == 'vam') {
1021
-		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1022
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1021
+		$settings = array_merge($settings, array('globalVAM' => 'TRUE'));
1022
+	} else $settings = array_merge($settings, array('globalVAM' => 'FALSE'));
1023 1023
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1024
-		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1025
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1024
+		$settings = array_merge($settings, array('globalSchedulesFetch' => 'FALSE', 'globalTranslationFetch' => 'FALSE'));
1025
+	} else $settings = array_merge($settings, array('globalSchedulesFetch' => 'TRUE', 'globalTranslationFetch' => 'TRUE'));
1026 1026
 	
1027 1027
 
1028 1028
 
1029
-	$notam = filter_input(INPUT_POST,'notam',FILTER_SANITIZE_STRING);
1029
+	$notam = filter_input(INPUT_POST, 'notam', FILTER_SANITIZE_STRING);
1030 1030
 	if ($notam == 'notam') {
1031
-		$settings = array_merge($settings,array('globalNOTAM' => 'TRUE'));
1031
+		$settings = array_merge($settings, array('globalNOTAM' => 'TRUE'));
1032 1032
 	} else {
1033
-		$settings = array_merge($settings,array('globalNOTAM' => 'FALSE'));
1033
+		$settings = array_merge($settings, array('globalNOTAM' => 'FALSE'));
1034 1034
 	}
1035
-	$owner = filter_input(INPUT_POST,'owner',FILTER_SANITIZE_STRING);
1035
+	$owner = filter_input(INPUT_POST, 'owner', FILTER_SANITIZE_STRING);
1036 1036
 	if ($owner == 'owner') {
1037
-		$settings = array_merge($settings,array('globalOwner' => 'TRUE'));
1037
+		$settings = array_merge($settings, array('globalOwner' => 'TRUE'));
1038 1038
 	} else {
1039
-		$settings = array_merge($settings,array('globalOwner' => 'FALSE'));
1039
+		$settings = array_merge($settings, array('globalOwner' => 'FALSE'));
1040 1040
 	}
1041
-	$map3d = filter_input(INPUT_POST,'map3d',FILTER_SANITIZE_STRING);
1041
+	$map3d = filter_input(INPUT_POST, 'map3d', FILTER_SANITIZE_STRING);
1042 1042
 	if ($map3d == 'map3d') {
1043
-		$settings = array_merge($settings,array('globalMap3D' => 'TRUE'));
1043
+		$settings = array_merge($settings, array('globalMap3D' => 'TRUE'));
1044 1044
 	} else {
1045
-		$settings = array_merge($settings,array('globalMap3D' => 'FALSE'));
1045
+		$settings = array_merge($settings, array('globalMap3D' => 'FALSE'));
1046 1046
 	}
1047
-	$mapsatellites = filter_input(INPUT_POST,'mapsatellites',FILTER_SANITIZE_STRING);
1047
+	$mapsatellites = filter_input(INPUT_POST, 'mapsatellites', FILTER_SANITIZE_STRING);
1048 1048
 	if ($mapsatellites == 'mapsatellites') {
1049
-		$settings = array_merge($settings,array('globalMapSatellites' => 'TRUE'));
1049
+		$settings = array_merge($settings, array('globalMapSatellites' => 'TRUE'));
1050 1050
 	} else {
1051
-		$settings = array_merge($settings,array('globalMapSatellites' => 'FALSE'));
1051
+		$settings = array_merge($settings, array('globalMapSatellites' => 'FALSE'));
1052 1052
 	}
1053
-	$map3ddefault = filter_input(INPUT_POST,'map3ddefault',FILTER_SANITIZE_STRING);
1053
+	$map3ddefault = filter_input(INPUT_POST, 'map3ddefault', FILTER_SANITIZE_STRING);
1054 1054
 	if ($map3ddefault == 'map3ddefault') {
1055
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'TRUE'));
1055
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'TRUE'));
1056 1056
 	} else {
1057
-		$settings = array_merge($settings,array('globalMap3Ddefault' => 'FALSE'));
1057
+		$settings = array_merge($settings, array('globalMap3Ddefault' => 'FALSE'));
1058 1058
 	}
1059
-	$translate = filter_input(INPUT_POST,'translate',FILTER_SANITIZE_STRING);
1059
+	$translate = filter_input(INPUT_POST, 'translate', FILTER_SANITIZE_STRING);
1060 1060
 	if ($translate == 'translate') {
1061
-		$settings = array_merge($settings,array('globalTranslate' => 'TRUE'));
1061
+		$settings = array_merge($settings, array('globalTranslate' => 'TRUE'));
1062 1062
 	} else {
1063
-		$settings = array_merge($settings,array('globalTranslate' => 'FALSE'));
1063
+		$settings = array_merge($settings, array('globalTranslate' => 'FALSE'));
1064 1064
 	}
1065
-	$estimation = filter_input(INPUT_POST,'estimation',FILTER_SANITIZE_STRING);
1065
+	$estimation = filter_input(INPUT_POST, 'estimation', FILTER_SANITIZE_STRING);
1066 1066
 	if ($estimation == 'estimation') {
1067
-		$settings = array_merge($settings,array('globalMapEstimation' => 'TRUE'));
1067
+		$settings = array_merge($settings, array('globalMapEstimation' => 'TRUE'));
1068 1068
 	} else {
1069
-		$settings = array_merge($settings,array('globalMapEstimation' => 'FALSE'));
1069
+		$settings = array_merge($settings, array('globalMapEstimation' => 'FALSE'));
1070 1070
 	}
1071
-	$metar = filter_input(INPUT_POST,'metar',FILTER_SANITIZE_STRING);
1071
+	$metar = filter_input(INPUT_POST, 'metar', FILTER_SANITIZE_STRING);
1072 1072
 	if ($metar == 'metar') {
1073
-		$settings = array_merge($settings,array('globalMETAR' => 'TRUE'));
1073
+		$settings = array_merge($settings, array('globalMETAR' => 'TRUE'));
1074 1074
 	} else {
1075
-		$settings = array_merge($settings,array('globalMETAR' => 'FALSE'));
1075
+		$settings = array_merge($settings, array('globalMETAR' => 'FALSE'));
1076 1076
 	}
1077
-	$metarcycle = filter_input(INPUT_POST,'metarcycle',FILTER_SANITIZE_STRING);
1077
+	$metarcycle = filter_input(INPUT_POST, 'metarcycle', FILTER_SANITIZE_STRING);
1078 1078
 	if ($metarcycle == 'metarcycle') {
1079
-		$settings = array_merge($settings,array('globalMETARcycle' => 'TRUE'));
1079
+		$settings = array_merge($settings, array('globalMETARcycle' => 'TRUE'));
1080 1080
 	} else {
1081
-		$settings = array_merge($settings,array('globalMETARcycle' => 'FALSE'));
1081
+		$settings = array_merge($settings, array('globalMETARcycle' => 'FALSE'));
1082 1082
 	}
1083
-	$fork = filter_input(INPUT_POST,'fork',FILTER_SANITIZE_STRING);
1083
+	$fork = filter_input(INPUT_POST, 'fork', FILTER_SANITIZE_STRING);
1084 1084
 	if ($fork == 'fork') {
1085
-		$settings = array_merge($settings,array('globalFork' => 'TRUE'));
1085
+		$settings = array_merge($settings, array('globalFork' => 'TRUE'));
1086 1086
 	} else {
1087
-		$settings = array_merge($settings,array('globalFork' => 'FALSE'));
1087
+		$settings = array_merge($settings, array('globalFork' => 'FALSE'));
1088 1088
 	}
1089 1089
 
1090
-	$colormap = filter_input(INPUT_POST,'colormap',FILTER_SANITIZE_STRING);
1090
+	$colormap = filter_input(INPUT_POST, 'colormap', FILTER_SANITIZE_STRING);
1091 1091
 	if ($colormap == 'colormap') {
1092
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'TRUE'));
1092
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'TRUE'));
1093 1093
 	} else {
1094
-		$settings = array_merge($settings,array('globalMapAltitudeColor' => 'FALSE'));
1094
+		$settings = array_merge($settings, array('globalMapAltitudeColor' => 'FALSE'));
1095 1095
 	}
1096 1096
 	
1097 1097
 	if (isset($_POST['aircrafticoncolor'])) {
1098
-		$aircrafticoncolor = filter_input(INPUT_POST,'aircrafticoncolor',FILTER_SANITIZE_STRING);
1099
-		$settings = array_merge($settings,array('globalAircraftIconColor' => substr($aircrafticoncolor,1)));
1098
+		$aircrafticoncolor = filter_input(INPUT_POST, 'aircrafticoncolor', FILTER_SANITIZE_STRING);
1099
+		$settings = array_merge($settings, array('globalAircraftIconColor' => substr($aircrafticoncolor, 1)));
1100 1100
 	}
1101 1101
 
1102
-	$airportzoom = filter_input(INPUT_POST,'airportzoom',FILTER_SANITIZE_NUMBER_INT);
1103
-	$settings = array_merge($settings,array('globalAirportZoom' => $airportzoom));
1102
+	$airportzoom = filter_input(INPUT_POST, 'airportzoom', FILTER_SANITIZE_NUMBER_INT);
1103
+	$settings = array_merge($settings, array('globalAirportZoom' => $airportzoom));
1104 1104
 
1105
-	$unitdistance = filter_input(INPUT_POST,'unitdistance',FILTER_SANITIZE_STRING);
1106
-	$settings = array_merge($settings,array('globalUnitDistance' => $unitdistance));
1107
-	$unitaltitude = filter_input(INPUT_POST,'unitaltitude',FILTER_SANITIZE_STRING);
1108
-	$settings = array_merge($settings,array('globalUnitAltitude' => $unitaltitude));
1109
-	$unitspeed = filter_input(INPUT_POST,'unitspeed',FILTER_SANITIZE_STRING);
1110
-	$settings = array_merge($settings,array('globalUnitSpeed' => $unitspeed));
1105
+	$unitdistance = filter_input(INPUT_POST, 'unitdistance', FILTER_SANITIZE_STRING);
1106
+	$settings = array_merge($settings, array('globalUnitDistance' => $unitdistance));
1107
+	$unitaltitude = filter_input(INPUT_POST, 'unitaltitude', FILTER_SANITIZE_STRING);
1108
+	$settings = array_merge($settings, array('globalUnitAltitude' => $unitaltitude));
1109
+	$unitspeed = filter_input(INPUT_POST, 'unitspeed', FILTER_SANITIZE_STRING);
1110
+	$settings = array_merge($settings, array('globalUnitSpeed' => $unitspeed));
1111 1111
 
1112
-	$mappopup = filter_input(INPUT_POST,'mappopup',FILTER_SANITIZE_STRING);
1112
+	$mappopup = filter_input(INPUT_POST, 'mappopup', FILTER_SANITIZE_STRING);
1113 1113
 	if ($mappopup == 'mappopup') {
1114
-		$settings = array_merge($settings,array('globalMapPopup' => 'TRUE'));
1114
+		$settings = array_merge($settings, array('globalMapPopup' => 'TRUE'));
1115 1115
 	} else {
1116
-		$settings = array_merge($settings,array('globalMapPopup' => 'FALSE'));
1116
+		$settings = array_merge($settings, array('globalMapPopup' => 'FALSE'));
1117 1117
 	}
1118
-	$airportpopup = filter_input(INPUT_POST,'airportpopup',FILTER_SANITIZE_STRING);
1118
+	$airportpopup = filter_input(INPUT_POST, 'airportpopup', FILTER_SANITIZE_STRING);
1119 1119
 	if ($airportpopup == 'airportpopup') {
1120
-		$settings = array_merge($settings,array('globalAirportPopup' => 'TRUE'));
1120
+		$settings = array_merge($settings, array('globalAirportPopup' => 'TRUE'));
1121 1121
 	} else {
1122
-		$settings = array_merge($settings,array('globalAirportPopup' => 'FALSE'));
1122
+		$settings = array_merge($settings, array('globalAirportPopup' => 'FALSE'));
1123 1123
 	}
1124
-	$maphistory = filter_input(INPUT_POST,'maphistory',FILTER_SANITIZE_STRING);
1124
+	$maphistory = filter_input(INPUT_POST, 'maphistory', FILTER_SANITIZE_STRING);
1125 1125
 	if ($maphistory == 'maphistory') {
1126
-		$settings = array_merge($settings,array('globalMapHistory' => 'TRUE'));
1126
+		$settings = array_merge($settings, array('globalMapHistory' => 'TRUE'));
1127 1127
 	} else {
1128
-		$settings = array_merge($settings,array('globalMapHistory' => 'FALSE'));
1128
+		$settings = array_merge($settings, array('globalMapHistory' => 'FALSE'));
1129 1129
 	}
1130
-	$flightroute = filter_input(INPUT_POST,'flightroute',FILTER_SANITIZE_STRING);
1130
+	$flightroute = filter_input(INPUT_POST, 'flightroute', FILTER_SANITIZE_STRING);
1131 1131
 	if ($flightroute == 'flightroute') {
1132
-		$settings = array_merge($settings,array('globalMapRoute' => 'TRUE'));
1132
+		$settings = array_merge($settings, array('globalMapRoute' => 'TRUE'));
1133 1133
 	} else {
1134
-		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1134
+		$settings = array_merge($settings, array('globalMapRoute' => 'FALSE'));
1135 1135
 	}
1136 1136
 
1137
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1137
+	if (!isset($globalTransaction)) $settings = array_merge($settings, array('globalTransaction' => 'TRUE'));
1138 1138
 
1139 1139
 	// Set some defaults values...
1140 1140
 	if (!isset($globalAircraftImageSources)) {
1141
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1142
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1141
+	    $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
1142
+	    $settings = array_merge($settings, array('globalAircraftImageSources' => $globalAircraftImageSources));
1143 1143
 	}
1144 1144
 
1145 1145
 	if (!isset($globalSchedulesSources)) {
1146
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1147
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1146
+	    $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightradar24', 'flightaware');
1147
+    	    $settings = array_merge($settings, array('globalSchedulesSources' => $globalSchedulesSources));
1148 1148
     	}
1149 1149
 
1150
-	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1150
+	$settings = array_merge($settings, array('globalInstalled' => 'TRUE'));
1151 1151
 
1152 1152
 	if ($error == '') settings::modify_settings($settings);
1153 1153
 	if ($error == '') settings::comment_settings($settings_comment);
Please login to merge, or discard this patch.
Braces   +401 added lines, -104 removed lines patch added patch discarded remove patch
@@ -124,45 +124,72 @@  discard block
 block discarded – undo
124 124
 			</div>
125 125
 			<p>
126 126
 				<label for="dbhost">Database hostname</label>
127
-				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) print $globalDBhost; ?>" />
127
+				<input type="text" name="dbhost" id="dbhost" value="<?php if (isset($globalDBhost)) {
128
+	print $globalDBhost;
129
+}
130
+?>" />
128 131
 			</p>
129 132
 			<p>
130 133
 				<label for="dbport">Database port</label>
131
-				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) print $globalDBport; ?>" />
134
+				<input type="text" name="dbport" id="dbport" value="<?php if (isset($globalDBport)) {
135
+	print $globalDBport;
136
+}
137
+?>" />
132 138
 				<p class="help-block">Default is 3306 for MariaDB/MySQL, 5432 for PostgreSQL</p>
133 139
 			</p>
134 140
 			<p>
135 141
 				<label for="dbname">Database name</label>
136
-				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) print $globalDBname; ?>" />
142
+				<input type="text" name="dbname" id="dbname" value="<?php if (isset($globalDBname)) {
143
+	print $globalDBname;
144
+}
145
+?>" />
137 146
 			</p>
138 147
 			<p>
139 148
 				<label for="dbuser">Database user</label>
140
-				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) print $globalDBuser; ?>" />
149
+				<input type="text" name="dbuser" id="dbuser" value="<?php if (isset($globalDBuser)) {
150
+	print $globalDBuser;
151
+}
152
+?>" />
141 153
 			</p>
142 154
 			<p>
143 155
 				<label for="dbuserpass">Database user password</label>
144
-				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) print $globalDBpass; ?>" />
156
+				<input type="password" name="dbuserpass" id="dbuserpass" value="<?php if (isset($globalDBpass)) {
157
+	print $globalDBpass;
158
+}
159
+?>" />
145 160
 			</p>
146 161
 		</fieldset>
147 162
 		<fieldset id="site">
148 163
 			<legend>Site configuration</legend>
149 164
 			<p>
150 165
 				<label for="sitename">Site name</label>
151
-				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) print $globalName; ?>" />
166
+				<input type="text" name="sitename" id="sitename" value="<?php if (isset($globalName)) {
167
+	print $globalName;
168
+}
169
+?>" />
152 170
 			</p>
153 171
 			<p>
154 172
 				<label for="siteurl">Site directory</label>
155
-				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) print $globalURL; ?>" />
173
+				<input type="text" name="siteurl" id="siteurl" value="<?php if (isset($globalURL)) {
174
+	print $globalURL;
175
+}
176
+?>" />
156 177
 				<p class="help-block">Can be null. ex : <i>flightairmap</i> if complete URL is <i>http://toto.com/flightairmap</i></p>
157 178
 			</p>
158 179
 			<p>
159 180
 				<label for="timezone">Timezone</label>
160
-				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) print $globalTimezone; ?>" />
181
+				<input type="text" name="timezone" id="timezone" value="<?php if (isset($globalTimezone)) {
182
+	print $globalTimezone;
183
+}
184
+?>" />
161 185
 				<p class="help-block">ex : UTC, Europe/Paris,...</p>
162 186
 			</p>
163 187
 			<p>
164 188
 				<label for="language">Language</label>
165
-				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) print $globalLanguage; ?>" />
189
+				<input type="text" name="language" id="language" value="<?php if (isset($globalLanguage)) {
190
+	print $globalLanguage;
191
+}
192
+?>" />
166 193
 				<p class="help-block">Used only when link to wikipedia for now. Can be EN,DE,FR,...</p>
167 194
 			</p>
168 195
 		</fieldset>
@@ -183,11 +210,17 @@  discard block
 block discarded – undo
183 210
 			<div id="mapbox_data">
184 211
 				<p>
185 212
 					<label for="mapboxid">Mapbox id</label>
186
-					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) print $globalMapboxId; ?>" />
213
+					<input type="text" name="mapboxid" id="mapboxid" value="<?php if (isset($globalMapboxId)) {
214
+	print $globalMapboxId;
215
+}
216
+?>" />
187 217
 				</p>
188 218
 				<p>
189 219
 					<label for="mapboxtoken">Mapbox token</label>
190
-					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) print $globalMapboxToken; ?>" />
220
+					<input type="text" name="mapboxtoken" id="mapboxtoken" value="<?php if (isset($globalMapboxToken)) {
221
+	print $globalMapboxToken;
222
+}
223
+?>" />
191 224
 				</p>
192 225
 				<p class="help-block">Get a key <a href="https://www.mapbox.com/developers/">here</a></p>
193 226
 			</div>
@@ -195,7 +228,10 @@  discard block
 block discarded – undo
195 228
 			<div id="google_data">
196 229
 				<p>
197 230
 					<label for="googlekey">Google API key</label>
198
-					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) print $globalGoogleAPIKey; ?>" />
231
+					<input type="text" name="googlekey" id="googlekey" value="<?php if (isset($globalGoogleAPIKey)) {
232
+	print $globalGoogleAPIKey;
233
+}
234
+?>" />
199 235
 					<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>
200 236
 				</p>
201 237
 			</div>
@@ -203,7 +239,10 @@  discard block
 block discarded – undo
203 239
 			<div id="bing_data">
204 240
 				<p>
205 241
 					<label for="bingkey">Bing Map key</label>
206
-					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) print $globalBingMapKey; ?>" />
242
+					<input type="text" name="bingkey" id="bingkey" value="<?php if (isset($globalBingMapKey)) {
243
+	print $globalBingMapKey;
244
+}
245
+?>" />
207 246
 					<p class="help-block">Get a key <a href="https://www.bingmapsportal.com/">here</a></p>
208 247
 				</p>
209 248
 			</div>
@@ -211,7 +250,10 @@  discard block
 block discarded – undo
211 250
 			<div id="mapquest_data">
212 251
 				<p>
213 252
 					<label for="mapquestkey">MapQuest key</label>
214
-					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) print $globalMapQuestKey; ?>" />
253
+					<input type="text" name="mapquestkey" id="mapquestkey" value="<?php if (isset($globalMapQuestKey)) {
254
+	print $globalMapQuestKey;
255
+}
256
+?>" />
215 257
 					<p class="help-block">Get a key <a href="https://developer.mapquest.com/user/me/apps">here</a></p>
216 258
 				</p>
217 259
 			</div>
@@ -219,11 +261,17 @@  discard block
 block discarded – undo
219 261
 			<div id="here_data">
220 262
 				<p>
221 263
 					<label for="hereappid">Here App_Id</label>
222
-					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) print $globalHereappId; ?>" />
264
+					<input type="text" name="hereappid" id="hereappid" value="<?php if (isset($globalHereappId)) {
265
+	print $globalHereappId;
266
+}
267
+?>" />
223 268
 				</p>
224 269
 				<p>
225 270
 					<label for="hereappcode">Here App_Code</label>
226
-					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) print $globalHereappCode; ?>" />
271
+					<input type="text" name="hereappcode" id="hereappcode" value="<?php if (isset($globalHereappCode)) {
272
+	print $globalHereappCode;
273
+}
274
+?>" />
227 275
 				</p>
228 276
 				<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>
229 277
 			</div>
@@ -232,42 +280,86 @@  discard block
 block discarded – undo
232 280
 			<legend>Coverage area</legend>
233 281
 			<p>
234 282
 				<label for="latitudemax">The maximum latitude (north)</label>
235
-				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) print $globalLatitudeMax; ?>" />
283
+				<input type="text" name="latitudemax" id="latitudemax" value="<?php if (isset($globalLatitudeMax)) {
284
+	print $globalLatitudeMax;
285
+}
286
+?>" />
236 287
 			</p>
237 288
 			<p>
238 289
 				<label for="latitudemin">The minimum latitude (south)</label>
239
-				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) print $globalLatitudeMin; ?>" />
290
+				<input type="text" name="latitudemin" id="latitudemin" value="<?php if (isset($globalLatitudeMin)) {
291
+	print $globalLatitudeMin;
292
+}
293
+?>" />
240 294
 			</p>
241 295
 			<p>
242 296
 				<label for="longitudemax">The maximum longitude (west)</label>
243
-				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) print $globalLongitudeMax; ?>" />
297
+				<input type="text" name="longitudemax" id="longitudemax" value="<?php if (isset($globalLongitudeMax)) {
298
+	print $globalLongitudeMax;
299
+}
300
+?>" />
244 301
 			</p>
245 302
 			<p>
246 303
 				<label for="longitudemin">The minimum longitude (east)</label>
247
-				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) print $globalLongitudeMin; ?>" />
304
+				<input type="text" name="longitudemin" id="longitudemin" value="<?php if (isset($globalLongitudeMin)) {
305
+	print $globalLongitudeMin;
306
+}
307
+?>" />
248 308
 			</p>
249 309
 			<p>
250 310
 				<label for="latitudecenter">The latitude center</label>
251
-				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) print $globalCenterLatitude; ?>" />
311
+				<input type="text" name="latitudecenter" id="latitudecenter" value="<?php if (isset($globalCenterLatitude)) {
312
+	print $globalCenterLatitude;
313
+}
314
+?>" />
252 315
 			</p>
253 316
 			<p>
254 317
 				<label for="longitudecenter">The longitude center</label>
255
-				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) print $globalCenterLongitude; ?>" />
318
+				<input type="text" name="longitudecenter" id="longitudecenter" value="<?php if (isset($globalCenterLongitude)) {
319
+	print $globalCenterLongitude;
320
+}
321
+?>" />
256 322
 			</p>
257 323
 			<p>
258 324
 				<label for="livezoom">Default Zoom on live map</label>
259
-				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>" />
325
+				<input type="number" name="livezoom" id="livezoom" value="<?php if (isset($globalLiveZoom)) {
326
+	print $globalLiveZoom;
327
+} else {
328
+	print '9';
329
+}
330
+?>" />
260 331
 			</p>
261 332
 			<p>
262 333
 				<label for="squawk_country">Country for squawk usage</label>
263 334
 				<select name="squawk_country" id="squawk_country">
264
-					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') print ' selected '; ?>>UK</option>
265
-					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') print ' selected '; ?>>NZ</option>
266
-					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') print ' selected '; ?>>US</option>
267
-					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') print ' selected '; ?>>AU</option>
268
-					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') print ' selected '; ?>>NL</option>
269
-					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') print ' selected '; ?>>FR</option>
270
-					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') print ' selected '; ?>>TR</option>
335
+					<option value="UK"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'UK') {
336
+	print ' selected ';
337
+}
338
+?>>UK</option>
339
+					<option value="NZ"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NZ') {
340
+	print ' selected ';
341
+}
342
+?>>NZ</option>
343
+					<option value="US"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'US') {
344
+	print ' selected ';
345
+}
346
+?>>US</option>
347
+					<option value="AU"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'AU') {
348
+	print ' selected ';
349
+}
350
+?>>AU</option>
351
+					<option value="NL"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'NL') {
352
+	print ' selected ';
353
+}
354
+?>>NL</option>
355
+					<option value="FR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'FR') {
356
+	print ' selected ';
357
+}
358
+?>>FR</option>
359
+					<option value="TR"<?php if (isset($globalSquawkCountry) && $globalSquawkCountry == 'TR') {
360
+	print ' selected ';
361
+}
362
+?>>TR</option>
271 363
 				</select>
272 364
 			</p>
273 365
 		</fieldset>
@@ -276,15 +368,24 @@  discard block
 block discarded – undo
276 368
 			<p><i>Only put in DB flights that are inside a circle</i></p>
277 369
 			<p>
278 370
 				<label for="latitude">Center latitude</label>
279
-				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) echo $globalDistanceIgnore['latitude']; ?>" />
371
+				<input type="text" name="zoilatitude" id="latitude" value="<?php if (isset($globalDistanceIgnore['latitude'])) {
372
+	echo $globalDistanceIgnore['latitude'];
373
+}
374
+?>" />
280 375
 			</p>
281 376
 			<p>
282 377
 				<label for="longitude">Center longitude</label>
283
-				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) echo $globalDistanceIgnore['longitude']; ?>" />
378
+				<input type="text" name="zoilongitude" id="longitude" value="<?php if (isset($globalDistanceIgnore['longitude'])) {
379
+	echo $globalDistanceIgnore['longitude'];
380
+}
381
+?>" />
284 382
 			</p>
285 383
 			<p>
286 384
 				<label for="Distance">Distance (in km)</label>
287
-				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) echo $globalDistanceIgnore['distance']; ?>" />
385
+				<input type="text" name="zoidistance" id="distance" value="<?php if (isset($globalDistanceIgnore['distance'])) {
386
+	echo $globalDistanceIgnore['distance'];
387
+}
388
+?>" />
288 389
 			</p>
289 390
 		</fieldset>
290 391
 		<fieldset id="sourceloc">
@@ -379,11 +480,17 @@  discard block
 block discarded – undo
379 480
 			<div id="flightaware_data">
380 481
 				<p>
381 482
 					<label for="flightawareusername">FlightAware username</label>
382
-					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) print $globalFlightAwareUsername; ?>" />
483
+					<input type="text" name="flightawareusername" id="flightawareusername" value="<?php if (isset($globalFlightAwareUsername)) {
484
+	print $globalFlightAwareUsername;
485
+}
486
+?>" />
383 487
 				</p>
384 488
 				<p>
385 489
 					<label for="flightawarepassword">FlightAware password/API key</label>
386
-					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) print $globalFlightAwarePassword; ?>" />
490
+					<input type="text" name="flightawarepassword" id="flightawarepassword" value="<?php if (isset($globalFlightAwarePassword)) {
491
+	print $globalFlightAwarePassword;
492
+}
493
+?>" />
387 494
 				</p>
388 495
 			</div>
389 496
 -->
@@ -442,23 +549,68 @@  discard block
 block discarded – undo
442 549
 								?>
443 550
 								<td>
444 551
 									<select name="format[]" id="format">
445
-										<option value="auto" <?php if (!isset($source['format'])) print 'selected'; ?>>Auto</option>
446
-										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') print 'selected'; ?>>SBS</option>
447
-										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') print 'selected'; ?>>TSV</option>
448
-										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') print 'selected'; ?>>Raw</option>
449
-										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') print 'selected'; ?>>APRS</option>
450
-										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') print 'selected'; ?>>Radarcape deltadb.txt</option>
451
-										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') print 'selected'; ?>>Vatsim</option>
452
-										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') print 'selected'; ?>>Virtual Radar Server</option>
453
-										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') print 'selected'; ?>>phpVMS</option>
454
-										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') print 'selected'; ?>>Virtual Airline Manager</option>
455
-										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') print 'selected'; ?>>IVAO</option>
456
-										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') print 'selected'; ?>>FlightGear Multiplayer</option>
457
-										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') print 'selected'; ?>>FlightGear Singleplayer</option>
552
+										<option value="auto" <?php if (!isset($source['format'])) {
553
+	print 'selected';
554
+}
555
+?>>Auto</option>
556
+										<option value="sbs" <?php if (isset($source['format']) && $source['format'] == 'sbs') {
557
+	print 'selected';
558
+}
559
+?>>SBS</option>
560
+										<option value="tsv" <?php if (isset($source['format']) && $source['format'] == 'tsv') {
561
+	print 'selected';
562
+}
563
+?>>TSV</option>
564
+										<option value="raw" <?php if (isset($source['format']) && $source['format'] == 'raw') {
565
+	print 'selected';
566
+}
567
+?>>Raw</option>
568
+										<option value="aprs" <?php if (isset($source['format']) && $source['format'] == 'aprs') {
569
+	print 'selected';
570
+}
571
+?>>APRS</option>
572
+										<option value="deltadbtxt" <?php if (isset($source['format']) && $source['format'] == 'deltadbtxt') {
573
+	print 'selected';
574
+}
575
+?>>Radarcape deltadb.txt</option>
576
+										<option value="vatsimtxt" <?php if (isset($source['format']) && $source['format'] == 'vatsimtxt') {
577
+	print 'selected';
578
+}
579
+?>>Vatsim</option>
580
+										<option value="aircraftlistjson" <?php if (isset($source['format']) && $source['format'] == 'aircraftlistjson') {
581
+	print 'selected';
582
+}
583
+?>>Virtual Radar Server</option>
584
+										<option value="phpvmacars" <?php if (isset($source['format']) && $source['format'] == 'phpvmacars') {
585
+	print 'selected';
586
+}
587
+?>>phpVMS</option>
588
+										<option value="vam" <?php if (isset($source['format']) && $source['format'] == 'vam') {
589
+	print 'selected';
590
+}
591
+?>>Virtual Airline Manager</option>
592
+										<option value="whazzup" <?php if (isset($source['format']) && $source['format'] == 'whazzup') {
593
+	print 'selected';
594
+}
595
+?>>IVAO</option>
596
+										<option value="flightgearmp" <?php if (isset($source['format']) && $source['format'] == 'flightgearmp') {
597
+	print 'selected';
598
+}
599
+?>>FlightGear Multiplayer</option>
600
+										<option value="flightgearsp" <?php if (isset($source['format']) && $source['format'] == 'flightgearsp') {
601
+	print 'selected';
602
+}
603
+?>>FlightGear Singleplayer</option>
458 604
 									</select>
459 605
 								</td>
460
-								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) print $source['name']; ?>" /></td>
461
-								<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>
606
+								<td><input type="text" name="name[]" id="name" value="<?php if (isset($source['name'])) {
607
+	print $source['name'];
608
+}
609
+?>" /></td>
610
+								<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']) {
611
+	print 'checked';
612
+}
613
+?> /></td>
462 614
 								<td><input type="button" id="delhost" value="Delete" onclick="deleteRow(this)" /> <input type="button" id="addhost" value="Add" onclick="insRow()" /></td>
463 615
 							</tr>
464 616
 <?php
@@ -502,11 +654,17 @@  discard block
 block discarded – undo
502 654
 					<p>Listen UDP server for acarsdec/acarsdeco2/...</p>
503 655
 					<p>
504 656
 						<label for="acarshost">ACARS UDP host</label>
505
-						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) print $globalACARSHost; ?>" />
657
+						<input type="text" name="acarshost" id="acarshost" value="<?php if (isset($globalACARSHost)) {
658
+	print $globalACARSHost;
659
+}
660
+?>" />
506 661
 					</p>
507 662
 					<p>
508 663
 						<label for="acarsport">ACARS UDP port</label>
509
-						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) print $globalACARSPort; ?>" />
664
+						<input type="number" name="acarsport" id="acarsport" value="<?php if (isset($globalACARSPort)) {
665
+	print $globalACARSPort;
666
+}
667
+?>" />
510 668
 					</p>
511 669
 				</fieldset>
512 670
 			</div>
@@ -575,13 +733,19 @@  discard block
 block discarded – undo
575 733
 			<div id="schedules_options">
576 734
 				<p>
577 735
 					<label for="britishairways">British Airways API Key</label>
578
-					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) print $globalBritishAirwaysKey; ?>" />
736
+					<input type="text" name="britishairways" id="britishairways" value="<?php if (isset($globalBritishAirwaysKey)) {
737
+	print $globalBritishAirwaysKey;
738
+}
739
+?>" />
579 740
 					<p class="help-block">Register an account on <a href="https://developer.ba.com/">https://developer.ba.com/</a></p>
580 741
 				</p>
581 742
 				<!--
582 743
 				<p>
583 744
 					<label for="transavia">Transavia Test API Consumer Key</label>
584
-					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) print $globalTransaviaKey; ?>" />
745
+					<input type="text" name="transavia" id="transavia" value="<?php if (isset($globalTransaviaKey)) {
746
+	print $globalTransaviaKey;
747
+}
748
+?>" />
585 749
 					<p class="help-block">Register an account on <a href="https://developer.transavia.com">https://developer.transavia.com</a></p>
586 750
 				</p>
587 751
 				-->
@@ -590,10 +754,16 @@  discard block
 block discarded – undo
590 754
 						<b>Lufthansa API Key</b>
591 755
 						<p>
592 756
 							<label for="lufthansakey">Key</label>
593
-							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) print $globalLufthansaKey['key']; ?>" />
757
+							<input type="text" name="lufthansakey" id="lufthansakey" value="<?php if (isset($globalLufthansaKey['key'])) {
758
+	print $globalLufthansaKey['key'];
759
+}
760
+?>" />
594 761
 						</p><p>
595 762
 							<label for="lufthansasecret">Secret</label>
596
-							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) print $globalLufthansaKey['secret']; ?>" />
763
+							<input type="text" name="lufthansasecret" id="lufthansasecret" value="<?php if (isset($globalLufthansaKey['secret'])) {
764
+	print $globalLufthansaKey['secret'];
765
+}
766
+?>" />
597 767
 						</p>
598 768
 					</div>
599 769
 					<p class="help-block">Register an account on <a href="https://developer.lufthansa.com/page">https://developer.lufthansa.com/page</a></p>
@@ -613,7 +783,10 @@  discard block
 block discarded – undo
613 783
 			</p>
614 784
 			<p>
615 785
 				<label for="notamsource">URL of your feed from notaminfo.com</label>
616
-				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) print $globalNOTAMSource; ?>" />
786
+				<input type="text" name="notamsource" id="notamsource" value="<?php if (isset($globalNOTAMSource)) {
787
+	print $globalNOTAMSource;
788
+}
789
+?>" />
617 790
 				<p class="help-block">If you want to use world NOTAM from FlightAirMap website, leave it blank</p>
618 791
 			</p>
619 792
 			<br />
@@ -629,14 +802,20 @@  discard block
 block discarded – undo
629 802
 			<div id="metarsrc">
630 803
 				<p>
631 804
 					<label for="metarsource">URL of your METAR source</label>
632
-					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) print $globalMETARurl; ?>" />
805
+					<input type="text" name="metarsource" id="metarsource" value="<?php if (isset($globalMETARurl)) {
806
+	print $globalMETARurl;
807
+}
808
+?>" />
633 809
 					<p class="help-block">Use {icao} to specify where we replace by airport icao. ex : http://metar.vatsim.net/metar.php?id={icao}</p>
634 810
 				</p>
635 811
 			</div>
636 812
 			<br />
637 813
 			<p>
638 814
 				<label for="bitly">Bit.ly access token api (used in search page)</label>
639
-				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) print $globalBitlyAccessToken; ?>" />
815
+				<input type="text" name="bitly" id="bitly" value="<?php if (isset($globalBitlyAccessToken)) {
816
+	print $globalBitlyAccessToken;
817
+}
818
+?>" />
640 819
 			</p>
641 820
 			<br />
642 821
 			<p>
@@ -650,7 +829,12 @@  discard block
 block discarded – undo
650 829
 			</p>
651 830
 			<p>
652 831
 				<label for="archivemonths">Generate statistics, delete or put in archive flights older than xx months</label>
653
-				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) print $globalArchiveMonths; else echo '0'; ?>" />
832
+				<input type="number" name="archivemonths" id="archivemonths" value="<?php if (isset($globalArchiveMonths)) {
833
+	print $globalArchiveMonths;
834
+} else {
835
+	echo '0';
836
+}
837
+?>" />
654 838
 				<p class="help-block">0 to disable, delete old flight if <i>Archive all flights data</i> is disabled</p>
655 839
 			</p>
656 840
 			<p>
@@ -660,12 +844,22 @@  discard block
 block discarded – undo
660 844
 			</p>
661 845
 			<p>
662 846
 				<label for="archivekeepmonths">Keep flights data for xx months in archive</label>
663
-				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) print $globalArchiveKeepMonths; else echo '0'; ?>" />
847
+				<input type="number" name="archivekeepmonths" id="archivekeepmonths" value="<?php if (isset($globalArchiveKeepMonths)) {
848
+	print $globalArchiveKeepMonths;
849
+} else {
850
+	echo '0';
851
+}
852
+?>" />
664 853
 				<p class="help-block">0 to disable</p>
665 854
 			</p>
666 855
 			<p>
667 856
 				<label for="archivekeeptrackmonths">Keep flights track data for xx months in archive</label>
668
-				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) print $globalArchiveKeepTrackMonths; else echo '0'; ?>" />
857
+				<input type="number" name="archivekeeptrackmonths" id="archivekeeptrackmonths" value="<?php if (isset($globalArchiveKeepTrackMonths)) {
858
+	print $globalArchiveKeepTrackMonths;
859
+} else {
860
+	echo '0';
861
+}
862
+?>" />
669 863
 				<p class="help-block">0 to disable, should be less or egal to <i>Keep flights data</i> value</p>
670 864
 			</p>
671 865
 			<br />
@@ -675,7 +869,12 @@  discard block
 block discarded – undo
675 869
 				<p class="help-block">Uncheck if the script is running as cron job</p>
676 870
 				<div id="cronends"> 
677 871
 					<label for="cronend">Run script for xx seconds</label>
678
-					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) print $globalCronEnd; else print '0'; ?>" />
872
+					<input type="number" name="cronend" id="cronend" value="<?php if (isset($globalCronEnd)) {
873
+	print $globalCronEnd;
874
+} else {
875
+	print '0';
876
+}
877
+?>" />
679 878
 					<p class="help-block">Set to 0 to disable. Should be disabled if source is URL.</p>
680 879
 				</div>
681 880
 			</p>
@@ -715,26 +914,49 @@  discard block
 block discarded – undo
715 914
 			<br />
716 915
 			<p>
717 916
 				<label for="refresh">Show flights detected since xxx seconds</label>
718
-				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) echo $globalLiveInterval; else echo '200'; ?>" />
917
+				<input type="number" name="refresh" id="refresh" value="<?php if (isset($globalLiveInterval)) {
918
+	echo $globalLiveInterval;
919
+} else {
920
+	echo '200';
921
+}
922
+?>" />
719 923
 			</p>
720 924
 			<p>
721 925
 				<label for="maprefresh">Live map refresh (in seconds)</label>
722
-				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) echo $globalMapRefresh; else echo '30'; ?>" />
926
+				<input type="number" name="maprefresh" id="maprefresh" value="<?php if (isset($globalMapRefresh)) {
927
+	echo $globalMapRefresh;
928
+} else {
929
+	echo '30';
930
+}
931
+?>" />
723 932
 			</p>
724 933
 			<p>
725 934
 				<label for="mapidle">Map idle timeout (in minutes)</label>
726
-				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) echo $globalMapIdleTimeout; else echo '30'; ?>" />
935
+				<input type="number" name="mapidle" id="mapidle" value="<?php if (isset($globalMapIdleTimeout)) {
936
+	echo $globalMapIdleTimeout;
937
+} else {
938
+	echo '30';
939
+}
940
+?>" />
727 941
 				<p class="help-block">0 to disable</p>
728 942
 			</p>
729 943
 			<br />
730 944
 			<p>
731 945
 				<label for="closestmindist">Distance to airport set as arrival (in km)</label>
732
-				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) echo $globalClosestMinDist; else echo '50'; ?>" />
946
+				<input type="number" name="closestmindist" id="closestmindist" value="<?php if (isset($globalClosestMinDist)) {
947
+	echo $globalClosestMinDist;
948
+} else {
949
+	echo '50';
950
+}
951
+?>" />
733 952
 			</p>
734 953
 			<br />
735 954
 			<p>
736 955
 				<label for="aircraftsize">Size of aircraft icon on map (default to 30px if zoom > 7 else 15px), empty to default</label>
737
-				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) echo $globalAircraftSize;?>" />
956
+				<input type="number" name="aircraftsize" id="aircraftsize" value="<?php if (isset($globalAircraftSize)) {
957
+	echo $globalAircraftSize;
958
+}
959
+?>" />
738 960
 			</p>
739 961
 			<br />
740 962
 			<p>
@@ -742,7 +964,12 @@  discard block
 block discarded – undo
742 964
 			    if (extension_loaded('gd') && function_exists('gd_info')) {
743 965
 			?>
744 966
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
745
-				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
967
+				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) {
968
+	echo $globalAircraftIconColor;
969
+} else {
970
+	echo '1a3151';
971
+}
972
+?>" />
746 973
 			<?php
747 974
 				if (!is_writable('../cache')) {
748 975
 			?>
@@ -760,8 +987,18 @@  discard block
 block discarded – undo
760 987
 			<p>
761 988
 				<label for="airportzoom">Zoom level minimum to see airports icons</label>
762 989
 				<div class="range">
763
-					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?>" />
764
-					<output id="range"><?php if (isset($globalAirportZoom)) echo $globalAirportZoom; else echo '7'; ?></output>
990
+					<input type="range" name="airportzoom" id="airportzoom" value="<?php if (isset($globalAirportZoom)) {
991
+	echo $globalAirportZoom;
992
+} else {
993
+	echo '7';
994
+}
995
+?>" />
996
+					<output id="range"><?php if (isset($globalAirportZoom)) {
997
+	echo $globalAirportZoom;
998
+} else {
999
+	echo '7';
1000
+}
1001
+?></output>
765 1002
 				</div>
766 1003
 			</p>
767 1004
 		</fieldset>
@@ -789,8 +1026,12 @@  discard block
 block discarded – undo
789 1026
 	$dbhost = filter_input(INPUT_POST,'dbhost',FILTER_SANITIZE_STRING);
790 1027
 	$dbport = filter_input(INPUT_POST,'dbport',FILTER_SANITIZE_STRING);
791 1028
 
792
-	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) $error .= 'Mysql driver for PDO must be loaded';
793
-	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) $error .= 'PosgreSQL driver for PDO must be loaded';
1029
+	if ($dbtype == 'mysql' && !extension_loaded('pdo_mysql')) {
1030
+		$error .= 'Mysql driver for PDO must be loaded';
1031
+	}
1032
+	if ($dbtype == 'pgsql' && !extension_loaded('pdo_pgsql')) {
1033
+		$error .= 'PosgreSQL driver for PDO must be loaded';
1034
+	}
794 1035
 	
795 1036
 	$_SESSION['database_root'] = $dbroot;
796 1037
 	$_SESSION['database_rootpass'] = $dbrootpass;
@@ -857,15 +1098,23 @@  discard block
 block discarded – undo
857 1098
 	$source_city = $_POST['source_city'];
858 1099
 	$source_country = $_POST['source_country'];
859 1100
 	$source_ref = $_POST['source_ref'];
860
-	if (isset($source_id)) $source_id = $_POST['source_id'];
861
-	else $source_id = array();
1101
+	if (isset($source_id)) {
1102
+		$source_id = $_POST['source_id'];
1103
+	} else {
1104
+		$source_id = array();
1105
+	}
862 1106
 	
863 1107
 	$sources = array();
864 1108
 	foreach ($source_name as $keys => $name) {
865
-	    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]);
866
-	    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]);
1109
+	    if (isset($source_id[$keys])) {
1110
+	    	$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]);
1111
+	    } else {
1112
+	    	$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]);
1113
+	    }
1114
+	}
1115
+	if (count($sources) > 0) {
1116
+		$_SESSION['sources'] = $sources;
867 1117
 	}
868
-	if (count($sources) > 0) $_SESSION['sources'] = $sources;
869 1118
 
870 1119
 	//$sbshost = filter_input(INPUT_POST,'sbshost',FILTER_SANITIZE_STRING);
871 1120
 	//$sbsport = filter_input(INPUT_POST,'sbsport',FILTER_SANITIZE_NUMBER_INT);
@@ -903,13 +1152,21 @@  discard block
 block discarded – undo
903 1152
 	$port = $_POST['port'];
904 1153
 	$name = $_POST['name'];
905 1154
 	$format = $_POST['format'];
906
-	if (isset($_POST['sourcestats'])) $sourcestats = $_POST['sourcestats'];
907
-	else $sourcestats = array();
1155
+	if (isset($_POST['sourcestats'])) {
1156
+		$sourcestats = $_POST['sourcestats'];
1157
+	} else {
1158
+		$sourcestats = array();
1159
+	}
908 1160
 	$gSources = array();
909 1161
 	foreach ($host as $key => $h) {
910
-		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) $cov = 'TRUE';
911
-		else $cov = 'FALSE';
912
-		if ($h != '') $gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1162
+		if (isset($sourcestats[$key]) && $sourcestats[$key] == 1) {
1163
+			$cov = 'TRUE';
1164
+		} else {
1165
+			$cov = 'FALSE';
1166
+		}
1167
+		if ($h != '') {
1168
+			$gSources[] = array('host' => $h, 'port' => $port[$key],'name' => $name[$key],'format' => $format[$key],'sourcestats' => $cov);
1169
+		}
913 1170
 	}
914 1171
 	$settings = array_merge($settings,array('globalSources' => $gSources));
915 1172
 
@@ -933,7 +1190,9 @@  discard block
 block discarded – undo
933 1190
 	$zoidistance = filter_input(INPUT_POST,'zoidistance',FILTER_SANITIZE_NUMBER_INT);
934 1191
 	if ($zoilatitude != '' && $zoilongitude != '' && $zoidistance != '') {
935 1192
 		$settings = array_merge($settings,array('globalDistanceIgnore' => array('latitude' => $zoilatitude,'longitude' => $zoilongitude,'distance' => $zoidistance)));
936
-	} else $settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1193
+	} else {
1194
+		$settings = array_merge($settings,array('globalDistanceIgnore' => array()));
1195
+	}
937 1196
 
938 1197
 	$refresh = filter_input(INPUT_POST,'refresh',FILTER_SANITIZE_NUMBER_INT);
939 1198
 	$settings = array_merge($settings,array('globalLiveInterval' => $refresh));
@@ -972,7 +1231,9 @@  discard block
 block discarded – undo
972 1231
 
973 1232
 	// Create in settings.php keys not yet configurable if not already here
974 1233
 	//if (!isset($globalImageBingKey)) $settings = array_merge($settings,array('globalImageBingKey' => ''));
975
-	if (!isset($globalDebug)) $settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1234
+	if (!isset($globalDebug)) {
1235
+		$settings = array_merge($settings,array('globalDebug' => 'TRUE'));
1236
+	}
976 1237
 
977 1238
 	$archive = filter_input(INPUT_POST,'archive',FILTER_SANITIZE_STRING);
978 1239
 	if ($archive == 'archive') {
@@ -1002,27 +1263,43 @@  discard block
 block discarded – undo
1002 1263
 	}
1003 1264
 */
1004 1265
 	$settings = array_merge($settings,array('globalFlightAware' => 'FALSE'));
1005
-	if ($globalsbs == 'sbs') $settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1006
-	else $settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1007
-	if ($globalaprs == 'aprs') $settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1008
-	else $settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1266
+	if ($globalsbs == 'sbs') {
1267
+		$settings = array_merge($settings,array('globalSBS1' => 'TRUE'));
1268
+	} else {
1269
+		$settings = array_merge($settings,array('globalSBS1' => 'FALSE'));
1270
+	}
1271
+	if ($globalaprs == 'aprs') {
1272
+		$settings = array_merge($settings,array('globalAPRS' => 'TRUE'));
1273
+	} else {
1274
+		$settings = array_merge($settings,array('globalAPRS' => 'FALSE'));
1275
+	}
1009 1276
 	if ($globalivao == 'ivao') {
1010 1277
 		//$settings = array_merge($settings,array('globalIVAO' => 'TRUE','globalVATSIM' => 'FALSE'));
1011 1278
 		$settings = array_merge($settings,array('globalIVAO' => 'TRUE'));
1012
-	} else $settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1279
+	} else {
1280
+		$settings = array_merge($settings,array('globalIVAO' => 'FALSE'));
1281
+	}
1013 1282
 	if ($globalvatsim == 'vatsim') {
1014 1283
 		//$settings = array_merge($settings,array('globalVATSIM' => 'TRUE','globalIVAO' => 'FALSE'));
1015 1284
 		$settings = array_merge($settings,array('globalVATSIM' => 'TRUE'));
1016
-	} else $settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1285
+	} else {
1286
+		$settings = array_merge($settings,array('globalVATSIM' => 'FALSE'));
1287
+	}
1017 1288
 	if ($globalphpvms == 'phpvms') {
1018 1289
 		$settings = array_merge($settings,array('globalphpVMS' => 'TRUE'));
1019
-	} else $settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1290
+	} else {
1291
+		$settings = array_merge($settings,array('globalphpVMS' => 'FALSE'));
1292
+	}
1020 1293
 	if ($globalvam == 'vam') {
1021 1294
 		$settings = array_merge($settings,array('globalVAM' => 'TRUE'));
1022
-	} else $settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1295
+	} else {
1296
+		$settings = array_merge($settings,array('globalVAM' => 'FALSE'));
1297
+	}
1023 1298
 	if ($globalvatsim == 'vatsim' || $globalivao == 'ivao' || $globalphpvms == 'phpvms') {
1024 1299
 		$settings = array_merge($settings,array('globalSchedulesFetch' => 'FALSE','globalTranslationFetch' => 'FALSE'));
1025
-	} else $settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1300
+	} else {
1301
+		$settings = array_merge($settings,array('globalSchedulesFetch' => 'TRUE','globalTranslationFetch' => 'TRUE'));
1302
+	}
1026 1303
 	
1027 1304
 
1028 1305
 
@@ -1134,7 +1411,9 @@  discard block
 block discarded – undo
1134 1411
 		$settings = array_merge($settings,array('globalMapRoute' => 'FALSE'));
1135 1412
 	}
1136 1413
 
1137
-	if (!isset($globalTransaction)) $settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1414
+	if (!isset($globalTransaction)) {
1415
+		$settings = array_merge($settings,array('globalTransaction' => 'TRUE'));
1416
+	}
1138 1417
 
1139 1418
 	// Set some defaults values...
1140 1419
 	if (!isset($globalAircraftImageSources)) {
@@ -1149,15 +1428,23 @@  discard block
 block discarded – undo
1149 1428
 
1150 1429
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1151 1430
 
1152
-	if ($error == '') settings::modify_settings($settings);
1153
-	if ($error == '') settings::comment_settings($settings_comment);
1431
+	if ($error == '') {
1432
+		settings::modify_settings($settings);
1433
+	}
1434
+	if ($error == '') {
1435
+		settings::comment_settings($settings_comment);
1436
+	}
1154 1437
 	if ($error != '') {
1155 1438
 		print '<div class="info column">'.$error.'</div>';
1156 1439
 		require('../footer.php');
1157 1440
 		exit;
1158 1441
 	} else {
1159
-		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') $_SESSION['waypoints'] = 1;
1160
-		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') $_SESSION['owner'] = 1;
1442
+		if (isset($_POST['waypoints']) && $_POST['waypoints'] == 'waypoints') {
1443
+			$_SESSION['waypoints'] = 1;
1444
+		}
1445
+		if (isset($_POST['owner']) && $_POST['owner'] == 'owner') {
1446
+			$_SESSION['owner'] = 1;
1447
+		}
1161 1448
 		if (isset($_POST['createdb'])) {
1162 1449
 			$_SESSION['install'] = 'database_create';
1163 1450
 		} else {
@@ -1198,10 +1485,18 @@  discard block
 block discarded – undo
1198 1485
 	$popw = false;
1199 1486
 	foreach ($_SESSION['done'] as $done) {
1200 1487
 	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1201
-	    if ($done == 'Create database') $pop = true;
1202
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1203
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1204
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1488
+	    if ($done == 'Create database') {
1489
+	    	$pop = true;
1490
+	    }
1491
+	    if ($_SESSION['install'] == 'database_create') {
1492
+	    	$pop = true;
1493
+	    }
1494
+	    if ($_SESSION['install'] == 'database_import') {
1495
+	    	$popi = true;
1496
+	    }
1497
+	    if ($_SESSION['install'] == 'waypoints') {
1498
+	    	$popw = true;
1499
+	    }
1205 1500
 	}
1206 1501
 	if ($pop) {
1207 1502
 	    sleep(5);
@@ -1212,7 +1507,9 @@  discard block
 block discarded – undo
1212 1507
 	} else if ($popw) {
1213 1508
 	    sleep(5);
1214 1509
 	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1215
-	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1510
+	} else {
1511
+		print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1512
+	}
1216 1513
 	print '</div></ul>';
1217 1514
 	print '<div id="error"></div>';
1218 1515
 /*	foreach ($_SESSION['done'] as $done) {
Please login to merge, or discard this patch.
install/VAM/VAM-json.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@
 block discarded – undo
11 11
 	die();
12 12
 }
13 13
 $query = 'select * from vam_live_flights rc, gvausers gu where gu.gvauser_id = rc.gvauser_id';  
14
-$json_data=array();  
14
+$json_data = array();  
15 15
 $result = $db->query($query);
16 16
 while ($rec = $result->fetch_assoc())
17 17
 {  
18
-	$json_array['gvauser_id']=$rec['gvauser_id']; // users "pilot unique ID" "40"
19
-	$json_array['flight_id']=$rec['flight_id']; // flight_id
20
-	$json_array['pilot_id']=$rec['callsign']; // users pilot_id "VAM500"
21
-	$json_array['callsign']=substr($rec['flight_id'],-7);  // substr icao Flight "AFR524"
22
-	$json_array['pilot_name']=$rec['name'] .' '.$rec['surname'] ;  // Users "name + surname"
23
-	$json_array['plane_type']=$rec['plane_type'];  // type Plane "B739"
24
-	$json_array['departure']=$rec['departure'];  // departure ICAO
25
-	$json_array['arrival']=$rec['arrival'];     // arrival Ident
26
-	$json_array['latitude']=$rec['latitude'];  // return 55.7328860921521
27
-	$json_array['longitude']=$rec['longitude'];  // return 8.87433614409404
28
-	$json_array['altitude']=$rec['altitude'];  // return "147"
29
-	$json_array['heading']=$rec['heading'];  // return "307"
30
-	$json_array['ias']=$rec['ias'];  // return speed "IAS"
31
-	$json_array['gs']=$rec['gs'];  // return speed "GS"
18
+	$json_array['gvauser_id'] = $rec['gvauser_id']; // users "pilot unique ID" "40"
19
+	$json_array['flight_id'] = $rec['flight_id']; // flight_id
20
+	$json_array['pilot_id'] = $rec['callsign']; // users pilot_id "VAM500"
21
+	$json_array['callsign'] = substr($rec['flight_id'], -7); // substr icao Flight "AFR524"
22
+	$json_array['pilot_name'] = $rec['name'].' '.$rec['surname']; // Users "name + surname"
23
+	$json_array['plane_type'] = $rec['plane_type']; // type Plane "B739"
24
+	$json_array['departure'] = $rec['departure']; // departure ICAO
25
+	$json_array['arrival'] = $rec['arrival']; // arrival Ident
26
+	$json_array['latitude'] = $rec['latitude']; // return 55.7328860921521
27
+	$json_array['longitude'] = $rec['longitude']; // return 8.87433614409404
28
+	$json_array['altitude'] = $rec['altitude']; // return "147"
29
+	$json_array['heading'] = $rec['heading']; // return "307"
30
+	$json_array['ias'] = $rec['ias']; // return speed "IAS"
31
+	$json_array['gs'] = $rec['gs']; // return speed "GS"
32 32
 	// $json_array['routes']=$rec['routes'];  // (unusable)
33
-	$json_array['flight_status']=$rec['flight_status'];  // "return Status"
34
-	$json_array['last_update']=$rec['last_update'];  // return "DateTime"
35
-	array_push($json_data,$json_array);  
33
+	$json_array['flight_status'] = $rec['flight_status']; // "return Status"
34
+	$json_array['last_update'] = $rec['last_update']; // return "DateTime"
35
+	array_push($json_data, $json_array);  
36 36
  }  
37 37
 echo json_encode($json_data);  
38 38
 ?>
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
require/class.SpotterImport.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 
11 11
 class SpotterImport {
12
-    private $all_flights = array();
13
-    private $last_delete_hourly = 0;
14
-    private $last_delete = 0;
15
-    private $stats = array();
16
-    private $tmd = 0;
17
-    private $source_location = array();
18
-    public $db = null;
19
-    public $nb = 0;
20
-
21
-    public function __construct($dbc = null) {
12
+	private $all_flights = array();
13
+	private $last_delete_hourly = 0;
14
+	private $last_delete = 0;
15
+	private $stats = array();
16
+	private $tmd = 0;
17
+	private $source_location = array();
18
+	public $db = null;
19
+	public $nb = 0;
20
+
21
+	public function __construct($dbc = null) {
22 22
 	global $globalBeta;
23 23
 	$Connection = new Connection($dbc);
24 24
 	$this->db = $Connection->db();
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
33
-	    	$type = $srcst['stats_type'];
32
+		foreach($sourcestat as $srcst) {
33
+			$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35
-		    $source = $srcst['source_name'];
36
-		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
-	        }
39
-	    }
35
+			$source = $srcst['source_name'];
36
+			$data = $srcst['source_data'];
37
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
38
+			}
39
+		}
40
+	}
40 41
 	}
41
-    }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+	public function get_Schedule($id,$ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -59,35 +59,35 @@  discard block
 block discarded – undo
59 59
 	$Translation = new Translation($dbc);
60 60
 	$operator = $Spotter->getOperator($ident);
61 61
 	if ($Schedule->checkSchedule($operator) == 0) {
62
-	    $operator = $Translation->checkTranslation($ident);
63
-	    if ($Schedule->checkSchedule($operator) == 0) {
62
+		$operator = $Translation->checkTranslation($ident);
63
+		if ($Schedule->checkSchedule($operator) == 0) {
64 64
 		$schedule = $Schedule->fetchSchedule($operator);
65 65
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
-		    // Should also check if route schedule = route from DB
70
-		    if ($schedule['DepartureAirportIATA'] != '') {
66
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
69
+			// Should also check if route schedule = route from DB
70
+			if ($schedule['DepartureAirportIATA'] != '') {
71 71
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
72
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
-			    if ($airport_icao != '') {
72
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
73
+				if ($airport_icao != '') {
74 74
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
75 75
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
76
-			    }
76
+				}
77
+			}
77 78
 			}
78
-		    }
79
-		    if ($schedule['ArrivalAirportIATA'] != '') {
79
+			if ($schedule['ArrivalAirportIATA'] != '') {
80 80
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
81
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
-			    if ($airport_icao != '') {
81
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
82
+				if ($airport_icao != '') {
83 83
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
84 84
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
85
-			    }
85
+				}
86
+			}
86 87
 			}
87
-		    }
88
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
88
+			$Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
89
+		}
89 90
 		}
90
-	    }
91 91
 	}
92 92
 	// close connection, at least one way will work ?
93 93
        
@@ -105,92 +105,92 @@  discard block
 block discarded – undo
105 105
 	}
106 106
 	  */
107 107
 	}
108
-    }
108
+	}
109 109
 
110
-    public function checkAll() {
110
+	public function checkAll() {
111 111
 	global $globalDebug;
112 112
 	if ($globalDebug) echo "Update last seen flights data...\n";
113 113
 	foreach ($this->all_flights as $key => $flight) {
114
-	    if (isset($this->all_flights[$key]['id'])) {
114
+		if (isset($this->all_flights[$key]['id'])) {
115 115
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
116
-    		$Spotter = new Spotter($this->db);
117
-        	$real_arrival = $this->arrival($key);
118
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
119
-            }
116
+			$Spotter = new Spotter($this->db);
117
+			$real_arrival = $this->arrival($key);
118
+			$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
119
+			}
120
+	}
120 121
 	}
121
-    }
122 122
 
123
-    public function arrival($key) {
123
+	public function arrival($key) {
124 124
 	global $globalClosestMinDist, $globalDebug;
125 125
 	if ($globalDebug) echo 'Update arrival...'."\n";
126 126
 	$Spotter = new Spotter($this->db);
127
-        $airport_icao = '';
128
-        $airport_time = '';
129
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
127
+		$airport_icao = '';
128
+		$airport_time = '';
129
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
130 130
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
-    	    if (isset($closestAirports[0])) {
133
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
-        	    $airport_icao = $closestAirports[0]['icao'];
135
-        	    $airport_time = $this->all_flights[$key]['datetime'];
136
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
-        	    foreach ($closestAirports as $airport) {
139
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
-        		    $airport_icao = $airport['icao'];
141
-        		    $airport_time = $this->all_flights[$key]['datetime'];
142
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
-        		    break;
144
-        		}
145
-        	    }
146
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
147
-        		$airport_icao = $closestAirports[0]['icao'];
148
-        		$airport_time = $this->all_flights[$key]['datetime'];
149
-        	} else {
150
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
-        	}
152
-    	    } else {
153
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
-    	    }
155
-
156
-        } else {
157
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
-        }
159
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
-    }
161
-
162
-
163
-
164
-    public function del() {
131
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
132
+			if (isset($closestAirports[0])) {
133
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134
+				$airport_icao = $closestAirports[0]['icao'];
135
+				$airport_time = $this->all_flights[$key]['datetime'];
136
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
137
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
138
+				foreach ($closestAirports as $airport) {
139
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
140
+					$airport_icao = $airport['icao'];
141
+					$airport_time = $this->all_flights[$key]['datetime'];
142
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
143
+					break;
144
+				}
145
+				}
146
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
147
+				$airport_icao = $closestAirports[0]['icao'];
148
+				$airport_time = $this->all_flights[$key]['datetime'];
149
+			} else {
150
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
151
+			}
152
+			} else {
153
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
154
+			}
155
+
156
+		} else {
157
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158
+		}
159
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
160
+	}
161
+
162
+
163
+
164
+	public function del() {
165 165
 	global $globalDebug;
166 166
 	// Delete old infos
167 167
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
168 168
 	foreach ($this->all_flights as $key => $flight) {
169
-    	    if (isset($flight['lastupdate'])) {
170
-        	if ($flight['lastupdate'] < (time()-3000)) {
171
-            	    if (isset($this->all_flights[$key]['id'])) {
172
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
169
+			if (isset($flight['lastupdate'])) {
170
+			if ($flight['lastupdate'] < (time()-3000)) {
171
+					if (isset($this->all_flights[$key]['id'])) {
172
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
173 173
 			/*
174 174
 			$SpotterLive = new SpotterLive();
175 175
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
176 176
 			$SpotterLive->db = null;
177 177
 			*/
178
-            		$real_arrival = $this->arrival($key);
179
-            		$Spotter = new Spotter($this->db);
180
-            		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
178
+					$real_arrival = $this->arrival($key);
179
+					$Spotter = new Spotter($this->db);
180
+					if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181 181
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
182 182
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183 183
 			}
184 184
 			// Put in archive
185 185
 //			$Spotter->db = null;
186
-            	    }
187
-            	    unset($this->all_flights[$key]);
188
-    	        }
189
-	    }
190
-        }
191
-    }
192
-
193
-    public function add($line) {
186
+					}
187
+					unset($this->all_flights[$key]);
188
+				}
189
+		}
190
+		}
191
+	}
192
+
193
+	public function add($line) {
194 194
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM;
195 195
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
196 196
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 	
216 216
 	// SBS format is CSV format
217 217
 	if(is_array($line) && isset($line['hex'])) {
218
-	    //print_r($line);
219
-  	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
218
+		//print_r($line);
219
+  		if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
220 220
 
221 221
 		// Increment message number
222 222
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
223
-		    $current_date = date('Y-m-d');
224
-		    $source = $line['source_name'];
225
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
227
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
228
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
223
+			$current_date = date('Y-m-d');
224
+			$source = $line['source_name'];
225
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
226
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
227
+				$this->stats[$current_date][$source]['msg']['date'] = time();
228
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
229
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
230 230
 		}
231 231
 		
232 232
 		/*
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 		//$this->db = $dbc;
243 243
 
244 244
 		$hex = trim($line['hex']);
245
-	        if (!isset($line['id'])) $id = trim($line['hex']);
246
-	        else $id = trim($line['id']);
245
+			if (!isset($line['id'])) $id = trim($line['hex']);
246
+			else $id = trim($line['id']);
247 247
 		
248 248
 		//print_r($this->all_flights);
249 249
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
250
-		    $this->all_flights[$id] = array('hex' => $hex);
251
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
250
+			$this->all_flights[$id] = array('hex' => $hex);
251
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
252
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
253 253
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
254
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
254
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
255
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
256 256
 
257 257
 			$timeelapsed = microtime(true);
258 258
 			$Spotter = new Spotter($this->db);
@@ -261,37 +261,37 @@  discard block
 block discarded – undo
261 261
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
262 262
 
263 263
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
264
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
265
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
266
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
268 268
 			}
269 269
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
270
-		    } else if (isset($line['aircraft_name'])) {
270
+			} else if (isset($line['aircraft_name'])) {
271 271
 			// Get aircraft ICAO from aircraft name
272 272
 			$Spotter = new Spotter($this->db);
273 273
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 274
 			$Spotter->db = null;
275 275
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276 276
 			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
279
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
-		    if (!isset($line['id'])) {
277
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
279
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
280
+			if (!isset($line['id'])) {
281 281
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282 282
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 283
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284 284
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
285
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
285
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
287 287
 
288
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
288
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289 289
 		}
290 290
 		
291 291
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
292
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
292
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293 293
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
294
-		    } else {
294
+			} else {
295 295
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
296 296
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
297 297
 				/*
@@ -300,38 +300,38 @@  discard block
 block discarded – undo
300 300
 				print_r($line);
301 301
 				*/
302 302
 				return '';
303
-		    }
303
+			}
304 304
 		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
305 305
 
306 306
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
307
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
308 308
 		}
309 309
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
310
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
311 311
 		}
312 312
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
313
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
314 314
 		}
315 315
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
316
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
317 317
 		}
318 318
  
319 319
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
321
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
321
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
322 322
 			$timeelapsed = microtime(true);
323
-            		$Spotter = new Spotter($this->db);
324
-            		$fromsource = NULL;
325
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
326
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
323
+					$Spotter = new Spotter($this->db);
324
+					$fromsource = NULL;
325
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
326
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
327 327
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
328 328
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
329 329
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
330
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
330
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
331 331
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
332 332
 			$Spotter->db = null;
333 333
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
334
-		    }
334
+			}
335 335
 
336 336
 /*
337 337
 		    if (!isset($line['id'])) {
@@ -341,26 +341,26 @@  discard block
 block discarded – undo
341 341
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
342 342
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343 343
   */
344
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
344
+			if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
345 345
 
346
-		    //$putinarchive = true;
347
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
346
+			//$putinarchive = true;
347
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
348 348
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
349
-		    }
350
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
349
+			}
350
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
351 351
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
352
-		    }
353
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
355
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
352
+			}
353
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
355
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
356 356
 				$timeelapsed = microtime(true);
357 357
 				$Spotter = new Spotter($this->db);
358 358
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
359 359
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
360
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
360
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
361 361
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
362 362
 
363
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
363
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364 364
 			$timeelapsed = microtime(true);
365 365
 			$Spotter = new Spotter($this->db);
366 366
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375 375
 
376 376
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
377
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
377
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
379 379
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
380
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
381
-		    	    }
380
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
381
+					}
382 382
 			}
383 383
 			if (!isset($globalFork)) $globalFork = TRUE;
384 384
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
@@ -396,33 +396,33 @@  discard block
 block discarded – undo
396 396
 				$this->get_Schedule($id,trim($line['ident']));
397 397
 			//    }
398 398
 			}
399
-		    }
399
+			}
400 400
 		}
401 401
 
402 402
 		if (isset($line['speed']) && $line['speed'] != '') {
403 403
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
404
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
405
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
406
-		    //$dataFound = true;
404
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
405
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
406
+			//$dataFound = true;
407 407
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
408
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
409
-		    if ($distance > 1000 && $distance < 10000) {
410
-		    // use datetime
408
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
409
+			if ($distance > 1000 && $distance < 10000) {
410
+			// use datetime
411 411
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
412 412
 			$speed = $speed*3.6;
413 413
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
414 414
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
415
-		    }
415
+			}
416 416
 		}
417 417
 
418 418
 
419 419
 
420
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
421
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
422
-	    	    else unset($timediff);
423
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
420
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
421
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
422
+				else unset($timediff);
423
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
424 424
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
425
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
425
+				if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
426 426
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
427 427
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
428 428
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 				$this->tmd = 0;
439 439
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
440 440
 				//$putinarchive = true;
441
-			    } 
442
-			    /*else {
441
+				} 
442
+				/*else {
443 443
 			    
444 444
 				echo '//////// checkLine FALSE'."\n";
445 445
 				echo 'Check DATA : '.$this->all_flights[$id]['archive_latitude'].' '.$this->all_flights[$id]['archive_longitude'].' '.$this->all_flights[$id]['livedb_latitude'].' '.$this->all_flights[$id]['livedb_longitude'].' '.$line['latitude'].' '.$line['longitude']."\n";
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 			}
449 449
 
450 450
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
451
-			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
451
+				//if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
452 452
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
453 453
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
454
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
455
-				    $dataFound = true;
456
-				    $this->all_flights[$id]['time_last_coord'] = time();
454
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
455
+					$dataFound = true;
456
+					$this->all_flights[$id]['time_last_coord'] = time();
457 457
 				}
458 458
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
459 459
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -464,20 +464,20 @@  discard block
 block discarded – undo
464 464
 				    //$putinarchive = true;
465 465
 				}
466 466
 				*/
467
-			    /*
467
+				/*
468 468
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
469 469
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
470 470
 			    }
471 471
 			    */
472 472
 			}
473 473
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
474
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
475
-			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
474
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
475
+				//if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
476 476
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
477 477
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
478
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
479
-				    $dataFound = true;
480
-				    $this->all_flights[$id]['time_last_coord'] = time();
478
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
479
+					$dataFound = true;
480
+					$this->all_flights[$id]['time_last_coord'] = time();
481 481
 				}
482 482
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
483 483
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -495,53 +495,53 @@  discard block
 block discarded – undo
495 495
 			    */
496 496
 			}
497 497
 
498
-		    } else if ($globalDebug && $timediff > 20) {
498
+			} else if ($globalDebug && $timediff > 20) {
499 499
 			$this->tmd = $this->tmd + 1;
500 500
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
501 501
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
502 502
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
503 503
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
504
-		    }
504
+			}
505 505
 		}
506 506
 		if (isset($line['last_update']) && $line['last_update'] != '') {
507
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
508
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
507
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
508
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
509 509
 		}
510 510
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
511
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
512
-		    //$dataFound = true;
511
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
512
+			//$dataFound = true;
513 513
 		}
514 514
 		if (isset($line['format_source']) && $line['format_source'] != '') {
515
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
515
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
516 516
 		}
517 517
 		if (isset($line['source_name']) && $line['source_name'] != '') {
518
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
518
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
519 519
 		}
520 520
 		if (isset($line['emergency']) && $line['emergency'] != '') {
521
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
522
-		    //$dataFound = true;
521
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
522
+			//$dataFound = true;
523 523
 		}
524 524
 		if (isset($line['ground']) && $line['ground'] != '') {
525
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
525
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
526 526
 			// Here we force archive of flight because after ground it's a new one (or should be)
527 527
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
528 528
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
529 529
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
530
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
530
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
531 531
 			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
532
-		    }
533
-		    if ($line['ground'] != 1) $line['ground'] = 0;
534
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
535
-		    //$dataFound = true;
532
+			}
533
+			if ($line['ground'] != 1) $line['ground'] = 0;
534
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
535
+			//$dataFound = true;
536 536
 		}
537 537
 		if (isset($line['squawk']) && $line['squawk'] != '') {
538
-		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
539
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
540
-			    $highlight = '';
541
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
542
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
543
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
544
-			    if ($highlight != '') {
538
+			if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
539
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
540
+				$highlight = '';
541
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
542
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
543
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
544
+				if ($highlight != '') {
545 545
 				$timeelapsed = microtime(true);
546 546
 				$Spotter = new Spotter($this->db);
547 547
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -551,38 +551,38 @@  discard block
 block discarded – undo
551 551
 				$this->all_flights[$id]['putinarchive'] = true;
552 552
 				//$putinarchive = true;
553 553
 				//$highlight = '';
554
-			    }
554
+				}
555 555
 			    
556
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
557
-		    //$dataFound = true;
556
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
557
+			//$dataFound = true;
558 558
 		}
559 559
 
560 560
 		if (isset($line['altitude']) && $line['altitude'] != '') {
561
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
561
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
562 562
 			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
563 563
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
564 564
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
565 565
 			//$dataFound = true;
566
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
566
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
567 567
   		}
568 568
 
569 569
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
570
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
571 571
 		}
572 572
 		
573 573
 		if (isset($line['heading']) && $line['heading'] != '') {
574
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
575
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
576
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
577
-		    //$dataFound = true;
574
+			if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
575
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
576
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
577
+			//$dataFound = true;
578 578
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
579
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
580
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
581
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
582
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
579
+  			$heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
580
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
581
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
582
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
583 583
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
584
-  		    // If not enough messages and ACARS set heading to 0
585
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
584
+  			// If not enough messages and ACARS set heading to 0
585
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
586 586
   		}
587 587
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
588 588
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -592,119 +592,119 @@  discard block
 block discarded – undo
592 592
 		//if (time()-$this->all_flights[$id]['lastupdate'] > 30 && $dataFound == true && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
593 593
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
594 594
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
595
-		    $this->all_flights[$id]['lastupdate'] = time();
596
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
597
-		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
598
-			    //print_r($this->all_flights);
599
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
600
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
601
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
595
+			$this->all_flights[$id]['lastupdate'] = time();
596
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
597
+				if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
598
+				//print_r($this->all_flights);
599
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
600
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
601
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
602 602
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
603 603
 				$timeelapsed = microtime(true);
604 604
 				$SpotterLive = new SpotterLive($this->db);
605 605
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
606
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
607
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
606
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
607
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
608 608
 				} elseif (isset($line['id'])) {
609
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
610
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
609
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
610
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
611 611
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
612
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
613
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
612
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
613
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
614 614
 				} else $recent_ident = '';
615 615
 				$SpotterLive->db=null;
616 616
 
617 617
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
618 618
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
619
-			    } else {
619
+				} else {
620 620
 				$recent_ident = '';
621 621
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
622
-			    }
623
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
624
-			    if($recent_ident == "")
625
-			    {
622
+				}
623
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
624
+				if($recent_ident == "")
625
+				{
626 626
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
627 627
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
628 628
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
629 629
 				//adds the spotter data for the archive
630 630
 				$ignoreImport = false;
631 631
 				foreach($globalAirportIgnore as $airportIgnore) {
632
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
632
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
633 633
 					$ignoreImport = true;
634
-				    }
634
+					}
635 635
 				}
636 636
 				if (count($globalAirportAccept) > 0) {
637
-				    $ignoreImport = true;
638
-				    foreach($globalAirportIgnore as $airportIgnore) {
637
+					$ignoreImport = true;
638
+					foreach($globalAirportIgnore as $airportIgnore) {
639 639
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
640
-					    $ignoreImport = false;
640
+						$ignoreImport = false;
641
+					}
641 642
 					}
642
-				    }
643 643
 				}
644 644
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
645
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
645
+					foreach($globalAirlineIgnore as $airlineIgnore) {
646 646
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
647
-					    $ignoreImport = true;
647
+						$ignoreImport = true;
648
+					}
648 649
 					}
649
-				    }
650 650
 				}
651 651
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
652
-				    $ignoreImport = true;
653
-				    foreach($globalAirlineAccept as $airlineAccept) {
652
+					$ignoreImport = true;
653
+					foreach($globalAirlineAccept as $airlineAccept) {
654 654
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
655
-					    $ignoreImport = false;
655
+						$ignoreImport = false;
656
+					}
656 657
 					}
657
-				    }
658 658
 				}
659 659
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
660
-				    $ignoreImport = true;
661
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
660
+					$ignoreImport = true;
661
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
662 662
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
663
-					    $ignoreImport = false;
663
+						$ignoreImport = false;
664
+					}
664 665
 					}
665
-				    }
666 666
 				}
667 667
 				
668 668
 				if (!$ignoreImport) {
669
-				    $highlight = '';
670
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
671
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
672
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
673
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
674
-				    $timeelapsed = microtime(true);
675
-				    $Spotter = new Spotter($this->db);
676
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
677
-				    $Spotter->db = null;
678
-				    if ($globalDebug && isset($result)) echo $result."\n";
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
669
+					$highlight = '';
670
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
671
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
672
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
673
+					if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
674
+					$timeelapsed = microtime(true);
675
+					$Spotter = new Spotter($this->db);
676
+					$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
677
+					$Spotter->db = null;
678
+					if ($globalDebug && isset($result)) echo $result."\n";
679
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
680 680
 				    
681
-				    // Add source stat in DB
682
-				    $Stats = new Stats($this->db);
683
-				    if (!empty($this->stats)) {
681
+					// Add source stat in DB
682
+					$Stats = new Stats($this->db);
683
+					if (!empty($this->stats)) {
684 684
 					if ($globalDebug) echo 'Add source stats : ';
685
-				        foreach($this->stats as $date => $data) {
686
-					    foreach($data as $source => $sourced) {
687
-					        //print_r($sourced);
688
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
689
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
690
-				    		if (isset($sourced['msg'])) {
691
-				    		    if (time() - $sourced['msg']['date'] > 10) {
692
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
693
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
694
-			    			        unset($this->stats[$date][$source]['msg']);
695
-			    			    }
696
-			    			}
697
-			    		    }
698
-			    		    if ($date != date('Y-m-d')) {
699
-			    			unset($this->stats[$date]);
700
-			    		    }
701
-				    	}
702
-				    	if ($globalDebug) echo 'Done'."\n";
703
-
704
-				    }
705
-				    $Stats->db = null;
685
+						foreach($this->stats as $date => $data) {
686
+						foreach($data as $source => $sourced) {
687
+							//print_r($sourced);
688
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
689
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
690
+							if (isset($sourced['msg'])) {
691
+								if (time() - $sourced['msg']['date'] > 10) {
692
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
693
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
694
+									unset($this->stats[$date][$source]['msg']);
695
+								}
696
+							}
697
+							}
698
+							if ($date != date('Y-m-d')) {
699
+							unset($this->stats[$date]);
700
+							}
701
+						}
702
+						if ($globalDebug) echo 'Done'."\n";
703
+
704
+					}
705
+					$Stats->db = null;
706 706
 				    
707
-				    $this->del();
707
+					$this->del();
708 708
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
709 709
 				//$ignoreImport = false;
710 710
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -722,18 +722,18 @@  discard block
 block discarded – undo
722 722
 			*/
723 723
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
724 724
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
725
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
726
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
727
-				    $SpotterLive = new SpotterLive($this->db);
728
-				    $SpotterLive->deleteLiveSpotterData();
729
-				    $SpotterLive->db=null;
730
-				    if ($globalDebug) echo " Done\n";
731
-				    $this->last_delete = time();
725
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
726
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
727
+					$SpotterLive = new SpotterLive($this->db);
728
+					$SpotterLive->deleteLiveSpotterData();
729
+					$SpotterLive->db=null;
730
+					if ($globalDebug) echo " Done\n";
731
+					$this->last_delete = time();
732 732
 				}
733
-			    } else {
733
+				} else {
734 734
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
735
-				    $this->all_flights[$id]['id'] = $recent_ident;
736
-				    $this->all_flights[$id]['addedSpotter'] = 1;
735
+					$this->all_flights[$id]['id'] = $recent_ident;
736
+					$this->all_flights[$id]['addedSpotter'] = 1;
737 737
 				}
738 738
 				if (isset($globalDaemon) && !$globalDaemon) {
739 739
 					$Spotter = new Spotter($this->db);
@@ -741,14 +741,14 @@  discard block
 block discarded – undo
741 741
 					$Spotter->db = null;
742 742
 				}
743 743
 				
744
-			    }
744
+				}
745
+			}
745 746
 			}
746
-		    }
747
-		    //adds the spotter LIVE data
748
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
749
-		    //echo "\nAdd in Live !! \n";
750
-		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
751
-		    if ($globalDebug) {
747
+			//adds the spotter LIVE data
748
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
749
+			//echo "\nAdd in Live !! \n";
750
+			//echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
751
+			if ($globalDebug) {
752 752
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalphpVAM) && $globalphpVAM)) {
753 753
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
754 754
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
@@ -756,49 +756,49 @@  discard block
 block discarded – undo
756 756
 				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
757 757
 				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
758 758
 			}
759
-		    }
760
-		    $ignoreImport = false;
761
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
759
+			}
760
+			$ignoreImport = false;
761
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 763
 
764
-		    foreach($globalAirportIgnore as $airportIgnore) {
765
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
766
-			    $ignoreImport = true;
764
+			foreach($globalAirportIgnore as $airportIgnore) {
765
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
766
+				$ignoreImport = true;
767
+			}
767 768
 			}
768
-		    }
769
-		    if (count($globalAirportAccept) > 0) {
770
-		        $ignoreImport = true;
771
-		        foreach($globalAirportIgnore as $airportIgnore) {
772
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
769
+			if (count($globalAirportAccept) > 0) {
770
+				$ignoreImport = true;
771
+				foreach($globalAirportIgnore as $airportIgnore) {
772
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
773 773
 				$ignoreImport = false;
774
-			    }
774
+				}
775 775
 			}
776
-		    }
777
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
776
+			}
777
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
778 778
 			foreach($globalAirlineIgnore as $airlineIgnore) {
779
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
779
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
780 780
 				$ignoreImport = true;
781
-			    }
781
+				}
782 782
 			}
783
-		    }
784
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
783
+			}
784
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
785 785
 			$ignoreImport = true;
786 786
 			foreach($globalAirlineAccept as $airlineAccept) {
787
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
787
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
788 788
 				$ignoreImport = false;
789
-			    }
789
+				}
790 790
 			}
791
-		    }
792
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
791
+			}
792
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
793 793
 			$ignoreImport = true;
794 794
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
795
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
796
-			        $ignoreImport = false;
797
-			    }
795
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
796
+					$ignoreImport = false;
797
+				}
798
+			}
798 799
 			}
799
-		    }
800 800
 
801
-		    if (!$ignoreImport) {
801
+			if (!$ignoreImport) {
802 802
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
803 803
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
804 804
 				$timeelapsed = microtime(true);
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 					if ($stats_heading == 16) $stats_heading = 0;
837 837
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
838 838
 						for ($i=0;$i<=15;$i++) {
839
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
839
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
840 840
 						}
841 841
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
842 842
 					} else {
@@ -849,11 +849,11 @@  discard block
 block discarded – undo
849 849
 					//var_dump($this->stats);
850 850
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
851 851
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
852
-						    end($this->stats[$current_date][$source]['hist']);
853
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
852
+							end($this->stats[$current_date][$source]['hist']);
853
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
854 854
 						} else $mini = 0;
855 855
 						for ($i=$mini;$i<=$distance;$i+=10) {
856
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
856
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
857 857
 						}
858 858
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
859 859
 					} else {
@@ -870,22 +870,22 @@  discard block
 block discarded – undo
870 870
 			
871 871
 			
872 872
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
873
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
874
-			    $SpotterLive = new SpotterLive($this->db);
875
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
876
-			    $SpotterLive->db = null;
877
-			    //SpotterLive->deleteLiveSpotterData();
878
-			    if ($globalDebug) echo " Done\n";
879
-			    $this->last_delete_hourly = time();
873
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
874
+				$SpotterLive = new SpotterLive($this->db);
875
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
876
+				$SpotterLive->db = null;
877
+				//SpotterLive->deleteLiveSpotterData();
878
+				if ($globalDebug) echo " Done\n";
879
+				$this->last_delete_hourly = time();
880 880
 			}
881 881
 			
882
-		    }
883
-		    //$ignoreImport = false;
882
+			}
883
+			//$ignoreImport = false;
884 884
 		}
885 885
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
886 886
 		if ($send) return $this->all_flights[$id];
887
-	    }
887
+		}
888
+	}
888 889
 	}
889
-    }
890 890
 }
891 891
 ?>
Please login to merge, or discard this patch.
Spacing   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	$currentdate = date('Y-m-d');
30 30
 	$sourcestat = $Stats->getStatsSource($currentdate);
31 31
 	if (!empty($sourcestat)) {
32
-	    foreach($sourcestat as $srcst) {
32
+	    foreach ($sourcestat as $srcst) {
33 33
 	    	$type = $srcst['stats_type'];
34 34
 		if ($type == 'polar' || $type == 'hist') {
35 35
 		    $source = $srcst['source_name'];
36 36
 		    $data = $srcst['source_data'];
37
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
37
+		    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
38 38
 	        }
39 39
 	    }
40 40
 	}
41 41
     }
42 42
 
43
-    public function get_Schedule($id,$ident) {
43
+    public function get_Schedule($id, $ident) {
44 44
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 45
 	// Get schedule here, so it's done only one time
46 46
 	
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 		$schedule = $Schedule->fetchSchedule($operator);
65 65
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
66 66
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
67
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
68
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
67
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
68
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
69 69
 		    // Should also check if route schedule = route from DB
70 70
 		    if ($schedule['DepartureAirportIATA'] != '') {
71 71
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 			    }
86 86
 			}
87 87
 		    }
88
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
88
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
89 89
 		}
90 90
 	    }
91 91
 	}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
116 116
     		$Spotter = new Spotter($this->db);
117 117
         	$real_arrival = $this->arrival($key);
118
-        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
118
+        	$Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
119 119
             }
120 120
 	}
121 121
     }
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $airport_time = '';
129 129
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
130 130
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
131
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
131
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
132 132
     	    if (isset($closestAirports[0])) {
133 133
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
134 134
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         		    break;
144 144
         		}
145 145
         	    }
146
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
146
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
147 147
         		$airport_icao = $closestAirports[0]['icao'];
148 148
         		$airport_time = $this->all_flights[$key]['datetime'];
149 149
         	} else {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         } else {
157 157
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
158 158
         }
159
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
159
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
160 160
     }
161 161
 
162 162
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
168 168
 	foreach ($this->all_flights as $key => $flight) {
169 169
     	    if (isset($flight['lastupdate'])) {
170
-        	if ($flight['lastupdate'] < (time()-3000)) {
170
+        	if ($flight['lastupdate'] < (time() - 3000)) {
171 171
             	    if (isset($this->all_flights[$key]['id'])) {
172 172
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
173 173
 			/*
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             		$real_arrival = $this->arrival($key);
179 179
             		$Spotter = new Spotter($this->db);
180 180
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
181
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
181
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
182 182
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
183 183
 			}
184 184
 			// Put in archive
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	$send = false;
215 215
 	
216 216
 	// SBS format is CSV format
217
-	if(is_array($line) && isset($line['hex'])) {
217
+	if (is_array($line) && isset($line['hex'])) {
218 218
 	    //print_r($line);
219 219
   	    if ($line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6) {
220 220
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		//print_r($this->all_flights);
249 249
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
250 250
 		    $this->all_flights[$id] = array('hex' => $hex);
251
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
251
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
252 252
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
253 253
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
254 254
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			$Spotter = new Spotter($this->db);
259 259
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
260 260
 			$Spotter->db = null;
261
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
261
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
262 262
 
263 263
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
264 264
 			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
@@ -266,31 +266,31 @@  discard block
 block discarded – undo
266 266
 			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
267 267
 			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
268 268
 			}
269
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
270 270
 		    } else if (isset($line['aircraft_name'])) {
271 271
 			// Get aircraft ICAO from aircraft name
272 272
 			$Spotter = new Spotter($this->db);
273 273
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
274 274
 			$Spotter->db = null;
275
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
276
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
277
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
278
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => false));
279
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
275
+			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
276
+			else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
277
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
278
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => false));
279
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
280 280
 		    if (!isset($line['id'])) {
281 281
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
282 282
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
283 283
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
284
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
285 285
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
286
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
286
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
287 287
 
288 288
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
289 289
 		}
290 290
 		
291
-		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
291
+		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/', $line['datetime'])) {
292 292
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
293
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
294 294
 		    } else {
295 295
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
296 296
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -301,23 +301,23 @@  discard block
 block discarded – undo
301 301
 				*/
302 302
 				return '';
303 303
 		    }
304
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
304
+		} else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
305 305
 
306 306
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
307
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
307
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
308 308
 		}
309 309
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
310
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
310
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
311 311
 		}
312 312
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
313
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
313
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
314 314
 		}
315 315
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
316
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
316
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
317 317
 		}
318 318
  
319 319
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
320
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
321 321
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
322 322
 			$timeelapsed = microtime(true);
323 323
             		$Spotter = new Spotter($this->db);
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
328 328
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
329 329
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
330
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
330
+            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
331 331
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
332 332
 			$Spotter->db = null;
333
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
333
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
334 334
 		    }
335 335
 
336 336
 /*
@@ -341,24 +341,24 @@  discard block
 block discarded – undo
341 341
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
342 342
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
343 343
   */
344
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
344
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
345 345
 
346 346
 		    //$putinarchive = true;
347 347
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
348
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
349 349
 		    }
350 350
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
351
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
352 352
 		    }
353 353
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
354
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
354
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
355 355
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
356 356
 				$timeelapsed = microtime(true);
357 357
 				$Spotter = new Spotter($this->db);
358 358
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
359 359
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
360
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
361
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
361
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
362 362
 
363 363
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
364 364
 			$timeelapsed = microtime(true);
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 				$Translation->db = null;
372 372
 			}
373 373
 			$Spotter->db = null;
374
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
374
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
375 375
 
376 376
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
377 377
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
378 378
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
379 379
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
380
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
380
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
381 381
 		    	    }
382 382
 			}
383 383
 			if (!isset($globalFork)) $globalFork = TRUE;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 				}
394 394
 			    } else {
395 395
 			    */
396
-				$this->get_Schedule($id,trim($line['ident']));
396
+				$this->get_Schedule($id, trim($line['ident']));
397 397
 			//    }
398 398
 			}
399 399
 		    }
@@ -401,16 +401,16 @@  discard block
 block discarded – undo
401 401
 
402 402
 		if (isset($line['speed']) && $line['speed'] != '') {
403 403
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
404
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
405
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
404
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
405
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
406 406
 		    //$dataFound = true;
407 407
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
408
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
408
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
409 409
 		    if ($distance > 1000 && $distance < 10000) {
410 410
 		    // use datetime
411 411
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
412 412
 			$speed = $speed*3.6;
413
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
413
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
414 414
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
415 415
 		    }
416 416
 		}
@@ -418,11 +418,11 @@  discard block
 block discarded – undo
418 418
 
419 419
 
420 420
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
421
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
421
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
422 422
 	    	    else unset($timediff);
423
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
423
+	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) {
424 424
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
425
-			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
425
+			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
426 426
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
427 427
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
428 428
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 				//echo "\n".' ------- Check Country.... ';
432 432
 				$timeelapsed = microtime(true);
433 433
 				$Spotter = new Spotter($this->db);
434
-				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
434
+				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
435 435
 				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
436 436
 				$Spotter->db = null;
437
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
437
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
438 438
 				$this->tmd = 0;
439 439
 				//echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
440 440
 				//$putinarchive = true;
@@ -450,13 +450,13 @@  discard block
 block discarded – undo
450 450
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
451 451
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
452 452
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
453
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
453
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
454 454
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
455 455
 				    $dataFound = true;
456 456
 				    $this->all_flights[$id]['time_last_coord'] = time();
457 457
 				}
458 458
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
459
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
459
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
460 460
 				/*
461 461
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
462 462
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
475 475
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
476 476
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
477
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
477
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
478 478
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
479 479
 				    $dataFound = true;
480 480
 				    $this->all_flights[$id]['time_last_coord'] = time();
481 481
 				}
482 482
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
483
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
483
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
484 484
 				/*
485 485
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
486 486
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -498,45 +498,45 @@  discard block
 block discarded – undo
498 498
 		    } else if ($globalDebug && $timediff > 20) {
499 499
 			$this->tmd = $this->tmd + 1;
500 500
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
501
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
502
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
501
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
502
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
503 503
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
504 504
 		    }
505 505
 		}
506 506
 		if (isset($line['last_update']) && $line['last_update'] != '') {
507 507
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
508
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
508
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
509 509
 		}
510 510
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
511
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
511
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
512 512
 		    //$dataFound = true;
513 513
 		}
514 514
 		if (isset($line['format_source']) && $line['format_source'] != '') {
515
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
515
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
516 516
 		}
517 517
 		if (isset($line['source_name']) && $line['source_name'] != '') {
518
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
518
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
519 519
 		}
520 520
 		if (isset($line['emergency']) && $line['emergency'] != '') {
521
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
521
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
522 522
 		    //$dataFound = true;
523 523
 		}
524 524
 		if (isset($line['ground']) && $line['ground'] != '') {
525 525
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
526 526
 			// Here we force archive of flight because after ground it's a new one (or should be)
527
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
528
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
529
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
530
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
531
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
527
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
528
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
529
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
530
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
531
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
532 532
 		    }
533 533
 		    if ($line['ground'] != 1) $line['ground'] = 0;
534
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
534
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
535 535
 		    //$dataFound = true;
536 536
 		}
537 537
 		if (isset($line['squawk']) && $line['squawk'] != '') {
538 538
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
539
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
539
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
540 540
 			    $highlight = '';
541 541
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
542 542
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -544,48 +544,48 @@  discard block
 block discarded – undo
544 544
 			    if ($highlight != '') {
545 545
 				$timeelapsed = microtime(true);
546 546
 				$Spotter = new Spotter($this->db);
547
-				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
547
+				$Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
548 548
 				$Spotter->db = null;
549
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
549
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
550 550
 
551 551
 				$this->all_flights[$id]['putinarchive'] = true;
552 552
 				//$putinarchive = true;
553 553
 				//$highlight = '';
554 554
 			    }
555 555
 			    
556
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
556
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
557 557
 		    //$dataFound = true;
558 558
 		}
559 559
 
560 560
 		if (isset($line['altitude']) && $line['altitude'] != '') {
561 561
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
562
-			if (abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
564
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
562
+			if (abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
563
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
564
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
565 565
 			//$dataFound = true;
566 566
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
567 567
   		}
568 568
 
569 569
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
570
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
571 571
 		}
572 572
 		
573 573
 		if (isset($line['heading']) && $line['heading'] != '') {
574
-		    if (abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
575
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
576
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
574
+		    if (abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
575
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
576
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
577 577
 		    //$dataFound = true;
578 578
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
579
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
580
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
581
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
579
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
580
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
581
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
582 582
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
583 583
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
584 584
   		    // If not enough messages and ACARS set heading to 0
585
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
585
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
586 586
   		}
587
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
588
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
587
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
588
+		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
589 589
 
590 590
 //		print_r($this->all_flights[$id]);
591 591
 		//gets the callsign from the last hour
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 		if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
595 595
 		    $this->all_flights[$id]['lastupdate'] = time();
596 596
 		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
597
-		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
597
+		        if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
598 598
 			    //print_r($this->all_flights);
599 599
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
600 600
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -604,61 +604,61 @@  discard block
 block discarded – undo
604 604
 				$SpotterLive = new SpotterLive($this->db);
605 605
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
606 606
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
607
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
607
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
608 608
 				} elseif (isset($line['id'])) {
609 609
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
610
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
610
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
611 611
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
612 612
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
613
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
613
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
614 614
 				} else $recent_ident = '';
615
-				$SpotterLive->db=null;
615
+				$SpotterLive->db = null;
616 616
 
617 617
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
618 618
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
619 619
 			    } else {
620 620
 				$recent_ident = '';
621
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
621
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
622 622
 			    }
623 623
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
624
-			    if($recent_ident == "")
624
+			    if ($recent_ident == "")
625 625
 			    {
626 626
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
627 627
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
628 628
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
629 629
 				//adds the spotter data for the archive
630 630
 				$ignoreImport = false;
631
-				foreach($globalAirportIgnore as $airportIgnore) {
631
+				foreach ($globalAirportIgnore as $airportIgnore) {
632 632
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
633 633
 					$ignoreImport = true;
634 634
 				    }
635 635
 				}
636 636
 				if (count($globalAirportAccept) > 0) {
637 637
 				    $ignoreImport = true;
638
-				    foreach($globalAirportIgnore as $airportIgnore) {
638
+				    foreach ($globalAirportIgnore as $airportIgnore) {
639 639
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
640 640
 					    $ignoreImport = false;
641 641
 					}
642 642
 				    }
643 643
 				}
644 644
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
645
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
646
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
645
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
646
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
647 647
 					    $ignoreImport = true;
648 648
 					}
649 649
 				    }
650 650
 				}
651 651
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
652 652
 				    $ignoreImport = true;
653
-				    foreach($globalAirlineAccept as $airlineAccept) {
654
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
653
+				    foreach ($globalAirlineAccept as $airlineAccept) {
654
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
655 655
 					    $ignoreImport = false;
656 656
 					}
657 657
 				    }
658 658
 				}
659 659
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
660 660
 				    $ignoreImport = true;
661
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
661
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
662 662
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
663 663
 					    $ignoreImport = false;
664 664
 					}
@@ -670,27 +670,27 @@  discard block
 block discarded – undo
670 670
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
671 671
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
672 672
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
673
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
673
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
674 674
 				    $timeelapsed = microtime(true);
675 675
 				    $Spotter = new Spotter($this->db);
676
-				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
676
+				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']);
677 677
 				    $Spotter->db = null;
678 678
 				    if ($globalDebug && isset($result)) echo $result."\n";
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
679
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
680 680
 				    
681 681
 				    // Add source stat in DB
682 682
 				    $Stats = new Stats($this->db);
683 683
 				    if (!empty($this->stats)) {
684 684
 					if ($globalDebug) echo 'Add source stats : ';
685
-				        foreach($this->stats as $date => $data) {
686
-					    foreach($data as $source => $sourced) {
685
+				        foreach ($this->stats as $date => $data) {
686
+					    foreach ($data as $source => $sourced) {
687 687
 					        //print_r($sourced);
688
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
689
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
688
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
689
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
690 690
 				    		if (isset($sourced['msg'])) {
691 691
 				    		    if (time() - $sourced['msg']['date'] > 10) {
692 692
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
693
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
693
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
694 694
 			    			        unset($this->stats[$date][$source]['msg']);
695 695
 			    			    }
696 696
 			    			}
@@ -726,18 +726,18 @@  discard block
 block discarded – undo
726 726
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
727 727
 				    $SpotterLive = new SpotterLive($this->db);
728 728
 				    $SpotterLive->deleteLiveSpotterData();
729
-				    $SpotterLive->db=null;
729
+				    $SpotterLive->db = null;
730 730
 				    if ($globalDebug) echo " Done\n";
731 731
 				    $this->last_delete = time();
732 732
 				}
733 733
 			    } else {
734
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
734
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) {
735 735
 				    $this->all_flights[$id]['id'] = $recent_ident;
736 736
 				    $this->all_flights[$id]['addedSpotter'] = 1;
737 737
 				}
738 738
 				if (isset($globalDaemon) && !$globalDaemon) {
739 739
 					$Spotter = new Spotter($this->db);
740
-					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
740
+					$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
741 741
 					$Spotter->db = null;
742 742
 				}
743 743
 				
@@ -761,37 +761,37 @@  discard block
 block discarded – undo
761 761
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762 762
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 763
 
764
-		    foreach($globalAirportIgnore as $airportIgnore) {
764
+		    foreach ($globalAirportIgnore as $airportIgnore) {
765 765
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
766 766
 			    $ignoreImport = true;
767 767
 			}
768 768
 		    }
769 769
 		    if (count($globalAirportAccept) > 0) {
770 770
 		        $ignoreImport = true;
771
-		        foreach($globalAirportIgnore as $airportIgnore) {
771
+		        foreach ($globalAirportIgnore as $airportIgnore) {
772 772
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
773 773
 				$ignoreImport = false;
774 774
 			    }
775 775
 			}
776 776
 		    }
777 777
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
778
-			foreach($globalAirlineIgnore as $airlineIgnore) {
779
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
778
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
779
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
780 780
 				$ignoreImport = true;
781 781
 			    }
782 782
 			}
783 783
 		    }
784 784
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
785 785
 			$ignoreImport = true;
786
-			foreach($globalAirlineAccept as $airlineAccept) {
787
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
786
+			foreach ($globalAirlineAccept as $airlineAccept) {
787
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
788 788
 				$ignoreImport = false;
789 789
 			    }
790 790
 			}
791 791
 		    }
792 792
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
793 793
 			$ignoreImport = true;
794
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
794
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
795 795
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
796 796
 			        $ignoreImport = false;
797 797
 			    }
@@ -799,13 +799,13 @@  discard block
 block discarded – undo
799 799
 		    }
800 800
 
801 801
 		    if (!$ignoreImport) {
802
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
802
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
803 803
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
804 804
 				$timeelapsed = microtime(true);
805 805
 				$SpotterLive = new SpotterLive($this->db);
806
-				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
806
+				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
807 807
 				$SpotterLive->db = null;
808
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
808
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
809 809
 
810 810
 				// Put statistics in $this->stats variable
811 811
 				//if ($line['format_source'] != 'aprs') {
@@ -823,19 +823,19 @@  discard block
 block discarded – undo
823 823
 							$latitude = $globalCenterLatitude;
824 824
 							$longitude = $globalCenterLongitude;
825 825
 						}
826
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
826
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
827 827
 					} else {
828 828
 						$latitude = $this->source_location[$source]['latitude'];
829 829
 						$longitude = $this->source_location[$source]['longitude'];
830 830
 					}
831
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
831
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
832 832
 					//$stats_heading = $stats_heading%22.5;
833 833
 					$stats_heading = round($stats_heading/22.5);
834
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
834
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
835 835
 					$current_date = date('Y-m-d');
836 836
 					if ($stats_heading == 16) $stats_heading = 0;
837 837
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
838
-						for ($i=0;$i<=15;$i++) {
838
+						for ($i = 0; $i <= 15; $i++) {
839 839
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
840 840
 						}
841 841
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -850,9 +850,9 @@  discard block
 block discarded – undo
850 850
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
851 851
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
852 852
 						    end($this->stats[$current_date][$source]['hist']);
853
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
853
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
854 854
 						} else $mini = 0;
855
-						for ($i=$mini;$i<=$distance;$i+=10) {
855
+						for ($i = $mini; $i <= $distance; $i += 10) {
856 856
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
857 857
 						}
858 858
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
866 866
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
867 867
 				if ($globalDebug) echo $result."\n";
868
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
868
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
869 869
 			//$this->del();
870 870
 			
871 871
 			
Please login to merge, or discard this patch.
require/class.Spotter.php 2 patches
Spacing   +791 added lines, -791 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $db;
9 9
 	
10 10
 	public function __construct($dbc = null) {
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter;
22
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
22
+		if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter);
23 23
 		$filter_query_join = '';
24 24
 		$filter_query_where = '';
25 25
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
26 26
 			if ($filter['airlines'][0] != '') {
27
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
27
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
28 28
 			}
29 29
 		}
30 30
 		
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_output.flightaware_id ";
33 33
 		}
34 34
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
35
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
35
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_output.flightaware_id";
36 36
 		}
37 37
 		if (isset($filter['source']) && !empty($filter['source'])) {
38
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
38
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
39 39
 		}
40 40
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
41 41
 			if ($filter_query_where == '') {
42
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
42
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
43 43
 			} else {
44
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
44
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
45 45
 			}
46 46
 		}
47 47
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 			$sth = $this->db->prepare($query.$limitQuery);
90 90
 			$sth->execute($params);
91 91
 		} catch (PDOException $e) {
92
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
92
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
93 93
 			exit();
94 94
 		}
95 95
 		
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		$spotter_array = array();
100 100
 		
101 101
 
102
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
102
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
103 103
 		{
104 104
 			$num_rows++;
105 105
 			$temp_array = array();
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			if (isset($row['route_stop'])) {
145 145
 				$temp_array['route_stop'] = $row['route_stop'];
146 146
 				if ($row['route_stop'] != '') {
147
-					$allroute = explode(' ',$row['route_stop']);
147
+					$allroute = explode(' ', $row['route_stop']);
148 148
 			
149 149
 					foreach ($allroute as $route) {
150 150
 						$route_airport_array = $this->getAllAirportInfo($route);
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 				{
200 200
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
201 201
 				} else {
202
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
202
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
203 203
 				}
204 204
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
205
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
206
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
205
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
206
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
207 207
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
208 208
 			}
209 209
 			
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
238 238
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
239 239
 					if (is_numeric(substr($row['ident'], 2, 1))) {
240
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
240
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
241 241
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
242
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
242
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
243 243
 					} else {
244 244
 						$airline_array = $this->getAllAirlineInfo('NA');
245 245
 					}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 				$temp_array['airline_type'] = $row['airline_type'];
266 266
 			}
267 267
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
268
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
268
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
269 269
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
270 270
 				if (count($acars_array) > 0) {
271 271
 					$temp_array['acars'] = $acars_array;
@@ -282,11 +282,11 @@  discard block
 block discarded – undo
282 282
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
283 283
 			}
284 284
 
285
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
285
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
286 286
 			{
287 287
 				if ($globalIVAO) {
288
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
289
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
288
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
289
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
290 290
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
291 291
 				if (count($image_array) > 0) {
292 292
 					$temp_array['image'] = $image_array[0]['image'];
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 			if (isset($row['arrival_airport_time']) && $row['arrival_airport_time'] != '') {
310 310
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
311 311
 			}
312
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
312
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
313 313
 				$schedule_array = $Schedule->getSchedule($temp_array['ident']);
314 314
 				//print_r($schedule_array);
315 315
 				if (count($schedule_array) > 0) {
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 			if (isset($row['squawk'])) {
391 391
 				$temp_array['squawk'] = $row['squawk'];
392 392
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
393
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
394
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
393
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
394
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
395 395
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
396
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
397
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
398
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
396
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
397
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
398
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
399 399
 			}
400 400
     			
401 401
 			$temp_array['query_number_rows'] = $num_rows;
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	* @return Array the spotter information
415 415
 	*
416 416
 	*/
417
-	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filter = array())
417
+	public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filter = array())
418 418
 	{
419 419
 		global $globalTimezone, $globalDBdriver;
420 420
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
 		$query_values = array();
426 426
 		$additional_query = '';
427
-		$filter_query = $this->getFilter($filter,true,true);
427
+		$filter_query = $this->getFilter($filter, true, true);
428 428
 		if ($q != "")
429 429
 		{
430 430
 			if (!is_string($q))
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
 				return false;
433 433
 			} else {
434 434
 				$q_array = explode(" ", $q);
435
-				foreach ($q_array as $q_item){
436
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
435
+				foreach ($q_array as $q_item) {
436
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
437 437
 					$additional_query .= " AND (";
438 438
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
439 439
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -465,37 +465,37 @@  discard block
 block discarded – undo
465 465
 
466 466
 		if ($registration != "")
467 467
 		{
468
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
468
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
469 469
 			if (!is_string($registration))
470 470
 			{
471 471
 				return false;
472 472
 			} else {
473 473
 				$additional_query .= " AND spotter_output.registration = :registration";
474
-				$query_values = array_merge($query_values,array(':registration' => $registration));
474
+				$query_values = array_merge($query_values, array(':registration' => $registration));
475 475
 			}
476 476
 		}
477 477
 
478 478
 		if ($aircraft_icao != "")
479 479
 		{
480
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
480
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
481 481
 			if (!is_string($aircraft_icao))
482 482
 			{
483 483
 				return false;
484 484
 			} else {
485 485
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
486
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
486
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
487 487
 			}
488 488
 		}
489 489
 
490 490
 		if ($aircraft_manufacturer != "")
491 491
 		{
492
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
492
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
493 493
 			if (!is_string($aircraft_manufacturer))
494 494
 			{
495 495
 				return false;
496 496
 			} else {
497 497
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
498
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
498
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
499 499
 			}
500 500
 		}
501 501
 
@@ -511,25 +511,25 @@  discard block
 block discarded – undo
511 511
 
512 512
 		if ($airline_icao != "")
513 513
 		{
514
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
514
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
515 515
 			if (!is_string($airline_icao))
516 516
 			{
517 517
 				return false;
518 518
 			} else {
519 519
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
520
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
520
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
521 521
 			}
522 522
 		}
523 523
 
524 524
 		if ($airline_country != "")
525 525
 		{
526
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
526
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
527 527
 			if (!is_string($airline_country))
528 528
 			{
529 529
 				return false;
530 530
 			} else {
531 531
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
532
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
532
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
533 533
 			}
534 534
 		}
535 535
 
@@ -556,31 +556,31 @@  discard block
 block discarded – undo
556 556
 
557 557
 		if ($airport != "")
558 558
 		{
559
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
559
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
560 560
 			if (!is_string($airport))
561 561
 			{
562 562
 				return false;
563 563
 			} else {
564 564
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
565
-				$query_values = array_merge($query_values,array(':airport' => $airport));
565
+				$query_values = array_merge($query_values, array(':airport' => $airport));
566 566
 			}
567 567
 		}
568 568
 
569 569
 		if ($airport_country != "")
570 570
 		{
571
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
571
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
572 572
 			if (!is_string($airport_country))
573 573
 			{
574 574
 				return false;
575 575
 			} else {
576 576
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
577
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
577
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
578 578
 			}
579 579
 		}
580 580
     
581 581
 		if ($callsign != "")
582 582
 		{
583
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
583
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
584 584
 			if (!is_string($callsign))
585 585
 			{
586 586
 				return false;
@@ -588,79 +588,79 @@  discard block
 block discarded – undo
588 588
 				$translate = $Translation->ident2icao($callsign);
589 589
 				if ($translate != $callsign) {
590 590
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
591
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
591
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
592 592
 				} else {
593 593
 					$additional_query .= " AND spotter_output.ident = :callsign";
594
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
594
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
595 595
 				}
596 596
 			}
597 597
 		}
598 598
 
599 599
 		if ($owner != "")
600 600
 		{
601
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
601
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
602 602
 			if (!is_string($owner))
603 603
 			{
604 604
 				return false;
605 605
 			} else {
606 606
 				$additional_query .= " AND spotter_output.owner_name = :owner";
607
-				$query_values = array_merge($query_values,array(':owner' => $owner));
607
+				$query_values = array_merge($query_values, array(':owner' => $owner));
608 608
 			}
609 609
 		}
610 610
 
611 611
 		if ($pilot_name != "")
612 612
 		{
613
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
613
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
614 614
 			if (!is_string($pilot_name))
615 615
 			{
616 616
 				return false;
617 617
 			} else {
618 618
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
619
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
619
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
620 620
 			}
621 621
 		}
622 622
 
623 623
 		if ($pilot_id != "")
624 624
 		{
625
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
625
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
626 626
 			if (!is_string($pilot_id))
627 627
 			{
628 628
 				return false;
629 629
 			} else {
630 630
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
631
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
631
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
632 632
 			}
633 633
 		}
634 634
 
635 635
 		if ($departure_airport_route != "")
636 636
 		{
637
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
637
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
638 638
 			if (!is_string($departure_airport_route))
639 639
 			{
640 640
 				return false;
641 641
 			} else {
642 642
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
643
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
643
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
644 644
 			}
645 645
 		}
646 646
 
647 647
 		if ($arrival_airport_route != "")
648 648
 		{
649
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
649
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
650 650
 			if (!is_string($arrival_airport_route))
651 651
 			{
652 652
 				return false;
653 653
 			} else {
654 654
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
655
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
655
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
656 656
 			}
657 657
 		}
658 658
 
659 659
 		if ($altitude != "")
660 660
 		{
661 661
 			$altitude_array = explode(",", $altitude);
662
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
663
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
662
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
663
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
664 664
 
665 665
 			if ($altitude_array[1] != "")
666 666
 			{                
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 		if ($date_posted != "")
677 677
 		{
678 678
 			$date_array = explode(",", $date_posted);
679
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
680
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
679
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
680
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
681 681
 
682 682
 			if ($globalTimezone != '') {
683 683
 				date_default_timezone_set($globalTimezone);
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
 		{
709 709
 			$limit_array = explode(",", $limit);
710 710
 			
711
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
712
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
711
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
712
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
713 713
 			
714 714
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
715 715
 			{
@@ -738,23 +738,23 @@  discard block
 block discarded – undo
738 738
 
739 739
 
740 740
 		if ($origLat != "" && $origLon != "" && $dist != "") {
741
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
741
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
742 742
 
743 743
 			if ($globalDBdriver == 'mysql') {
744
-				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
744
+				$query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
745 745
 						FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
746 746
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
747 747
 			} else {
748
-				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
748
+				$query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
749 749
 						FROM spotter_output, spotter_archive".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
750 750
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
751 751
 			}
752 752
 		} else {		
753
-			$query  = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' 
753
+			$query = "SELECT spotter_output.* FROM spotter_output ".$filter_query." spotter_output.ident <> '' 
754 754
 					".$additional_query."
755 755
 					".$orderby_query;
756 756
 		}
757
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
757
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
758 758
 		return $spotter_array;
759 759
 	}
760 760
 	
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 		{
778 778
 			$limit_array = explode(",", $limit);
779 779
 			
780
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
781
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
780
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
781
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
782 782
 			
783 783
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
784 784
 			{
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 			$orderby_query = " ORDER BY spotter_output.date DESC";
796 796
 		}
797 797
 
798
-		$query  = $global_query.$filter_query." ".$orderby_query;
798
+		$query = $global_query.$filter_query." ".$orderby_query;
799 799
 
800
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query);
800
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
801 801
 
802 802
 		return $spotter_array;
803 803
 	}
@@ -843,34 +843,34 @@  discard block
 block discarded – undo
843 843
 			{
844 844
 				return false;
845 845
 			} else {
846
-				if ($interval == "30m"){
846
+				if ($interval == "30m") {
847 847
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
848
-				} else if ($interval == "1h"){
848
+				} else if ($interval == "1h") {
849 849
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
850
-				} else if ($interval == "3h"){
850
+				} else if ($interval == "3h") {
851 851
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
852
-				} else if ($interval == "6h"){
852
+				} else if ($interval == "6h") {
853 853
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
854
-				} else if ($interval == "12h"){
854
+				} else if ($interval == "12h") {
855 855
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
856
-				} else if ($interval == "24h"){
856
+				} else if ($interval == "24h") {
857 857
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
858
-				} else if ($interval == "7d"){
858
+				} else if ($interval == "7d") {
859 859
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
860
-				} else if ($interval == "30d"){
860
+				} else if ($interval == "30d") {
861 861
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
862 862
 				} 
863 863
 			}
864 864
 		}
865 865
 
866
-		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
866
+		$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
867 867
                    WHERE spotter_output.latitude <> '' 
868 868
 				   AND spotter_output.longitude <> '' 
869 869
                    ".$additional_query."
870 870
                    HAVING distance < :radius  
871 871
 				   ORDER BY distance";
872 872
 
873
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
873
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
874 874
 
875 875
 		return $spotter_array;
876 876
 	}
@@ -882,21 +882,21 @@  discard block
 block discarded – undo
882 882
 	* @return Array the spotter information
883 883
 	*
884 884
 	*/
885
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
885
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
886 886
 	{
887 887
 		global $global_query;
888 888
 		
889 889
 		date_default_timezone_set('UTC');
890 890
 
891
-		$filter_query = $this->getFilter($filter,true,true);
891
+		$filter_query = $this->getFilter($filter, true, true);
892 892
 
893 893
 		$limit_query = '';
894 894
 		if ($limit != "")
895 895
 		{
896 896
 			$limit_array = explode(",", $limit);
897 897
 			
898
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
899
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
898
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
899
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
900 900
 			
901 901
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
902 902
 			{
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
914 914
 		}
915 915
 
916
-		$query  = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
916
+		$query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
917 917
 
918 918
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
919 919
 
@@ -932,15 +932,15 @@  discard block
 block discarded – undo
932 932
 		global $global_query;
933 933
 		
934 934
 		date_default_timezone_set('UTC');
935
-		$filter_query = $this->getFilter($filter,true,true);
935
+		$filter_query = $this->getFilter($filter, true, true);
936 936
 
937 937
 		$limit_query = '';
938 938
 		if ($limit != "")
939 939
 		{
940 940
 			$limit_array = explode(",", $limit);
941 941
 			
942
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
943
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
942
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
943
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
944 944
 			
945 945
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
946 946
 			{
@@ -957,7 +957,7 @@  discard block
 block discarded – undo
957 957
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
958 958
 		}
959 959
 
960
-		$query  = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
960
+		$query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
961 961
 
962 962
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
963 963
 
@@ -971,20 +971,20 @@  discard block
 block discarded – undo
971 971
 	* @return Array the spotter information
972 972
 	*
973 973
 	*/
974
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
974
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
975 975
 	{
976 976
 		global $global_query;
977 977
 		
978 978
 		date_default_timezone_set('UTC');
979
-		$filter_query = $this->getFilter($filter,true,true);
979
+		$filter_query = $this->getFilter($filter, true, true);
980 980
 		
981 981
 		$limit_query = '';
982 982
 		if ($limit != "")
983 983
 		{
984 984
 			$limit_array = explode(",", $limit);
985 985
 			
986
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
986
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
987
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
988 988
 			
989 989
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990 990
 			{
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1002 1002
 		}
1003 1003
 
1004
-		$query  = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1004
+		$query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1005 1005
 
1006 1006
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1007 1007
 
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 		
1022 1022
 		date_default_timezone_set('UTC');
1023 1023
 		
1024
-		$filter_query = $this->getFilter($filter,true,true);
1024
+		$filter_query = $this->getFilter($filter, true, true);
1025 1025
 		
1026 1026
 		$limit_query = '';
1027 1027
 		
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 		{
1030 1030
 			$limit_array = explode(",", $limit);
1031 1031
 			
1032
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1033
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1032
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1033
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1034 1034
 			
1035 1035
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1036 1036
 			{
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1048 1048
 		}
1049 1049
 
1050
-		$query  = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1050
+		$query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1051 1051
 
1052 1052
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1053 1053
 
@@ -1066,14 +1066,14 @@  discard block
 block discarded – undo
1066 1066
 		global $global_query;
1067 1067
 		
1068 1068
 		date_default_timezone_set('UTC');
1069
-		$filter_query = $this->getFilter($filter,true,true);
1069
+		$filter_query = $this->getFilter($filter, true, true);
1070 1070
 		$limit_query = '';
1071 1071
 		if ($limit != "")
1072 1072
 		{
1073 1073
 			$limit_array = explode(",", $limit);
1074 1074
 			
1075
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1076
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1075
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1076
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1077 1077
 			
1078 1078
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1079 1079
 			{
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1091 1091
 		}
1092 1092
 
1093
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1093
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1094 1094
 
1095 1095
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1096 1096
 
@@ -1114,9 +1114,9 @@  discard block
 block discarded – undo
1114 1114
 		$query_values = array(':id' => $id);
1115 1115
 
1116 1116
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1117
-		$query  = $global_query." WHERE ".$additional_query." ";
1117
+		$query = $global_query." WHERE ".$additional_query." ";
1118 1118
 
1119
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1119
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1120 1120
 
1121 1121
 		return $spotter_array;
1122 1122
 	}
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		{
1155 1155
 			$limit_array = explode(",", $limit);
1156 1156
 			
1157
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1158
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1157
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1158
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1159 1159
 			
1160 1160
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1161 1161
 			{
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		$query_values = array();
1197 1197
 		$limit_query = '';
1198 1198
 		$additional_query = '';
1199
-		$filter_query = $this->getFilter($filter,true,true);
1199
+		$filter_query = $this->getFilter($filter, true, true);
1200 1200
 		
1201 1201
 		if ($aircraft_type != "")
1202 1202
 		{
@@ -1213,8 +1213,8 @@  discard block
 block discarded – undo
1213 1213
 		{
1214 1214
 			$limit_array = explode(",", $limit);
1215 1215
 			
1216
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1217
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1216
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1217
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1218 1218
 			
1219 1219
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1220 1220
 			{
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 		$query_values = array();
1255 1255
 		$limit_query = '';
1256 1256
 		$additional_query = '';
1257
-		$filter_query = $this->getFilter($filter,true,true);
1257
+		$filter_query = $this->getFilter($filter, true, true);
1258 1258
 		
1259 1259
 		if ($registration != "")
1260 1260
 		{
@@ -1271,8 +1271,8 @@  discard block
 block discarded – undo
1271 1271
 		{
1272 1272
 			$limit_array = explode(",", $limit);
1273 1273
 			
1274
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1275
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1274
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1275
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1276 1276
 			
1277 1277
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1278 1278
 			{
@@ -1330,8 +1330,8 @@  discard block
 block discarded – undo
1330 1330
 		{
1331 1331
 			$limit_array = explode(",", $limit);
1332 1332
 			
1333
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1334
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1333
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1334
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1335 1335
 			
1336 1336
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1337 1337
 			{
@@ -1385,8 +1385,8 @@  discard block
 block discarded – undo
1385 1385
 		{
1386 1386
 			$limit_array = explode(",", $limit);
1387 1387
 			
1388
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1389
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1388
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1389
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1390 1390
 			
1391 1391
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1392 1392
 			{
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
 	* @return Array the spotter information
1419 1419
 	*
1420 1420
 	*/
1421
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1421
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1422 1422
 	{
1423 1423
 		global $global_query, $globalTimezone, $globalDBdriver;
1424 1424
 		
@@ -1428,19 +1428,19 @@  discard block
 block discarded – undo
1428 1428
 
1429 1429
 		$filter_query = '';
1430 1430
 		if (isset($filter['source']) && !empty($filter['source'])) {
1431
-			$filter_query = " AND format_source IN ('".implode("','",$filter['source'])."')";
1431
+			$filter_query = " AND format_source IN ('".implode("','", $filter['source'])."')";
1432 1432
 		}
1433 1433
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
1434
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1434
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1435 1435
 		}
1436 1436
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
1437 1437
 			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
1438 1438
 		}
1439 1439
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
1440
-			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
1440
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
1441 1441
 		}
1442 1442
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
1443
-			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1443
+			$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
1444 1444
 		}
1445 1445
 	
1446 1446
 		
@@ -1468,8 +1468,8 @@  discard block
 block discarded – undo
1468 1468
 		{
1469 1469
 			$limit_array = explode(",", $limit);
1470 1470
 			
1471
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1472
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1471
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1472
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1473 1473
 			
1474 1474
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1475 1475
 			{
@@ -1524,8 +1524,8 @@  discard block
 block discarded – undo
1524 1524
 		{
1525 1525
 			$limit_array = explode(",", $limit);
1526 1526
 			
1527
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1528
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1527
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1528
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1529 1529
 			
1530 1530
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1531 1531
 			{
@@ -1581,8 +1581,8 @@  discard block
 block discarded – undo
1581 1581
 		{
1582 1582
 			$limit_array = explode(",", $limit);
1583 1583
 			
1584
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1585
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1584
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1585
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1586 1586
 			
1587 1587
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1588 1588
 			{
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 			{
1631 1631
 				return false;
1632 1632
 			} else {
1633
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1633
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1634 1634
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1635 1635
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
1636 1636
 			}
@@ -1642,9 +1642,9 @@  discard block
 block discarded – undo
1642 1642
 			{
1643 1643
 				return false;
1644 1644
 			} else {
1645
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1645
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1646 1646
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1647
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1647
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1648 1648
 			}
1649 1649
 		}
1650 1650
 		
@@ -1652,8 +1652,8 @@  discard block
 block discarded – undo
1652 1652
 		{
1653 1653
 			$limit_array = explode(",", $limit);
1654 1654
 			
1655
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1656
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1655
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1656
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1657 1657
 			
1658 1658
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1659 1659
 			{
@@ -1692,15 +1692,15 @@  discard block
 block discarded – undo
1692 1692
 		global $global_query;
1693 1693
 		
1694 1694
 		date_default_timezone_set('UTC');
1695
-		$filter_query = $this->getFilter($filter,true,true);
1695
+		$filter_query = $this->getFilter($filter, true, true);
1696 1696
 		$limit_query = '';
1697 1697
 		
1698 1698
 		if ($limit != "")
1699 1699
 		{
1700 1700
 			$limit_array = explode(",", $limit);
1701 1701
 			
1702
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1703
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1702
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1703
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1704 1704
 			
1705 1705
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1706 1706
 			{
@@ -1717,7 +1717,7 @@  discard block
 block discarded – undo
1717 1717
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1718 1718
 		}
1719 1719
 
1720
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1720
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1721 1721
 
1722 1722
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1723 1723
 
@@ -1730,19 +1730,19 @@  discard block
 block discarded – undo
1730 1730
 	* @return String the highlight text
1731 1731
 	*
1732 1732
 	*/
1733
-	public function getHighlightByRegistration($registration,$filter = array())
1733
+	public function getHighlightByRegistration($registration, $filter = array())
1734 1734
 	{
1735 1735
 		global $global_query;
1736 1736
 		
1737 1737
 		date_default_timezone_set('UTC');
1738
-		$filter_query = $this->getFilter($filter,true,true);
1739
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1738
+		$filter_query = $this->getFilter($filter, true, true);
1739
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1740 1740
 		
1741
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1741
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1742 1742
 		$sth = $this->db->prepare($query);
1743 1743
 		$sth->execute(array(':registration' => $registration));
1744 1744
 
1745
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1745
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1746 1746
 		{
1747 1747
 			$highlight = $row['highlight'];
1748 1748
 		}
@@ -1758,14 +1758,14 @@  discard block
 block discarded – undo
1758 1758
 	* @return String usage
1759 1759
 	*
1760 1760
 	*/
1761
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1761
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1762 1762
 	{
1763 1763
 		
1764
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
1765
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
1764
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
1765
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
1766 1766
 
1767 1767
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
1768
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
1768
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
1769 1769
 		
1770 1770
 		$sth = $this->db->prepare($query);
1771 1771
 		$sth->execute($query_values);
@@ -1786,9 +1786,9 @@  discard block
 block discarded – undo
1786 1786
 	public function getAirportIcao($airport_iata = '')
1787 1787
 	{
1788 1788
 		
1789
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
1789
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
1790 1790
 
1791
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1791
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
1792 1792
 		$query_values = array(':airport' => $airport_iata);
1793 1793
 		
1794 1794
 		$sth = $this->db->prepare($query);
@@ -1809,12 +1809,12 @@  discard block
 block discarded – undo
1809 1809
 	* @return Float distance to the airport
1810 1810
 	*
1811 1811
 	*/
1812
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
1812
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
1813 1813
 	{
1814 1814
 		
1815
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
1815
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
1816 1816
 
1817
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1817
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
1818 1818
 		$query_values = array(':airport' => $airport_icao);
1819 1819
 		$sth = $this->db->prepare($query);
1820 1820
 		$sth->execute($query_values);
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
 			$airport_latitude = $row['latitude'];
1824 1824
 			$airport_longitude = $row['longitude'];
1825 1825
 			$Common = new Common();
1826
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1826
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
1827 1827
 		} else return '';
1828 1828
 	}
1829 1829
 	
@@ -1837,11 +1837,11 @@  discard block
 block discarded – undo
1837 1837
 	public function getAllAirportInfo($airport = '')
1838 1838
 	{
1839 1839
 		
1840
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
1840
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
1841 1841
 
1842 1842
 		$query_values = array();
1843 1843
 		if ($airport == 'NA') {
1844
-			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => ''));
1844
+			return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => ''));
1845 1845
 		} elseif ($airport == '') {
1846 1846
 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport";
1847 1847
 		} else {
@@ -1889,14 +1889,14 @@  discard block
 block discarded – undo
1889 1889
 	{
1890 1890
 		$lst_countries = '';
1891 1891
 		foreach ($countries as $country) {
1892
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
1892
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
1893 1893
 			if ($lst_countries == '') {
1894 1894
 				$lst_countries = "'".$country."'";
1895 1895
 			} else {
1896 1896
 				$lst_countries .= ",'".$country."'";
1897 1897
 			}
1898 1898
 		}
1899
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1899
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
1900 1900
 		
1901 1901
 		$sth = $this->db->prepare($query);
1902 1902
 		$sth->execute();
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 		$airport_array = array();
1905 1905
 		$temp_array = array();
1906 1906
 		
1907
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1907
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1908 1908
 		{
1909 1909
 			$temp_array['name'] = $row['name'];
1910 1910
 			$temp_array['city'] = $row['city'];
@@ -1932,10 +1932,10 @@  discard block
 block discarded – undo
1932 1932
 	{
1933 1933
 		global $globalDBdriver;
1934 1934
 		if (is_array($coord)) {
1935
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1936
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1937
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1938
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1935
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1936
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1937
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1938
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1939 1939
 		} else return array();
1940 1940
 		if ($globalDBdriver == 'mysql') {
1941 1941
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
     
1948 1948
 		$airport_array = array();
1949 1949
 		
1950
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1950
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1951 1951
 		{
1952 1952
 			$temp_array = $row;
1953 1953
 
@@ -1967,13 +1967,13 @@  discard block
 block discarded – undo
1967 1967
 	public function getAllWaypointsInfobyCoord($coord)
1968 1968
 	{
1969 1969
 		if (is_array($coord)) {
1970
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1971
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1972
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1973
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1970
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1971
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1972
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1973
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1974 1974
 		} else return array();
1975 1975
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
1976
-		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
1976
+		$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
1977 1977
 		//$query  = "SELECT waypoints.* FROM waypoints";
1978 1978
 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end";
1979 1979
 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
@@ -1985,7 +1985,7 @@  discard block
 block discarded – undo
1985 1985
     
1986 1986
 		$waypoints_array = array();
1987 1987
 		
1988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1989 1989
 		{
1990 1990
 			$temp_array = $row;
1991 1991
 
@@ -2005,10 +2005,10 @@  discard block
 block discarded – undo
2005 2005
 	*/
2006 2006
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2007 2007
 	{
2008
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2008
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2009 2009
 		if ($airline_icao == 'NA') {
2010 2010
 			$airline_array = array();
2011
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2011
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2012 2012
 			return $airline_array;
2013 2013
 		} else {
2014 2014
 			if (strlen($airline_icao) == 2) {
@@ -2029,7 +2029,7 @@  discard block
 block discarded – undo
2029 2029
 			if ($fromsource === NULL) {
2030 2030
 				$sth->execute(array(':airline_icao' => $airline_icao));
2031 2031
 			} else {
2032
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2032
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2033 2033
 			}
2034 2034
                         /*
2035 2035
 			$airline_array = array();
@@ -2070,12 +2070,12 @@  discard block
 block discarded – undo
2070 2070
 	*/
2071 2071
 	public function getAllAircraftInfo($aircraft_type)
2072 2072
 	{
2073
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2073
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2074 2074
 
2075 2075
 		if ($aircraft_type == 'NA') {
2076
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2076
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2077 2077
 		}
2078
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2078
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow FROM aircraft WHERE aircraft.icao = :aircraft_type";
2079 2079
 		
2080 2080
 		$sth = $this->db->prepare($query);
2081 2081
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2107,7 +2107,7 @@  discard block
 block discarded – undo
2107 2107
 	*/
2108 2108
 	public function getAircraftIcao($aircraft_type)
2109 2109
 	{
2110
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2110
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2111 2111
 		$all_aircraft = array('737-300' => 'B733',
2112 2112
 				'777-200' => 'B772',
2113 2113
 				'777-200ER' => 'B772',
@@ -2119,10 +2119,10 @@  discard block
 block discarded – undo
2119 2119
 				'A380' => 'A388');
2120 2120
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2121 2121
 
2122
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2122
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2123 2123
 		$aircraft_type = strtoupper($aircraft_type);
2124 2124
 		$sth = $this->db->prepare($query);
2125
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2125
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2126 2126
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2127 2127
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2128 2128
 		else return '';
@@ -2137,9 +2137,9 @@  discard block
 block discarded – undo
2137 2137
 	*/
2138 2138
 	public function getAllAircraftType($aircraft_modes)
2139 2139
 	{
2140
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2140
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2141 2141
 
2142
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2142
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
2143 2143
 		
2144 2144
 		$sth = $this->db->prepare($query);
2145 2145
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -2159,8 +2159,8 @@  discard block
 block discarded – undo
2159 2159
 	*/
2160 2160
 	public function getOperator($operator)
2161 2161
 	{
2162
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2163
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2162
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2163
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2164 2164
 		
2165 2165
 		$sth = $this->db->prepare($query);
2166 2166
 		$sth->execute(array(':operator' => $operator));
@@ -2180,9 +2180,9 @@  discard block
 block discarded – undo
2180 2180
 	*/
2181 2181
 	public function getRouteInfo($callsign)
2182 2182
 	{
2183
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2183
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2184 2184
                 if ($callsign == '') return array();
2185
-		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2185
+		$query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2186 2186
 		
2187 2187
 		$sth = $this->db->prepare($query);
2188 2188
 		$sth->execute(array(':callsign' => $callsign));
@@ -2202,9 +2202,9 @@  discard block
 block discarded – undo
2202 2202
 	*/
2203 2203
 	public function getAircraftInfoByRegistration($registration)
2204 2204
 	{
2205
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2205
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2206 2206
 
2207
-		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2207
+		$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2208 2208
 		
2209 2209
 		$sth = $this->db->prepare($query);
2210 2210
 		$sth->execute(array(':registration' => $registration));
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 		$aircraft_array = array();
2213 2213
 		$temp_array = array();
2214 2214
 		
2215
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2215
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2216 2216
 		{
2217 2217
 			$temp_array['airline_icao'] = $row['airline_icao'];
2218 2218
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2234,10 +2234,10 @@  discard block
 block discarded – undo
2234 2234
 	*/
2235 2235
 	public function getAircraftOwnerByRegistration($registration)
2236 2236
 	{
2237
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2237
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2238 2238
 		$Connection = new Connection($this->db);
2239 2239
 		if ($Connection->tableExists('aircraft_owner')) {
2240
-			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
2240
+			$query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
2241 2241
 			$sth = $this->db->prepare($query);
2242 2242
 			$sth->execute(array(':registration' => $registration));
2243 2243
 
@@ -2255,7 +2255,7 @@  discard block
 block discarded – undo
2255 2255
 	public function getAllFlightsforSitemap()
2256 2256
 	{
2257 2257
 		//$query  = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT ";
2258
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2258
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2259 2259
 		
2260 2260
 		$sth = $this->db->prepare($query);
2261 2261
 		$sth->execute();
@@ -2302,7 +2302,7 @@  discard block
 block discarded – undo
2302 2302
 		$manufacturer_array = array();
2303 2303
 		$temp_array = array();
2304 2304
 		
2305
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2305
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2306 2306
 		{
2307 2307
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2308 2308
 
@@ -2336,7 +2336,7 @@  discard block
 block discarded – undo
2336 2336
 		$aircraft_array = array();
2337 2337
 		$temp_array = array();
2338 2338
 		
2339
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2339
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2340 2340
 		{
2341 2341
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2342 2342
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2357,7 +2357,7 @@  discard block
 block discarded – undo
2357 2357
 	*/
2358 2358
 	public function getAllAircraftRegistrations()
2359 2359
 	{
2360
-		$query  = "SELECT DISTINCT spotter_output.registration 
2360
+		$query = "SELECT DISTINCT spotter_output.registration 
2361 2361
 				FROM spotter_output  
2362 2362
 				WHERE spotter_output.registration <> '' 
2363 2363
 				ORDER BY spotter_output.registration ASC";
@@ -2368,7 +2368,7 @@  discard block
 block discarded – undo
2368 2368
 		$aircraft_array = array();
2369 2369
 		$temp_array = array();
2370 2370
 		
2371
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2371
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2372 2372
 		{
2373 2373
 			$temp_array['registration'] = $row['registration'];
2374 2374
 
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 	public function getAllSourceName($type = '')
2389 2389
 	{
2390 2390
 		$query_values = array();
2391
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2391
+		$query = "SELECT DISTINCT spotter_output.source_name 
2392 2392
 				FROM spotter_output  
2393 2393
 				WHERE spotter_output.source_name <> ''";
2394 2394
 		if ($type != '') {
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
 		$source_array = array();
2405 2405
 		$temp_array = array();
2406 2406
 		
2407
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2407
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2408 2408
 		{
2409 2409
 			$temp_array['source_name'] = $row['source_name'];
2410 2410
 			$source_array[] = $temp_array;
@@ -2420,10 +2420,10 @@  discard block
 block discarded – undo
2420 2420
 	* @return Array list of airline names
2421 2421
 	*
2422 2422
 	*/
2423
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL)
2423
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL)
2424 2424
 	{
2425
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2426
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2425
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2426
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2427 2427
 		if ($airline_type == '' || $airline_type == 'all') {
2428 2428
 			/*
2429 2429
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 				$query_data = array(':forsource' => $forsource);
2443 2443
 			}
2444 2444
 		} else {
2445
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2445
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2446 2446
 					FROM spotter_output
2447 2447
 					WHERE spotter_output.airline_icao <> '' 
2448 2448
 					AND spotter_output.airline_type = :airline_type 
@@ -2456,7 +2456,7 @@  discard block
 block discarded – undo
2456 2456
 		$airline_array = array();
2457 2457
 		$temp_array = array();
2458 2458
 		
2459
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2459
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2460 2460
 		{
2461 2461
 			$temp_array['airline_icao'] = $row['airline_icao'];
2462 2462
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2477,7 +2477,7 @@  discard block
 block discarded – undo
2477 2477
 	public function getAllAirlineCountries()
2478 2478
 	{
2479 2479
 		
2480
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2480
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2481 2481
 				FROM spotter_output  
2482 2482
 				WHERE spotter_output.airline_country <> '' 
2483 2483
 				ORDER BY spotter_output.airline_country ASC";
@@ -2489,7 +2489,7 @@  discard block
 block discarded – undo
2489 2489
 		$airline_array = array();
2490 2490
 		$temp_array = array();
2491 2491
 		
2492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2493 2493
 		{
2494 2494
 			$temp_array['airline_country'] = $row['airline_country'];
2495 2495
 
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
 	{
2512 2512
 		$airport_array = array();
2513 2513
 
2514
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2514
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2515 2515
 				FROM spotter_output 
2516 2516
 				WHERE spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2517 2517
 				ORDER BY spotter_output.departure_airport_city ASC";
@@ -2521,7 +2521,7 @@  discard block
 block discarded – undo
2521 2521
 		$sth->execute();
2522 2522
 
2523 2523
 		$temp_array = array();
2524
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2524
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2525 2525
 		{
2526 2526
 			$temp_array['airport_icao'] = $row['airport_icao'];
2527 2527
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2531,7 +2531,7 @@  discard block
 block discarded – undo
2531 2531
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2532 2532
 		}
2533 2533
 
2534
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2534
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2535 2535
 								FROM spotter_output 
2536 2536
 								WHERE spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2537 2537
 								ORDER BY spotter_output.arrival_airport_city ASC";
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
 		$sth = $this->db->prepare($query);
2540 2540
 		$sth->execute();
2541 2541
 
2542
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2542
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2543 2543
 			{
2544 2544
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2545 2545
 		//	{
@@ -2579,14 +2579,14 @@  discard block
 block discarded – undo
2579 2579
    
2580 2580
 		$temp_array = array();
2581 2581
 		
2582
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2582
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2583 2583
 		{
2584 2584
 			$temp_array['airport_country'] = $row['airport_country'];
2585 2585
 
2586 2586
 			$airport_array[$row['airport_country']] = $temp_array;
2587 2587
 		}
2588 2588
 								
2589
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2589
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2590 2590
 								FROM spotter_output
2591 2591
 								WHERE spotter_output.arrival_airport_country <> '' 
2592 2592
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
 		$sth = $this->db->prepare($query);
2595 2595
 		$sth->execute();
2596 2596
 		
2597
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2597
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2598 2598
 		{
2599 2599
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
2600 2600
 			{
@@ -2617,9 +2617,9 @@  discard block
 block discarded – undo
2617 2617
 	*/
2618 2618
 	public function getAllCountries()
2619 2619
 	{
2620
-		$Connection= new Connection($this->db);
2620
+		$Connection = new Connection($this->db);
2621 2621
 		if ($Connection->tableExists('countries')) {
2622
-			$query  = "SELECT countries.name AS airport_country
2622
+			$query = "SELECT countries.name AS airport_country
2623 2623
 				FROM countries
2624 2624
 				ORDER BY countries.name ASC";
2625 2625
 			$sth = $this->db->prepare($query);
@@ -2628,13 +2628,13 @@  discard block
 block discarded – undo
2628 2628
 			$temp_array = array();
2629 2629
 			$country_array = array();
2630 2630
 		
2631
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2631
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2632 2632
 			{
2633 2633
 				$temp_array['country'] = $row['airport_country'];
2634 2634
 				$country_array[$row['airport_country']] = $temp_array;
2635 2635
 			}
2636 2636
 		} else {
2637
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2637
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
2638 2638
 								FROM spotter_output
2639 2639
 								WHERE spotter_output.departure_airport_country <> '' 
2640 2640
 								ORDER BY spotter_output.departure_airport_country ASC";
@@ -2644,13 +2644,13 @@  discard block
 block discarded – undo
2644 2644
    
2645 2645
 			$temp_array = array();
2646 2646
 			$country_array = array();
2647
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
2647
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2648 2648
 			{
2649 2649
 				$temp_array['country'] = $row['airport_country'];
2650 2650
 				$country_array[$row['airport_country']] = $temp_array;
2651 2651
 			}
2652 2652
 
2653
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2653
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2654 2654
 								FROM spotter_output
2655 2655
 								WHERE spotter_output.arrival_airport_country <> '' 
2656 2656
 								ORDER BY spotter_output.arrival_airport_country ASC";
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
 		$sth = $this->db->prepare($query);
2659 2659
 		$sth->execute();
2660 2660
 		
2661
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2661
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2662 2662
 		{
2663 2663
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
2664 2664
 			{
@@ -2668,7 +2668,7 @@  discard block
 block discarded – undo
2668 2668
 			}
2669 2669
 		}
2670 2670
 		
2671
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2671
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2672 2672
 								FROM spotter_output  
2673 2673
 								WHERE spotter_output.airline_country <> '' 
2674 2674
 								ORDER BY spotter_output.airline_country ASC";
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 		$sth = $this->db->prepare($query);
2677 2677
 		$sth->execute();
2678 2678
 		
2679
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2679
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2680 2680
 		{
2681 2681
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
2682 2682
 			{
@@ -2700,7 +2700,7 @@  discard block
 block discarded – undo
2700 2700
 	*/
2701 2701
 	public function getAllIdents()
2702 2702
 	{
2703
-		$query  = "SELECT DISTINCT spotter_output.ident
2703
+		$query = "SELECT DISTINCT spotter_output.ident
2704 2704
 								FROM spotter_output
2705 2705
 								WHERE spotter_output.ident <> '' 
2706 2706
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
 		$ident_array = array();
2712 2712
 		$temp_array = array();
2713 2713
 		
2714
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2714
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2715 2715
 		{
2716 2716
 			$temp_array['ident'] = $row['ident'];
2717 2717
 			$ident_array[] = $temp_array;
@@ -3047,12 +3047,12 @@  discard block
 block discarded – undo
3047 3047
 		} else $offset = '+00:00';
3048 3048
 
3049 3049
 		if ($globalDBdriver == 'mysql') {
3050
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3050
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3051 3051
 								FROM spotter_output
3052 3052
 								WHERE spotter_output.date <> '' 
3053 3053
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3054 3054
 		} else {
3055
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3055
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3056 3056
 								FROM spotter_output
3057 3057
 								WHERE spotter_output.date <> '' 
3058 3058
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3064,7 +3064,7 @@  discard block
 block discarded – undo
3064 3064
 		$date_array = array();
3065 3065
 		$temp_array = array();
3066 3066
 		
3067
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3067
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3068 3068
 		{
3069 3069
 			$temp_array['date'] = $row['date'];
3070 3070
 
@@ -3084,7 +3084,7 @@  discard block
 block discarded – undo
3084 3084
 	*/
3085 3085
 	public function getAllRoutes()
3086 3086
 	{
3087
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3087
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route,  spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao 
3088 3088
 				FROM spotter_output
3089 3089
 				WHERE spotter_output.ident <> '' 
3090 3090
 				GROUP BY route
@@ -3095,7 +3095,7 @@  discard block
 block discarded – undo
3095 3095
 
3096 3096
 		$routes_array = array();
3097 3097
 		$temp_array = array();
3098
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3098
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3099 3099
 		{
3100 3100
 			$temp_array['route'] = $row['route'];
3101 3101
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3114,21 +3114,21 @@  discard block
 block discarded – undo
3114 3114
 	* @return String success or false
3115 3115
 	*
3116 3116
 	*/	
3117
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3117
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3118 3118
 	{
3119 3119
 		if (!is_numeric(substr($ident, 0, 3)))
3120 3120
 		{
3121 3121
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3122
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3122
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3123 3123
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3124
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3124
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3125 3125
 			} else {
3126 3126
 				$airline_array = $this->getAllAirlineInfo("NA");
3127 3127
 			}
3128 3128
 			if (count($airline_array) == 0) {
3129 3129
 				$airline_array = $this->getAllAirlineInfo("NA");
3130 3130
 			}
3131
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3131
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3132 3132
 				$airline_array = $this->getAllAirlineInfo("NA");
3133 3133
 			}
3134 3134
 		} else {
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 
3142 3142
 
3143 3143
 		$query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id';
3144
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type);
3144
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type);
3145 3145
 
3146 3146
 		try {
3147 3147
 			$sth = $this->db->prepare($query);
@@ -3162,11 +3162,11 @@  discard block
 block discarded – undo
3162 3162
 	* @return String success or false
3163 3163
 	*
3164 3164
 	*/	
3165
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3165
+	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '')
3166 3166
 	{
3167 3167
 		if ($groundspeed == '') $groundspeed = NULL;
3168 3168
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3169
-                $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3169
+                $query_values = array(':flightaware_id' => $flightaware_id, ':real_arrival_airport_icao' => $arrival_airport_icao, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3170 3170
 
3171 3171
 		try {
3172 3172
 			$sth = $this->db->prepare($query);
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 	* @param String $verticalrate vertival rate of flight
3207 3207
 	* @return String success or false
3208 3208
 	*/
3209
-	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '')
3209
+	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '')
3210 3210
 	{
3211 3211
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
3212 3212
 		
@@ -3230,13 +3230,13 @@  discard block
 block discarded – undo
3230 3230
 				if ($ModeS != '') {
3231 3231
 					$timeelapsed = microtime(true);
3232 3232
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3233
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3233
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3234 3234
 				} else {
3235
-					$myhex = explode('-',$flightaware_id);
3235
+					$myhex = explode('-', $flightaware_id);
3236 3236
 					if (count($myhex) > 0) {
3237 3237
 						$timeelapsed = microtime(true);
3238 3238
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3239
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3239
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3240 3240
 					}
3241 3241
 				}
3242 3242
 			}
@@ -3258,24 +3258,24 @@  discard block
 block discarded – undo
3258 3258
 				{
3259 3259
 					$timeelapsed = microtime(true);
3260 3260
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3261
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3261
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3262 3262
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3263
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3263
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3264 3264
 					} else {
3265 3265
 						$airline_array = $this->getAllAirlineInfo("NA");
3266 3266
 					}
3267 3267
 					if (count($airline_array) == 0) {
3268 3268
 						$airline_array = $this->getAllAirlineInfo("NA");
3269 3269
 					}
3270
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3270
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3271 3271
 						$airline_array = $this->getAllAirlineInfo("NA");
3272 3272
 					}
3273
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3273
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3274 3274
 
3275 3275
 				} else {
3276 3276
 					$timeelapsed = microtime(true);
3277 3277
 					$airline_array = $this->getAllAirlineInfo("NA");
3278
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3278
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3279 3279
 				}
3280 3280
 			}
3281 3281
 		} else $airline_array = array();
@@ -3292,27 +3292,27 @@  discard block
 block discarded – undo
3292 3292
 				{
3293 3293
 					$timeelapsed = microtime(true);
3294 3294
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3295
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3295
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3296 3296
 				} else {
3297 3297
 					$timeelapsed = microtime(true);
3298 3298
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3299
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3299
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3300 3300
 				}
3301 3301
 			}
3302 3302
 		} else {
3303 3303
 			if ($ModeS != '') {
3304 3304
 				$timeelapsed = microtime(true);
3305 3305
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3306
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3306
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3307 3307
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3308 3308
 				{
3309 3309
 					$timeelapsed = microtime(true);
3310 3310
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3311
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3311
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3312 3312
 				} else {
3313 3313
 					$timeelapsed = microtime(true);
3314 3314
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3315
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3315
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3316 3316
 				}
3317 3317
 			}
3318 3318
 		}
@@ -3327,7 +3327,7 @@  discard block
 block discarded – undo
3327 3327
 			} else {
3328 3328
 				$timeelapsed = microtime(true);
3329 3329
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3330
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3330
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3331 3331
 			}
3332 3332
 		}
3333 3333
 		
@@ -3341,7 +3341,7 @@  discard block
 block discarded – undo
3341 3341
 			} else {
3342 3342
 				$timeelapsed = microtime(true);
3343 3343
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3344
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3344
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3345 3345
 			}
3346 3346
 		}
3347 3347
 
@@ -3405,7 +3405,7 @@  discard block
 block discarded – undo
3405 3405
 		{
3406 3406
 			$timeelapsed = microtime(true);
3407 3407
 			$image_array = $Image->getSpotterImage($registration);
3408
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3408
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3409 3409
 			if (!isset($image_array[0]['registration']))
3410 3410
 			{
3411 3411
 				//echo "Add image !!!! \n";
@@ -3413,7 +3413,7 @@  discard block
 block discarded – undo
3413 3413
 			}
3414 3414
 			$timeelapsed = microtime(true);
3415 3415
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3416
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3416
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3417 3417
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3418 3418
 		}
3419 3419
     
@@ -3421,33 +3421,33 @@  discard block
 block discarded – undo
3421 3421
 		{
3422 3422
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3423 3423
             		else $airline_icao = '';
3424
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3424
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3425 3425
 			if (!isset($image_array[0]['registration']))
3426 3426
 			{
3427 3427
 				//echo "Add image !!!! \n";
3428
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3428
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3429 3429
 			}
3430 3430
 		}
3431 3431
     
3432
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3433
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3434
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3435
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3436
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3437
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3438
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3439
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3440
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3441
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3442
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3443
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3444
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3445
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3446
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3447
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3448
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3449
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3450
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3432
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3433
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3434
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3435
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3436
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3437
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3438
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3439
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3440
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3441
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3442
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3443
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3444
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3445
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3446
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3447
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3448
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3449
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3450
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3451 3451
 	
3452 3452
 		if (count($airline_array) == 0) 
3453 3453
 		{
@@ -3471,7 +3471,7 @@  discard block
 block discarded – undo
3471 3471
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3472 3472
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3473 3473
                 if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3474
-                $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3474
+                $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3475 3475
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3476 3476
 
3477 3477
                 $airline_name = $airline_array[0]['name'];
@@ -3481,7 +3481,7 @@  discard block
 block discarded – undo
3481 3481
 		if ($airline_type == '') {
3482 3482
 			$timeelapsed = microtime(true);
3483 3483
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3484
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3484
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3485 3485
 		}
3486 3486
 		if ($airline_type == null) $airline_type = '';
3487 3487
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3492,7 +3492,7 @@  discard block
 block discarded – undo
3492 3492
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3493 3493
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3494 3494
                 $arrival_airport_country = $arrival_airport_array[0]['country'];
3495
-                $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3495
+                $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name);
3496 3496
 
3497 3497
 		try {
3498 3498
 		        
@@ -3518,13 +3518,13 @@  discard block
 block discarded – undo
3518 3518
 	{
3519 3519
 		global $globalDBdriver, $globalTimezone;
3520 3520
 		if ($globalDBdriver == 'mysql') {
3521
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3521
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3522 3522
 								WHERE spotter_output.ident = :ident 
3523 3523
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3524 3524
 								AND spotter_output.date < UTC_TIMESTAMP()";
3525 3525
 			$query_data = array(':ident' => $ident);
3526 3526
 		} else {
3527
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3527
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3528 3528
 								WHERE spotter_output.ident = :ident 
3529 3529
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3530 3530
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
@@ -3533,8 +3533,8 @@  discard block
 block discarded – undo
3533 3533
 		
3534 3534
 		$sth = $this->db->prepare($query);
3535 3535
 		$sth->execute($query_data);
3536
-    		$ident_result='';
3537
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3536
+    		$ident_result = '';
3537
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3538 3538
 		{
3539 3539
 			$ident_result = $row['ident'];
3540 3540
 		}
@@ -3560,8 +3560,8 @@  discard block
 block discarded – undo
3560 3560
 				return false;
3561 3561
 			} else {
3562 3562
 				$q_array = explode(" ", $q);
3563
-				foreach ($q_array as $q_item){
3564
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3563
+				foreach ($q_array as $q_item) {
3564
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3565 3565
 					$additional_query .= " AND (";
3566 3566
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3567 3567
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3576,11 +3576,11 @@  discard block
 block discarded – undo
3576 3576
 			}
3577 3577
 		}
3578 3578
 		if ($globalDBdriver == 'mysql') {
3579
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3579
+			$query = "SELECT spotter_output.* FROM spotter_output 
3580 3580
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3581 3581
 				AND spotter_output.date < UTC_TIMESTAMP()";
3582 3582
 		} else {
3583
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3583
+			$query = "SELECT spotter_output.* FROM spotter_output 
3584 3584
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3585 3585
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3586 3586
 		}
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3601 3601
 	{
3602 3602
 		global $globalDBdriver;
3603
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3603
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3604 3604
 		 			FROM spotter_output
3605 3605
 					WHERE spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA' ";
3606 3606
 		if ($olderthanmonths > 0) {
@@ -3625,7 +3625,7 @@  discard block
 block discarded – undo
3625 3625
  
3626 3626
 		$airline_array = array();
3627 3627
 		$temp_array = array();
3628
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3628
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3629 3629
 		{
3630 3630
 			$temp_array['airline_name'] = $row['airline_name'];
3631 3631
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3642,11 +3642,11 @@  discard block
 block discarded – undo
3642 3642
 	* @return Array the pilots list
3643 3643
 	*
3644 3644
 	*/
3645
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3645
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3646 3646
 	{
3647 3647
 		global $globalDBdriver;
3648
-		$filter_query = $this->getFilter($filters,true,true);
3649
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3648
+		$filter_query = $this->getFilter($filters, true, true);
3649
+		$query = "SELECT DISTINCT spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3650 3650
 		 			FROM spotter_output".$filter_query." spotter_output.pilot_id <> '' ";
3651 3651
                 if ($olderthanmonths > 0) {
3652 3652
             		if ($globalDBdriver == 'mysql') {
@@ -3672,7 +3672,7 @@  discard block
 block discarded – undo
3672 3672
 		$airline_array = array();
3673 3673
 		$temp_array = array();
3674 3674
         
3675
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3675
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3676 3676
 		{
3677 3677
 			$temp_array['pilot_name'] = $row['pilot_name'];
3678 3678
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3691,7 +3691,7 @@  discard block
 block discarded – undo
3691 3691
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3692 3692
 	{
3693 3693
 		global $globalDBdriver;
3694
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3694
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count
3695 3695
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
3696 3696
                 if ($olderthanmonths > 0) {
3697 3697
             		if ($globalDBdriver == 'mysql') {
@@ -3717,7 +3717,7 @@  discard block
 block discarded – undo
3717 3717
 		$airline_array = array();
3718 3718
 		$temp_array = array();
3719 3719
         
3720
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3720
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3721 3721
 		{
3722 3722
 			$temp_array['pilot_name'] = $row['pilot_name'];
3723 3723
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -3734,11 +3734,11 @@  discard block
 block discarded – undo
3734 3734
 	* @return Array the pilots list
3735 3735
 	*
3736 3736
 	*/
3737
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
3737
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
3738 3738
 	{
3739 3739
 		global $globalDBdriver;
3740
-		$filter_query = $this->getFilter($filters,true,true);
3741
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3740
+		$filter_query = $this->getFilter($filters, true, true);
3741
+		$query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3742 3742
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3743 3743
                 if ($olderthanmonths > 0) {
3744 3744
             		if ($globalDBdriver == 'mysql') {
@@ -3764,7 +3764,7 @@  discard block
 block discarded – undo
3764 3764
 		$airline_array = array();
3765 3765
 		$temp_array = array();
3766 3766
         
3767
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3767
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3768 3768
 		{
3769 3769
 			$temp_array['owner_name'] = $row['owner_name'];
3770 3770
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3782,7 +3782,7 @@  discard block
 block discarded – undo
3782 3782
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
3783 3783
 	{
3784 3784
 		global $globalDBdriver;
3785
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3785
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
3786 3786
 		 			FROM spotter_output WHERE spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
3787 3787
                 if ($olderthanmonths > 0) {
3788 3788
             		if ($globalDBdriver == 'mysql') {
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 		$airline_array = array();
3809 3809
 		$temp_array = array();
3810 3810
         
3811
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3811
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3812 3812
 		{
3813 3813
 			$temp_array['owner_name'] = $row['owner_name'];
3814 3814
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -3826,9 +3826,9 @@  discard block
 block discarded – undo
3826 3826
 	*/
3827 3827
 	public function countAllAirlinesByAircraft($aircraft_icao)
3828 3828
 	{
3829
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3829
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3830 3830
 
3831
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3831
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3832 3832
 		 			FROM spotter_output
3833 3833
 					WHERE spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
3834 3834
                     GROUP BY spotter_output.airline_name
@@ -3841,7 +3841,7 @@  discard block
 block discarded – undo
3841 3841
 		$airline_array = array();
3842 3842
 		$temp_array = array();
3843 3843
         
3844
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3844
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3845 3845
 		{
3846 3846
 			$temp_array['airline_name'] = $row['airline_name'];
3847 3847
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3863,9 +3863,9 @@  discard block
 block discarded – undo
3863 3863
 	*/
3864 3864
 	public function countAllAirlineCountriesByAircraft($aircraft_icao)
3865 3865
 	{
3866
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3866
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3867 3867
       
3868
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3868
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3869 3869
 		 			FROM spotter_output
3870 3870
 					WHERE spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
3871 3871
                     GROUP BY spotter_output.airline_country
@@ -3879,7 +3879,7 @@  discard block
 block discarded – undo
3879 3879
 		$airline_country_array = array();
3880 3880
 		$temp_array = array();
3881 3881
         
3882
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3882
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3883 3883
 		{
3884 3884
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3885 3885
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3900,9 +3900,9 @@  discard block
 block discarded – undo
3900 3900
 	*/
3901 3901
 	public function countAllAirlinesByAirport($airport_icao)
3902 3902
 	{
3903
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3903
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3904 3904
 
3905
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3905
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3906 3906
 		 			FROM spotter_output
3907 3907
 					WHERE spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) 
3908 3908
                     GROUP BY spotter_output.airline_name
@@ -3915,7 +3915,7 @@  discard block
 block discarded – undo
3915 3915
 		$airline_array = array();
3916 3916
 		$temp_array = array();
3917 3917
         
3918
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3918
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3919 3919
 		{
3920 3920
 			$temp_array['airline_name'] = $row['airline_name'];
3921 3921
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -3936,9 +3936,9 @@  discard block
 block discarded – undo
3936 3936
 	*/
3937 3937
 	public function countAllAirlineCountriesByAirport($airport_icao)
3938 3938
 	{
3939
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
3939
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
3940 3940
       
3941
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3941
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
3942 3942
 		 			FROM spotter_output
3943 3943
 					WHERE spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )
3944 3944
 					GROUP BY spotter_output.airline_country
@@ -3952,7 +3952,7 @@  discard block
 block discarded – undo
3952 3952
 		$airline_country_array = array();
3953 3953
 		$temp_array = array();
3954 3954
         
3955
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3955
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3956 3956
 		{
3957 3957
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
3958 3958
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -3971,9 +3971,9 @@  discard block
 block discarded – undo
3971 3971
 	*/
3972 3972
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer)
3973 3973
 	{
3974
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
3974
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
3975 3975
 
3976
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3976
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
3977 3977
 		 			FROM spotter_output
3978 3978
 					WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
3979 3979
 					GROUP BY spotter_output.airline_name
@@ -3985,7 +3985,7 @@  discard block
 block discarded – undo
3985 3985
 		$airline_array = array();
3986 3986
 		$temp_array = array();
3987 3987
         
3988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3989 3989
 		{
3990 3990
 			$temp_array['airline_name'] = $row['airline_name'];
3991 3991
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4007,9 +4007,9 @@  discard block
 block discarded – undo
4007 4007
 	*/
4008 4008
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer)
4009 4009
 	{
4010
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4010
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4011 4011
       
4012
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4012
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4013 4013
 		 			FROM spotter_output
4014 4014
 					WHERE spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4015 4015
 					GROUP BY spotter_output.airline_country
@@ -4023,7 +4023,7 @@  discard block
 block discarded – undo
4023 4023
 		$airline_country_array = array();
4024 4024
 		$temp_array = array();
4025 4025
         
4026
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4026
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4027 4027
 		{
4028 4028
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4029 4029
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4042,7 +4042,7 @@  discard block
 block discarded – undo
4042 4042
 	public function countAllAirlinesByDate($date)
4043 4043
 	{
4044 4044
 		global $globalTimezone, $globalDBdriver;
4045
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4045
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4046 4046
 
4047 4047
 		if ($globalTimezone != '') {
4048 4048
 			date_default_timezone_set($globalTimezone);
@@ -4051,13 +4051,13 @@  discard block
 block discarded – undo
4051 4051
 		} else $offset = '+00:00';
4052 4052
 
4053 4053
 		if ($globalDBdriver == 'mysql') {
4054
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4054
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4055 4055
 		 			FROM spotter_output
4056 4056
 					WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4057 4057
 					GROUP BY spotter_output.airline_name
4058 4058
 					ORDER BY airline_count DESC";
4059 4059
 		} else {
4060
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4060
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4061 4061
 		 			FROM spotter_output
4062 4062
 					WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4063 4063
 					GROUP BY spotter_output.airline_name
@@ -4069,7 +4069,7 @@  discard block
 block discarded – undo
4069 4069
 
4070 4070
 		$airline_array = array();
4071 4071
 		$temp_array = array();
4072
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4072
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4073 4073
 		{
4074 4074
 			$temp_array['airline_name'] = $row['airline_name'];
4075 4075
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4092,7 +4092,7 @@  discard block
 block discarded – undo
4092 4092
 	public function countAllAirlineCountriesByDate($date)
4093 4093
 	{
4094 4094
 		global $globalTimezone, $globalDBdriver;
4095
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4095
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4096 4096
 		if ($globalTimezone != '') {
4097 4097
 			date_default_timezone_set($globalTimezone);
4098 4098
 			$datetime = new DateTime($date);
@@ -4100,14 +4100,14 @@  discard block
 block discarded – undo
4100 4100
 		} else $offset = '+00:00';
4101 4101
 		
4102 4102
 		if ($globalDBdriver == 'mysql') {
4103
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4103
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4104 4104
 		 			FROM spotter_output
4105 4105
 					WHERE spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4106 4106
 					GROUP BY spotter_output.airline_country
4107 4107
 					ORDER BY airline_country_count DESC
4108 4108
 					LIMIT 10 OFFSET 0";
4109 4109
 		} else {
4110
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4110
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4111 4111
 		 			FROM spotter_output
4112 4112
 					WHERE spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4113 4113
 					GROUP BY spotter_output.airline_country
@@ -4120,7 +4120,7 @@  discard block
 block discarded – undo
4120 4120
  
4121 4121
 		$airline_country_array = array();
4122 4122
 		$temp_array = array();
4123
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4123
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4124 4124
 		{
4125 4125
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4126 4126
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4139,9 +4139,9 @@  discard block
 block discarded – undo
4139 4139
 	*/
4140 4140
 	public function countAllAirlinesByIdent($ident)
4141 4141
 	{
4142
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4142
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4143 4143
 
4144
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4144
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4145 4145
 		 		FROM spotter_output
4146 4146
 				WHERE spotter_output.ident = :ident  
4147 4147
 				GROUP BY spotter_output.airline_name
@@ -4154,7 +4154,7 @@  discard block
 block discarded – undo
4154 4154
 		$airline_array = array();
4155 4155
 		$temp_array = array();
4156 4156
         
4157
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4157
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4158 4158
 		{
4159 4159
 			$temp_array['airline_name'] = $row['airline_name'];
4160 4160
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4174,10 +4174,10 @@  discard block
 block discarded – undo
4174 4174
 	*/
4175 4175
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao)
4176 4176
 	{
4177
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4178
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4177
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4178
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4179 4179
 
4180
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4180
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4181 4181
 		 			FROM spotter_output
4182 4182
 					WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4183 4183
 					GROUP BY spotter_output.airline_name
@@ -4185,12 +4185,12 @@  discard block
 block discarded – undo
4185 4185
       
4186 4186
 		
4187 4187
 		$sth = $this->db->prepare($query);
4188
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4188
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4189 4189
       
4190 4190
 		$airline_array = array();
4191 4191
 		$temp_array = array();
4192 4192
         
4193
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4193
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4194 4194
 		{
4195 4195
 			$temp_array['airline_name'] = $row['airline_name'];
4196 4196
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4210,10 +4210,10 @@  discard block
 block discarded – undo
4210 4210
 	*/
4211 4211
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao)
4212 4212
 	{
4213
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4214
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4213
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4214
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4215 4215
       
4216
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4216
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4217 4217
 		 		FROM spotter_output
4218 4218
 				WHERE spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4219 4219
 				GROUP BY spotter_output.airline_country
@@ -4222,11 +4222,11 @@  discard block
 block discarded – undo
4222 4222
       
4223 4223
 		
4224 4224
 		$sth = $this->db->prepare($query);
4225
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4225
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4226 4226
       
4227 4227
 		$airline_country_array = array();
4228 4228
 		$temp_array = array();
4229
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4229
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4230 4230
 		{
4231 4231
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4232 4232
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4246,9 +4246,9 @@  discard block
 block discarded – undo
4246 4246
 	*/
4247 4247
 	public function countAllAirlinesByCountry($country)
4248 4248
 	{
4249
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4249
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4250 4250
 
4251
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4251
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4252 4252
 		 		FROM spotter_output
4253 4253
 				WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4254 4254
 				GROUP BY spotter_output.airline_name
@@ -4260,7 +4260,7 @@  discard block
 block discarded – undo
4260 4260
 
4261 4261
 		$airline_array = array();
4262 4262
 		$temp_array = array();
4263
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4263
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4264 4264
 		{
4265 4265
 			$temp_array['airline_name'] = $row['airline_name'];
4266 4266
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4281,9 +4281,9 @@  discard block
 block discarded – undo
4281 4281
 	*/
4282 4282
 	public function countAllAirlineCountriesByCountry($country)
4283 4283
 	{
4284
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4284
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4285 4285
       
4286
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4286
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4287 4287
 		 		FROM spotter_output
4288 4288
 				WHERE spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4289 4289
 				GROUP BY spotter_output.airline_country
@@ -4296,7 +4296,7 @@  discard block
 block discarded – undo
4296 4296
 
4297 4297
 		$airline_country_array = array();
4298 4298
 		$temp_array = array();
4299
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4299
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4300 4300
 		{
4301 4301
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4302 4302
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4315,7 +4315,7 @@  discard block
 block discarded – undo
4315 4315
 	*/
4316 4316
 	public function countAllAirlineCountries($limit = true)
4317 4317
 	{
4318
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4318
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4319 4319
 		 			FROM spotter_output
4320 4320
 					WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4321 4321
 					GROUP BY spotter_output.airline_country
@@ -4327,7 +4327,7 @@  discard block
 block discarded – undo
4327 4327
 
4328 4328
 		$airline_array = array();
4329 4329
 		$temp_array = array();
4330
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4330
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4331 4331
 		{
4332 4332
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4333 4333
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4343,10 +4343,10 @@  discard block
 block discarded – undo
4343 4343
 	* @return Array the airline country list
4344 4344
 	*
4345 4345
 	*/
4346
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
4346
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
4347 4347
 	{
4348 4348
 		global $globalDBdriver;
4349
-		$Connection= new Connection($this->db);
4349
+		$Connection = new Connection($this->db);
4350 4350
 		if (!$Connection->tableExists('countries')) return array();
4351 4351
 		/*
4352 4352
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -4381,7 +4381,7 @@  discard block
 block discarded – undo
4381 4381
 		$flight_array = array();
4382 4382
 		$temp_array = array();
4383 4383
         
4384
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4384
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4385 4385
 		{
4386 4386
 			$temp_array['flight_count'] = $row['nb'];
4387 4387
 			$temp_array['flight_country'] = $row['name'];
@@ -4399,12 +4399,12 @@  discard block
 block discarded – undo
4399 4399
 	* @return Array the aircraft list
4400 4400
 	*
4401 4401
 	*/
4402
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
4402
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4403 4403
 	{
4404 4404
 		global $globalDBdriver;
4405
-		$filter_query = $this->getFilter($filters,true,true);
4405
+		$filter_query = $this->getFilter($filters, true, true);
4406 4406
 
4407
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4407
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4408 4408
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
4409 4409
 		if ($olderthanmonths > 0) {
4410 4410
 			if ($globalDBdriver == 'mysql') {
@@ -4429,7 +4429,7 @@  discard block
 block discarded – undo
4429 4429
 
4430 4430
 		$aircraft_array = array();
4431 4431
 		$temp_array = array();
4432
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4432
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4433 4433
 		{
4434 4434
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4435 4435
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4446,10 +4446,10 @@  discard block
 block discarded – undo
4446 4446
 	* @return Array the aircraft list
4447 4447
 	*
4448 4448
 	*/
4449
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
4449
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4450 4450
 	{
4451 4451
 		global $globalDBdriver;
4452
-		$query  = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4452
+		$query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
4453 4453
 		    FROM spotter_output
4454 4454
 		    WHERE spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' ";
4455 4455
 		if ($olderthanmonths > 0) {
@@ -4475,7 +4475,7 @@  discard block
 block discarded – undo
4475 4475
 
4476 4476
 		$aircraft_array = array();
4477 4477
 		$temp_array = array();
4478
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4478
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4479 4479
 		{
4480 4480
 			$temp_array['airline_icao'] = $row['airline_icao'];
4481 4481
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -4497,9 +4497,9 @@  discard block
 block discarded – undo
4497 4497
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao)
4498 4498
 	{
4499 4499
 		$Image = new Image($this->db);
4500
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4500
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4501 4501
 
4502
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4502
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4503 4503
 				FROM spotter_output
4504 4504
 				WHERE spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
4505 4505
 				GROUP BY spotter_output.registration 
@@ -4511,14 +4511,14 @@  discard block
 block discarded – undo
4511 4511
 		$aircraft_array = array();
4512 4512
 		$temp_array = array();
4513 4513
         
4514
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4514
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4515 4515
 		{
4516 4516
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4517 4517
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4518 4518
 			$temp_array['registration'] = $row['registration'];
4519 4519
 			$temp_array['airline_name'] = $row['airline_name'];
4520 4520
 			$temp_array['image_thumbnail'] = "";
4521
-			if($row['registration'] != "")
4521
+			if ($row['registration'] != "")
4522 4522
 			{
4523 4523
 				$image_array = $Image->getSpotterImage($row['registration']);
4524 4524
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4539,9 +4539,9 @@  discard block
 block discarded – undo
4539 4539
 	*/
4540 4540
 	public function countAllAircraftTypesByAirline($airline_icao)
4541 4541
 	{
4542
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4542
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4543 4543
 
4544
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4544
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4545 4545
 				FROM spotter_output
4546 4546
 				WHERE spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
4547 4547
 				GROUP BY spotter_output.aircraft_name 
@@ -4553,7 +4553,7 @@  discard block
 block discarded – undo
4553 4553
 		$aircraft_array = array();
4554 4554
 		$temp_array = array();
4555 4555
 
4556
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4556
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4557 4557
 		{
4558 4558
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4559 4559
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4574,9 +4574,9 @@  discard block
 block discarded – undo
4574 4574
 	public function countAllAircraftRegistrationByAirline($airline_icao)
4575 4575
 	{
4576 4576
 		$Image = new Image($this->db);
4577
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4577
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4578 4578
 
4579
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4579
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4580 4580
 				FROM spotter_output
4581 4581
 				WHERE spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
4582 4582
 				GROUP BY spotter_output.registration 
@@ -4587,14 +4587,14 @@  discard block
 block discarded – undo
4587 4587
 
4588 4588
 		$aircraft_array = array();
4589 4589
 		$temp_array = array();
4590
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4590
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4591 4591
 		{
4592 4592
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4593 4593
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4594 4594
 			$temp_array['registration'] = $row['registration'];
4595 4595
 			$temp_array['airline_name'] = $row['airline_name'];
4596 4596
 			$temp_array['image_thumbnail'] = "";
4597
-			if($row['registration'] != "")
4597
+			if ($row['registration'] != "")
4598 4598
 			{
4599 4599
 				$image_array = $Image->getSpotterImage($row['registration']);
4600 4600
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4615,9 +4615,9 @@  discard block
 block discarded – undo
4615 4615
 	*/
4616 4616
 	public function countAllAircraftManufacturerByAirline($airline_icao)
4617 4617
 	{
4618
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
4618
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
4619 4619
 
4620
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4620
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4621 4621
 				FROM spotter_output
4622 4622
 				WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
4623 4623
 				GROUP BY spotter_output.aircraft_manufacturer 
@@ -4629,7 +4629,7 @@  discard block
 block discarded – undo
4629 4629
 		$aircraft_array = array();
4630 4630
 		$temp_array = array();
4631 4631
 
4632
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4632
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4633 4633
 		{
4634 4634
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4635 4635
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4648,9 +4648,9 @@  discard block
 block discarded – undo
4648 4648
 	*/
4649 4649
 	public function countAllAircraftTypesByAirport($airport_icao)
4650 4650
 	{
4651
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4651
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4652 4652
 
4653
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4653
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4654 4654
 				FROM spotter_output
4655 4655
 				WHERE spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
4656 4656
 				GROUP BY spotter_output.aircraft_name 
@@ -4661,7 +4661,7 @@  discard block
 block discarded – undo
4661 4661
 
4662 4662
 		$aircraft_array = array();
4663 4663
 		$temp_array = array();
4664
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4664
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4665 4665
 		{
4666 4666
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4667 4667
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4682,9 +4682,9 @@  discard block
 block discarded – undo
4682 4682
 	public function countAllAircraftRegistrationByAirport($airport_icao)
4683 4683
 	{
4684 4684
 		$Image = new Image($this->db);
4685
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4685
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4686 4686
 
4687
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4687
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
4688 4688
                     FROM spotter_output
4689 4689
                     WHERE spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
4690 4690
                     GROUP BY spotter_output.registration 
@@ -4696,14 +4696,14 @@  discard block
 block discarded – undo
4696 4696
 
4697 4697
 		$aircraft_array = array();
4698 4698
 		$temp_array = array();
4699
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4699
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4700 4700
 		{
4701 4701
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4702 4702
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4703 4703
 			$temp_array['registration'] = $row['registration'];
4704 4704
 			$temp_array['airline_name'] = $row['airline_name'];
4705 4705
 			$temp_array['image_thumbnail'] = "";
4706
-			if($row['registration'] != "")
4706
+			if ($row['registration'] != "")
4707 4707
 			{
4708 4708
 				$image_array = $Image->getSpotterImage($row['registration']);
4709 4709
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4723,9 +4723,9 @@  discard block
 block discarded – undo
4723 4723
 	*/
4724 4724
 	public function countAllAircraftManufacturerByAirport($airport_icao)
4725 4725
 	{
4726
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4726
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4727 4727
 
4728
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4728
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4729 4729
                     FROM spotter_output
4730 4730
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  
4731 4731
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -4737,7 +4737,7 @@  discard block
 block discarded – undo
4737 4737
 
4738 4738
 		$aircraft_array = array();
4739 4739
 		$temp_array = array();
4740
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4740
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4741 4741
 		{
4742 4742
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4743 4743
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4754,9 +4754,9 @@  discard block
 block discarded – undo
4754 4754
 	*/
4755 4755
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer)
4756 4756
 	{
4757
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4757
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4758 4758
 
4759
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4759
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4760 4760
                     FROM spotter_output
4761 4761
                     WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
4762 4762
                     GROUP BY spotter_output.aircraft_name 
@@ -4766,7 +4766,7 @@  discard block
 block discarded – undo
4766 4766
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4767 4767
 		$aircraft_array = array();
4768 4768
 		$temp_array = array();
4769
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4769
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4770 4770
 		{
4771 4771
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4772 4772
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4786,9 +4786,9 @@  discard block
 block discarded – undo
4786 4786
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer)
4787 4787
 	{
4788 4788
 		$Image = new Image($this->db);
4789
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4789
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4790 4790
 
4791
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4791
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
4792 4792
                     FROM spotter_output
4793 4793
                     WHERE spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
4794 4794
                     GROUP BY spotter_output.registration 
@@ -4799,14 +4799,14 @@  discard block
 block discarded – undo
4799 4799
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
4800 4800
 		$aircraft_array = array();
4801 4801
 		$temp_array = array();
4802
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4802
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4803 4803
 		{
4804 4804
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4805 4805
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4806 4806
 			$temp_array['registration'] = $row['registration'];
4807 4807
 			$temp_array['airline_name'] = $row['airline_name'];
4808 4808
 			$temp_array['image_thumbnail'] = "";
4809
-			if($row['registration'] != "")
4809
+			if ($row['registration'] != "")
4810 4810
 			{
4811 4811
 				$image_array = $Image->getSpotterImage($row['registration']);
4812 4812
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4826,7 +4826,7 @@  discard block
 block discarded – undo
4826 4826
 	public function countAllAircraftTypesByDate($date)
4827 4827
 	{
4828 4828
 		global $globalTimezone, $globalDBdriver;
4829
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4829
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4830 4830
 		if ($globalTimezone != '') {
4831 4831
 			date_default_timezone_set($globalTimezone);
4832 4832
 			$datetime = new DateTime($date);
@@ -4834,13 +4834,13 @@  discard block
 block discarded – undo
4834 4834
 		} else $offset = '+00:00';
4835 4835
 
4836 4836
 		if ($globalDBdriver == 'mysql') {
4837
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4837
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4838 4838
 					FROM spotter_output
4839 4839
 					WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
4840 4840
 					GROUP BY spotter_output.aircraft_name 
4841 4841
 					ORDER BY aircraft_icao_count DESC";
4842 4842
 		} else {
4843
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4843
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4844 4844
 					FROM spotter_output
4845 4845
 					WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
4846 4846
 					GROUP BY spotter_output.aircraft_name 
@@ -4852,7 +4852,7 @@  discard block
 block discarded – undo
4852 4852
 
4853 4853
 		$aircraft_array = array();
4854 4854
 		$temp_array = array();
4855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4856 4856
 		{
4857 4857
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4858 4858
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -4874,7 +4874,7 @@  discard block
 block discarded – undo
4874 4874
 	{
4875 4875
 		global $globalTimezone, $globalDBdriver;
4876 4876
 		$Image = new Image($this->db);
4877
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4877
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4878 4878
 		if ($globalTimezone != '') {
4879 4879
 			date_default_timezone_set($globalTimezone);
4880 4880
 			$datetime = new DateTime($date);
@@ -4882,13 +4882,13 @@  discard block
 block discarded – undo
4882 4882
 		} else $offset = '+00:00';
4883 4883
 
4884 4884
 		if ($globalDBdriver == 'mysql') {
4885
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4885
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4886 4886
 					FROM spotter_output
4887 4887
 					WHERE spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4888 4888
 					GROUP BY spotter_output.registration 
4889 4889
 					ORDER BY registration_count DESC";
4890 4890
 		} else {
4891
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4891
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
4892 4892
 					FROM spotter_output
4893 4893
 					WHERE spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4894 4894
 					GROUP BY spotter_output.registration 
@@ -4900,14 +4900,14 @@  discard block
 block discarded – undo
4900 4900
 
4901 4901
 		$aircraft_array = array();
4902 4902
 		$temp_array = array();
4903
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4903
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4904 4904
 		{
4905 4905
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4906 4906
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
4907 4907
 			$temp_array['registration'] = $row['registration'];
4908 4908
 			$temp_array['airline_name'] = $row['airline_name'];
4909 4909
 			$temp_array['image_thumbnail'] = "";
4910
-			if($row['registration'] != "")
4910
+			if ($row['registration'] != "")
4911 4911
 			{
4912 4912
 				$image_array = $Image->getSpotterImage($row['registration']);
4913 4913
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -4929,7 +4929,7 @@  discard block
 block discarded – undo
4929 4929
 	public function countAllAircraftManufacturerByDate($date)
4930 4930
 	{
4931 4931
 		global $globalTimezone, $globalDBdriver;
4932
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4932
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4933 4933
 		if ($globalTimezone != '') {
4934 4934
 			date_default_timezone_set($globalTimezone);
4935 4935
 			$datetime = new DateTime($date);
@@ -4937,13 +4937,13 @@  discard block
 block discarded – undo
4937 4937
 		} else $offset = '+00:00';
4938 4938
 
4939 4939
 		if ($globalDBdriver == 'mysql') {
4940
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4940
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4941 4941
 				FROM spotter_output
4942 4942
 				WHERE spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4943 4943
 				GROUP BY spotter_output.aircraft_manufacturer 
4944 4944
 				ORDER BY aircraft_manufacturer_count DESC";
4945 4945
 		} else {
4946
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4946
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
4947 4947
 				FROM spotter_output
4948 4948
 				WHERE spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4949 4949
 				GROUP BY spotter_output.aircraft_manufacturer 
@@ -4956,7 +4956,7 @@  discard block
 block discarded – undo
4956 4956
 		$aircraft_array = array();
4957 4957
 		$temp_array = array();
4958 4958
 
4959
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4959
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4960 4960
 		{
4961 4961
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
4962 4962
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -4975,9 +4975,9 @@  discard block
 block discarded – undo
4975 4975
 	*/
4976 4976
 	public function countAllAircraftTypesByIdent($ident)
4977 4977
 	{
4978
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4978
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4979 4979
 
4980
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4980
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
4981 4981
 				FROM spotter_output
4982 4982
 				WHERE spotter_output.ident = :ident 
4983 4983
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
@@ -4989,7 +4989,7 @@  discard block
 block discarded – undo
4989 4989
 		$aircraft_array = array();
4990 4990
 		$temp_array = array();
4991 4991
 
4992
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4992
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4993 4993
 		{
4994 4994
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
4995 4995
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5010,9 +5010,9 @@  discard block
 block discarded – undo
5010 5010
 	public function countAllAircraftRegistrationByIdent($ident)
5011 5011
 	{
5012 5012
 		$Image = new Image($this->db);
5013
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5013
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5014 5014
 
5015
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5015
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5016 5016
                     FROM spotter_output
5017 5017
                     WHERE spotter_output.registration <> '' AND spotter_output.ident = :ident   
5018 5018
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
@@ -5025,14 +5025,14 @@  discard block
 block discarded – undo
5025 5025
 		$aircraft_array = array();
5026 5026
 		$temp_array = array();
5027 5027
         
5028
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5028
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5029 5029
 		{
5030 5030
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5031 5031
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5032 5032
 			$temp_array['registration'] = $row['registration'];
5033 5033
 			$temp_array['airline_name'] = $row['airline_name'];
5034 5034
 			$temp_array['image_thumbnail'] = "";
5035
-			if($row['registration'] != "")
5035
+			if ($row['registration'] != "")
5036 5036
 			{
5037 5037
 				$image_array = $Image->getSpotterImage($row['registration']);
5038 5038
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5053,9 +5053,9 @@  discard block
 block discarded – undo
5053 5053
 	*/
5054 5054
 	public function countAllAircraftManufacturerByIdent($ident)
5055 5055
 	{
5056
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5056
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5057 5057
 
5058
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5058
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5059 5059
                     FROM spotter_output
5060 5060
                     WHERE spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
5061 5061
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -5066,7 +5066,7 @@  discard block
 block discarded – undo
5066 5066
 		$sth->execute(array(':ident' => $ident));
5067 5067
 		$aircraft_array = array();
5068 5068
 		$temp_array = array();
5069
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5069
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5070 5070
 		{
5071 5071
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5072 5072
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5084,11 +5084,11 @@  discard block
 block discarded – undo
5084 5084
 	*/
5085 5085
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao)
5086 5086
 	{
5087
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5088
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5087
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5088
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5089 5089
 		
5090 5090
 
5091
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5091
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5092 5092
                     FROM spotter_output
5093 5093
                     WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
5094 5094
                     GROUP BY spotter_output.aircraft_name 
@@ -5096,10 +5096,10 @@  discard block
 block discarded – undo
5096 5096
  
5097 5097
 		
5098 5098
 		$sth = $this->db->prepare($query);
5099
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5099
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5100 5100
 		$aircraft_array = array();
5101 5101
 		$temp_array = array();
5102
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5102
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5103 5103
 		{
5104 5104
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5105 5105
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5118,10 +5118,10 @@  discard block
 block discarded – undo
5118 5118
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao)
5119 5119
 	{
5120 5120
 		$Image = new Image($this->db);
5121
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5122
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5121
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5122
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5123 5123
 
5124
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5124
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5125 5125
                     FROM spotter_output
5126 5126
                     WHERE spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)   
5127 5127
                     GROUP BY spotter_output.registration 
@@ -5129,19 +5129,19 @@  discard block
 block discarded – undo
5129 5129
 
5130 5130
 		
5131 5131
 		$sth = $this->db->prepare($query);
5132
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5132
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5133 5133
       
5134 5134
 		$aircraft_array = array();
5135 5135
 		$temp_array = array();
5136 5136
         
5137
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5137
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5138 5138
 		{
5139 5139
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5140 5140
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5141 5141
 			$temp_array['registration'] = $row['registration'];
5142 5142
 			$temp_array['airline_name'] = $row['airline_name'];
5143 5143
 			$temp_array['image_thumbnail'] = "";
5144
-			if($row['registration'] != "")
5144
+			if ($row['registration'] != "")
5145 5145
 			{
5146 5146
 				$image_array = $Image->getSpotterImage($row['registration']);
5147 5147
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5163,10 +5163,10 @@  discard block
 block discarded – undo
5163 5163
 	*/
5164 5164
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao)
5165 5165
 	{
5166
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
5167
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
5166
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
5167
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
5168 5168
 
5169
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5169
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5170 5170
                     FROM spotter_output
5171 5171
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
5172 5172
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -5174,12 +5174,12 @@  discard block
 block discarded – undo
5174 5174
 
5175 5175
 		
5176 5176
 		$sth = $this->db->prepare($query);
5177
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
5177
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
5178 5178
       
5179 5179
 		$aircraft_array = array();
5180 5180
 		$temp_array = array();
5181 5181
         
5182
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5182
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5183 5183
 		{
5184 5184
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5185 5185
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5201,9 +5201,9 @@  discard block
 block discarded – undo
5201 5201
 	*/
5202 5202
 	public function countAllAircraftTypesByCountry($country)
5203 5203
 	{
5204
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5204
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5205 5205
 
5206
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5206
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5207 5207
                     FROM spotter_output
5208 5208
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
5209 5209
                     GROUP BY spotter_output.aircraft_name 
@@ -5216,7 +5216,7 @@  discard block
 block discarded – undo
5216 5216
 		$aircraft_array = array();
5217 5217
 		$temp_array = array();
5218 5218
         
5219
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5219
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5220 5220
 		{
5221 5221
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5222 5222
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5238,9 +5238,9 @@  discard block
 block discarded – undo
5238 5238
 	public function countAllAircraftRegistrationByCountry($country)
5239 5239
 	{
5240 5240
 		$Image = new Image($this->db);
5241
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5241
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5242 5242
 
5243
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5243
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5244 5244
                     FROM spotter_output
5245 5245
                     WHERE spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
5246 5246
                     GROUP BY spotter_output.registration 
@@ -5253,14 +5253,14 @@  discard block
 block discarded – undo
5253 5253
 		$aircraft_array = array();
5254 5254
 		$temp_array = array();
5255 5255
         
5256
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5256
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5257 5257
 		{
5258 5258
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5259 5259
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5260 5260
 			$temp_array['registration'] = $row['registration'];
5261 5261
 			$temp_array['airline_name'] = $row['airline_name'];
5262 5262
 			$temp_array['image_thumbnail'] = "";
5263
-			if($row['registration'] != "")
5263
+			if ($row['registration'] != "")
5264 5264
 			{
5265 5265
 				$image_array = $Image->getSpotterImage($row['registration']);
5266 5266
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5282,9 +5282,9 @@  discard block
 block discarded – undo
5282 5282
 	*/
5283 5283
 	public function countAllAircraftManufacturerByCountry($country)
5284 5284
 	{
5285
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
5285
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
5286 5286
 
5287
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5287
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5288 5288
                     FROM spotter_output
5289 5289
                     WHERE spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) 
5290 5290
                     GROUP BY spotter_output.aircraft_manufacturer 
@@ -5297,7 +5297,7 @@  discard block
 block discarded – undo
5297 5297
 		$aircraft_array = array();
5298 5298
 		$temp_array = array();
5299 5299
         
5300
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5300
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5301 5301
 		{
5302 5302
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5303 5303
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5318,8 +5318,8 @@  discard block
 block discarded – undo
5318 5318
 	*/
5319 5319
 	public function countAllAircraftManufacturers($filter = array())
5320 5320
 	{
5321
-		$filter_query = $this->getFilter($filter,true,true);
5322
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5321
+		$filter_query = $this->getFilter($filter, true, true);
5322
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5323 5323
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
5324 5324
                 $query .= " GROUP BY spotter_output.aircraft_manufacturer
5325 5325
 					ORDER BY aircraft_manufacturer_count DESC
@@ -5332,7 +5332,7 @@  discard block
 block discarded – undo
5332 5332
 		$manufacturer_array = array();
5333 5333
 		$temp_array = array();
5334 5334
         
5335
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5335
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5336 5336
 		{
5337 5337
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5338 5338
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5351,12 +5351,12 @@  discard block
 block discarded – undo
5351 5351
 	* @return Array the aircraft list
5352 5352
 	*
5353 5353
 	*/
5354
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5354
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5355 5355
 	{
5356 5356
 		global $globalDBdriver;
5357 5357
 		$Image = new Image($this->db);
5358
-		$filter_query = $this->getFilter($filters,true,true);
5359
-		$query  = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5358
+		$filter_query = $this->getFilter($filters, true, true);
5359
+		$query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5360 5360
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
5361 5361
                 if ($olderthanmonths > 0) {
5362 5362
             		if ($globalDBdriver == 'mysql') {
@@ -5384,7 +5384,7 @@  discard block
 block discarded – undo
5384 5384
 		$aircraft_array = array();
5385 5385
 		$temp_array = array();
5386 5386
         
5387
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5387
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5388 5388
 		{
5389 5389
 			$temp_array['registration'] = $row['registration'];
5390 5390
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5392,7 +5392,7 @@  discard block
 block discarded – undo
5392 5392
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5393 5393
 			$temp_array['airline_name'] = $row['airline_name'];
5394 5394
 			$temp_array['image_thumbnail'] = "";
5395
-			if($row['registration'] != "")
5395
+			if ($row['registration'] != "")
5396 5396
 			{
5397 5397
 				$image_array = $Image->getSpotterImage($row['registration']);
5398 5398
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5411,11 +5411,11 @@  discard block
 block discarded – undo
5411 5411
 	* @return Array the aircraft list
5412 5412
 	*
5413 5413
 	*/
5414
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
5414
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
5415 5415
 	{
5416 5416
 		global $globalDBdriver;
5417 5417
 		$Image = new Image($this->db);
5418
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5418
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao,  spotter_output.aircraft_name, spotter_output.airline_name    
5419 5419
                     FROM spotter_output 
5420 5420
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
5421 5421
                 if ($olderthanmonths > 0) {
@@ -5444,7 +5444,7 @@  discard block
 block discarded – undo
5444 5444
 		$aircraft_array = array();
5445 5445
 		$temp_array = array();
5446 5446
         
5447
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5447
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5448 5448
 		{
5449 5449
 			$temp_array['registration'] = $row['registration'];
5450 5450
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -5453,7 +5453,7 @@  discard block
 block discarded – undo
5453 5453
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5454 5454
 			$temp_array['airline_name'] = $row['airline_name'];
5455 5455
 			$temp_array['image_thumbnail'] = "";
5456
-			if($row['registration'] != "")
5456
+			if ($row['registration'] != "")
5457 5457
 			{
5458 5458
 				$image_array = $Image->getSpotterImage($row['registration']);
5459 5459
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5472,11 +5472,11 @@  discard block
 block discarded – undo
5472 5472
 	* @return Array the airport list
5473 5473
 	*
5474 5474
 	*/
5475
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5475
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5476 5476
 	{
5477 5477
 		global $globalDBdriver;
5478
-		$filter_query = $this->getFilter($filters,true,true);
5479
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5478
+		$filter_query = $this->getFilter($filters, true, true);
5479
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5480 5480
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA'";
5481 5481
                 if ($olderthanmonths > 0) {
5482 5482
             		if ($globalDBdriver == 'mysql') {
@@ -5505,7 +5505,7 @@  discard block
 block discarded – undo
5505 5505
 		$airport_array = array();
5506 5506
 		$temp_array = array();
5507 5507
         
5508
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5508
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5509 5509
 		{
5510 5510
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5511 5511
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5527,7 +5527,7 @@  discard block
 block discarded – undo
5527 5527
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
5528 5528
 	{
5529 5529
 		global $globalDBdriver;
5530
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5530
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5531 5531
 								FROM spotter_output
5532 5532
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' ";
5533 5533
                 if ($olderthanmonths > 0) {
@@ -5557,7 +5557,7 @@  discard block
 block discarded – undo
5557 5557
 		$airport_array = array();
5558 5558
 		$temp_array = array();
5559 5559
         
5560
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5560
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5561 5561
 		{
5562 5562
 			$temp_array['airline_icao'] = $row['airline_icao'];
5563 5563
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5577,11 +5577,11 @@  discard block
 block discarded – undo
5577 5577
 	* @return Array the airport list
5578 5578
 	*
5579 5579
 	*/
5580
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
5580
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5581 5581
 	{
5582 5582
 		global $globalDBdriver;
5583
-		$filter_query = $this->getFilter($filters,true,true);
5584
-		$query  = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5583
+		$filter_query = $this->getFilter($filters, true, true);
5584
+		$query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5585 5585
 				FROM spotter_output, airport".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao";
5586 5586
                 if ($olderthanmonths > 0) {
5587 5587
             		if ($globalDBdriver == 'mysql') {
@@ -5609,7 +5609,7 @@  discard block
 block discarded – undo
5609 5609
 		$airport_array = array();
5610 5610
 		$temp_array = array();
5611 5611
         
5612
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5612
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5613 5613
 		{
5614 5614
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5615 5615
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5631,7 +5631,7 @@  discard block
 block discarded – undo
5631 5631
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
5632 5632
 	{
5633 5633
 		global $globalDBdriver;
5634
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5634
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country
5635 5635
 				FROM spotter_output, airport
5636 5636
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao ";
5637 5637
                 if ($olderthanmonths > 0) {
@@ -5661,7 +5661,7 @@  discard block
 block discarded – undo
5661 5661
 		$airport_array = array();
5662 5662
 		$temp_array = array();
5663 5663
         
5664
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5664
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5665 5665
 		{
5666 5666
 			$temp_array['airline_icao'] = $row['airline_icao'];
5667 5667
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -5683,9 +5683,9 @@  discard block
 block discarded – undo
5683 5683
 	*/
5684 5684
 	public function countAllDepartureAirportsByAirline($airline_icao)
5685 5685
 	{
5686
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5686
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5687 5687
 
5688
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5688
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5689 5689
 								FROM spotter_output
5690 5690
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
5691 5691
                     GROUP BY spotter_output.departure_airport_icao
@@ -5698,7 +5698,7 @@  discard block
 block discarded – undo
5698 5698
 		$airport_array = array();
5699 5699
 		$temp_array = array();
5700 5700
         
5701
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5701
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5702 5702
 		{
5703 5703
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5704 5704
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5722,9 +5722,9 @@  discard block
 block discarded – undo
5722 5722
 	*/
5723 5723
 	public function countAllDepartureAirportCountriesByAirline($airline_icao)
5724 5724
 	{
5725
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5725
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5726 5726
 					
5727
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5727
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5728 5728
 								FROM spotter_output 
5729 5729
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
5730 5730
                     GROUP BY spotter_output.departure_airport_country
@@ -5737,7 +5737,7 @@  discard block
 block discarded – undo
5737 5737
 		$airport_array = array();
5738 5738
 		$temp_array = array();
5739 5739
         
5740
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5740
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5741 5741
 		{
5742 5742
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5743 5743
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5758,9 +5758,9 @@  discard block
 block discarded – undo
5758 5758
 	*/
5759 5759
 	public function countAllDepartureAirportsByAircraft($aircraft_icao)
5760 5760
 	{
5761
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5761
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5762 5762
 
5763
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5763
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5764 5764
 								FROM spotter_output
5765 5765
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
5766 5766
                     GROUP BY spotter_output.departure_airport_icao
@@ -5773,7 +5773,7 @@  discard block
 block discarded – undo
5773 5773
 		$airport_array = array();
5774 5774
 		$temp_array = array();
5775 5775
         
5776
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5776
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5777 5777
 		{
5778 5778
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5779 5779
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5796,9 +5796,9 @@  discard block
 block discarded – undo
5796 5796
 	*/
5797 5797
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao)
5798 5798
 	{
5799
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5799
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5800 5800
 					
5801
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5801
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5802 5802
 								FROM spotter_output 
5803 5803
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
5804 5804
                     GROUP BY spotter_output.departure_airport_country
@@ -5811,7 +5811,7 @@  discard block
 block discarded – undo
5811 5811
 		$airport_array = array();
5812 5812
 		$temp_array = array();
5813 5813
         
5814
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5814
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5815 5815
 		{
5816 5816
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5817 5817
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5831,9 +5831,9 @@  discard block
 block discarded – undo
5831 5831
 	*/
5832 5832
 	public function countAllDepartureAirportsByRegistration($registration)
5833 5833
 	{
5834
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5834
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5835 5835
 
5836
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5836
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5837 5837
 								FROM spotter_output
5838 5838
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration 
5839 5839
                     GROUP BY spotter_output.departure_airport_icao
@@ -5846,7 +5846,7 @@  discard block
 block discarded – undo
5846 5846
 		$airport_array = array();
5847 5847
 		$temp_array = array();
5848 5848
         
5849
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5849
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5850 5850
 		{
5851 5851
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5852 5852
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5869,9 +5869,9 @@  discard block
 block discarded – undo
5869 5869
 	*/
5870 5870
 	public function countAllDepartureAirportCountriesByRegistration($registration)
5871 5871
 	{
5872
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
5872
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
5873 5873
 					
5874
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5874
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5875 5875
 								FROM spotter_output 
5876 5876
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
5877 5877
                     GROUP BY spotter_output.departure_airport_country
@@ -5884,7 +5884,7 @@  discard block
 block discarded – undo
5884 5884
 		$airport_array = array();
5885 5885
 		$temp_array = array();
5886 5886
         
5887
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5887
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5888 5888
 		{
5889 5889
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5890 5890
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5904,9 +5904,9 @@  discard block
 block discarded – undo
5904 5904
 	*/
5905 5905
 	public function countAllDepartureAirportsByAirport($airport_icao)
5906 5906
 	{
5907
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5907
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5908 5908
 
5909
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5909
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5910 5910
 								FROM spotter_output
5911 5911
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao 
5912 5912
                     GROUP BY spotter_output.departure_airport_icao
@@ -5919,7 +5919,7 @@  discard block
 block discarded – undo
5919 5919
 		$airport_array = array();
5920 5920
 		$temp_array = array();
5921 5921
         
5922
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5922
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5923 5923
 		{
5924 5924
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5925 5925
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -5942,9 +5942,9 @@  discard block
 block discarded – undo
5942 5942
 	*/
5943 5943
 	public function countAllDepartureAirportCountriesByAirport($airport_icao)
5944 5944
 	{
5945
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5945
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5946 5946
 					
5947
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5947
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
5948 5948
 								FROM spotter_output 
5949 5949
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
5950 5950
                     GROUP BY spotter_output.departure_airport_country
@@ -5957,7 +5957,7 @@  discard block
 block discarded – undo
5957 5957
 		$airport_array = array();
5958 5958
 		$temp_array = array();
5959 5959
         
5960
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5960
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5961 5961
 		{
5962 5962
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
5963 5963
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -5978,9 +5978,9 @@  discard block
 block discarded – undo
5978 5978
 	*/
5979 5979
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer)
5980 5980
 	{
5981
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5981
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5982 5982
 
5983
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5983
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
5984 5984
 								FROM spotter_output
5985 5985
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
5986 5986
                     GROUP BY spotter_output.departure_airport_icao
@@ -5993,7 +5993,7 @@  discard block
 block discarded – undo
5993 5993
 		$airport_array = array();
5994 5994
 		$temp_array = array();
5995 5995
         
5996
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5996
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5997 5997
 		{
5998 5998
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
5999 5999
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6016,9 +6016,9 @@  discard block
 block discarded – undo
6016 6016
 	*/
6017 6017
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer)
6018 6018
 	{
6019
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6019
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6020 6020
 					
6021
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6021
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6022 6022
 								FROM spotter_output 
6023 6023
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6024 6024
                     GROUP BY spotter_output.departure_airport_country
@@ -6031,7 +6031,7 @@  discard block
 block discarded – undo
6031 6031
 		$airport_array = array();
6032 6032
 		$temp_array = array();
6033 6033
         
6034
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6034
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6035 6035
 		{
6036 6036
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6037 6037
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6052,7 +6052,7 @@  discard block
 block discarded – undo
6052 6052
 	public function countAllDepartureAirportsByDate($date)
6053 6053
 	{
6054 6054
 		global $globalTimezone, $globalDBdriver;
6055
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6055
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6056 6056
 
6057 6057
 		if ($globalTimezone != '') {
6058 6058
 			date_default_timezone_set($globalTimezone);
@@ -6061,13 +6061,13 @@  discard block
 block discarded – undo
6061 6061
 		} else $offset = '+00:00';
6062 6062
 
6063 6063
 		if ($globalDBdriver == 'mysql') {
6064
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6064
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6065 6065
 					FROM spotter_output
6066 6066
 					WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
6067 6067
 					GROUP BY spotter_output.departure_airport_icao
6068 6068
 					ORDER BY airport_departure_icao_count DESC";
6069 6069
 		} else {
6070
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6070
+			$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6071 6071
 					FROM spotter_output
6072 6072
 					WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
6073 6073
 					GROUP BY spotter_output.departure_airport_icao
@@ -6080,7 +6080,7 @@  discard block
 block discarded – undo
6080 6080
 		$airport_array = array();
6081 6081
 		$temp_array = array();
6082 6082
         
6083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6084 6084
 		{
6085 6085
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6086 6086
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6104,7 +6104,7 @@  discard block
 block discarded – undo
6104 6104
 	public function countAllDepartureAirportCountriesByDate($date)
6105 6105
 	{
6106 6106
 		global $globalTimezone, $globalDBdriver;
6107
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6107
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6108 6108
 		if ($globalTimezone != '') {
6109 6109
 			date_default_timezone_set($globalTimezone);
6110 6110
 			$datetime = new DateTime($date);
@@ -6112,13 +6112,13 @@  discard block
 block discarded – undo
6112 6112
 		} else $offset = '+00:00';
6113 6113
 
6114 6114
 		if ($globalDBdriver == 'mysql') {
6115
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6115
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6116 6116
 					FROM spotter_output 
6117 6117
 					WHERE spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6118 6118
 					GROUP BY spotter_output.departure_airport_country
6119 6119
 					ORDER BY airport_departure_country_count DESC";
6120 6120
 		} else {
6121
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6121
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6122 6122
 					FROM spotter_output 
6123 6123
 					WHERE spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
6124 6124
 					GROUP BY spotter_output.departure_airport_country
@@ -6131,7 +6131,7 @@  discard block
 block discarded – undo
6131 6131
 		$airport_array = array();
6132 6132
 		$temp_array = array();
6133 6133
         
6134
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6134
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6135 6135
 		{
6136 6136
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6137 6137
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6151,9 +6151,9 @@  discard block
 block discarded – undo
6151 6151
 	*/
6152 6152
 	public function countAllDepartureAirportsByIdent($ident)
6153 6153
 	{
6154
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6154
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6155 6155
 
6156
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6156
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6157 6157
 		    FROM spotter_output
6158 6158
                     WHERE spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.ident = :ident 
6159 6159
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -6166,7 +6166,7 @@  discard block
 block discarded – undo
6166 6166
 		$airport_array = array();
6167 6167
 		$temp_array = array();
6168 6168
         
6169
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6169
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6170 6170
 		{
6171 6171
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6172 6172
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6190,9 +6190,9 @@  discard block
 block discarded – undo
6190 6190
 	*/
6191 6191
 	public function countAllDepartureAirportCountriesByIdent($ident)
6192 6192
 	{
6193
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6193
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6194 6194
 					
6195
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6195
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6196 6196
 								FROM spotter_output 
6197 6197
                     WHERE spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
6198 6198
                     GROUP BY spotter_output.departure_airport_country
@@ -6205,7 +6205,7 @@  discard block
 block discarded – undo
6205 6205
 		$airport_array = array();
6206 6206
 		$temp_array = array();
6207 6207
         
6208
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6208
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6209 6209
 		{
6210 6210
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6211 6211
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6226,9 +6226,9 @@  discard block
 block discarded – undo
6226 6226
 	*/
6227 6227
 	public function countAllDepartureAirportsByCountry($country)
6228 6228
 	{
6229
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6229
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6230 6230
 
6231
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6231
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6232 6232
 								FROM spotter_output
6233 6233
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
6234 6234
                     GROUP BY spotter_output.departure_airport_icao
@@ -6241,7 +6241,7 @@  discard block
 block discarded – undo
6241 6241
 		$airport_array = array();
6242 6242
 		$temp_array = array();
6243 6243
         
6244
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6244
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6245 6245
 		{
6246 6246
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6247 6247
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6264,9 +6264,9 @@  discard block
 block discarded – undo
6264 6264
 	*/
6265 6265
 	public function countAllDepartureAirportCountriesByCountry($country)
6266 6266
 	{
6267
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6267
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6268 6268
 					
6269
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6269
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
6270 6270
 								FROM spotter_output 
6271 6271
                     WHERE spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6272 6272
                     GROUP BY spotter_output.departure_airport_country
@@ -6279,7 +6279,7 @@  discard block
 block discarded – undo
6279 6279
 		$airport_array = array();
6280 6280
 		$temp_array = array();
6281 6281
         
6282
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6282
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6283 6283
 		{
6284 6284
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6285 6285
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6297,11 +6297,11 @@  discard block
 block discarded – undo
6297 6297
 	* @return Array the airport list
6298 6298
 	*
6299 6299
 	*/
6300
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
6300
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6301 6301
 	{
6302 6302
 		global $globalDBdriver;
6303
-		$filter_query = $this->getFilter($filters,true,true);
6304
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6303
+		$filter_query = $this->getFilter($filters, true, true);
6304
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6305 6305
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
6306 6306
                 if ($olderthanmonths > 0) {
6307 6307
             		if ($globalDBdriver == 'mysql') {
@@ -6336,7 +6336,7 @@  discard block
 block discarded – undo
6336 6336
 		$airport_array = array();
6337 6337
 		$temp_array = array();
6338 6338
         
6339
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6339
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6340 6340
 		{
6341 6341
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6342 6342
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6362,7 +6362,7 @@  discard block
 block discarded – undo
6362 6362
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
6363 6363
 	{
6364 6364
 		global $globalDBdriver;
6365
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6365
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6366 6366
 								FROM spotter_output 
6367 6367
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' ";
6368 6368
                 if ($olderthanmonths > 0) {
@@ -6398,7 +6398,7 @@  discard block
 block discarded – undo
6398 6398
 		$airport_array = array();
6399 6399
 		$temp_array = array();
6400 6400
         
6401
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6401
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6402 6402
 		{
6403 6403
 			$temp_array['airline_icao'] = $row['airline_icao'];
6404 6404
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -6423,11 +6423,11 @@  discard block
 block discarded – undo
6423 6423
 	* @return Array the airport list
6424 6424
 	*
6425 6425
 	*/
6426
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
6426
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
6427 6427
 	{
6428 6428
 		global $globalDBdriver;
6429
-		$filter_query = $this->getFilter($filters,true,true);
6430
-		$query  = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6429
+		$filter_query = $this->getFilter($filters, true, true);
6430
+		$query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6431 6431
 			FROM spotter_output, airport".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao";
6432 6432
                 if ($olderthanmonths > 0) {
6433 6433
             		if ($globalDBdriver == 'mysql') {
@@ -6461,7 +6461,7 @@  discard block
 block discarded – undo
6461 6461
 		$airport_array = array();
6462 6462
 		$temp_array = array();
6463 6463
         
6464
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6464
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6465 6465
 		{
6466 6466
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6467 6467
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6484,10 +6484,10 @@  discard block
 block discarded – undo
6484 6484
 	* @return Array the airport list
6485 6485
 	*
6486 6486
 	*/
6487
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false)
6487
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false)
6488 6488
 	{
6489 6489
 		global $globalDBdriver;
6490
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6490
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country 
6491 6491
 			FROM spotter_output, airport 
6492 6492
                     WHERE spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao ";
6493 6493
                 if ($olderthanmonths > 0) {
@@ -6523,7 +6523,7 @@  discard block
 block discarded – undo
6523 6523
 		$airport_array = array();
6524 6524
 		$temp_array = array();
6525 6525
         
6526
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6526
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6527 6527
 		{
6528 6528
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6529 6529
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6549,9 +6549,9 @@  discard block
 block discarded – undo
6549 6549
 	*/
6550 6550
 	public function countAllArrivalAirportsByAirline($airline_icao)
6551 6551
 	{
6552
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6552
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6553 6553
 
6554
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6554
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6555 6555
 								FROM spotter_output 
6556 6556
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao 
6557 6557
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6564,7 +6564,7 @@  discard block
 block discarded – undo
6564 6564
 		$airport_array = array();
6565 6565
 		$temp_array = array();
6566 6566
         
6567
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6567
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6568 6568
 		{
6569 6569
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6570 6570
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6587,9 +6587,9 @@  discard block
 block discarded – undo
6587 6587
 	*/
6588 6588
 	public function countAllArrivalAirportCountriesByAirline($airline_icao)
6589 6589
 	{
6590
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6590
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6591 6591
 					
6592
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6592
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6593 6593
 								FROM spotter_output 
6594 6594
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6595 6595
                     GROUP BY spotter_output.arrival_airport_country
@@ -6602,7 +6602,7 @@  discard block
 block discarded – undo
6602 6602
 		$airport_array = array();
6603 6603
 		$temp_array = array();
6604 6604
         
6605
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6605
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6606 6606
 		{
6607 6607
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6608 6608
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6622,9 +6622,9 @@  discard block
 block discarded – undo
6622 6622
 	*/
6623 6623
 	public function countAllArrivalAirportsByAircraft($aircraft_icao)
6624 6624
 	{
6625
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6625
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6626 6626
 
6627
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6627
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6628 6628
 								FROM spotter_output 
6629 6629
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao 
6630 6630
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6637,7 +6637,7 @@  discard block
 block discarded – undo
6637 6637
 		$airport_array = array();
6638 6638
 		$temp_array = array();
6639 6639
         
6640
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6640
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6641 6641
 		{
6642 6642
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6643 6643
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6661,9 +6661,9 @@  discard block
 block discarded – undo
6661 6661
 	*/
6662 6662
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao)
6663 6663
 	{
6664
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6664
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6665 6665
 					
6666
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6666
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6667 6667
 								FROM spotter_output 
6668 6668
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
6669 6669
                     GROUP BY spotter_output.arrival_airport_country
@@ -6676,7 +6676,7 @@  discard block
 block discarded – undo
6676 6676
 		$airport_array = array();
6677 6677
 		$temp_array = array();
6678 6678
         
6679
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6679
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6680 6680
 		{
6681 6681
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6682 6682
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6696,9 +6696,9 @@  discard block
 block discarded – undo
6696 6696
 	*/
6697 6697
 	public function countAllArrivalAirportsByRegistration($registration)
6698 6698
 	{
6699
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6699
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6700 6700
 
6701
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6701
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6702 6702
 								FROM spotter_output 
6703 6703
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.registration = :registration 
6704 6704
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6711,7 +6711,7 @@  discard block
 block discarded – undo
6711 6711
 		$airport_array = array();
6712 6712
 		$temp_array = array();
6713 6713
         
6714
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6714
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6715 6715
 		{
6716 6716
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6717 6717
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6734,9 +6734,9 @@  discard block
 block discarded – undo
6734 6734
 	*/
6735 6735
 	public function countAllArrivalAirportCountriesByRegistration($registration)
6736 6736
 	{
6737
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
6737
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
6738 6738
 					
6739
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6739
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6740 6740
 								FROM spotter_output 
6741 6741
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
6742 6742
                     GROUP BY spotter_output.arrival_airport_country
@@ -6749,7 +6749,7 @@  discard block
 block discarded – undo
6749 6749
 		$airport_array = array();
6750 6750
 		$temp_array = array();
6751 6751
         
6752
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6752
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6753 6753
 		{
6754 6754
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6755 6755
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6770,9 +6770,9 @@  discard block
 block discarded – undo
6770 6770
 	*/
6771 6771
 	public function countAllArrivalAirportsByAirport($airport_icao)
6772 6772
 	{
6773
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6773
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6774 6774
 
6775
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6775
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6776 6776
 								FROM spotter_output 
6777 6777
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.departure_airport_icao = :airport_icao 
6778 6778
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6785,7 +6785,7 @@  discard block
 block discarded – undo
6785 6785
 		$airport_array = array();
6786 6786
 		$temp_array = array();
6787 6787
         
6788
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6788
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6789 6789
 		{
6790 6790
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6791 6791
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6808,9 +6808,9 @@  discard block
 block discarded – undo
6808 6808
 	*/
6809 6809
 	public function countAllArrivalAirportCountriesByAirport($airport_icao)
6810 6810
 	{
6811
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
6811
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
6812 6812
 					
6813
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6813
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6814 6814
 								FROM spotter_output 
6815 6815
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
6816 6816
                     GROUP BY spotter_output.arrival_airport_country
@@ -6823,7 +6823,7 @@  discard block
 block discarded – undo
6823 6823
 		$airport_array = array();
6824 6824
 		$temp_array = array();
6825 6825
         
6826
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6826
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6827 6827
 		{
6828 6828
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6829 6829
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6843,9 +6843,9 @@  discard block
 block discarded – undo
6843 6843
 	*/
6844 6844
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer)
6845 6845
 	{
6846
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6846
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6847 6847
 
6848
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6848
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6849 6849
 								FROM spotter_output 
6850 6850
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6851 6851
                     GROUP BY spotter_output.arrival_airport_icao
@@ -6858,7 +6858,7 @@  discard block
 block discarded – undo
6858 6858
 		$airport_array = array();
6859 6859
 		$temp_array = array();
6860 6860
         
6861
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6861
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6862 6862
 		{
6863 6863
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6864 6864
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6882,9 +6882,9 @@  discard block
 block discarded – undo
6882 6882
 	*/
6883 6883
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer)
6884 6884
 	{
6885
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
6885
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
6886 6886
 					
6887
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6887
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6888 6888
 								FROM spotter_output 
6889 6889
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
6890 6890
                     GROUP BY spotter_output.arrival_airport_country
@@ -6897,7 +6897,7 @@  discard block
 block discarded – undo
6897 6897
 		$airport_array = array();
6898 6898
 		$temp_array = array();
6899 6899
         
6900
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6900
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6901 6901
 		{
6902 6902
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
6903 6903
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -6919,7 +6919,7 @@  discard block
 block discarded – undo
6919 6919
 	public function countAllArrivalAirportsByDate($date)
6920 6920
 	{
6921 6921
 		global $globalTimezone, $globalDBdriver;
6922
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6922
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6923 6923
 		if ($globalTimezone != '') {
6924 6924
 			date_default_timezone_set($globalTimezone);
6925 6925
 			$datetime = new DateTime($date);
@@ -6927,13 +6927,13 @@  discard block
 block discarded – undo
6927 6927
 		} else $offset = '+00:00';
6928 6928
 
6929 6929
 		if ($globalDBdriver == 'mysql') {
6930
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6930
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6931 6931
 					FROM spotter_output 
6932 6932
 					WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
6933 6933
 					GROUP BY spotter_output.arrival_airport_icao
6934 6934
 					ORDER BY airport_arrival_icao_count DESC";
6935 6935
 		} else {
6936
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6936
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
6937 6937
 					FROM spotter_output 
6938 6938
 					WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
6939 6939
 					GROUP BY spotter_output.arrival_airport_icao
@@ -6946,7 +6946,7 @@  discard block
 block discarded – undo
6946 6946
 		$airport_array = array();
6947 6947
 		$temp_array = array();
6948 6948
         
6949
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6949
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6950 6950
 		{
6951 6951
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
6952 6952
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -6970,7 +6970,7 @@  discard block
 block discarded – undo
6970 6970
 	public function countAllArrivalAirportCountriesByDate($date)
6971 6971
 	{
6972 6972
 		global $globalTimezone, $globalDBdriver;
6973
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
6973
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
6974 6974
 		if ($globalTimezone != '') {
6975 6975
 			date_default_timezone_set($globalTimezone);
6976 6976
 			$datetime = new DateTime($date);
@@ -6978,13 +6978,13 @@  discard block
 block discarded – undo
6978 6978
 		} else $offset = '+00:00';
6979 6979
 
6980 6980
 		if ($globalDBdriver == 'mysql') {
6981
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6981
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6982 6982
 					FROM spotter_output 
6983 6983
 					WHERE spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
6984 6984
 					GROUP BY spotter_output.arrival_airport_country
6985 6985
 					ORDER BY airport_arrival_country_count DESC";
6986 6986
 		} else {
6987
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6987
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
6988 6988
 					FROM spotter_output 
6989 6989
 					WHERE spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
6990 6990
 					GROUP BY spotter_output.arrival_airport_country
@@ -6997,7 +6997,7 @@  discard block
 block discarded – undo
6997 6997
 		$airport_array = array();
6998 6998
 		$temp_array = array();
6999 6999
         
7000
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7000
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7001 7001
 		{
7002 7002
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7003 7003
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7017,9 +7017,9 @@  discard block
 block discarded – undo
7017 7017
 	*/
7018 7018
 	public function countAllArrivalAirportsByIdent($ident)
7019 7019
 	{
7020
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7020
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7021 7021
 
7022
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7022
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7023 7023
 		    FROM spotter_output 
7024 7024
                     WHERE spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.ident = :ident  
7025 7025
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7032,7 +7032,7 @@  discard block
 block discarded – undo
7032 7032
 		$airport_array = array();
7033 7033
 		$temp_array = array();
7034 7034
         
7035
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7035
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7036 7036
 		{
7037 7037
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7038 7038
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7055,9 +7055,9 @@  discard block
 block discarded – undo
7055 7055
 	*/
7056 7056
 	public function countAllArrivalAirportCountriesByIdent($ident)
7057 7057
 	{
7058
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7058
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7059 7059
 					
7060
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7060
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7061 7061
 								FROM spotter_output 
7062 7062
                     WHERE spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
7063 7063
                     GROUP BY spotter_output.arrival_airport_country
@@ -7070,7 +7070,7 @@  discard block
 block discarded – undo
7070 7070
 		$airport_array = array();
7071 7071
 		$temp_array = array();
7072 7072
         
7073
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7073
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7074 7074
 		{
7075 7075
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7076 7076
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7091,9 +7091,9 @@  discard block
 block discarded – undo
7091 7091
 	*/
7092 7092
 	public function countAllArrivalAirportsByCountry($country)
7093 7093
 	{
7094
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7094
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7095 7095
 
7096
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7096
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7097 7097
 								FROM spotter_output 
7098 7098
                     WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
7099 7099
                     GROUP BY spotter_output.arrival_airport_icao
@@ -7106,7 +7106,7 @@  discard block
 block discarded – undo
7106 7106
 		$airport_array = array();
7107 7107
 		$temp_array = array();
7108 7108
         
7109
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7109
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7110 7110
 		{
7111 7111
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7112 7112
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7129,9 +7129,9 @@  discard block
 block discarded – undo
7129 7129
 	*/
7130 7130
 	public function countAllArrivalAirportCountriesByCountry($country)
7131 7131
 	{
7132
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7132
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7133 7133
 					
7134
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7134
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7135 7135
 								FROM spotter_output 
7136 7136
                     WHERE spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7137 7137
                     GROUP BY spotter_output.arrival_airport_country
@@ -7144,7 +7144,7 @@  discard block
 block discarded – undo
7144 7144
 		$airport_array = array();
7145 7145
 		$temp_array = array();
7146 7146
         
7147
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7147
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7148 7148
 		{
7149 7149
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7150 7150
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7165,7 +7165,7 @@  discard block
 block discarded – undo
7165 7165
 	*/
7166 7166
 	public function countAllDepartureCountries($filters = array())
7167 7167
 	{
7168
-		$filter_query = $this->getFilter($filters,true,true);
7168
+		$filter_query = $this->getFilter($filters, true, true);
7169 7169
 		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7170 7170
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA'";
7171 7171
 		$query .= " GROUP BY spotter_output.departure_airport_country
@@ -7179,7 +7179,7 @@  discard block
 block discarded – undo
7179 7179
 		$airport_array = array();
7180 7180
 		$temp_array = array();
7181 7181
         
7182
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7182
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7183 7183
 		{
7184 7184
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
7185 7185
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -7197,9 +7197,9 @@  discard block
 block discarded – undo
7197 7197
 	* @return Array the airport arrival list
7198 7198
 	*
7199 7199
 	*/
7200
-	public function countAllArrivalCountries($limit = true,$filters = array())
7200
+	public function countAllArrivalCountries($limit = true, $filters = array())
7201 7201
 	{
7202
-		$filter_query = $this->getFilter($filters,true,true);
7202
+		$filter_query = $this->getFilter($filters, true, true);
7203 7203
 		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
7204 7204
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7205 7205
 		$query .= " GROUP BY spotter_output.arrival_airport_country
@@ -7213,7 +7213,7 @@  discard block
 block discarded – undo
7213 7213
 		$airport_array = array();
7214 7214
 		$temp_array = array();
7215 7215
         
7216
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7216
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7217 7217
 		{
7218 7218
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
7219 7219
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -7237,7 +7237,7 @@  discard block
 block discarded – undo
7237 7237
 	public function countAllRoutes()
7238 7238
 	{
7239 7239
 		
7240
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7240
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7241 7241
 		    FROM spotter_output
7242 7242
                     WHERE spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> 'NA'
7243 7243
                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
@@ -7251,7 +7251,7 @@  discard block
 block discarded – undo
7251 7251
 		$routes_array = array();
7252 7252
 		$temp_array = array();
7253 7253
         
7254
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7254
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7255 7255
 		{
7256 7256
 			$temp_array['route_count'] = $row['route_count'];
7257 7257
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7280,9 +7280,9 @@  discard block
 block discarded – undo
7280 7280
 	*/
7281 7281
 	public function countAllRoutesByAircraft($aircraft_icao)
7282 7282
 	{
7283
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7283
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7284 7284
 		
7285
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7285
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7286 7286
 								FROM spotter_output
7287 7287
                     WHERE spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7288 7288
                     GROUP BY route
@@ -7295,7 +7295,7 @@  discard block
 block discarded – undo
7295 7295
 		$routes_array = array();
7296 7296
 		$temp_array = array();
7297 7297
         
7298
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7298
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7299 7299
 		{
7300 7300
 			$temp_array['route_count'] = $row['route_count'];
7301 7301
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7324,7 +7324,7 @@  discard block
 block discarded – undo
7324 7324
 	{
7325 7325
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7326 7326
 		
7327
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7327
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7328 7328
 								FROM spotter_output
7329 7329
                     WHERE spotter_output.ident <> '' AND spotter_output.registration = :registration 
7330 7330
                     GROUP BY route
@@ -7337,7 +7337,7 @@  discard block
 block discarded – undo
7337 7337
 		$routes_array = array();
7338 7338
 		$temp_array = array();
7339 7339
         
7340
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7340
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7341 7341
 		{
7342 7342
 			$temp_array['route_count'] = $row['route_count'];
7343 7343
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7365,9 +7365,9 @@  discard block
 block discarded – undo
7365 7365
 	*/
7366 7366
 	public function countAllRoutesByAirline($airline_icao)
7367 7367
 	{
7368
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7368
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7369 7369
 		
7370
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7370
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7371 7371
 								FROM spotter_output
7372 7372
                     WHERE spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
7373 7373
                     GROUP BY route
@@ -7380,7 +7380,7 @@  discard block
 block discarded – undo
7380 7380
 		$routes_array = array();
7381 7381
 		$temp_array = array();
7382 7382
         
7383
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7383
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7384 7384
 		{
7385 7385
 			$temp_array['route_count'] = $row['route_count'];
7386 7386
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7408,9 +7408,9 @@  discard block
 block discarded – undo
7408 7408
 	*/
7409 7409
 	public function countAllRoutesByAirport($airport_icao)
7410 7410
 	{
7411
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7411
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7412 7412
 		
7413
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7413
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7414 7414
 								FROM spotter_output
7415 7415
                     WHERE spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
7416 7416
                     GROUP BY route
@@ -7423,7 +7423,7 @@  discard block
 block discarded – undo
7423 7423
 		$routes_array = array();
7424 7424
 		$temp_array = array();
7425 7425
         
7426
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7426
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7427 7427
 		{
7428 7428
 			$temp_array['route_count'] = $row['route_count'];
7429 7429
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7451,9 +7451,9 @@  discard block
 block discarded – undo
7451 7451
 	*/
7452 7452
 	public function countAllRoutesByCountry($country)
7453 7453
 	{
7454
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7454
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7455 7455
 		
7456
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7456
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7457 7457
 								FROM spotter_output
7458 7458
                     WHERE spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7459 7459
                     GROUP BY route
@@ -7466,7 +7466,7 @@  discard block
 block discarded – undo
7466 7466
 		$routes_array = array();
7467 7467
 		$temp_array = array();
7468 7468
         
7469
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7469
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7470 7470
 		{
7471 7471
 			$temp_array['route_count'] = $row['route_count'];
7472 7472
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7494,7 +7494,7 @@  discard block
 block discarded – undo
7494 7494
 	public function countAllRoutesByDate($date)
7495 7495
 	{
7496 7496
 		global $globalTimezone, $globalDBdriver;
7497
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7497
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7498 7498
 		if ($globalTimezone != '') {
7499 7499
 			date_default_timezone_set($globalTimezone);
7500 7500
 			$datetime = new DateTime($date);
@@ -7502,13 +7502,13 @@  discard block
 block discarded – undo
7502 7502
 		} else $offset = '+00:00';
7503 7503
 		
7504 7504
 		if ($globalDBdriver == 'mysql') {
7505
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7505
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7506 7506
 					FROM spotter_output
7507 7507
 					WHERE spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
7508 7508
 					GROUP BY route
7509 7509
 					ORDER BY route_count DESC";
7510 7510
 		} else {
7511
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7511
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7512 7512
 					FROM spotter_output
7513 7513
 					WHERE spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
7514 7514
 					GROUP BY route
@@ -7521,7 +7521,7 @@  discard block
 block discarded – undo
7521 7521
 		$routes_array = array();
7522 7522
 		$temp_array = array();
7523 7523
         
7524
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7524
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7525 7525
 		{
7526 7526
 			$temp_array['route_count'] = $row['route_count'];
7527 7527
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7548,9 +7548,9 @@  discard block
 block discarded – undo
7548 7548
 	*/
7549 7549
 	public function countAllRoutesByIdent($ident)
7550 7550
 	{
7551
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7551
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7552 7552
 		
7553
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7553
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7554 7554
 		    FROM spotter_output
7555 7555
                     WHERE spotter_output.ident <> '' AND spotter_output.ident = :ident   
7556 7556
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7563,7 +7563,7 @@  discard block
 block discarded – undo
7563 7563
 		$routes_array = array();
7564 7564
 		$temp_array = array();
7565 7565
         
7566
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7566
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7567 7567
 		{
7568 7568
 			$temp_array['route_count'] = $row['route_count'];
7569 7569
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7590,9 +7590,9 @@  discard block
 block discarded – undo
7590 7590
 	*/
7591 7591
 	public function countAllRoutesByManufacturer($aircraft_manufacturer)
7592 7592
 	{
7593
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7593
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7594 7594
 		
7595
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7595
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7596 7596
 		    FROM spotter_output
7597 7597
                     WHERE spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
7598 7598
                     GROUP BY route
@@ -7605,7 +7605,7 @@  discard block
 block discarded – undo
7605 7605
 		$routes_array = array();
7606 7606
 		$temp_array = array();
7607 7607
         
7608
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7608
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7609 7609
 		{
7610 7610
 			$temp_array['route_count'] = $row['route_count'];
7611 7611
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -7633,7 +7633,7 @@  discard block
 block discarded – undo
7633 7633
 	*/
7634 7634
 	public function countAllRoutesWithWaypoints()
7635 7635
 	{
7636
-		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7636
+		$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
7637 7637
 		    FROM spotter_output
7638 7638
                     WHERE spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
7639 7639
                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
@@ -7647,7 +7647,7 @@  discard block
 block discarded – undo
7647 7647
 		$routes_array = array();
7648 7648
 		$temp_array = array();
7649 7649
         
7650
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7650
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7651 7651
 		{
7652 7652
 			$temp_array['spotter_id'] = $row['spotter_id'];
7653 7653
 			$temp_array['route_count'] = $row['route_count'];
@@ -7675,11 +7675,11 @@  discard block
 block discarded – undo
7675 7675
 	* @return Array the callsign list
7676 7676
 	*
7677 7677
 	*/
7678
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
7678
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
7679 7679
 	{
7680 7680
 		global $globalDBdriver;
7681
-		$filter_query = $this->getFilter($filters,true,true);
7682
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7681
+		$filter_query = $this->getFilter($filters, true, true);
7682
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7683 7683
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7684 7684
 		 if ($olderthanmonths > 0) {
7685 7685
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -7698,7 +7698,7 @@  discard block
 block discarded – undo
7698 7698
 		$callsign_array = array();
7699 7699
 		$temp_array = array();
7700 7700
         
7701
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7701
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7702 7702
 		{
7703 7703
 			$temp_array['callsign_icao'] = $row['ident'];
7704 7704
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7720,7 +7720,7 @@  discard block
 block discarded – undo
7720 7720
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
7721 7721
 	{
7722 7722
 		global $globalDBdriver;
7723
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7723
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
7724 7724
                     FROM spotter_output
7725 7725
                     WHERE spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7726 7726
 		 if ($olderthanmonths > 0) {
@@ -7740,7 +7740,7 @@  discard block
 block discarded – undo
7740 7740
 		$callsign_array = array();
7741 7741
 		$temp_array = array();
7742 7742
         
7743
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7743
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7744 7744
 		{
7745 7745
 			$temp_array['callsign_icao'] = $row['ident'];
7746 7746
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -7794,7 +7794,7 @@  discard block
 block discarded – undo
7794 7794
 		$date_array = array();
7795 7795
 		$temp_array = array();
7796 7796
         
7797
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7797
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7798 7798
 		{
7799 7799
 			$temp_array['date_name'] = $row['date_name'];
7800 7800
 			$temp_array['date_count'] = $row['date_count'];
@@ -7821,14 +7821,14 @@  discard block
 block discarded – undo
7821 7821
 		} else $offset = '+00:00';
7822 7822
 
7823 7823
 		if ($globalDBdriver == 'mysql') {
7824
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7824
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7825 7825
 								FROM spotter_output 
7826 7826
 								WHERE spotter_output.airline_icao <> '' 
7827 7827
 								GROUP BY spotter_output.airline_icao, date_name 
7828 7828
 								ORDER BY date_count DESC
7829 7829
 								LIMIT 10 OFFSET 0";
7830 7830
 		} else {
7831
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7831
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7832 7832
 								FROM spotter_output 
7833 7833
 								WHERE spotter_output.airline_icao <> '' 
7834 7834
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -7843,7 +7843,7 @@  discard block
 block discarded – undo
7843 7843
 		$date_array = array();
7844 7844
 		$temp_array = array();
7845 7845
         
7846
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7846
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7847 7847
 		{
7848 7848
 			$temp_array['date_name'] = $row['date_name'];
7849 7849
 			$temp_array['date_count'] = $row['date_count'];
@@ -7869,7 +7869,7 @@  discard block
 block discarded – undo
7869 7869
 			$datetime = new DateTime();
7870 7870
 			$offset = $datetime->format('P');
7871 7871
 		} else $offset = '+00:00';
7872
-		$filter_query = $this->getFilter($filters,true,true);
7872
+		$filter_query = $this->getFilter($filters, true, true);
7873 7873
 		if ($globalDBdriver == 'mysql') {
7874 7874
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7875 7875
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -7890,7 +7890,7 @@  discard block
 block discarded – undo
7890 7890
 		$date_array = array();
7891 7891
 		$temp_array = array();
7892 7892
         
7893
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7893
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7894 7894
 		{
7895 7895
 			$temp_array['date_name'] = $row['date_name'];
7896 7896
 			$temp_array['date_count'] = $row['date_count'];
@@ -7915,7 +7915,7 @@  discard block
 block discarded – undo
7915 7915
 			$datetime = new DateTime();
7916 7916
 			$offset = $datetime->format('P');
7917 7917
 		} else $offset = '+00:00';
7918
-		$filter_query = $this->getFilter($filters,true,true);
7918
+		$filter_query = $this->getFilter($filters, true, true);
7919 7919
 		if ($globalDBdriver == 'mysql') {
7920 7920
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7921 7921
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -7936,7 +7936,7 @@  discard block
 block discarded – undo
7936 7936
 		$date_array = array();
7937 7937
 		$temp_array = array();
7938 7938
         
7939
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7939
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7940 7940
 		{
7941 7941
 			$temp_array['date_name'] = $row['date_name'];
7942 7942
 			$temp_array['date_count'] = $row['date_count'];
@@ -7964,14 +7964,14 @@  discard block
 block discarded – undo
7964 7964
 		} else $offset = '+00:00';
7965 7965
 		
7966 7966
 		if ($globalDBdriver == 'mysql') {
7967
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7967
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
7968 7968
 								FROM spotter_output 
7969 7969
 								WHERE spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
7970 7970
 								GROUP BY spotter_output.airline_icao, date_name 
7971 7971
 								ORDER BY spotter_output.date ASC";
7972 7972
 			$query_data = array(':offset' => $offset);
7973 7973
 		} else {
7974
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7974
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
7975 7975
 								FROM spotter_output 
7976 7976
 								WHERE spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
7977 7977
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -7985,7 +7985,7 @@  discard block
 block discarded – undo
7985 7985
 		$date_array = array();
7986 7986
 		$temp_array = array();
7987 7987
         
7988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7989 7989
 		{
7990 7990
 			$temp_array['date_name'] = $row['date_name'];
7991 7991
 			$temp_array['date_count'] = $row['date_count'];
@@ -8032,7 +8032,7 @@  discard block
 block discarded – undo
8032 8032
 		$date_array = array();
8033 8033
 		$temp_array = array();
8034 8034
         
8035
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8035
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8036 8036
 		{
8037 8037
 			$temp_array['month_name'] = $row['month_name'];
8038 8038
 			$temp_array['year_name'] = $row['year_name'];
@@ -8060,13 +8060,13 @@  discard block
 block discarded – undo
8060 8060
 		} else $offset = '+00:00';
8061 8061
 
8062 8062
 		if ($globalDBdriver == 'mysql') {
8063
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8063
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8064 8064
 								FROM spotter_output 
8065 8065
 								WHERE spotter_output.airline_icao <> '' 
8066 8066
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
8067 8067
 								ORDER BY date_count DESC";
8068 8068
 		} else {
8069
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8069
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8070 8070
 								FROM spotter_output 
8071 8071
 								WHERE spotter_output.airline_icao <> '' 
8072 8072
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -8080,7 +8080,7 @@  discard block
 block discarded – undo
8080 8080
 		$date_array = array();
8081 8081
 		$temp_array = array();
8082 8082
         
8083
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8083
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8084 8084
 		{
8085 8085
 			$temp_array['month_name'] = $row['month_name'];
8086 8086
 			$temp_array['year_name'] = $row['year_name'];
@@ -8109,13 +8109,13 @@  discard block
 block discarded – undo
8109 8109
 		} else $offset = '+00:00';
8110 8110
 
8111 8111
 		if ($globalDBdriver == 'mysql') {
8112
-			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8112
+			$query = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
8113 8113
 								FROM spotter_output s
8114 8114
 								WHERE s.airline_type = 'military'
8115 8115
 								GROUP BY year_name, month_name 
8116 8116
 								ORDER BY date_count DESC";
8117 8117
 		} else {
8118
-			$query  = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8118
+			$query = "SELECT EXTRACT(YEAR FROM s.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM s.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
8119 8119
 								FROM spotter_output s
8120 8120
 								WHERE s.airline_type = 'military'
8121 8121
 								GROUP BY year_name, month_name 
@@ -8128,7 +8128,7 @@  discard block
 block discarded – undo
8128 8128
 		$date_array = array();
8129 8129
 		$temp_array = array();
8130 8130
         
8131
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8131
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8132 8132
 		{
8133 8133
 			$temp_array['month_name'] = $row['month_name'];
8134 8134
 			$temp_array['year_name'] = $row['year_name'];
@@ -8156,13 +8156,13 @@  discard block
 block discarded – undo
8156 8156
 		} else $offset = '+00:00';
8157 8157
 
8158 8158
 		if ($globalDBdriver == 'mysql') {
8159
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8159
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8160 8160
 								FROM spotter_output 
8161 8161
 								WHERE owner_name <> ''
8162 8162
 								GROUP BY year_name, month_name
8163 8163
 								ORDER BY date_count DESC";
8164 8164
 		} else {
8165
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8165
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8166 8166
 								FROM spotter_output 
8167 8167
 								WHERE owner_name <> ''
8168 8168
 								GROUP BY year_name, month_name
@@ -8175,7 +8175,7 @@  discard block
 block discarded – undo
8175 8175
 		$date_array = array();
8176 8176
 		$temp_array = array();
8177 8177
         
8178
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8178
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8179 8179
 		{
8180 8180
 			$temp_array['month_name'] = $row['month_name'];
8181 8181
 			$temp_array['year_name'] = $row['year_name'];
@@ -8203,13 +8203,13 @@  discard block
 block discarded – undo
8203 8203
 		} else $offset = '+00:00';
8204 8204
 
8205 8205
 		if ($globalDBdriver == 'mysql') {
8206
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8206
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
8207 8207
 								FROM spotter_output 
8208 8208
 								WHERE owner_name <> '' AND spotter_output.airline_icao <> '' 
8209 8209
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8210 8210
 								ORDER BY date_count DESC";
8211 8211
 		} else {
8212
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8212
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
8213 8213
 								FROM spotter_output 
8214 8214
 								WHERE owner_name <> '' AND spotter_output.airline_icao <> '' 
8215 8215
 								GROUP BY spotter_output.airline_icao, year_name, month_name
@@ -8222,7 +8222,7 @@  discard block
 block discarded – undo
8222 8222
 		$date_array = array();
8223 8223
 		$temp_array = array();
8224 8224
         
8225
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8225
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8226 8226
 		{
8227 8227
 			$temp_array['month_name'] = $row['month_name'];
8228 8228
 			$temp_array['year_name'] = $row['year_name'];
@@ -8251,13 +8251,13 @@  discard block
 block discarded – undo
8251 8251
 		} else $offset = '+00:00';
8252 8252
 
8253 8253
 		if ($globalDBdriver == 'mysql') {
8254
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8254
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8255 8255
 								FROM spotter_output 
8256 8256
 								WHERE pilot_id <> '' AND pilot_id IS NOT NULL
8257 8257
 								GROUP BY year_name, month_name
8258 8258
 								ORDER BY date_count DESC";
8259 8259
 		} else {
8260
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8260
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8261 8261
 								FROM spotter_output 
8262 8262
 								WHERE pilot_id <> '' AND pilot_id IS NOT NULL
8263 8263
 								GROUP BY year_name, month_name
@@ -8270,7 +8270,7 @@  discard block
 block discarded – undo
8270 8270
 		$date_array = array();
8271 8271
 		$temp_array = array();
8272 8272
         
8273
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8273
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8274 8274
 		{
8275 8275
 			$temp_array['month_name'] = $row['month_name'];
8276 8276
 			$temp_array['year_name'] = $row['year_name'];
@@ -8298,13 +8298,13 @@  discard block
 block discarded – undo
8298 8298
 		} else $offset = '+00:00';
8299 8299
 
8300 8300
 		if ($globalDBdriver == 'mysql') {
8301
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8301
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
8302 8302
 								FROM spotter_output 
8303 8303
 								WHERE spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8304 8304
 								GROUP BY spotter_output.airline_icao,year_name, month_name
8305 8305
 								ORDER BY date_count DESC";
8306 8306
 		} else {
8307
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8307
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
8308 8308
 								FROM spotter_output 
8309 8309
 								WHERE spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
8310 8310
 								GROUP BY spotter_output.airline_icao, year_name, month_name
@@ -8317,7 +8317,7 @@  discard block
 block discarded – undo
8317 8317
 		$date_array = array();
8318 8318
 		$temp_array = array();
8319 8319
         
8320
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8320
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8321 8321
 		{
8322 8322
 			$temp_array['month_name'] = $row['month_name'];
8323 8323
 			$temp_array['year_name'] = $row['year_name'];
@@ -8346,13 +8346,13 @@  discard block
 block discarded – undo
8346 8346
 		} else $offset = '+00:00';
8347 8347
 
8348 8348
 		if ($globalDBdriver == 'mysql') {
8349
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
8349
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
8350 8350
 								FROM spotter_output 
8351 8351
 								WHERE airline_icao <> '' 
8352 8352
 								GROUP BY year_name, month_name
8353 8353
 								ORDER BY date_count DESC";
8354 8354
 		} else {
8355
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
8355
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
8356 8356
 								FROM spotter_output 
8357 8357
 								WHERE airline_icao <> '' 
8358 8358
 								GROUP BY year_name, month_name
@@ -8365,7 +8365,7 @@  discard block
 block discarded – undo
8365 8365
 		$date_array = array();
8366 8366
 		$temp_array = array();
8367 8367
         
8368
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8368
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8369 8369
 		{
8370 8370
 			$temp_array['month_name'] = $row['month_name'];
8371 8371
 			$temp_array['year_name'] = $row['year_name'];
@@ -8393,13 +8393,13 @@  discard block
 block discarded – undo
8393 8393
 		} else $offset = '+00:00';
8394 8394
 
8395 8395
 		if ($globalDBdriver == 'mysql') {
8396
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8396
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8397 8397
 								FROM spotter_output 
8398 8398
 								WHERE aircraft_icao <> '' 
8399 8399
 								GROUP BY year_name, month_name
8400 8400
 								ORDER BY date_count DESC";
8401 8401
 		} else {
8402
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8402
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8403 8403
 								FROM spotter_output 
8404 8404
 								WHERE aircraft_icao <> '' 
8405 8405
 								GROUP BY year_name, month_name
@@ -8412,7 +8412,7 @@  discard block
 block discarded – undo
8412 8412
 		$date_array = array();
8413 8413
 		$temp_array = array();
8414 8414
         
8415
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8415
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8416 8416
 		{
8417 8417
 			$temp_array['month_name'] = $row['month_name'];
8418 8418
 			$temp_array['year_name'] = $row['year_name'];
@@ -8441,13 +8441,13 @@  discard block
 block discarded – undo
8441 8441
 		} else $offset = '+00:00';
8442 8442
 
8443 8443
 		if ($globalDBdriver == 'mysql') {
8444
-			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8444
+			$query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
8445 8445
 								FROM spotter_output 
8446 8446
 								WHERE aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
8447 8447
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8448 8448
 								ORDER BY date_count DESC";
8449 8449
 		} else {
8450
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8450
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
8451 8451
 								FROM spotter_output 
8452 8452
 								WHERE aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
8453 8453
 								GROUP BY spotter_output.airline_icao, year_name, month_name
@@ -8460,7 +8460,7 @@  discard block
 block discarded – undo
8460 8460
 		$date_array = array();
8461 8461
 		$temp_array = array();
8462 8462
         
8463
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8463
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8464 8464
 		{
8465 8465
 			$temp_array['month_name'] = $row['month_name'];
8466 8466
 			$temp_array['year_name'] = $row['year_name'];
@@ -8489,13 +8489,13 @@  discard block
 block discarded – undo
8489 8489
 		} else $offset = '+00:00';
8490 8490
 
8491 8491
 		if ($globalDBdriver == 'mysql') {
8492
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8492
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8493 8493
 								FROM spotter_output 
8494 8494
 								WHERE real_arrival_airport_icao <> '' 
8495 8495
 								GROUP BY year_name, month_name
8496 8496
 								ORDER BY date_count DESC";
8497 8497
 		} else {
8498
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8498
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8499 8499
 								FROM spotter_output 
8500 8500
 								WHERE real_arrival_airport_icao <> '' 
8501 8501
 								GROUP BY year_name, month_name
@@ -8508,7 +8508,7 @@  discard block
 block discarded – undo
8508 8508
 		$date_array = array();
8509 8509
 		$temp_array = array();
8510 8510
         
8511
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8511
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8512 8512
 		{
8513 8513
 			$temp_array['month_name'] = $row['month_name'];
8514 8514
 			$temp_array['year_name'] = $row['year_name'];
@@ -8537,13 +8537,13 @@  discard block
 block discarded – undo
8537 8537
 		} else $offset = '+00:00';
8538 8538
 
8539 8539
 		if ($globalDBdriver == 'mysql') {
8540
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8540
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
8541 8541
 								FROM spotter_output 
8542 8542
 								WHERE real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8543 8543
 								GROUP BY spotter_output.airline_icao, year_name, month_name
8544 8544
 								ORDER BY date_count DESC";
8545 8545
 		} else {
8546
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8546
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
8547 8547
 								FROM spotter_output 
8548 8548
 								WHERE real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
8549 8549
 								GROUP BY spotter_output.airline_icao, year_name, month_name
@@ -8556,7 +8556,7 @@  discard block
 block discarded – undo
8556 8556
 		$date_array = array();
8557 8557
 		$temp_array = array();
8558 8558
         
8559
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8559
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8560 8560
 		{
8561 8561
 			$temp_array['month_name'] = $row['month_name'];
8562 8562
 			$temp_array['year_name'] = $row['year_name'];
@@ -8584,7 +8584,7 @@  discard block
 block discarded – undo
8584 8584
 			$datetime = new DateTime();
8585 8585
 			$offset = $datetime->format('P');
8586 8586
 		} else $offset = '+00:00';
8587
-		$filter_query = $this->getFilter($filters,true,true);
8587
+		$filter_query = $this->getFilter($filters, true, true);
8588 8588
 		if ($globalDBdriver == 'mysql') {
8589 8589
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
8590 8590
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -8605,7 +8605,7 @@  discard block
 block discarded – undo
8605 8605
 		$date_array = array();
8606 8606
 		$temp_array = array();
8607 8607
         
8608
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8608
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8609 8609
 		{
8610 8610
 			$temp_array['year_name'] = $row['year_name'];
8611 8611
 			$temp_array['month_name'] = $row['month_name'];
@@ -8625,7 +8625,7 @@  discard block
 block discarded – undo
8625 8625
 	* @return Array the hour list
8626 8626
 	*
8627 8627
 	*/
8628
-	public function countAllHours($orderby,$filters = array())
8628
+	public function countAllHours($orderby, $filters = array())
8629 8629
 	{
8630 8630
 		global $globalTimezone, $globalDBdriver;
8631 8631
 		if ($globalTimezone != '') {
@@ -8673,7 +8673,7 @@  discard block
 block discarded – undo
8673 8673
 		$hour_array = array();
8674 8674
 		$temp_array = array();
8675 8675
         
8676
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8676
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8677 8677
 		{
8678 8678
 			$temp_array['hour_name'] = $row['hour_name'];
8679 8679
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8710,7 +8710,7 @@  discard block
 block discarded – undo
8710 8710
 		}
8711 8711
 		
8712 8712
 		if ($globalDBdriver == 'mysql') {
8713
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8713
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8714 8714
 								FROM spotter_output 
8715 8715
 								WHERE spotter_output.airline_icao <> '' 
8716 8716
 								GROUP BY spotter_output.airline_icao, hour_name 
@@ -8724,7 +8724,7 @@  discard block
 block discarded – undo
8724 8724
   */    
8725 8725
 		$query_data = array(':offset' => $offset);
8726 8726
 		} else {
8727
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8727
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8728 8728
 								FROM spotter_output 
8729 8729
 								WHERE spotter_output.airline_icao <> '' 
8730 8730
 								GROUP BY spotter_output.airline_icao, hour_name 
@@ -8738,7 +8738,7 @@  discard block
 block discarded – undo
8738 8738
 		$hour_array = array();
8739 8739
 		$temp_array = array();
8740 8740
         
8741
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8741
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8742 8742
 		{
8743 8743
 			$temp_array['hour_name'] = $row['hour_name'];
8744 8744
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8767,16 +8767,16 @@  discard block
 block discarded – undo
8767 8767
 			$offset = $datetime->format('P');
8768 8768
 		} else $offset = '+00:00';
8769 8769
 
8770
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8770
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8771 8771
 
8772 8772
 		if ($globalDBdriver == 'mysql') {
8773
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8773
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8774 8774
 								FROM spotter_output 
8775 8775
 								WHERE spotter_output.airline_icao = :airline_icao
8776 8776
 								GROUP BY hour_name 
8777 8777
 								ORDER BY hour_name ASC";
8778 8778
 		} else {
8779
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8779
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8780 8780
 								FROM spotter_output 
8781 8781
 								WHERE spotter_output.airline_icao = :airline_icao
8782 8782
 								GROUP BY hour_name 
@@ -8784,12 +8784,12 @@  discard block
 block discarded – undo
8784 8784
 		}
8785 8785
 		
8786 8786
 		$sth = $this->db->prepare($query);
8787
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
8787
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
8788 8788
       
8789 8789
 		$hour_array = array();
8790 8790
 		$temp_array = array();
8791 8791
         
8792
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8792
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8793 8793
 		{
8794 8794
 			$temp_array['hour_name'] = $row['hour_name'];
8795 8795
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8812,7 +8812,7 @@  discard block
 block discarded – undo
8812 8812
 	public function countAllHoursByAircraft($aircraft_icao)
8813 8813
 	{
8814 8814
 		global $globalTimezone, $globalDBdriver;
8815
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8815
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8816 8816
 		if ($globalTimezone != '') {
8817 8817
 			date_default_timezone_set($globalTimezone);
8818 8818
 			$datetime = new DateTime();
@@ -8820,13 +8820,13 @@  discard block
 block discarded – undo
8820 8820
 		} else $offset = '+00:00';
8821 8821
 
8822 8822
 		if ($globalDBdriver == 'mysql') {
8823
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8823
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8824 8824
 								FROM spotter_output 
8825 8825
 								WHERE spotter_output.aircraft_icao = :aircraft_icao
8826 8826
 								GROUP BY hour_name 
8827 8827
 								ORDER BY hour_name ASC";
8828 8828
 		} else {
8829
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8829
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8830 8830
 								FROM spotter_output 
8831 8831
 								WHERE spotter_output.aircraft_icao = :aircraft_icao
8832 8832
 								GROUP BY hour_name 
@@ -8834,12 +8834,12 @@  discard block
 block discarded – undo
8834 8834
 		}
8835 8835
 		
8836 8836
 		$sth = $this->db->prepare($query);
8837
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
8837
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
8838 8838
       
8839 8839
 		$hour_array = array();
8840 8840
 		$temp_array = array();
8841 8841
         
8842
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8842
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8843 8843
 		{
8844 8844
 			$temp_array['hour_name'] = $row['hour_name'];
8845 8845
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8860,7 +8860,7 @@  discard block
 block discarded – undo
8860 8860
 	public function countAllHoursByRegistration($registration)
8861 8861
 	{
8862 8862
 		global $globalTimezone, $globalDBdriver;
8863
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8863
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8864 8864
 		if ($globalTimezone != '') {
8865 8865
 			date_default_timezone_set($globalTimezone);
8866 8866
 			$datetime = new DateTime();
@@ -8868,13 +8868,13 @@  discard block
 block discarded – undo
8868 8868
 		} else $offset = '+00:00';
8869 8869
 
8870 8870
 		if ($globalDBdriver == 'mysql') {
8871
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8871
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8872 8872
 								FROM spotter_output 
8873 8873
 								WHERE spotter_output.registration = :registration
8874 8874
 								GROUP BY hour_name 
8875 8875
 								ORDER BY hour_name ASC";
8876 8876
 		} else {
8877
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8877
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8878 8878
 								FROM spotter_output 
8879 8879
 								WHERE spotter_output.registration = :registration
8880 8880
 								GROUP BY hour_name 
@@ -8882,12 +8882,12 @@  discard block
 block discarded – undo
8882 8882
 		}
8883 8883
 		
8884 8884
 		$sth = $this->db->prepare($query);
8885
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
8885
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
8886 8886
       
8887 8887
 		$hour_array = array();
8888 8888
 		$temp_array = array();
8889 8889
         
8890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8891 8891
 		{
8892 8892
 			$temp_array['hour_name'] = $row['hour_name'];
8893 8893
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8908,7 +8908,7 @@  discard block
 block discarded – undo
8908 8908
 	public function countAllHoursByAirport($airport_icao)
8909 8909
 	{
8910 8910
 		global $globalTimezone, $globalDBdriver;
8911
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8911
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8912 8912
 		if ($globalTimezone != '') {
8913 8913
 			date_default_timezone_set($globalTimezone);
8914 8914
 			$datetime = new DateTime();
@@ -8916,13 +8916,13 @@  discard block
 block discarded – undo
8916 8916
 		} else $offset = '+00:00';
8917 8917
 
8918 8918
 		if ($globalDBdriver == 'mysql') {
8919
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8919
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8920 8920
 								FROM spotter_output 
8921 8921
 								WHERE (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8922 8922
 								GROUP BY hour_name 
8923 8923
 								ORDER BY hour_name ASC";
8924 8924
 		} else {
8925
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8925
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8926 8926
 								FROM spotter_output 
8927 8927
 								WHERE (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8928 8928
 								GROUP BY hour_name 
@@ -8930,12 +8930,12 @@  discard block
 block discarded – undo
8930 8930
 		}
8931 8931
 		
8932 8932
 		$sth = $this->db->prepare($query);
8933
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
8933
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
8934 8934
       
8935 8935
 		$hour_array = array();
8936 8936
 		$temp_array = array();
8937 8937
         
8938
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8938
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8939 8939
 		{
8940 8940
 			$temp_array['hour_name'] = $row['hour_name'];
8941 8941
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -8957,7 +8957,7 @@  discard block
 block discarded – undo
8957 8957
 	public function countAllHoursByManufacturer($aircraft_manufacturer)
8958 8958
 	{
8959 8959
 		global $globalTimezone, $globalDBdriver;
8960
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8960
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8961 8961
 		if ($globalTimezone != '') {
8962 8962
 			date_default_timezone_set($globalTimezone);
8963 8963
 			$datetime = new DateTime();
@@ -8965,13 +8965,13 @@  discard block
 block discarded – undo
8965 8965
 		} else $offset = '+00:00';
8966 8966
 
8967 8967
 		if ($globalDBdriver == 'mysql') {
8968
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8968
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
8969 8969
 								FROM spotter_output 
8970 8970
 								WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8971 8971
 								GROUP BY hour_name 
8972 8972
 								ORDER BY hour_name ASC";
8973 8973
 		} else {
8974
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8974
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
8975 8975
 								FROM spotter_output 
8976 8976
 								WHERE spotter_output.aircraft_manufacturer = :aircraft_manufacturer
8977 8977
 								GROUP BY hour_name 
@@ -8979,12 +8979,12 @@  discard block
 block discarded – undo
8979 8979
 		}
8980 8980
 		
8981 8981
 		$sth = $this->db->prepare($query);
8982
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
8982
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
8983 8983
       
8984 8984
 		$hour_array = array();
8985 8985
 		$temp_array = array();
8986 8986
         
8987
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8987
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8988 8988
 		{
8989 8989
 			$temp_array['hour_name'] = $row['hour_name'];
8990 8990
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9006,7 +9006,7 @@  discard block
 block discarded – undo
9006 9006
 	public function countAllHoursByDate($date)
9007 9007
 	{
9008 9008
 		global $globalTimezone, $globalDBdriver;
9009
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
9009
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
9010 9010
 		if ($globalTimezone != '') {
9011 9011
 			date_default_timezone_set($globalTimezone);
9012 9012
 			$datetime = new DateTime($date);
@@ -9014,13 +9014,13 @@  discard block
 block discarded – undo
9014 9014
 		} else $offset = '+00:00';
9015 9015
 
9016 9016
 		if ($globalDBdriver == 'mysql') {
9017
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9017
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9018 9018
 								FROM spotter_output 
9019 9019
 								WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
9020 9020
 								GROUP BY hour_name 
9021 9021
 								ORDER BY hour_name ASC";
9022 9022
 		} else {
9023
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9023
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9024 9024
 								FROM spotter_output 
9025 9025
 								WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
9026 9026
 								GROUP BY hour_name 
@@ -9033,7 +9033,7 @@  discard block
 block discarded – undo
9033 9033
 		$hour_array = array();
9034 9034
 		$temp_array = array();
9035 9035
         
9036
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9036
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9037 9037
 		{
9038 9038
 			$temp_array['hour_name'] = $row['hour_name'];
9039 9039
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9055,7 +9055,7 @@  discard block
 block discarded – undo
9055 9055
 	public function countAllHoursByIdent($ident)
9056 9056
 	{
9057 9057
 		global $globalTimezone, $globalDBdriver;
9058
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9058
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9059 9059
 		if ($globalTimezone != '') {
9060 9060
 			date_default_timezone_set($globalTimezone);
9061 9061
 			$datetime = new DateTime();
@@ -9063,13 +9063,13 @@  discard block
 block discarded – undo
9063 9063
 		} else $offset = '+00:00';
9064 9064
 
9065 9065
 		if ($globalDBdriver == 'mysql') {
9066
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9066
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9067 9067
 								FROM spotter_output 
9068 9068
 								WHERE spotter_output.ident = :ident 
9069 9069
 								GROUP BY hour_name 
9070 9070
 								ORDER BY hour_name ASC";
9071 9071
 		} else {
9072
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9072
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9073 9073
 								FROM spotter_output 
9074 9074
 								WHERE spotter_output.ident = :ident 
9075 9075
 								GROUP BY hour_name 
@@ -9078,12 +9078,12 @@  discard block
 block discarded – undo
9078 9078
       
9079 9079
 		
9080 9080
 		$sth = $this->db->prepare($query);
9081
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
9081
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
9082 9082
       
9083 9083
 		$hour_array = array();
9084 9084
 		$temp_array = array();
9085 9085
         
9086
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9086
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9087 9087
 		{
9088 9088
 			$temp_array['hour_name'] = $row['hour_name'];
9089 9089
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9105,8 +9105,8 @@  discard block
 block discarded – undo
9105 9105
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao)
9106 9106
 	{
9107 9107
 		global $globalTimezone, $globalDBdriver;
9108
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
9109
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
9108
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
9109
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
9110 9110
 		if ($globalTimezone != '') {
9111 9111
 			date_default_timezone_set($globalTimezone);
9112 9112
 			$datetime = new DateTime();
@@ -9114,13 +9114,13 @@  discard block
 block discarded – undo
9114 9114
 		} else $offset = '+00:00';
9115 9115
 
9116 9116
 		if ($globalDBdriver == 'mysql') {
9117
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9117
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9118 9118
 								FROM spotter_output 
9119 9119
 								WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9120 9120
 								GROUP BY hour_name 
9121 9121
 								ORDER BY hour_name ASC";
9122 9122
 		} else {
9123
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9123
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9124 9124
 								FROM spotter_output 
9125 9125
 								WHERE (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
9126 9126
 								GROUP BY hour_name 
@@ -9128,12 +9128,12 @@  discard block
 block discarded – undo
9128 9128
 		}
9129 9129
 		
9130 9130
 		$sth = $this->db->prepare($query);
9131
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
9131
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
9132 9132
       
9133 9133
 		$hour_array = array();
9134 9134
 		$temp_array = array();
9135 9135
         
9136
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9136
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9137 9137
 		{
9138 9138
 			$temp_array['hour_name'] = $row['hour_name'];
9139 9139
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9154,7 +9154,7 @@  discard block
 block discarded – undo
9154 9154
 	public function countAllHoursByCountry($country)
9155 9155
 	{
9156 9156
 		global $globalTimezone, $globalDBdriver;
9157
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
9157
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
9158 9158
 		if ($globalTimezone != '') {
9159 9159
 			date_default_timezone_set($globalTimezone);
9160 9160
 			$datetime = new DateTime();
@@ -9162,13 +9162,13 @@  discard block
 block discarded – undo
9162 9162
 		} else $offset = '+00:00';
9163 9163
 
9164 9164
 		if ($globalDBdriver == 'mysql') {
9165
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9165
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9166 9166
 								FROM spotter_output 
9167 9167
 								WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9168 9168
 								GROUP BY hour_name 
9169 9169
 								ORDER BY hour_name ASC";
9170 9170
 		} else {
9171
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9171
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9172 9172
 								FROM spotter_output 
9173 9173
 								WHERE ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
9174 9174
 								GROUP BY hour_name 
@@ -9176,12 +9176,12 @@  discard block
 block discarded – undo
9176 9176
 		}
9177 9177
 		
9178 9178
 		$sth = $this->db->prepare($query);
9179
-		$sth->execute(array(':country' => $country,':offset' => $offset));
9179
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
9180 9180
       
9181 9181
 		$hour_array = array();
9182 9182
 		$temp_array = array();
9183 9183
         
9184
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9184
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9185 9185
 		{
9186 9186
 			$temp_array['hour_name'] = $row['hour_name'];
9187 9187
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9203,8 +9203,8 @@  discard block
 block discarded – undo
9203 9203
 	*/
9204 9204
 	public function countOverallAircrafts($filters = array())
9205 9205
 	{
9206
-		$filter_query = $this->getFilter($filters,true,true);
9207
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9206
+		$filter_query = $this->getFilter($filters, true, true);
9207
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
9208 9208
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9209 9209
 		$sth = $this->db->prepare($query);
9210 9210
 		$sth->execute();
@@ -9219,8 +9219,8 @@  discard block
 block discarded – undo
9219 9219
 	*/
9220 9220
 	public function countOverallArrival($filters = array())
9221 9221
 	{
9222
-		$filter_query = $this->getFilter($filters,true,true);
9223
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9222
+		$filter_query = $this->getFilter($filters, true, true);
9223
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
9224 9224
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
9225 9225
 		
9226 9226
 		$sth = $this->db->prepare($query);
@@ -9236,8 +9236,8 @@  discard block
 block discarded – undo
9236 9236
 	*/
9237 9237
 	public function countOverallPilots($filters = array())
9238 9238
 	{
9239
-		$filter_query = $this->getFilter($filters,true,true);
9240
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9239
+		$filter_query = $this->getFilter($filters, true, true);
9240
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
9241 9241
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
9242 9242
 		$sth = $this->db->prepare($query);
9243 9243
 		$sth->execute();
@@ -9252,8 +9252,8 @@  discard block
 block discarded – undo
9252 9252
 	*/
9253 9253
 	public function countOverallOwners($filters = array())
9254 9254
 	{
9255
-		$filter_query = $this->getFilter($filters,true,true);
9256
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9255
+		$filter_query = $this->getFilter($filters, true, true);
9256
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
9257 9257
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
9258 9258
 		$sth = $this->db->prepare($query);
9259 9259
 		$sth->execute();
@@ -9286,8 +9286,8 @@  discard block
 block discarded – undo
9286 9286
 	*/
9287 9287
 	public function countOverallMilitaryFlights($filters = array())
9288 9288
 	{
9289
-		$filter_query = $this->getFilter($filters,true,true);
9290
-		$query  = "SELECT COUNT(s.spotter_id) AS flight_count  
9289
+		$filter_query = $this->getFilter($filters, true, true);
9290
+		$query = "SELECT COUNT(s.spotter_id) AS flight_count  
9291 9291
                     FROM spotter_output s, airlines a".$filter_query." s.airline_icao = a.icao AND a.type = 'military'";
9292 9292
       
9293 9293
 		$sth = $this->db->prepare($query);
@@ -9331,13 +9331,13 @@  discard block
 block discarded – undo
9331 9331
 		} else $offset = '+00:00';
9332 9332
 
9333 9333
 		if ($globalDBdriver == 'mysql') {
9334
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9334
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
9335 9335
 								FROM spotter_output 
9336 9336
 								WHERE DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
9337 9337
 								GROUP BY hour_name 
9338 9338
 								ORDER BY hour_name ASC";
9339 9339
 		} else {
9340
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9340
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
9341 9341
 								FROM spotter_output 
9342 9342
 								WHERE to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
9343 9343
 								GROUP BY hour_name 
@@ -9350,7 +9350,7 @@  discard block
 block discarded – undo
9350 9350
 		$hour_array = array();
9351 9351
 		$temp_array = array();
9352 9352
         
9353
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9353
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9354 9354
 		{
9355 9355
 			$temp_array['hour_name'] = $row['hour_name'];
9356 9356
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -9374,8 +9374,8 @@  discard block
 block discarded – undo
9374 9374
 		if ($limit != "")
9375 9375
 		{
9376 9376
 			$limit_array = explode(",", $limit);
9377
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
9378
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
9377
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
9378
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
9379 9379
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
9380 9380
 			{
9381 9381
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -9430,7 +9430,7 @@  discard block
 block discarded – undo
9430 9430
 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH')
9431 9431
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
9432 9432
 			//echo $query;
9433
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
9433
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
9434 9434
 			/*
9435 9435
 			$sth = $this->db->prepare($query);
9436 9436
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -9449,9 +9449,9 @@  discard block
 block discarded – undo
9449 9449
 	*/
9450 9450
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
9451 9451
 	{
9452
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
9452
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
9453 9453
 
9454
-		$query  = "SELECT spotter_output.spotter_id
9454
+		$query = "SELECT spotter_output.spotter_id
9455 9455
 								FROM spotter_output 
9456 9456
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
9457 9457
         
@@ -9459,7 +9459,7 @@  discard block
 block discarded – undo
9459 9459
 		$sth = $this->db->prepare($query);
9460 9460
 		$sth->execute();
9461 9461
 
9462
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9462
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9463 9463
 		{
9464 9464
 			return $row['spotter_id'];
9465 9465
 		}
@@ -9484,23 +9484,23 @@  discard block
 block discarded – undo
9484 9484
 		}
9485 9485
 		
9486 9486
 		$current_date = date("Y-m-d H:i:s");
9487
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
9487
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
9488 9488
 		
9489 9489
 		$diff = abs(strtotime($current_date) - strtotime($date));
9490 9490
 
9491
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
9491
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
9492 9492
 		$years = $time_array['years'];
9493 9493
 		
9494
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
9494
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
9495 9495
 		$months = $time_array['months'];
9496 9496
 		
9497
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
9497
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
9498 9498
 		$days = $time_array['days'];
9499
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
9499
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
9500 9500
 		$hours = $time_array['hours'];
9501
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
9501
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
9502 9502
 		$minutes = $time_array['minutes'];
9503
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9503
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
9504 9504
 		
9505 9505
 		return $time_array;	
9506 9506
 	}	
@@ -9526,63 +9526,63 @@  discard block
 block discarded – undo
9526 9526
 			$temp_array['direction_degree'] = $direction;
9527 9527
 			$temp_array['direction_shortname'] = "N";
9528 9528
 			$temp_array['direction_fullname'] = "North";
9529
-		} elseif ($direction >= 22.5 && $direction < 45){
9529
+		} elseif ($direction >= 22.5 && $direction < 45) {
9530 9530
 			$temp_array['direction_degree'] = $direction;
9531 9531
 			$temp_array['direction_shortname'] = "NNE";
9532 9532
 			$temp_array['direction_fullname'] = "North-Northeast";
9533
-		} elseif ($direction >= 45 && $direction < 67.5){
9533
+		} elseif ($direction >= 45 && $direction < 67.5) {
9534 9534
 			$temp_array['direction_degree'] = $direction;
9535 9535
 			$temp_array['direction_shortname'] = "NE";
9536 9536
 			$temp_array['direction_fullname'] = "Northeast";
9537
-		} elseif ($direction >= 67.5 && $direction < 90){
9537
+		} elseif ($direction >= 67.5 && $direction < 90) {
9538 9538
 			$temp_array['direction_degree'] = $direction;
9539 9539
 			$temp_array['direction_shortname'] = "ENE";
9540 9540
 			$temp_array['direction_fullname'] = "East-Northeast";
9541
-		} elseif ($direction >= 90 && $direction < 112.5){
9541
+		} elseif ($direction >= 90 && $direction < 112.5) {
9542 9542
 			$temp_array['direction_degree'] = $direction;
9543 9543
 			$temp_array['direction_shortname'] = "E";
9544 9544
 			$temp_array['direction_fullname'] = "East";
9545
-		} elseif ($direction >= 112.5 && $direction < 135){
9545
+		} elseif ($direction >= 112.5 && $direction < 135) {
9546 9546
 			$temp_array['direction_degree'] = $direction;
9547 9547
 			$temp_array['direction_shortname'] = "ESE";
9548 9548
 			$temp_array['direction_fullname'] = "East-Southeast";
9549
-		} elseif ($direction >= 135 && $direction < 157.5){
9549
+		} elseif ($direction >= 135 && $direction < 157.5) {
9550 9550
 			$temp_array['direction_degree'] = $direction;
9551 9551
 			$temp_array['direction_shortname'] = "SE";
9552 9552
 			$temp_array['direction_fullname'] = "Southeast";
9553
-		} elseif ($direction >= 157.5 && $direction < 180){
9553
+		} elseif ($direction >= 157.5 && $direction < 180) {
9554 9554
 			$temp_array['direction_degree'] = $direction;
9555 9555
 			$temp_array['direction_shortname'] = "SSE";
9556 9556
 			$temp_array['direction_fullname'] = "South-Southeast";
9557
-		} elseif ($direction >= 180 && $direction < 202.5){
9557
+		} elseif ($direction >= 180 && $direction < 202.5) {
9558 9558
 			$temp_array['direction_degree'] = $direction;
9559 9559
 			$temp_array['direction_shortname'] = "S";
9560 9560
 			$temp_array['direction_fullname'] = "South";
9561
-		} elseif ($direction >= 202.5 && $direction < 225){
9561
+		} elseif ($direction >= 202.5 && $direction < 225) {
9562 9562
 			$temp_array['direction_degree'] = $direction;
9563 9563
 			$temp_array['direction_shortname'] = "SSW";
9564 9564
 			$temp_array['direction_fullname'] = "South-Southwest";
9565
-		} elseif ($direction >= 225 && $direction < 247.5){
9565
+		} elseif ($direction >= 225 && $direction < 247.5) {
9566 9566
 			$temp_array['direction_degree'] = $direction;
9567 9567
 			$temp_array['direction_shortname'] = "SW";
9568 9568
 			$temp_array['direction_fullname'] = "Southwest";
9569
-		} elseif ($direction >= 247.5 && $direction < 270){
9569
+		} elseif ($direction >= 247.5 && $direction < 270) {
9570 9570
 			$temp_array['direction_degree'] = $direction;
9571 9571
 			$temp_array['direction_shortname'] = "WSW";
9572 9572
 			$temp_array['direction_fullname'] = "West-Southwest";
9573
-		} elseif ($direction >= 270 && $direction < 292.5){
9573
+		} elseif ($direction >= 270 && $direction < 292.5) {
9574 9574
 			$temp_array['direction_degree'] = $direction;
9575 9575
 			$temp_array['direction_shortname'] = "W";
9576 9576
 			$temp_array['direction_fullname'] = "West";
9577
-		} elseif ($direction >= 292.5 && $direction < 315){
9577
+		} elseif ($direction >= 292.5 && $direction < 315) {
9578 9578
 			$temp_array['direction_degree'] = $direction;
9579 9579
 			$temp_array['direction_shortname'] = "WNW";
9580 9580
 			$temp_array['direction_fullname'] = "West-Northwest";
9581
-		} elseif ($direction >= 315 && $direction < 337.5){
9581
+		} elseif ($direction >= 315 && $direction < 337.5) {
9582 9582
 			$temp_array['direction_degree'] = $direction;
9583 9583
 			$temp_array['direction_shortname'] = "NW";
9584 9584
 			$temp_array['direction_fullname'] = "Northwest";
9585
-		} elseif ($direction >= 337.5 && $direction < 360){
9585
+		} elseif ($direction >= 337.5 && $direction < 360) {
9586 9586
 			$temp_array['direction_degree'] = $direction;
9587 9587
 			$temp_array['direction_shortname'] = "NNW";
9588 9588
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -9635,9 +9635,9 @@  discard block
 block discarded – undo
9635 9635
 	*/
9636 9636
 	public function getAircraftRegistrationBymodeS($aircraft_modes)
9637 9637
 	{
9638
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9638
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9639 9639
 	
9640
-		$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9640
+		$query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9641 9641
 		
9642 9642
 		$sth = $this->db->prepare($query);
9643 9643
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9659,9 +9659,9 @@  discard block
 block discarded – undo
9659 9659
 	*/
9660 9660
 	public function getAircraftTypeBymodeS($aircraft_modes)
9661 9661
 	{
9662
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
9662
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
9663 9663
 	
9664
-		$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9664
+		$query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes LIMIT 1";
9665 9665
 		
9666 9666
 		$sth = $this->db->prepare($query);
9667 9667
 		$sth->execute(array(':aircraft_modes' => $aircraft_modes));
@@ -9681,11 +9681,11 @@  discard block
 block discarded – undo
9681 9681
 	* @param Float $longitude longitute of the flight
9682 9682
 	* @return String the countrie
9683 9683
 	*/
9684
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
9684
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
9685 9685
 	{
9686 9686
 		global $globalDBdriver, $globalDebug;
9687
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9688
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9687
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9688
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
9689 9689
 	
9690 9690
 		$Connection = new Connection($this->db);
9691 9691
 		if (!$Connection->tableExists('countries')) return '';
@@ -9724,19 +9724,19 @@  discard block
 block discarded – undo
9724 9724
 	*/
9725 9725
 	public function convertAircraftRegistration($registration)
9726 9726
 	{
9727
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9727
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9728 9728
 		$registration_prefix = '';
9729 9729
 		$registration_1 = substr($registration, 0, 1);
9730 9730
 		$registration_2 = substr($registration, 0, 2);
9731 9731
 
9732 9732
 		//first get the prefix based on two characters
9733
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9733
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
9734 9734
       
9735 9735
 		
9736 9736
 		$sth = $this->db->prepare($query);
9737 9737
 		$sth->execute(array(':registration_2' => $registration_2));
9738 9738
         
9739
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9739
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9740 9740
 		{
9741 9741
 			$registration_prefix = $row['registration_prefix'];
9742 9742
 		}
@@ -9744,11 +9744,11 @@  discard block
 block discarded – undo
9744 9744
 		//if we didn't find a two chracter prefix lets just search the one with one character
9745 9745
 		if ($registration_prefix == '')
9746 9746
 		{
9747
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9747
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
9748 9748
 			$sth = $this->db->prepare($query);
9749 9749
 			$sth->execute(array(':registration_1' => $registration_1));
9750 9750
 	        
9751
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9751
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9752 9752
 			{
9753 9753
 				$registration_prefix = $row['registration_prefix'];
9754 9754
 			}
@@ -9762,7 +9762,7 @@  discard block
 block discarded – undo
9762 9762
 			} else {
9763 9763
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
9764 9764
 			}
9765
-		} else if(strlen($registration_prefix) == 2){
9765
+		} else if (strlen($registration_prefix) == 2) {
9766 9766
 			if (0 === strpos($registration, 'N')) {
9767 9767
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
9768 9768
 			} else {
@@ -9781,17 +9781,17 @@  discard block
 block discarded – undo
9781 9781
 	*/
9782 9782
 	public function countryFromAircraftRegistration($registration)
9783 9783
 	{
9784
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
9784
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
9785 9785
 		
9786 9786
 		$registration_prefix = '';
9787
-		$registration_test = explode('-',$registration);
9787
+		$registration_test = explode('-', $registration);
9788 9788
 		$country = '';
9789 9789
 		if ($registration_test[0] != $registration) {
9790 9790
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9791 9791
 	      
9792 9792
 			$sth = $this->db->prepare($query);
9793 9793
 			$sth->execute(array(':registration_1' => $registration_test[0]));
9794
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9794
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9795 9795
 			{
9796 9796
 				//$registration_prefix = $row['registration_prefix'];
9797 9797
 				$country = $row['country'];
@@ -9802,13 +9802,13 @@  discard block
 block discarded – undo
9802 9802
 
9803 9803
 			$country = '';
9804 9804
 			//first get the prefix based on two characters
9805
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9805
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
9806 9806
       
9807 9807
 			
9808 9808
 			$sth = $this->db->prepare($query);
9809 9809
 			$sth->execute(array(':registration_2' => $registration_2));
9810 9810
         
9811
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
9811
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9812 9812
 			{
9813 9813
 				$registration_prefix = $row['registration_prefix'];
9814 9814
 				$country = $row['country'];
@@ -9817,12 +9817,12 @@  discard block
 block discarded – undo
9817 9817
 			//if we didn't find a two chracter prefix lets just search the one with one character
9818 9818
 			if ($registration_prefix == "")
9819 9819
 			{
9820
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9820
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
9821 9821
 	      
9822 9822
 				$sth = $this->db->prepare($query);
9823 9823
 				$sth->execute(array(':registration_1' => $registration_1));
9824 9824
 	        
9825
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
9825
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9826 9826
 				{
9827 9827
 					//$registration_prefix = $row['registration_prefix'];
9828 9828
 					$country = $row['country'];
@@ -9839,9 +9839,9 @@  discard block
 block discarded – undo
9839 9839
 	* @param String $flightaware_id flightaware_id from spotter_output table
9840 9840
 	* @param String $highlight New highlight value
9841 9841
 	*/
9842
-	public function setHighlightFlight($flightaware_id,$highlight) {
9842
+	public function setHighlightFlight($flightaware_id, $highlight) {
9843 9843
 		
9844
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9844
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
9845 9845
 		$sth = $this->db->prepare($query);
9846 9846
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
9847 9847
 	}
@@ -9870,7 +9870,7 @@  discard block
 block discarded – undo
9870 9870
 		
9871 9871
 		$bitly_data = json_decode($bitly_data);
9872 9872
 		$bitly_url = '';
9873
-		if ($bitly_data->status_txt = "OK"){
9873
+		if ($bitly_data->status_txt = "OK") {
9874 9874
 			$bitly_url = $bitly_data->data->url;
9875 9875
 		}
9876 9876
 
@@ -9880,7 +9880,7 @@  discard block
 block discarded – undo
9880 9880
 
9881 9881
 	public function getOrderBy()
9882 9882
 	{
9883
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
9883
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
9884 9884
 		
9885 9885
 		return $orderby;
9886 9886
 		
@@ -10014,14 +10014,14 @@  discard block
 block discarded – undo
10014 10014
 		}
10015 10015
 		$sth = $this->db->prepare($query);
10016 10016
 		$sth->execute();
10017
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10017
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10018 10018
 		{
10019 10019
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
10020 10020
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
10021 10021
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
10022
-				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
10022
+				$update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
10023 10023
 				$sthu = $this->db->prepare($update_query);
10024
-				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country']));
10024
+				$sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country']));
10025 10025
 			}
10026 10026
 		}
10027 10027
 		
@@ -10034,7 +10034,7 @@  discard block
 block discarded – undo
10034 10034
 		}
10035 10035
 		$sth = $this->db->prepare($query);
10036 10036
 		$sth->execute();
10037
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10037
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10038 10038
 		{
10039 10039
 			if (is_numeric(substr($row['ident'], -1, 1)))
10040 10040
 			{
@@ -10043,11 +10043,11 @@  discard block
 block discarded – undo
10043 10043
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
10044 10044
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
10045 10045
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
10046
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
10046
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
10047 10047
 				if (isset($airline_array[0]['name'])) {
10048
-					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
10048
+					$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
10049 10049
 					$sthu = $this->db->prepare($update_query);
10050
-					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
10050
+					$sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
10051 10051
 				}
10052 10052
 			}
10053 10053
 		}
@@ -10067,18 +10067,18 @@  discard block
 block discarded – undo
10067 10067
 		}
10068 10068
 		$sth = $this->db->prepare($query);
10069 10069
 		$sth->execute();
10070
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10070
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10071 10071
 		{
10072 10072
 			if ($row['aircraft_icao'] != '') {
10073 10073
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
10074
-				if ($row['registration'] != ""){
10074
+				if ($row['registration'] != "") {
10075 10075
 					$image_array = $Image->getSpotterImage($row['registration']);
10076 10076
 					if (count($image_array) == 0) {
10077 10077
 						$Image->addSpotterImage($row['registration']);
10078 10078
 					}
10079 10079
 				}
10080 10080
 				if (count($aircraft_name) > 0) {
10081
-					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
10081
+					$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
10082 10082
 					$sthu = $this->db->prepare($update_query);
10083 10083
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
10084 10084
 				}
@@ -10093,10 +10093,10 @@  discard block
 block discarded – undo
10093 10093
 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output";
10094 10094
 		$sth = $this->db->prepare($query);
10095 10095
 		$sth->execute();
10096
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10096
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10097 10097
 		{
10098 10098
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
10099
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
10099
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
10100 10100
 				$airport_icao = '';
10101 10101
 				 if (isset($closestAirports[0])) {
10102 10102
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -10110,7 +10110,7 @@  discard block
 block discarded – undo
10110 10110
 								break;
10111 10111
 							}
10112 10112
 						}
10113
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10113
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
10114 10114
 						$airport_icao = $closestAirports[0]['icao'];
10115 10115
 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10116 10116
 					} else {
@@ -10121,28 +10121,28 @@  discard block
 block discarded – undo
10121 10121
 				}
10122 10122
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10123 10123
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10124
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10124
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10125 10125
 					$sthu = $this->db->prepare($update_query);
10126
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
10126
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
10127 10127
 				}
10128 10128
 			}
10129 10129
 		}
10130 10130
 	}
10131 10131
 	
10132
-	public function closestAirports($origLat,$origLon,$dist = 10) {
10132
+	public function closestAirports($origLat, $origLon, $dist = 10) {
10133 10133
 		global $globalDBdriver;
10134
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
10134
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
10135 10135
 /*
10136 10136
 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10137 10137
                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10138 10138
                       having distance < $dist ORDER BY distance limit 100;";
10139 10139
 */
10140 10140
 		if ($globalDBdriver == 'mysql') {
10141
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10141
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
10142 10142
 	                      FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10143 10143
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
10144 10144
                 } else {
10145
-			$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
10145
+			$query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance 
10146 10146
 	                      FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
10147 10147
 	                      AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;";
10148 10148
     		}
Please login to merge, or discard this patch.
Braces   +655 added lines, -227 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	*/
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter;
22
-		if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter);
22
+		if (is_array($globalFilter)) {
23
+			$filter = array_merge($globalFilter,$filter);
24
+		}
23 25
 		$filter_query_join = '';
24 26
 		$filter_query_where = '';
25 27
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
@@ -44,8 +46,11 @@  discard block
 block discarded – undo
44 46
 				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
45 47
 			}
46 48
 		}
47
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
48
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
49
+		if ($filter_query_where == '' && $where) {
50
+			$filter_query_where = ' WHERE';
51
+		} elseif ($filter_query_where != '' && $and) {
52
+			$filter_query_where .= ' AND';
53
+		}
49 54
 		$filter_query = $filter_query_join.$filter_query_where;
50 55
 		return $filter_query;
51 56
 	}
@@ -65,10 +70,18 @@  discard block
 block discarded – undo
65 70
 		$Image = new Image($this->db);
66 71
 		$Schedule = new Schedule($this->db);
67 72
 		$ACARS = new ACARS($this->db);
68
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
69
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
70
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
71
-		if (!isset($globalVAM)) $globalVAM = FALSE;
73
+		if (!isset($globalIVAO)) {
74
+			$globalIVAO = FALSE;
75
+		}
76
+		if (!isset($globalVATSIM)) {
77
+			$globalVATSIM = FALSE;
78
+		}
79
+		if (!isset($globalphpVMS)) {
80
+			$globalphpVMS = FALSE;
81
+		}
82
+		if (!isset($globalVAM)) {
83
+			$globalVAM = FALSE;
84
+		}
72 85
 		date_default_timezone_set('UTC');
73 86
 		
74 87
 		if (!is_string($query))
@@ -115,21 +128,35 @@  discard block
 block discarded – undo
115 128
 			} else {
116 129
 				$temp_array['spotter_id'] = '';
117 130
 			}
118
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
119
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
131
+			if (isset($row['flightaware_id'])) {
132
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
133
+			}
134
+			if (isset($row['modes'])) {
135
+				$temp_array['modes'] = $row['modes'];
136
+			}
120 137
 			$temp_array['ident'] = $row['ident'];
121 138
 			if (isset($row['registration']) && $row['registration'] != '') {
122 139
 				$temp_array['registration'] = $row['registration'];
123 140
 			} elseif (isset($temp_array['modes'])) {
124 141
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
125
-			} else $temp_array['registration'] = '';
126
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
142
+			} else {
143
+				$temp_array['registration'] = '';
144
+			}
145
+			if (isset($row['aircraft_icao'])) {
146
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
147
+			}
127 148
 			
128 149
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
129 150
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
130
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
131
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
132
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
151
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
152
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
153
+			}
154
+			if (isset($row['latitude'])) {
155
+				$temp_array['latitude'] = $row['latitude'];
156
+			}
157
+			if (isset($row['longitude'])) {
158
+				$temp_array['longitude'] = $row['longitude'];
159
+			}
133 160
 			/*
134 161
 			if (Connection->tableExists('countries')) {
135 162
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -139,8 +166,12 @@  discard block
 block discarded – undo
139 166
 				}
140 167
 			}
141 168
 			*/
142
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
143
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
169
+			if (isset($row['waypoints'])) {
170
+				$temp_array['waypoints'] = $row['waypoints'];
171
+			}
172
+			if (isset($row['format_source'])) {
173
+				$temp_array['format_source'] = $row['format_source'];
174
+			}
144 175
 			if (isset($row['route_stop'])) {
145 176
 				$temp_array['route_stop'] = $row['route_stop'];
146 177
 				if ($row['route_stop'] != '') {
@@ -159,13 +190,19 @@  discard block
 block discarded – undo
159 190
 					}
160 191
 				}
161 192
 			}
162
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
193
+			if (isset($row['altitude'])) {
194
+				$temp_array['altitude'] = $row['altitude'];
195
+			}
163 196
 			if (isset($row['heading'])) {
164 197
 				$temp_array['heading'] = $row['heading'];
165 198
 				$heading_direction = $this->parseDirection($row['heading']);
166
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
199
+				if (isset($heading_direction[0]['direction_fullname'])) {
200
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
201
+				}
202
+			}
203
+			if (isset($row['ground_speed'])) {
204
+				$temp_array['ground_speed'] = $row['ground_speed'];
167 205
 			}
168
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
169 206
 			$temp_array['image'] = "";
170 207
 			$temp_array['image_thumbnail'] = "";
171 208
 			$temp_array['image_source'] = "";
@@ -173,7 +210,9 @@  discard block
 block discarded – undo
173 210
  
174 211
 			if (isset($row['highlight'])) {
175 212
 				$temp_array['highlight'] = $row['highlight'];
176
-			} else $temp_array['highlight'] = '';
213
+			} else {
214
+				$temp_array['highlight'] = '';
215
+			}
177 216
 			
178 217
 			if (isset($row['date'])) {
179 218
 				$dateArray = $this->parseDateString($row['date']);
@@ -221,7 +260,9 @@  discard block
 block discarded – undo
221 260
 				
222 261
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
223 262
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
224
-					} else $temp_array['aircraft_shadow'] = 'default.png';
263
+					} else {
264
+						$temp_array['aircraft_shadow'] = 'default.png';
265
+					}
225 266
                                 } else {
226 267
                             		$temp_array['aircraft_shadow'] = 'default.png';
227 268
 					$temp_array['aircraft_name'] = 'N/A';
@@ -229,11 +270,17 @@  discard block
 block discarded – undo
229 270
                             	}
230 271
 			}
231 272
 			$fromsource = NULL;
232
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
233
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
234
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
235
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
236
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
273
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
274
+				$fromsource = $globalAirlinesSource;
275
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
276
+				$fromsource = 'vatsim';
277
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
278
+				$fromsource = 'ivao';
279
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
280
+				$fromsource = 'vatsim';
281
+			} elseif (isset($globalIVAO) && $globalIVAO) {
282
+				$fromsource = 'ivao';
283
+			}
237 284
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
238 285
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
239 286
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -256,12 +303,18 @@  discard block
 block discarded – undo
256 303
 				}
257 304
 			} else {
258 305
 				$temp_array['airline_icao'] = $row['airline_icao'];
259
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
260
-				else $temp_array['airline_iata'] = '';
306
+				if (isset($row['airline_iata'])) {
307
+					$temp_array['airline_iata'] = $row['airline_iata'];
308
+				} else {
309
+					$temp_array['airline_iata'] = '';
310
+				}
261 311
 				$temp_array['airline_name'] = $row['airline_name'];
262 312
 				$temp_array['airline_country'] = $row['airline_country'];
263
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
264
-				else $temp_array['airline_callsign'] = 'N/A';
313
+				if (isset($row['airline_callsign'])) {
314
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
315
+				} else {
316
+					$temp_array['airline_callsign'] = 'N/A';
317
+				}
265 318
 				$temp_array['airline_type'] = $row['airline_type'];
266 319
 			}
267 320
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
@@ -277,7 +330,9 @@  discard block
 block discarded – undo
277 330
 			}
278 331
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
279 332
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
280
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
333
+				if ($owner_info['owner'] != '') {
334
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
335
+				}
281 336
 				$temp_array['aircraft_base'] = $owner_info['base'];
282 337
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
283 338
 			}
@@ -285,9 +340,14 @@  discard block
 block discarded – undo
285 340
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
286 341
 			{
287 342
 				if ($globalIVAO) {
288
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
289
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
290
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
343
+					if (isset($temp_array['airline_icao'])) {
344
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
345
+					} else {
346
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
347
+					}
348
+				} else {
349
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
350
+				}
291 351
 				if (count($image_array) > 0) {
292 352
 					$temp_array['image'] = $image_array[0]['image'];
293 353
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -337,7 +397,9 @@  discard block
 block discarded – undo
337 397
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
338 398
 			if ($row['departure_airport_icao'] != '') {
339 399
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
340
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
400
+				if (!isset($departure_airport_array[0]['name'])) {
401
+					$departure_airport_array = $this->getAllAirportInfo('NA');
402
+				}
341 403
 			/*
342 404
 			} elseif ($row['departure_airport_name'] != '') {
343 405
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -345,7 +407,9 @@  discard block
 block discarded – undo
345 407
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
346 408
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
347 409
 			*/
348
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
410
+			} else {
411
+				$departure_airport_array = $this->getAllAirportInfo('NA');
412
+			}
349 413
 			if (isset($departure_airport_array[0]['name'])) {
350 414
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
351 415
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -365,8 +429,12 @@  discard block
 block discarded – undo
365 429
 			
366 430
 			if ($row['arrival_airport_icao'] != '') {
367 431
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
368
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
369
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
432
+				if (count($arrival_airport_array) == 0) {
433
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
434
+				}
435
+			} else {
436
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
437
+			}
370 438
 			if (isset($arrival_airport_array[0]['name'])) {
371 439
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
372 440
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -382,27 +450,45 @@  discard block
 block discarded – undo
382 450
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
383 451
 			}
384 452
 			*/
385
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
386
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
387
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
388
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
389
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
453
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
454
+				$temp_array['pilot_id'] = $row['pilot_id'];
455
+			}
456
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
457
+				$temp_array['pilot_name'] = $row['pilot_name'];
458
+			}
459
+			if (isset($row['source_name']) && $row['source_name'] != '') {
460
+				$temp_array['source_name'] = $row['source_name'];
461
+			}
462
+			if (isset($row['over_country']) && $row['over_country'] != '') {
463
+				$temp_array['over_country'] = $row['over_country'];
464
+			}
465
+			if (isset($row['distance']) && $row['distance'] != '') {
466
+				$temp_array['distance'] = $row['distance'];
467
+			}
390 468
 			if (isset($row['squawk'])) {
391 469
 				$temp_array['squawk'] = $row['squawk'];
392 470
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
393 471
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
394
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
472
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
473
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
474
+					}
395 475
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
396 476
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
397
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
398
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
477
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
478
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
479
+					}
480
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
481
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
482
+				}
399 483
 			}
400 484
     			
401 485
 			$temp_array['query_number_rows'] = $num_rows;
402 486
 			
403 487
 			$spotter_array[] = $temp_array;
404 488
 		}
405
-		if ($num_rows == 0) return array();
489
+		if ($num_rows == 0) {
490
+			return array();
491
+		}
406 492
 		$spotter_array[0]['query_number_rows'] = $num_rows;
407 493
 		return $spotter_array;
408 494
 	}	
@@ -435,7 +521,9 @@  discard block
 block discarded – undo
435 521
 				foreach ($q_array as $q_item){
436 522
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
437 523
 					$additional_query .= " AND (";
438
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
524
+					if (is_int($q_item)) {
525
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
526
+					}
439 527
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
440 528
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
441 529
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -456,7 +544,9 @@  discard block
 block discarded – undo
456 544
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
457 545
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
458 546
 					$translate = $Translation->ident2icao($q_item);
459
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
547
+					if ($translate != $q_item) {
548
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
549
+					}
460 550
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
461 551
 					$additional_query .= ")";
462 552
 				}
@@ -683,7 +773,9 @@  discard block
 block discarded – undo
683 773
 				date_default_timezone_set($globalTimezone);
684 774
 				$datetime = new DateTime();
685 775
 				$offset = $datetime->format('P');
686
-			} else $offset = '+00:00';
776
+			} else {
777
+				$offset = '+00:00';
778
+			}
687 779
 
688 780
 			if ($date_array[1] != "")
689 781
 			{
@@ -715,8 +807,12 @@  discard block
 block discarded – undo
715 807
 			{
716 808
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
717 809
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
718
-			} else $limit_query = "";
719
-		} else $limit_query = "";
810
+			} else {
811
+				$limit_query = "";
812
+			}
813
+		} else {
814
+			$limit_query = "";
815
+		}
720 816
 
721 817
 
722 818
 		if ($sort != "")
@@ -784,8 +880,12 @@  discard block
 block discarded – undo
784 880
 			{
785 881
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
786 882
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
787
-			} else $limit_query = "";
788
-		} else $limit_query = "";
883
+			} else {
884
+				$limit_query = "";
885
+			}
886
+		} else {
887
+			$limit_query = "";
888
+		}
789 889
 		
790 890
 		if ($sort != "")
791 891
 		{
@@ -1109,7 +1209,9 @@  discard block
 block discarded – undo
1109 1209
 		global $global_query;
1110 1210
 		
1111 1211
 		date_default_timezone_set('UTC');
1112
-		if ($id == '') return array();
1212
+		if ($id == '') {
1213
+			return array();
1214
+		}
1113 1215
 		$additional_query = "spotter_output.spotter_id = :id";
1114 1216
 		$query_values = array(':id' => $id);
1115 1217
 
@@ -1746,7 +1848,9 @@  discard block
 block discarded – undo
1746 1848
 		{
1747 1849
 			$highlight = $row['highlight'];
1748 1850
 		}
1749
-		if (isset($highlight)) return $highlight;
1851
+		if (isset($highlight)) {
1852
+			return $highlight;
1853
+		}
1750 1854
 	}
1751 1855
 
1752 1856
 	
@@ -1773,7 +1877,9 @@  discard block
 block discarded – undo
1773 1877
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
1774 1878
 		if (count($row) > 0) {
1775 1879
 			return $row['usage'];
1776
-		} else return '';
1880
+		} else {
1881
+			return '';
1882
+		}
1777 1883
 	}
1778 1884
 
1779 1885
 	/**
@@ -1797,7 +1903,9 @@  discard block
 block discarded – undo
1797 1903
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
1798 1904
 		if (count($row) > 0) {
1799 1905
 			return $row['icao'];
1800
-		} else return '';
1906
+		} else {
1907
+			return '';
1908
+		}
1801 1909
 	}
1802 1910
 
1803 1911
 	/**
@@ -1824,7 +1932,9 @@  discard block
 block discarded – undo
1824 1932
 			$airport_longitude = $row['longitude'];
1825 1933
 			$Common = new Common();
1826 1934
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
1827
-		} else return '';
1935
+		} else {
1936
+			return '';
1937
+		}
1828 1938
 	}
1829 1939
 	
1830 1940
 	/**
@@ -1936,7 +2046,9 @@  discard block
 block discarded – undo
1936 2046
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1937 2047
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1938 2048
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1939
-		} else return array();
2049
+		} else {
2050
+			return array();
2051
+		}
1940 2052
 		if ($globalDBdriver == 'mysql') {
1941 2053
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
1942 2054
 		} else {
@@ -1971,7 +2083,9 @@  discard block
 block discarded – undo
1971 2083
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1972 2084
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1973 2085
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1974
-		} else return array();
2086
+		} else {
2087
+			return array();
2088
+		}
1975 2089
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
1976 2090
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
1977 2091
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2053,7 +2167,9 @@  discard block
 block discarded – undo
2053 2167
 				$sth = $this->db->prepare($query);
2054 2168
 				$sth->execute(array(':fromsource' => $fromsource));
2055 2169
 				$row = $sth->fetch(PDO::FETCH_ASSOC);
2056
-				if ($row['nb'] == 0) $result = $this->getAllAirlineInfo($airline_icao);
2170
+				if ($row['nb'] == 0) {
2171
+					$result = $this->getAllAirlineInfo($airline_icao);
2172
+				}
2057 2173
 			}
2058 2174
 			return $result;
2059 2175
 		}
@@ -2117,15 +2233,20 @@  discard block
 block discarded – undo
2117 2233
 				'A320-211' => 'A320',
2118 2234
 				'747-8i' => 'B748',
2119 2235
 				'A380' => 'A388');
2120
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2236
+		if (isset($all_aircraft[$aircraft_type])) {
2237
+			return $all_aircraft[$aircraft_type];
2238
+		}
2121 2239
 
2122 2240
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2123 2241
 		$aircraft_type = strtoupper($aircraft_type);
2124 2242
 		$sth = $this->db->prepare($query);
2125 2243
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2126 2244
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2127
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2128
-		else return '';
2245
+		if (isset($result[0]['icao'])) {
2246
+			return $result[0]['icao'];
2247
+		} else {
2248
+			return '';
2249
+		}
2129 2250
 	}
2130 2251
 	
2131 2252
 	/**
@@ -2147,7 +2268,9 @@  discard block
 block discarded – undo
2147 2268
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2148 2269
 		if (isset($row['icaotypecode'])) {
2149 2270
 			return $row['icaotypecode'];
2150
-		} else return '';
2271
+		} else {
2272
+			return '';
2273
+		}
2151 2274
 	}
2152 2275
 
2153 2276
 	/**
@@ -2168,7 +2291,9 @@  discard block
 block discarded – undo
2168 2291
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2169 2292
 		if (isset($row['operator_correct'])) {
2170 2293
 			return $row['operator_correct'];
2171
-		} else return $operator;
2294
+		} else {
2295
+			return $operator;
2296
+		}
2172 2297
 	}
2173 2298
 
2174 2299
 	/**
@@ -2181,7 +2306,9 @@  discard block
 block discarded – undo
2181 2306
 	public function getRouteInfo($callsign)
2182 2307
 	{
2183 2308
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2184
-                if ($callsign == '') return array();
2309
+                if ($callsign == '') {
2310
+                	return array();
2311
+                }
2185 2312
 		$query  = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1";
2186 2313
 		
2187 2314
 		$sth = $this->db->prepare($query);
@@ -2190,7 +2317,9 @@  discard block
 block discarded – undo
2190 2317
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
2191 2318
 		if (count($row) > 0) {
2192 2319
 			return $row;
2193
-		} else return array();
2320
+		} else {
2321
+			return array();
2322
+		}
2194 2323
 	}
2195 2324
 	
2196 2325
 	/**
@@ -2242,7 +2371,9 @@  discard block
 block discarded – undo
2242 2371
 			$sth->execute(array(':registration' => $registration));
2243 2372
 
2244 2373
 			return $sth->fetch(PDO::FETCH_ASSOC);
2245
-		} else return array();
2374
+		} else {
2375
+			return array();
2376
+		}
2246 2377
 	}
2247 2378
 	
2248 2379
   
@@ -2398,8 +2529,11 @@  discard block
 block discarded – undo
2398 2529
 		$query .= " ORDER BY spotter_output.source_name ASC";
2399 2530
 
2400 2531
 		$sth = $this->db->prepare($query);
2401
-		if (!empty($query_values)) $sth->execute($query_values);
2402
-		else $sth->execute();
2532
+		if (!empty($query_values)) {
2533
+			$sth->execute($query_values);
2534
+		} else {
2535
+			$sth->execute();
2536
+		}
2403 2537
 
2404 2538
 		$source_array = array();
2405 2539
 		$temp_array = array();
@@ -2431,9 +2565,13 @@  discard block
 block discarded – undo
2431 2565
 								WHERE spotter_output.airline_icao <> '' 
2432 2566
 								ORDER BY spotter_output.airline_name ASC";
2433 2567
 			*/
2434
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2435
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2436
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2568
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2569
+				$forsource = $globalAirlinesSource;
2570
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2571
+				$forsource = 'vatsim';
2572
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2573
+				$forsource = 'ivao';
2574
+			}
2437 2575
 			if ($forsource === NULL) {
2438 2576
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2439 2577
 				$query_data = array();
@@ -2731,7 +2869,9 @@  discard block
 block discarded – undo
2731 2869
 			date_default_timezone_set($globalTimezone);
2732 2870
 			$datetime = new DateTime();
2733 2871
 			$offset = $datetime->format('P');
2734
-		} else $offset = '+00:00';
2872
+		} else {
2873
+			$offset = '+00:00';
2874
+		}
2735 2875
 		if ($airport_icao == '') {
2736 2876
 			if ($globalDBdriver == 'mysql') {
2737 2877
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2763,7 +2903,9 @@  discard block
 block discarded – undo
2763 2903
 			date_default_timezone_set($globalTimezone);
2764 2904
 			$datetime = new DateTime();
2765 2905
 			$offset = $datetime->format('P');
2766
-		} else $offset = '+00:00';
2906
+		} else {
2907
+			$offset = '+00:00';
2908
+		}
2767 2909
 		if ($airport_icao == '') {
2768 2910
 			if ($globalDBdriver == 'mysql') {
2769 2911
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -2795,7 +2937,9 @@  discard block
 block discarded – undo
2795 2937
 			date_default_timezone_set($globalTimezone);
2796 2938
 			$datetime = new DateTime();
2797 2939
 			$offset = $datetime->format('P');
2798
-		} else $offset = '+00:00';
2940
+		} else {
2941
+			$offset = '+00:00';
2942
+		}
2799 2943
 		if ($airport_icao == '') {
2800 2944
 			if ($globalDBdriver == 'mysql') {
2801 2945
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2838,7 +2982,9 @@  discard block
 block discarded – undo
2838 2982
 			date_default_timezone_set($globalTimezone);
2839 2983
 			$datetime = new DateTime();
2840 2984
 			$offset = $datetime->format('P');
2841
-		} else $offset = '+00:00';
2985
+		} else {
2986
+			$offset = '+00:00';
2987
+		}
2842 2988
 		if ($airport_icao == '') {
2843 2989
 			if ($globalDBdriver == 'mysql') {
2844 2990
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2882,7 +3028,9 @@  discard block
 block discarded – undo
2882 3028
 			date_default_timezone_set($globalTimezone);
2883 3029
 			$datetime = new DateTime();
2884 3030
 			$offset = $datetime->format('P');
2885
-		} else $offset = '+00:00';
3031
+		} else {
3032
+			$offset = '+00:00';
3033
+		}
2886 3034
 		if ($airport_icao == '') {
2887 3035
 			if ($globalDBdriver == 'mysql') {
2888 3036
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -2916,7 +3064,9 @@  discard block
 block discarded – undo
2916 3064
 			date_default_timezone_set($globalTimezone);
2917 3065
 			$datetime = new DateTime();
2918 3066
 			$offset = $datetime->format('P');
2919
-		} else $offset = '+00:00';
3067
+		} else {
3068
+			$offset = '+00:00';
3069
+		}
2920 3070
 		if ($airport_icao == '') {
2921 3071
 			if ($globalDBdriver == 'mysql') {
2922 3072
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -2962,7 +3112,9 @@  discard block
 block discarded – undo
2962 3112
 			date_default_timezone_set($globalTimezone);
2963 3113
 			$datetime = new DateTime();
2964 3114
 			$offset = $datetime->format('P');
2965
-		} else $offset = '+00:00';
3115
+		} else {
3116
+			$offset = '+00:00';
3117
+		}
2966 3118
 		if ($airport_icao == '') {
2967 3119
 			if ($globalDBdriver == 'mysql') {
2968 3120
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -2996,7 +3148,9 @@  discard block
 block discarded – undo
2996 3148
 			date_default_timezone_set($globalTimezone);
2997 3149
 			$datetime = new DateTime();
2998 3150
 			$offset = $datetime->format('P');
2999
-		} else $offset = '+00:00';
3151
+		} else {
3152
+			$offset = '+00:00';
3153
+		}
3000 3154
 		if ($airport_icao == '') {
3001 3155
 			if ($globalDBdriver == 'mysql') {
3002 3156
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3044,7 +3198,9 @@  discard block
 block discarded – undo
3044 3198
 			date_default_timezone_set($globalTimezone);
3045 3199
 			$datetime = new DateTime();
3046 3200
 			$offset = $datetime->format('P');
3047
-		} else $offset = '+00:00';
3201
+		} else {
3202
+			$offset = '+00:00';
3203
+		}
3048 3204
 
3049 3205
 		if ($globalDBdriver == 'mysql') {
3050 3206
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3164,7 +3320,9 @@  discard block
 block discarded – undo
3164 3320
 	*/	
3165 3321
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3166 3322
 	{
3167
-		if ($groundspeed == '') $groundspeed = NULL;
3323
+		if ($groundspeed == '') {
3324
+			$groundspeed = NULL;
3325
+		}
3168 3326
 		$query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id';
3169 3327
                 $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident);
3170 3328
 
@@ -3214,10 +3372,18 @@  discard block
 block discarded – undo
3214 3372
 		$Image = new Image($this->db);
3215 3373
 		$Common = new Common();
3216 3374
 		
3217
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3218
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3219
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3220
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3375
+		if (!isset($globalIVAO)) {
3376
+			$globalIVAO = FALSE;
3377
+		}
3378
+		if (!isset($globalVATSIM)) {
3379
+			$globalVATSIM = FALSE;
3380
+		}
3381
+		if (!isset($globalphpVMS)) {
3382
+			$globalphpVMS = FALSE;
3383
+		}
3384
+		if (!isset($globalVAM)) {
3385
+			$globalVAM = FALSE;
3386
+		}
3221 3387
 		date_default_timezone_set('UTC');
3222 3388
 		
3223 3389
 		//getting the registration
@@ -3230,23 +3396,33 @@  discard block
 block discarded – undo
3230 3396
 				if ($ModeS != '') {
3231 3397
 					$timeelapsed = microtime(true);
3232 3398
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS);
3233
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3399
+					if ($globalDebugTimeElapsed) {
3400
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3401
+					}
3234 3402
 				} else {
3235 3403
 					$myhex = explode('-',$flightaware_id);
3236 3404
 					if (count($myhex) > 0) {
3237 3405
 						$timeelapsed = microtime(true);
3238 3406
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0]);
3239
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3407
+						if ($globalDebugTimeElapsed) {
3408
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3409
+						}
3240 3410
 					}
3241 3411
 				}
3242 3412
 			}
3243 3413
 		}
3244 3414
 		$fromsource = NULL;
3245
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3246
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3247
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3248
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3249
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3415
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3416
+			$fromsource = $globalAirlinesSource;
3417
+		} elseif ($format_source == 'vatsimtxt') {
3418
+			$fromsource = 'vatsim';
3419
+		} elseif ($format_source == 'whazzup') {
3420
+			$fromsource = 'ivao';
3421
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3422
+			$fromsource = 'vatsim';
3423
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3424
+			$fromsource = 'ivao';
3425
+		}
3250 3426
 		//getting the airline information
3251 3427
 		if ($ident != "")
3252 3428
 		{
@@ -3270,15 +3446,21 @@  discard block
 block discarded – undo
3270 3446
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3271 3447
 						$airline_array = $this->getAllAirlineInfo("NA");
3272 3448
 					}
3273
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3449
+					if ($globalDebugTimeElapsed) {
3450
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3451
+					}
3274 3452
 
3275 3453
 				} else {
3276 3454
 					$timeelapsed = microtime(true);
3277 3455
 					$airline_array = $this->getAllAirlineInfo("NA");
3278
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3456
+					if ($globalDebugTimeElapsed) {
3457
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3458
+					}
3279 3459
 				}
3280 3460
 			}
3281
-		} else $airline_array = array();
3461
+		} else {
3462
+			$airline_array = array();
3463
+		}
3282 3464
 		
3283 3465
 		//getting the aircraft information
3284 3466
 		$aircraft_array = array();
@@ -3292,27 +3474,37 @@  discard block
 block discarded – undo
3292 3474
 				{
3293 3475
 					$timeelapsed = microtime(true);
3294 3476
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3295
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3477
+					if ($globalDebugTimeElapsed) {
3478
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3479
+					}
3296 3480
 				} else {
3297 3481
 					$timeelapsed = microtime(true);
3298 3482
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3299
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3483
+					if ($globalDebugTimeElapsed) {
3484
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3485
+					}
3300 3486
 				}
3301 3487
 			}
3302 3488
 		} else {
3303 3489
 			if ($ModeS != '') {
3304 3490
 				$timeelapsed = microtime(true);
3305 3491
 				$aircraft_icao = $this->getAllAircraftType($ModeS);
3306
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3492
+				if ($globalDebugTimeElapsed) {
3493
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3494
+				}
3307 3495
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3308 3496
 				{
3309 3497
 					$timeelapsed = microtime(true);
3310 3498
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3311
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3499
+					if ($globalDebugTimeElapsed) {
3500
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3501
+					}
3312 3502
 				} else {
3313 3503
 					$timeelapsed = microtime(true);
3314 3504
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3315
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3505
+					if ($globalDebugTimeElapsed) {
3506
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3507
+					}
3316 3508
 				}
3317 3509
 			}
3318 3510
 		}
@@ -3327,7 +3519,9 @@  discard block
 block discarded – undo
3327 3519
 			} else {
3328 3520
 				$timeelapsed = microtime(true);
3329 3521
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3330
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3522
+				if ($globalDebugTimeElapsed) {
3523
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3524
+				}
3331 3525
 			}
3332 3526
 		}
3333 3527
 		
@@ -3341,7 +3535,9 @@  discard block
 block discarded – undo
3341 3535
 			} else {
3342 3536
 				$timeelapsed = microtime(true);
3343 3537
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3344
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3538
+				if ($globalDebugTimeElapsed) {
3539
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3540
+				}
3345 3541
 			}
3346 3542
 		}
3347 3543
 
@@ -3376,7 +3572,9 @@  discard block
 block discarded – undo
3376 3572
 			{
3377 3573
 				return false;
3378 3574
 			}
3379
-		} else $altitude = 0;
3575
+		} else {
3576
+			$altitude = 0;
3577
+		}
3380 3578
 		
3381 3579
 		if ($heading != "")
3382 3580
 		{
@@ -3405,7 +3603,9 @@  discard block
 block discarded – undo
3405 3603
 		{
3406 3604
 			$timeelapsed = microtime(true);
3407 3605
 			$image_array = $Image->getSpotterImage($registration);
3408
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3606
+			if ($globalDebugTimeElapsed) {
3607
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3608
+			}
3409 3609
 			if (!isset($image_array[0]['registration']))
3410 3610
 			{
3411 3611
 				//echo "Add image !!!! \n";
@@ -3413,14 +3613,21 @@  discard block
 block discarded – undo
3413 3613
 			}
3414 3614
 			$timeelapsed = microtime(true);
3415 3615
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3416
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3417
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3616
+			if ($globalDebugTimeElapsed) {
3617
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3618
+			}
3619
+			if ($owner_info['owner'] != '') {
3620
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
3621
+			}
3418 3622
 		}
3419 3623
     
3420 3624
 		if ($globalIVAO && $aircraft_icao != '')
3421 3625
 		{
3422
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3423
-            		else $airline_icao = '';
3626
+            		if (isset($airline_array[0]['icao'])) {
3627
+            			$airline_icao = $airline_array[0]['icao'];
3628
+            		} else {
3629
+            			$airline_icao = '';
3630
+            		}
3424 3631
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3425 3632
 			if (!isset($image_array[0]['registration']))
3426 3633
 			{
@@ -3465,12 +3672,24 @@  discard block
 block discarded – undo
3465 3672
                 {
3466 3673
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3467 3674
                 }
3468
-                if ($registration == '') $registration = 'NA';
3469
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3470
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3471
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3472
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3473
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3675
+                if ($registration == '') {
3676
+                	$registration = 'NA';
3677
+                }
3678
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
3679
+                	$squawk = NULL;
3680
+                }
3681
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
3682
+                	$verticalrate = NULL;
3683
+                }
3684
+                if ($heading == '' || $Common->isInteger($heading) === false) {
3685
+                	$heading = 0;
3686
+                }
3687
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
3688
+                	$groundspeed = 0;
3689
+                }
3690
+                if (!isset($aircraft_owner)) {
3691
+                	$aircraft_owner = NULL;
3692
+                }
3474 3693
                 $query  = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) 
3475 3694
                 VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)";
3476 3695
 
@@ -3481,9 +3700,13 @@  discard block
 block discarded – undo
3481 3700
 		if ($airline_type == '') {
3482 3701
 			$timeelapsed = microtime(true);
3483 3702
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3484
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3703
+			if ($globalDebugTimeElapsed) {
3704
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3705
+			}
3706
+		}
3707
+		if ($airline_type == null) {
3708
+			$airline_type = '';
3485 3709
 		}
3486
-		if ($airline_type == null) $airline_type = '';
3487 3710
                 $aircraft_type = $aircraft_array[0]['type'];
3488 3711
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3489 3712
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -3618,7 +3841,9 @@  discard block
 block discarded – undo
3618 3841
 			}
3619 3842
 		}
3620 3843
 		$query .= "GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
3621
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3844
+		if ($limit) {
3845
+			$query .= " LIMIT 10 OFFSET 0";
3846
+		}
3622 3847
 		
3623 3848
 		$sth = $this->db->prepare($query);
3624 3849
 		$sth->execute();
@@ -3663,7 +3888,9 @@  discard block
 block discarded – undo
3663 3888
 			}
3664 3889
 		}
3665 3890
 		$query .= "GROUP BY spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3666
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3891
+		if ($limit) {
3892
+			$query .= " LIMIT 10 OFFSET 0";
3893
+		}
3667 3894
       
3668 3895
 		
3669 3896
 		$sth = $this->db->prepare($query);
@@ -3708,7 +3935,9 @@  discard block
 block discarded – undo
3708 3935
 			}
3709 3936
 		}
3710 3937
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name ORDER BY pilot_count DESC";
3711
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3938
+		if ($limit) {
3939
+			$query .= " LIMIT 10 OFFSET 0";
3940
+		}
3712 3941
       
3713 3942
 		
3714 3943
 		$sth = $this->db->prepare($query);
@@ -3755,7 +3984,9 @@  discard block
 block discarded – undo
3755 3984
 			}
3756 3985
 		}
3757 3986
 		$query .= "GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
3758
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
3987
+		if ($limit) {
3988
+			$query .= " LIMIT 10 OFFSET 0";
3989
+		}
3759 3990
       
3760 3991
 		
3761 3992
 		$sth = $this->db->prepare($query);
@@ -3799,7 +4030,9 @@  discard block
 block discarded – undo
3799 4030
 			}
3800 4031
 		}
3801 4032
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
3802
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4033
+		if ($limit) {
4034
+			$query .= " LIMIT 10 OFFSET 0";
4035
+		}
3803 4036
       
3804 4037
 		
3805 4038
 		$sth = $this->db->prepare($query);
@@ -4048,7 +4281,9 @@  discard block
 block discarded – undo
4048 4281
 			date_default_timezone_set($globalTimezone);
4049 4282
 			$datetime = new DateTime($date);
4050 4283
 			$offset = $datetime->format('P');
4051
-		} else $offset = '+00:00';
4284
+		} else {
4285
+			$offset = '+00:00';
4286
+		}
4052 4287
 
4053 4288
 		if ($globalDBdriver == 'mysql') {
4054 4289
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4097,7 +4332,9 @@  discard block
 block discarded – undo
4097 4332
 			date_default_timezone_set($globalTimezone);
4098 4333
 			$datetime = new DateTime($date);
4099 4334
 			$offset = $datetime->format('P');
4100
-		} else $offset = '+00:00';
4335
+		} else {
4336
+			$offset = '+00:00';
4337
+		}
4101 4338
 		
4102 4339
 		if ($globalDBdriver == 'mysql') {
4103 4340
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4320,7 +4557,9 @@  discard block
 block discarded – undo
4320 4557
 					WHERE spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA' 
4321 4558
 					GROUP BY spotter_output.airline_country
4322 4559
 					ORDER BY airline_country_count DESC";
4323
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4560
+		if ($limit) {
4561
+			$query .= " LIMIT 10 OFFSET 0";
4562
+		}
4324 4563
       
4325 4564
 		$sth = $this->db->prepare($query);
4326 4565
 		$sth->execute();
@@ -4347,7 +4586,9 @@  discard block
 block discarded – undo
4347 4586
 	{
4348 4587
 		global $globalDBdriver;
4349 4588
 		$Connection= new Connection($this->db);
4350
-		if (!$Connection->tableExists('countries')) return array();
4589
+		if (!$Connection->tableExists('countries')) {
4590
+			return array();
4591
+		}
4351 4592
 		/*
4352 4593
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
4353 4594
 					FROM countries c, spotter_output s
@@ -4372,7 +4613,9 @@  discard block
 block discarded – undo
4372 4613
 		}
4373 4614
 
4374 4615
 		$query .= "GROUP BY c.name ORDER BY nb DESC";
4375
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4616
+		if ($limit) {
4617
+			$query .= " LIMIT 10 OFFSET 0";
4618
+		}
4376 4619
       
4377 4620
 		
4378 4621
 		$sth = $this->db->prepare($query);
@@ -4422,7 +4665,9 @@  discard block
 block discarded – undo
4422 4665
 		}
4423 4666
 
4424 4667
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4425
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4668
+		if ($limit) {
4669
+			$query .= " LIMIT 10 OFFSET 0";
4670
+		}
4426 4671
  
4427 4672
 		$sth = $this->db->prepare($query);
4428 4673
 		$sth->execute();
@@ -4468,7 +4713,9 @@  discard block
 block discarded – undo
4468 4713
 		}
4469 4714
 
4470 4715
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
4471
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4716
+		if ($limit) {
4717
+			$query .= " LIMIT 10 OFFSET 0";
4718
+		}
4472 4719
  
4473 4720
 		$sth = $this->db->prepare($query);
4474 4721
 		$sth->execute();
@@ -4521,7 +4768,9 @@  discard block
 block discarded – undo
4521 4768
 			if($row['registration'] != "")
4522 4769
 			{
4523 4770
 				$image_array = $Image->getSpotterImage($row['registration']);
4524
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4771
+				if (isset($image_array[0]['image_thumbnail'])) {
4772
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4773
+				}
4525 4774
 			}
4526 4775
 			$temp_array['registration_count'] = $row['registration_count'];
4527 4776
 
@@ -4597,7 +4846,9 @@  discard block
 block discarded – undo
4597 4846
 			if($row['registration'] != "")
4598 4847
 			{
4599 4848
 				$image_array = $Image->getSpotterImage($row['registration']);
4600
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4849
+				if (isset($image_array[0]['image_thumbnail'])) {
4850
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
4851
+				}
4601 4852
 			}
4602 4853
 			$temp_array['registration_count'] = $row['registration_count'];
4603 4854
 
@@ -4831,7 +5082,9 @@  discard block
 block discarded – undo
4831 5082
 			date_default_timezone_set($globalTimezone);
4832 5083
 			$datetime = new DateTime($date);
4833 5084
 			$offset = $datetime->format('P');
4834
-		} else $offset = '+00:00';
5085
+		} else {
5086
+			$offset = '+00:00';
5087
+		}
4835 5088
 
4836 5089
 		if ($globalDBdriver == 'mysql') {
4837 5090
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -4879,7 +5132,9 @@  discard block
 block discarded – undo
4879 5132
 			date_default_timezone_set($globalTimezone);
4880 5133
 			$datetime = new DateTime($date);
4881 5134
 			$offset = $datetime->format('P');
4882
-		} else $offset = '+00:00';
5135
+		} else {
5136
+			$offset = '+00:00';
5137
+		}
4883 5138
 
4884 5139
 		if ($globalDBdriver == 'mysql') {
4885 5140
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
@@ -4934,7 +5189,9 @@  discard block
 block discarded – undo
4934 5189
 			date_default_timezone_set($globalTimezone);
4935 5190
 			$datetime = new DateTime($date);
4936 5191
 			$offset = $datetime->format('P');
4937
-		} else $offset = '+00:00';
5192
+		} else {
5193
+			$offset = '+00:00';
5194
+		}
4938 5195
 
4939 5196
 		if ($globalDBdriver == 'mysql') {
4940 5197
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5035,8 +5292,11 @@  discard block
 block discarded – undo
5035 5292
 			if($row['registration'] != "")
5036 5293
 			{
5037 5294
 				$image_array = $Image->getSpotterImage($row['registration']);
5038
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5039
-				else $temp_array['image_thumbnail'] = '';
5295
+				if (isset($image_array[0]['image_thumbnail'])) {
5296
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5297
+				} else {
5298
+					$temp_array['image_thumbnail'] = '';
5299
+				}
5040 5300
 			}
5041 5301
 			$temp_array['registration_count'] = $row['registration_count'];
5042 5302
 			$aircraft_array[] = $temp_array;
@@ -5144,7 +5404,9 @@  discard block
 block discarded – undo
5144 5404
 			if($row['registration'] != "")
5145 5405
 			{
5146 5406
 				$image_array = $Image->getSpotterImage($row['registration']);
5147
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5407
+				if (isset($image_array[0]['image_thumbnail'])) {
5408
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5409
+				}
5148 5410
 			}
5149 5411
 			$temp_array['registration_count'] = $row['registration_count'];
5150 5412
           
@@ -5263,7 +5525,9 @@  discard block
 block discarded – undo
5263 5525
 			if($row['registration'] != "")
5264 5526
 			{
5265 5527
 				$image_array = $Image->getSpotterImage($row['registration']);
5266
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5528
+				if (isset($image_array[0]['image_thumbnail'])) {
5529
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5530
+				}
5267 5531
 			}
5268 5532
 			$temp_array['registration_count'] = $row['registration_count'];
5269 5533
           
@@ -5376,7 +5640,9 @@  discard block
 block discarded – undo
5376 5640
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5377 5641
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5378 5642
                 $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5379
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5643
+		if ($limit) {
5644
+			$query .= " LIMIT 10 OFFSET 0";
5645
+		}
5380 5646
 		
5381 5647
 		$sth = $this->db->prepare($query);
5382 5648
 		$sth->execute();
@@ -5395,7 +5661,9 @@  discard block
 block discarded – undo
5395 5661
 			if($row['registration'] != "")
5396 5662
 			{
5397 5663
 				$image_array = $Image->getSpotterImage($row['registration']);
5398
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5664
+				if (isset($image_array[0]['image_thumbnail'])) {
5665
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5666
+				}
5399 5667
 			}
5400 5668
           
5401 5669
 			$aircraft_array[] = $temp_array;
@@ -5436,7 +5704,9 @@  discard block
 block discarded – undo
5436 5704
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5437 5705
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5438 5706
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
5439
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5707
+		if ($limit) {
5708
+			$query .= " LIMIT 10 OFFSET 0";
5709
+		}
5440 5710
 		
5441 5711
 		$sth = $this->db->prepare($query);
5442 5712
 		$sth->execute();
@@ -5456,7 +5726,9 @@  discard block
 block discarded – undo
5456 5726
 			if($row['registration'] != "")
5457 5727
 			{
5458 5728
 				$image_array = $Image->getSpotterImage($row['registration']);
5459
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5729
+				if (isset($image_array[0]['image_thumbnail'])) {
5730
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5731
+				}
5460 5732
 			}
5461 5733
           
5462 5734
 			$aircraft_array[] = $temp_array;
@@ -5497,7 +5769,9 @@  discard block
 block discarded – undo
5497 5769
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5498 5770
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5499 5771
 				ORDER BY airport_departure_icao_count DESC";
5500
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5772
+		if ($limit) {
5773
+			$query .= " LIMIT 10 OFFSET 0";
5774
+		}
5501 5775
       
5502 5776
 		$sth = $this->db->prepare($query);
5503 5777
 		$sth->execute();
@@ -5549,7 +5823,9 @@  discard block
 block discarded – undo
5549 5823
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5550 5824
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
5551 5825
 				ORDER BY airport_departure_icao_count DESC";
5552
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5826
+		if ($limit) {
5827
+			$query .= " LIMIT 10 OFFSET 0";
5828
+		}
5553 5829
       
5554 5830
 		$sth = $this->db->prepare($query);
5555 5831
 		$sth->execute();
@@ -5601,7 +5877,9 @@  discard block
 block discarded – undo
5601 5877
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5602 5878
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5603 5879
 				ORDER BY airport_departure_icao_count DESC";
5604
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5880
+		if ($limit) {
5881
+			$query .= " LIMIT 10 OFFSET 0";
5882
+		}
5605 5883
       
5606 5884
 		$sth = $this->db->prepare($query);
5607 5885
 		$sth->execute();
@@ -5653,7 +5931,9 @@  discard block
 block discarded – undo
5653 5931
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
5654 5932
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
5655 5933
 				ORDER BY airport_departure_icao_count DESC";
5656
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5934
+		if ($limit) {
5935
+			$query .= " LIMIT 10 OFFSET 0";
5936
+		}
5657 5937
       
5658 5938
 		$sth = $this->db->prepare($query);
5659 5939
 		$sth->execute();
@@ -6058,7 +6338,9 @@  discard block
 block discarded – undo
6058 6338
 			date_default_timezone_set($globalTimezone);
6059 6339
 			$datetime = new DateTime($date);
6060 6340
 			$offset = $datetime->format('P');
6061
-		} else $offset = '+00:00';
6341
+		} else {
6342
+			$offset = '+00:00';
6343
+		}
6062 6344
 
6063 6345
 		if ($globalDBdriver == 'mysql') {
6064 6346
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
@@ -6109,7 +6391,9 @@  discard block
 block discarded – undo
6109 6391
 			date_default_timezone_set($globalTimezone);
6110 6392
 			$datetime = new DateTime($date);
6111 6393
 			$offset = $datetime->format('P');
6112
-		} else $offset = '+00:00';
6394
+		} else {
6395
+			$offset = '+00:00';
6396
+		}
6113 6397
 
6114 6398
 		if ($globalDBdriver == 'mysql') {
6115 6399
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -6327,7 +6611,9 @@  discard block
 block discarded – undo
6327 6611
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6328 6612
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6329 6613
 					ORDER BY airport_arrival_icao_count DESC";
6330
-		if ($limit) $query .= " LIMIT 10";
6614
+		if ($limit) {
6615
+			$query .= " LIMIT 10";
6616
+		}
6331 6617
       
6332 6618
 		
6333 6619
 		$sth = $this->db->prepare($query);
@@ -6347,7 +6633,9 @@  discard block
 block discarded – undo
6347 6633
 			if ($icaoaskey) {
6348 6634
 				$icao = $row['arrival_airport_icao'];
6349 6635
 				$airport_array[$icao] = $temp_array;
6350
-			} else $airport_array[] = $temp_array;
6636
+			} else {
6637
+				$airport_array[] = $temp_array;
6638
+			}
6351 6639
 		}
6352 6640
 
6353 6641
 		return $airport_array;
@@ -6389,7 +6677,9 @@  discard block
 block discarded – undo
6389 6677
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6390 6678
                 $query .= "GROUP BY spotter_output.airline_icao,spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
6391 6679
 					ORDER BY airport_arrival_icao_count DESC";
6392
-		if ($limit) $query .= " LIMIT 10";
6680
+		if ($limit) {
6681
+			$query .= " LIMIT 10";
6682
+		}
6393 6683
       
6394 6684
 		
6395 6685
 		$sth = $this->db->prepare($query);
@@ -6410,7 +6700,9 @@  discard block
 block discarded – undo
6410 6700
 			if ($icaoaskey) {
6411 6701
 				$icao = $row['arrival_airport_icao'];
6412 6702
 				$airport_array[$icao] = $temp_array;
6413
-			} else $airport_array[] = $temp_array;
6703
+			} else {
6704
+				$airport_array[] = $temp_array;
6705
+			}
6414 6706
 		}
6415 6707
 
6416 6708
 		return $airport_array;
@@ -6452,7 +6744,9 @@  discard block
 block discarded – undo
6452 6744
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6453 6745
                 $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6454 6746
 					ORDER BY airport_arrival_icao_count DESC";
6455
-		if ($limit) $query .= " LIMIT 10";
6747
+		if ($limit) {
6748
+			$query .= " LIMIT 10";
6749
+		}
6456 6750
       
6457 6751
 		
6458 6752
 		$sth = $this->db->prepare($query);
@@ -6472,7 +6766,9 @@  discard block
 block discarded – undo
6472 6766
 			if ($icaoaskey) {
6473 6767
 				$icao = $row['arrival_airport_icao'];
6474 6768
 				$airport_array[$icao] = $temp_array;
6475
-			} else $airport_array[] = $temp_array;
6769
+			} else {
6770
+				$airport_array[] = $temp_array;
6771
+			}
6476 6772
 		}
6477 6773
 
6478 6774
 		return $airport_array;
@@ -6514,7 +6810,9 @@  discard block
 block discarded – undo
6514 6810
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6515 6811
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
6516 6812
 					ORDER BY airport_arrival_icao_count DESC";
6517
-		if ($limit) $query .= " LIMIT 10";
6813
+		if ($limit) {
6814
+			$query .= " LIMIT 10";
6815
+		}
6518 6816
       
6519 6817
 		
6520 6818
 		$sth = $this->db->prepare($query);
@@ -6535,7 +6833,9 @@  discard block
 block discarded – undo
6535 6833
 			if ($icaoaskey) {
6536 6834
 				$icao = $row['arrival_airport_icao'];
6537 6835
 				$airport_array[$icao] = $temp_array;
6538
-			} else $airport_array[] = $temp_array;
6836
+			} else {
6837
+				$airport_array[] = $temp_array;
6838
+			}
6539 6839
 		}
6540 6840
 
6541 6841
 		return $airport_array;
@@ -6924,7 +7224,9 @@  discard block
 block discarded – undo
6924 7224
 			date_default_timezone_set($globalTimezone);
6925 7225
 			$datetime = new DateTime($date);
6926 7226
 			$offset = $datetime->format('P');
6927
-		} else $offset = '+00:00';
7227
+		} else {
7228
+			$offset = '+00:00';
7229
+		}
6928 7230
 
6929 7231
 		if ($globalDBdriver == 'mysql') {
6930 7232
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
@@ -6975,7 +7277,9 @@  discard block
 block discarded – undo
6975 7277
 			date_default_timezone_set($globalTimezone);
6976 7278
 			$datetime = new DateTime($date);
6977 7279
 			$offset = $datetime->format('P');
6978
-		} else $offset = '+00:00';
7280
+		} else {
7281
+			$offset = '+00:00';
7282
+		}
6979 7283
 
6980 7284
 		if ($globalDBdriver == 'mysql') {
6981 7285
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -7204,7 +7508,9 @@  discard block
 block discarded – undo
7204 7508
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA'";
7205 7509
 		$query .= " GROUP BY spotter_output.arrival_airport_country
7206 7510
 					ORDER BY airport_arrival_country_count DESC";
7207
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7511
+		if ($limit) {
7512
+			$query .= " LIMIT 10 OFFSET 0";
7513
+		}
7208 7514
       
7209 7515
 		
7210 7516
 		$sth = $this->db->prepare($query);
@@ -7499,7 +7805,9 @@  discard block
 block discarded – undo
7499 7805
 			date_default_timezone_set($globalTimezone);
7500 7806
 			$datetime = new DateTime($date);
7501 7807
 			$offset = $datetime->format('P');
7502
-		} else $offset = '+00:00';
7808
+		} else {
7809
+			$offset = '+00:00';
7810
+		}
7503 7811
 		
7504 7812
 		if ($globalDBdriver == 'mysql') {
7505 7813
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -7682,15 +7990,23 @@  discard block
 block discarded – undo
7682 7990
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
7683 7991
                     FROM spotter_output".$filter_query." spotter_output.ident <> '' ";
7684 7992
 		 if ($olderthanmonths > 0) {
7685
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7686
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7993
+			if ($globalDBdriver == 'mysql') {
7994
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
7995
+			} else {
7996
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7997
+			}
7687 7998
 		}
7688 7999
 		if ($sincedate != '') {
7689
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
7690
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
8000
+			if ($globalDBdriver == 'mysql') {
8001
+				$query .= " AND spotter_output.date > '".$sincedate."'";
8002
+			} else {
8003
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
8004
+			}
7691 8005
 		}
7692 8006
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7693
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8007
+		if ($limit) {
8008
+			$query .= " LIMIT 10 OFFSET 0";
8009
+		}
7694 8010
       		
7695 8011
 		$sth = $this->db->prepare($query);
7696 8012
 		$sth->execute();
@@ -7724,15 +8040,23 @@  discard block
 block discarded – undo
7724 8040
                     FROM spotter_output
7725 8041
                     WHERE spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
7726 8042
 		 if ($olderthanmonths > 0) {
7727
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7728
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8043
+			if ($globalDBdriver == 'mysql') {
8044
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
8045
+			} else {
8046
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
8047
+			}
7729 8048
 		}
7730 8049
 		if ($sincedate != '') {
7731
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
7732
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8050
+			if ($globalDBdriver == 'mysql') {
8051
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
8052
+			} else {
8053
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
8054
+			}
7733 8055
 		}
7734 8056
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
7735
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
8057
+		if ($limit) {
8058
+			$query .= " LIMIT 10 OFFSET 0";
8059
+		}
7736 8060
       		
7737 8061
 		$sth = $this->db->prepare($query);
7738 8062
 		$sth->execute();
@@ -7769,7 +8093,9 @@  discard block
 block discarded – undo
7769 8093
 			date_default_timezone_set($globalTimezone);
7770 8094
 			$datetime = new DateTime();
7771 8095
 			$offset = $datetime->format('P');
7772
-		} else $offset = '+00:00';
8096
+		} else {
8097
+			$offset = '+00:00';
8098
+		}
7773 8099
 
7774 8100
 		if ($globalDBdriver == 'mysql') {
7775 8101
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7818,7 +8144,9 @@  discard block
 block discarded – undo
7818 8144
 			date_default_timezone_set($globalTimezone);
7819 8145
 			$datetime = new DateTime();
7820 8146
 			$offset = $datetime->format('P');
7821
-		} else $offset = '+00:00';
8147
+		} else {
8148
+			$offset = '+00:00';
8149
+		}
7822 8150
 
7823 8151
 		if ($globalDBdriver == 'mysql') {
7824 8152
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7868,7 +8196,9 @@  discard block
 block discarded – undo
7868 8196
 			date_default_timezone_set($globalTimezone);
7869 8197
 			$datetime = new DateTime();
7870 8198
 			$offset = $datetime->format('P');
7871
-		} else $offset = '+00:00';
8199
+		} else {
8200
+			$offset = '+00:00';
8201
+		}
7872 8202
 		$filter_query = $this->getFilter($filters,true,true);
7873 8203
 		if ($globalDBdriver == 'mysql') {
7874 8204
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7914,7 +8244,9 @@  discard block
 block discarded – undo
7914 8244
 			date_default_timezone_set($globalTimezone);
7915 8245
 			$datetime = new DateTime();
7916 8246
 			$offset = $datetime->format('P');
7917
-		} else $offset = '+00:00';
8247
+		} else {
8248
+			$offset = '+00:00';
8249
+		}
7918 8250
 		$filter_query = $this->getFilter($filters,true,true);
7919 8251
 		if ($globalDBdriver == 'mysql') {
7920 8252
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -7961,7 +8293,9 @@  discard block
 block discarded – undo
7961 8293
 			date_default_timezone_set($globalTimezone);
7962 8294
 			$datetime = new DateTime();
7963 8295
 			$offset = $datetime->format('P');
7964
-		} else $offset = '+00:00';
8296
+		} else {
8297
+			$offset = '+00:00';
8298
+		}
7965 8299
 		
7966 8300
 		if ($globalDBdriver == 'mysql') {
7967 8301
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -8011,7 +8345,9 @@  discard block
 block discarded – undo
8011 8345
 			date_default_timezone_set($globalTimezone);
8012 8346
 			$datetime = new DateTime();
8013 8347
 			$offset = $datetime->format('P');
8014
-		} else $offset = '+00:00';
8348
+		} else {
8349
+			$offset = '+00:00';
8350
+		}
8015 8351
 
8016 8352
 		if ($globalDBdriver == 'mysql') {
8017 8353
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8057,7 +8393,9 @@  discard block
 block discarded – undo
8057 8393
 			date_default_timezone_set($globalTimezone);
8058 8394
 			$datetime = new DateTime();
8059 8395
 			$offset = $datetime->format('P');
8060
-		} else $offset = '+00:00';
8396
+		} else {
8397
+			$offset = '+00:00';
8398
+		}
8061 8399
 
8062 8400
 		if ($globalDBdriver == 'mysql') {
8063 8401
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8106,7 +8444,9 @@  discard block
 block discarded – undo
8106 8444
 			date_default_timezone_set($globalTimezone);
8107 8445
 			$datetime = new DateTime();
8108 8446
 			$offset = $datetime->format('P');
8109
-		} else $offset = '+00:00';
8447
+		} else {
8448
+			$offset = '+00:00';
8449
+		}
8110 8450
 
8111 8451
 		if ($globalDBdriver == 'mysql') {
8112 8452
 			$query  = "SELECT YEAR(CONVERT_TZ(s.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(s.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -8153,7 +8493,9 @@  discard block
 block discarded – undo
8153 8493
 			date_default_timezone_set($globalTimezone);
8154 8494
 			$datetime = new DateTime();
8155 8495
 			$offset = $datetime->format('P');
8156
-		} else $offset = '+00:00';
8496
+		} else {
8497
+			$offset = '+00:00';
8498
+		}
8157 8499
 
8158 8500
 		if ($globalDBdriver == 'mysql') {
8159 8501
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -8200,7 +8542,9 @@  discard block
 block discarded – undo
8200 8542
 			date_default_timezone_set($globalTimezone);
8201 8543
 			$datetime = new DateTime();
8202 8544
 			$offset = $datetime->format('P');
8203
-		} else $offset = '+00:00';
8545
+		} else {
8546
+			$offset = '+00:00';
8547
+		}
8204 8548
 
8205 8549
 		if ($globalDBdriver == 'mysql') {
8206 8550
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -8248,7 +8592,9 @@  discard block
 block discarded – undo
8248 8592
 			date_default_timezone_set($globalTimezone);
8249 8593
 			$datetime = new DateTime();
8250 8594
 			$offset = $datetime->format('P');
8251
-		} else $offset = '+00:00';
8595
+		} else {
8596
+			$offset = '+00:00';
8597
+		}
8252 8598
 
8253 8599
 		if ($globalDBdriver == 'mysql') {
8254 8600
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -8295,7 +8641,9 @@  discard block
 block discarded – undo
8295 8641
 			date_default_timezone_set($globalTimezone);
8296 8642
 			$datetime = new DateTime();
8297 8643
 			$offset = $datetime->format('P');
8298
-		} else $offset = '+00:00';
8644
+		} else {
8645
+			$offset = '+00:00';
8646
+		}
8299 8647
 
8300 8648
 		if ($globalDBdriver == 'mysql') {
8301 8649
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -8343,7 +8691,9 @@  discard block
 block discarded – undo
8343 8691
 			date_default_timezone_set($globalTimezone);
8344 8692
 			$datetime = new DateTime();
8345 8693
 			$offset = $datetime->format('P');
8346
-		} else $offset = '+00:00';
8694
+		} else {
8695
+			$offset = '+00:00';
8696
+		}
8347 8697
 
8348 8698
 		if ($globalDBdriver == 'mysql') {
8349 8699
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -8390,7 +8740,9 @@  discard block
 block discarded – undo
8390 8740
 			date_default_timezone_set($globalTimezone);
8391 8741
 			$datetime = new DateTime();
8392 8742
 			$offset = $datetime->format('P');
8393
-		} else $offset = '+00:00';
8743
+		} else {
8744
+			$offset = '+00:00';
8745
+		}
8394 8746
 
8395 8747
 		if ($globalDBdriver == 'mysql') {
8396 8748
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -8438,7 +8790,9 @@  discard block
 block discarded – undo
8438 8790
 			date_default_timezone_set($globalTimezone);
8439 8791
 			$datetime = new DateTime();
8440 8792
 			$offset = $datetime->format('P');
8441
-		} else $offset = '+00:00';
8793
+		} else {
8794
+			$offset = '+00:00';
8795
+		}
8442 8796
 
8443 8797
 		if ($globalDBdriver == 'mysql') {
8444 8798
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -8486,7 +8840,9 @@  discard block
 block discarded – undo
8486 8840
 			date_default_timezone_set($globalTimezone);
8487 8841
 			$datetime = new DateTime();
8488 8842
 			$offset = $datetime->format('P');
8489
-		} else $offset = '+00:00';
8843
+		} else {
8844
+			$offset = '+00:00';
8845
+		}
8490 8846
 
8491 8847
 		if ($globalDBdriver == 'mysql') {
8492 8848
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -8534,7 +8890,9 @@  discard block
 block discarded – undo
8534 8890
 			date_default_timezone_set($globalTimezone);
8535 8891
 			$datetime = new DateTime();
8536 8892
 			$offset = $datetime->format('P');
8537
-		} else $offset = '+00:00';
8893
+		} else {
8894
+			$offset = '+00:00';
8895
+		}
8538 8896
 
8539 8897
 		if ($globalDBdriver == 'mysql') {
8540 8898
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -8583,7 +8941,9 @@  discard block
 block discarded – undo
8583 8941
 			date_default_timezone_set($globalTimezone);
8584 8942
 			$datetime = new DateTime();
8585 8943
 			$offset = $datetime->format('P');
8586
-		} else $offset = '+00:00';
8944
+		} else {
8945
+			$offset = '+00:00';
8946
+		}
8587 8947
 		$filter_query = $this->getFilter($filters,true,true);
8588 8948
 		if ($globalDBdriver == 'mysql') {
8589 8949
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -8632,7 +8992,9 @@  discard block
 block discarded – undo
8632 8992
 			date_default_timezone_set($globalTimezone);
8633 8993
 			$datetime = new DateTime();
8634 8994
 			$offset = $datetime->format('P');
8635
-		} else $offset = '+00:00';
8995
+		} else {
8996
+			$offset = '+00:00';
8997
+		}
8636 8998
 
8637 8999
 		$orderby_sql = '';
8638 9000
 		if ($orderby == "hour")
@@ -8697,7 +9059,9 @@  discard block
 block discarded – undo
8697 9059
 			date_default_timezone_set($globalTimezone);
8698 9060
 			$datetime = new DateTime();
8699 9061
 			$offset = $datetime->format('P');
8700
-		} else $offset = '+00:00';
9062
+		} else {
9063
+			$offset = '+00:00';
9064
+		}
8701 9065
 
8702 9066
 		$orderby_sql = '';
8703 9067
 		if ($orderby == "hour")
@@ -8765,7 +9129,9 @@  discard block
 block discarded – undo
8765 9129
 			date_default_timezone_set($globalTimezone);
8766 9130
 			$datetime = new DateTime();
8767 9131
 			$offset = $datetime->format('P');
8768
-		} else $offset = '+00:00';
9132
+		} else {
9133
+			$offset = '+00:00';
9134
+		}
8769 9135
 
8770 9136
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8771 9137
 
@@ -8817,7 +9183,9 @@  discard block
 block discarded – undo
8817 9183
 			date_default_timezone_set($globalTimezone);
8818 9184
 			$datetime = new DateTime();
8819 9185
 			$offset = $datetime->format('P');
8820
-		} else $offset = '+00:00';
9186
+		} else {
9187
+			$offset = '+00:00';
9188
+		}
8821 9189
 
8822 9190
 		if ($globalDBdriver == 'mysql') {
8823 9191
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8865,7 +9233,9 @@  discard block
 block discarded – undo
8865 9233
 			date_default_timezone_set($globalTimezone);
8866 9234
 			$datetime = new DateTime();
8867 9235
 			$offset = $datetime->format('P');
8868
-		} else $offset = '+00:00';
9236
+		} else {
9237
+			$offset = '+00:00';
9238
+		}
8869 9239
 
8870 9240
 		if ($globalDBdriver == 'mysql') {
8871 9241
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8913,7 +9283,9 @@  discard block
 block discarded – undo
8913 9283
 			date_default_timezone_set($globalTimezone);
8914 9284
 			$datetime = new DateTime();
8915 9285
 			$offset = $datetime->format('P');
8916
-		} else $offset = '+00:00';
9286
+		} else {
9287
+			$offset = '+00:00';
9288
+		}
8917 9289
 
8918 9290
 		if ($globalDBdriver == 'mysql') {
8919 9291
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -8962,7 +9334,9 @@  discard block
 block discarded – undo
8962 9334
 			date_default_timezone_set($globalTimezone);
8963 9335
 			$datetime = new DateTime();
8964 9336
 			$offset = $datetime->format('P');
8965
-		} else $offset = '+00:00';
9337
+		} else {
9338
+			$offset = '+00:00';
9339
+		}
8966 9340
 
8967 9341
 		if ($globalDBdriver == 'mysql') {
8968 9342
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9011,7 +9385,9 @@  discard block
 block discarded – undo
9011 9385
 			date_default_timezone_set($globalTimezone);
9012 9386
 			$datetime = new DateTime($date);
9013 9387
 			$offset = $datetime->format('P');
9014
-		} else $offset = '+00:00';
9388
+		} else {
9389
+			$offset = '+00:00';
9390
+		}
9015 9391
 
9016 9392
 		if ($globalDBdriver == 'mysql') {
9017 9393
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9060,7 +9436,9 @@  discard block
 block discarded – undo
9060 9436
 			date_default_timezone_set($globalTimezone);
9061 9437
 			$datetime = new DateTime();
9062 9438
 			$offset = $datetime->format('P');
9063
-		} else $offset = '+00:00';
9439
+		} else {
9440
+			$offset = '+00:00';
9441
+		}
9064 9442
 
9065 9443
 		if ($globalDBdriver == 'mysql') {
9066 9444
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9111,7 +9489,9 @@  discard block
 block discarded – undo
9111 9489
 			date_default_timezone_set($globalTimezone);
9112 9490
 			$datetime = new DateTime();
9113 9491
 			$offset = $datetime->format('P');
9114
-		} else $offset = '+00:00';
9492
+		} else {
9493
+			$offset = '+00:00';
9494
+		}
9115 9495
 
9116 9496
 		if ($globalDBdriver == 'mysql') {
9117 9497
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9159,7 +9539,9 @@  discard block
 block discarded – undo
9159 9539
 			date_default_timezone_set($globalTimezone);
9160 9540
 			$datetime = new DateTime();
9161 9541
 			$offset = $datetime->format('P');
9162
-		} else $offset = '+00:00';
9542
+		} else {
9543
+			$offset = '+00:00';
9544
+		}
9163 9545
 
9164 9546
 		if ($globalDBdriver == 'mysql') {
9165 9547
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9328,7 +9710,9 @@  discard block
 block discarded – undo
9328 9710
 			date_default_timezone_set($globalTimezone);
9329 9711
 			$datetime = new DateTime();
9330 9712
 			$offset = $datetime->format('P');
9331
-		} else $offset = '+00:00';
9713
+		} else {
9714
+			$offset = '+00:00';
9715
+		}
9332 9716
 
9333 9717
 		if ($globalDBdriver == 'mysql') {
9334 9718
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -9517,7 +9901,9 @@  discard block
 block discarded – undo
9517 9901
 	*/
9518 9902
 	public function parseDirection($direction = 0)
9519 9903
 	{
9520
-		if ($direction == '') $direction = 0;
9904
+		if ($direction == '') {
9905
+			$direction = 0;
9906
+		}
9521 9907
 		$direction_array = array();
9522 9908
 		$temp_array = array();
9523 9909
 
@@ -9618,7 +10004,9 @@  discard block
 block discarded – undo
9618 10004
 		if (isset($result->AirlineFlightInfoResult))
9619 10005
 		{
9620 10006
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
9621
-		} else return '';
10007
+		} else {
10008
+			return '';
10009
+		}
9622 10010
 		
9623 10011
 		$registration = $this->convertAircraftRegistration($registration);
9624 10012
 		
@@ -9646,7 +10034,9 @@  discard block
 block discarded – undo
9646 10034
 		if (count($row) > 0) {
9647 10035
 		    //return $row['Registration'];
9648 10036
 		    return $row['registration'];
9649
-		} else return '';
10037
+		} else {
10038
+			return '';
10039
+		}
9650 10040
 	
9651 10041
 	}
9652 10042
 
@@ -9668,9 +10058,14 @@  discard block
 block discarded – undo
9668 10058
     
9669 10059
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
9670 10060
 		if (count($row) > 0) {
9671
-		    if ($row['type_flight'] == null) return '';
9672
-		    else return $row['type_flight'];
9673
-		} else return '';
10061
+		    if ($row['type_flight'] == null) {
10062
+		    	return '';
10063
+		    } else {
10064
+		    	return $row['type_flight'];
10065
+		    }
10066
+		} else {
10067
+			return '';
10068
+		}
9674 10069
 	
9675 10070
 	}
9676 10071
 
@@ -9688,7 +10083,9 @@  discard block
 block discarded – undo
9688 10083
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
9689 10084
 	
9690 10085
 		$Connection = new Connection($this->db);
9691
-		if (!$Connection->tableExists('countries')) return '';
10086
+		if (!$Connection->tableExists('countries')) {
10087
+			return '';
10088
+		}
9692 10089
 	
9693 10090
 		try {
9694 10091
 			/*
@@ -9707,9 +10104,13 @@  discard block
 block discarded – undo
9707 10104
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
9708 10105
 			if (count($row) > 0) {
9709 10106
 				return $row;
9710
-			} else return '';
10107
+			} else {
10108
+				return '';
10109
+			}
9711 10110
 		} catch (PDOException $e) {
9712
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
10111
+			if (isset($globalDebug) && $globalDebug) {
10112
+				echo 'Error : '.$e->getMessage()."\n";
10113
+			}
9713 10114
 			return '';
9714 10115
 		}
9715 10116
 	
@@ -9857,7 +10258,9 @@  discard block
 block discarded – undo
9857 10258
 	{
9858 10259
 		global $globalBitlyAccessToken;
9859 10260
 		
9860
-		if ($globalBitlyAccessToken == '') return $url;
10261
+		if ($globalBitlyAccessToken == '') {
10262
+			return $url;
10263
+		}
9861 10264
         
9862 10265
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
9863 10266
 		
@@ -10006,7 +10409,9 @@  discard block
 block discarded – undo
10006 10409
 		
10007 10410
 
10008 10411
 		// routes
10009
-		if ($globalDebug) print "Routes...\n";
10412
+		if ($globalDebug) {
10413
+			print "Routes...\n";
10414
+		}
10010 10415
 		if ($globalDBdriver == 'mysql') {
10011 10416
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
10012 10417
 		} else {
@@ -10025,7 +10430,9 @@  discard block
 block discarded – undo
10025 10430
 			}
10026 10431
 		}
10027 10432
 		
10028
-		if ($globalDebug) print "Airlines...\n";
10433
+		if ($globalDebug) {
10434
+			print "Airlines...\n";
10435
+		}
10029 10436
 		//airlines
10030 10437
 		if ($globalDBdriver == 'mysql') {
10031 10438
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -10039,10 +10446,15 @@  discard block
 block discarded – undo
10039 10446
 			if (is_numeric(substr($row['ident'], -1, 1)))
10040 10447
 			{
10041 10448
 				$fromsource = NULL;
10042
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
10043
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
10044
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
10045
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
10449
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
10450
+					$fromsource = 'vatsim';
10451
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
10452
+					$fromsource = 'ivao';
10453
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
10454
+					$fromsource = 'vatsim';
10455
+				} elseif (isset($globalIVAO) && $globalIVAO) {
10456
+					$fromsource = 'ivao';
10457
+				}
10046 10458
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
10047 10459
 				if (isset($airline_array[0]['name'])) {
10048 10460
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -10052,13 +10464,17 @@  discard block
 block discarded – undo
10052 10464
 			}
10053 10465
 		}
10054 10466
 
10055
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
10467
+		if ($globalDebug) {
10468
+			print "Remove Duplicate in aircraft_modes...\n";
10469
+		}
10056 10470
 		//duplicate modes
10057 10471
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
10058 10472
 		$sth = $this->db->prepare($query);
10059 10473
 		$sth->execute();
10060 10474
 		
10061
-		if ($globalDebug) print "Aircraft...\n";
10475
+		if ($globalDebug) {
10476
+			print "Aircraft...\n";
10477
+		}
10062 10478
 		//aircraft
10063 10479
 		if ($globalDBdriver == 'mysql') {
10064 10480
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -10101,26 +10517,38 @@  discard block
 block discarded – undo
10101 10517
 				 if (isset($closestAirports[0])) {
10102 10518
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
10103 10519
 						$airport_icao = $closestAirports[0]['icao'];
10104
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10520
+						if ($globalDebug) {
10521
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10522
+						}
10105 10523
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
10106 10524
 						foreach ($closestAirports as $airport) {
10107 10525
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
10108 10526
 								$airport_icao = $airport['icao'];
10109
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10527
+								if ($globalDebug) {
10528
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
10529
+								}
10110 10530
 								break;
10111 10531
 							}
10112 10532
 						}
10113 10533
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
10114 10534
 						$airport_icao = $closestAirports[0]['icao'];
10115
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10535
+						if ($globalDebug) {
10536
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10537
+						}
10116 10538
 					} else {
10117
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10539
+						if ($globalDebug) {
10540
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
10541
+						}
10118 10542
 					}
10119 10543
 				} else {
10120
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10544
+					if ($globalDebug) {
10545
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
10546
+					}
10121 10547
 				}
10122 10548
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
10123
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
10549
+					if ($globalDebug) {
10550
+						echo "Updating airport to ".$airport_icao."...\n";
10551
+					}
10124 10552
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
10125 10553
 					$sthu = $this->db->prepare($update_query);
10126 10554
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -19,44 +19,44 @@  discard block
 block discarded – undo
19 19
 // Check if schema is at latest version
20 20
 $Connection = new Connection();
21 21
 if ($Connection->latest() === false) {
22
-    echo "You MUST update to latest schema. Run install/index.php";
23
-    exit();
22
+	echo "You MUST update to latest schema. Run install/index.php";
23
+	exit();
24 24
 }
25 25
 
26 26
 
27 27
 // This is to be compatible with old version of settings.php
28 28
 if (!isset($globalSources)) {
29
-    if (isset($globalSBS1Hosts)) {
30
-        //$hosts = $globalSBS1Hosts;
31
-        foreach ($globalSBS1Hosts as $host) {
32
-	    $globalSources[] = array('host' => $host);
33
-    	}
34
-    } else {
35
-        if (!isset($globalSBS1Host)) {
36
-	    echo '$globalSources MUST be defined !';
37
-	    die;
29
+	if (isset($globalSBS1Hosts)) {
30
+		//$hosts = $globalSBS1Hosts;
31
+		foreach ($globalSBS1Hosts as $host) {
32
+		$globalSources[] = array('host' => $host);
33
+		}
34
+	} else {
35
+		if (!isset($globalSBS1Host)) {
36
+		echo '$globalSources MUST be defined !';
37
+		die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40 40
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
41
-    }
41
+	}
42 42
 }
43 43
 
44 44
 $options = getopt('s::',array('source::','server','idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
48
-    $globalSources = array();
49
-    $globalSources[] = array('host' => $options['s']);
48
+	$globalSources = array();
49
+	$globalSources[] = array('host' => $options['s']);
50 50
 } elseif (isset($options['source'])) {
51
-    $globalSources = array();
52
-    $globalSources[] = array('host' => $options['source']);
51
+	$globalSources = array();
52
+	$globalSources[] = array('host' => $options['source']);
53 53
 }
54 54
 if (isset($options['server'])) $globalServer = TRUE;
55 55
 if (isset($options['idsource'])) $id_source = $options['idsource'];
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
58
+	if ($globalDebug) echo "Using Server Mode\n";
59
+	$SI=new SpotterServer();
60 60
 } else $SI=new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62 62
 $SBS=new SBS();
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
70
-        global $sockets;
71
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
-        die("Bye!\n");
73
-    });
74
-    pcntl_signal_dispatch();
69
+	pcntl_signal(SIGINT,  function() {
70
+		global $sockets;
71
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72
+		die("Bye!\n");
73
+	});
74
+	pcntl_signal_dispatch();
75 75
 }
76 76
 
77 77
 // let's try and connect
@@ -80,161 +80,161 @@  discard block
 block discarded – undo
80 80
 $aprs_full = false;
81 81
 
82 82
 function create_socket($host, $port, &$errno, &$errstr) {
83
-    $ip = gethostbyname($host);
84
-    $s = socket_create(AF_INET, SOCK_STREAM, 0);
85
-    $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
-        return $s;
89
-    }
90
-    $errno = socket_last_error($s);
91
-    $errstr = socket_strerror($errno);
92
-    socket_close($s);
93
-    return false;
83
+	$ip = gethostbyname($host);
84
+	$s = socket_create(AF_INET, SOCK_STREAM, 0);
85
+	$r = @socket_connect($s, $ip, $port);
86
+	if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
87
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88
+		return $s;
89
+	}
90
+	$errno = socket_last_error($s);
91
+	$errstr = socket_strerror($errno);
92
+	socket_close($s);
93
+	return false;
94 94
 }
95 95
 
96 96
 function create_socket_udp($host, $port, &$errno, &$errstr) {
97
-    echo "UDP !!";
98
-    $ip = gethostbyname($host);
99
-    $s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
-    $r = @socket_bind($s, $ip, $port);
101
-    if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
-        return $s;
103
-    }
104
-    $errno = socket_last_error($s);
105
-    $errstr = socket_strerror($errno);
106
-    socket_close($s);
107
-    return false;
97
+	echo "UDP !!";
98
+	$ip = gethostbyname($host);
99
+	$s = socket_create(AF_INET, SOCK_DGRAM, 0);
100
+	$r = @socket_bind($s, $ip, $port);
101
+	if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
102
+		return $s;
103
+	}
104
+	$errno = socket_last_error($s);
105
+	$errstr = socket_strerror($errno);
106
+	socket_close($s);
107
+	return false;
108 108
 }
109 109
 
110 110
 function connect_all($hosts) {
111
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
114
-    foreach ($hosts as $id => $value) {
111
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+	global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
+	if ($globalDebug) echo 'Connect to all...'."\n";
114
+	foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118 118
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
120
-        	//$formats[$id] = 'deltadbtxt';
121
-        	$globalSources[$id]['format'] = 'deltadbtxt';
122
-        	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
-        	//$formats[$id] = 'vatsimtxt';
126
-        	$globalSources[$id]['format'] = 'vatsimtxt';
127
-        	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130
-        	//$formats[$id] = 'aircraftlistjson';
131
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
132
-        	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
135
-        	//$formats[$id] = 'aircraftlistjson';
136
-        	$globalSources[$id]['format'] = 'opensky';
137
-        	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
-        	//$formats[$id] = 'radarvirtueljson';
141
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
142
-        	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
-        	    exit(0);
147
-        	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
-        	//$formats[$id] = 'planeupdatefaa';
150
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
151
-        	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
-        	    exit(0);
156
-        	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
-        	//$formats[$id] = 'phpvmacars';
159
-        	$globalSources[$id]['format'] = 'phpvmacars';
160
-        	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
163
-        	//$formats[$id] = 'phpvmacars';
164
-        	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
167
-        	//$formats[$id] = 'whazzup';
168
-        	$globalSources[$id]['format'] = 'whazzup';
169
-        	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
172
-        	//$formats[$id] = 'pirepsjson';
173
-        	$globalSources[$id]['format'] = 'pirepsjson';
174
-        	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
-        	//$formats[$id] = 'fr24json';
178
-        	$globalSources[$id]['format'] = 'fr24json';
179
-        	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
-        	    exit(0);
184
-        	}
185
-            //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
-        	//$formats[$id] = 'tsv';
188
-        	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
-            }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
195
-	    if (isset($hostport[1])) {
119
+			if (preg_match('/deltadb.txt$/i',$host)) {
120
+			//$formats[$id] = 'deltadbtxt';
121
+			$globalSources[$id]['format'] = 'deltadbtxt';
122
+			//$last_exec['deltadbtxt'] = 0;
123
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
125
+			//$formats[$id] = 'vatsimtxt';
126
+			$globalSources[$id]['format'] = 'vatsimtxt';
127
+			//$last_exec['vatsimtxt'] = 0;
128
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
130
+			//$formats[$id] = 'aircraftlistjson';
131
+			$globalSources[$id]['format'] = 'aircraftlistjson';
132
+			//$last_exec['aircraftlistjson'] = 0;
133
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
+			} else if (preg_match('/opensky/i',$host)) {
135
+			//$formats[$id] = 'aircraftlistjson';
136
+			$globalSources[$id]['format'] = 'opensky';
137
+			//$last_exec['aircraftlistjson'] = 0;
138
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140
+			//$formats[$id] = 'radarvirtueljson';
141
+			$globalSources[$id]['format'] = 'radarvirtueljson';
142
+			//$last_exec['radarvirtueljson'] = 0;
143
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
144
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146
+				exit(0);
147
+			}
148
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
149
+			//$formats[$id] = 'planeupdatefaa';
150
+			$globalSources[$id]['format'] = 'planeupdatefaa';
151
+			//$last_exec['planeupdatefaa'] = 0;
152
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
153
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155
+				exit(0);
156
+			}
157
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
158
+			//$formats[$id] = 'phpvmacars';
159
+			$globalSources[$id]['format'] = 'phpvmacars';
160
+			//$last_exec['phpvmacars'] = 0;
161
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
163
+			//$formats[$id] = 'phpvmacars';
164
+			$globalSources[$id]['format'] = 'vam';
165
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
+			} else if (preg_match('/whazzup/i',$host)) {
167
+			//$formats[$id] = 'whazzup';
168
+			$globalSources[$id]['format'] = 'whazzup';
169
+			//$last_exec['whazzup'] = 0;
170
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
+			} else if (preg_match('/recentpireps/i',$host)) {
172
+			//$formats[$id] = 'pirepsjson';
173
+			$globalSources[$id]['format'] = 'pirepsjson';
174
+			//$last_exec['pirepsjson'] = 0;
175
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177
+			//$formats[$id] = 'fr24json';
178
+			$globalSources[$id]['format'] = 'fr24json';
179
+			//$last_exec['fr24json'] = 0;
180
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
181
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183
+				exit(0);
184
+			}
185
+			//} else if (preg_match('/10001/',$host)) {
186
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187
+			//$formats[$id] = 'tsv';
188
+			$globalSources[$id]['format'] = 'tsv';
189
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190
+			}
191
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
+			if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
+		$hostport = explode(':',$host);
195
+		if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
198
-	    } else {
198
+		} else {
199 199
 		$port = $globalSources[$id]['port'];
200 200
 		$hostn = $globalSources[$id]['host'];
201
-	    }
202
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
204
-    	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
-	    }
207
-	    if ($s) {
208
-    	        $sockets[$id] = $s;
209
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
201
+		}
202
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
+			$s = create_socket($hostn,$port, $errno, $errstr);
204
+			} else {
205
+			$s = create_socket_udp($hostn,$port, $errno, $errstr);
206
+		}
207
+		if ($s) {
208
+				$sockets[$id] = $s;
209
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
+			if (preg_match('/aprs/',$hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
214 214
 			//$use_aprs = true;
215
-    		    } elseif ($port == '10001') {
216
-        		//$formats[$id] = 'tsv';
217
-        		$globalSources[$id]['format'] = 'tsv';
218
-		    } elseif ($port == '30002') {
219
-        		//$formats[$id] = 'raw';
220
-        		$globalSources[$id]['format'] = 'raw';
221
-		    } elseif ($port == '5001') {
222
-        		//$formats[$id] = 'raw';
223
-        		$globalSources[$id]['format'] = 'flightgearmp';
224
-		    } elseif ($port == '30005') {
215
+				} elseif ($port == '10001') {
216
+				//$formats[$id] = 'tsv';
217
+				$globalSources[$id]['format'] = 'tsv';
218
+			} elseif ($port == '30002') {
219
+				//$formats[$id] = 'raw';
220
+				$globalSources[$id]['format'] = 'raw';
221
+			} elseif ($port == '5001') {
222
+				//$formats[$id] = 'raw';
223
+				$globalSources[$id]['format'] = 'flightgearmp';
224
+			} elseif ($port == '30005') {
225 225
 			// Not yet supported
226
-        		//$formats[$id] = 'beast';
227
-        		$globalSources[$id]['format'] = 'beast';
228
-		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
230
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
226
+				//$formats[$id] = 'beast';
227
+				$globalSources[$id]['format'] = 'beast';
228
+			//} else $formats[$id] = 'sbs';
229
+			} else $globalSources[$id]['format'] = 'sbs';
230
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 231
 		}
232 232
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
233
-            } else {
233
+			} else {
234 234
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
235
-    	    }
236
-        }
237
-    }
235
+			}
236
+		}
237
+	}
238 238
 }
239 239
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
240 240
 
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 	die;
262 262
 }
263 263
 foreach ($globalSources as $key => $source) {
264
-    if (!isset($source['format'])) {
265
-        $globalSources[$key]['format'] = 'auto';
266
-    }
264
+	if (!isset($source['format'])) {
265
+		$globalSources[$key]['format'] = 'auto';
266
+	}
267 267
 }
268 268
 connect_all($globalSources);
269 269
 foreach ($globalSources as $key => $source) {
270
-    if (isset($source['format']) && $source['format'] == 'aprs') {
270
+	if (isset($source['format']) && $source['format'] == 'aprs') {
271 271
 	$aprs_connect = 0;
272 272
 	$use_aprs = true;
273 273
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
274 274
 	break;
275
-    }
275
+	}
276 276
 }
277 277
 
278 278
 if ($use_aprs) {
@@ -312,67 +312,67 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
316
-    // Delete old ATC
317
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
315
+	if (!$globalDaemon) $i = $endtime-time();
316
+	// Delete old ATC
317
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
319
-        $ATC->deleteOldATC();
320
-    }
319
+		$ATC->deleteOldATC();
320
+	}
321 321
     
322
-    if (count($last_exec) > 0) {
322
+	if (count($last_exec) > 0) {
323 323
 	$max = $globalMinFetch;
324 324
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
325
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
328
+		if ($globalDebug) echo 'Sleeping...'."\n";
329
+		sleep($globalMinFetch-$max+2);
330
+	}
330 331
 	}
331
-    }
332 332
 
333 333
     
334
-    //foreach ($formats as $id => $value) {
335
-    foreach ($globalSources as $id => $value) {
334
+	//foreach ($formats as $id => $value) {
335
+	foreach ($globalSources as $id => $value) {
336 336
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338
-	    //$buffer = $Common->getData($hosts[$id]);
339
-	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
342
-	    foreach ($buffer as $line) {
343
-    		if ($line != '') {
344
-    		    $line = explode(',', $line);
345
-	            $data = array();
346
-	            $data['hex'] = $line[1]; // hex
347
-	            $data['ident'] = $line[2]; // ident
348
-	            $data['altitude'] = $line[3]; // altitude
349
-	            $data['speed'] = $line[4]; // speed
350
-	            $data['heading'] = $line[5]; // heading
351
-	            $data['latitude'] = $line[6]; // lat
352
-	            $data['longitude'] = $line[7]; // long
353
-	            $data['verticalrate'] = ''; // vertical rate
354
-	            $data['squawk'] = ''; // squawk
355
-	            $data['emergency'] = ''; // emergency
356
-		    $data['datetime'] = date('Y-m-d H:i:s');
357
-		    $data['format_source'] = 'deltadbtxt';
358
-    		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
-    		    $SI->add($data);
362
-		    unset($data);
363
-    		}
364
-    	    }
365
-    	    $last_exec[$id]['last'] = time();
338
+		//$buffer = $Common->getData($hosts[$id]);
339
+		$buffer = $Common->getData($value['host']);
340
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
+		$buffer = explode('\n',$buffer);
342
+		foreach ($buffer as $line) {
343
+			if ($line != '') {
344
+				$line = explode(',', $line);
345
+				$data = array();
346
+				$data['hex'] = $line[1]; // hex
347
+				$data['ident'] = $line[2]; // ident
348
+				$data['altitude'] = $line[3]; // altitude
349
+				$data['speed'] = $line[4]; // speed
350
+				$data['heading'] = $line[5]; // heading
351
+				$data['latitude'] = $line[6]; // lat
352
+				$data['longitude'] = $line[7]; // long
353
+				$data['verticalrate'] = ''; // vertical rate
354
+				$data['squawk'] = ''; // squawk
355
+				$data['emergency'] = ''; // emergency
356
+			$data['datetime'] = date('Y-m-d H:i:s');
357
+			$data['format_source'] = 'deltadbtxt';
358
+				$data['id_source'] = $id_source;
359
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
361
+				$SI->add($data);
362
+			unset($data);
363
+			}
364
+			}
365
+			$last_exec[$id]['last'] = time();
366 366
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368
-	    //$buffer = $Common->getData($hosts[$id]);
369
-	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
372
-	    foreach ($buffer as $line) {
373
-    		if ($line != '') {
374
-    		    $line = explode(':', $line);
375
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
368
+		//$buffer = $Common->getData($hosts[$id]);
369
+		$buffer = $Common->getData($value['host']);
370
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
+		$buffer = explode('\n',$buffer);
372
+		foreach ($buffer as $line) {
373
+			if ($line != '') {
374
+				$line = explode(':', $line);
375
+				if (count($line) > 30 && $line[0] != 'callsign') {
376 376
 			$data = array();
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
@@ -384,36 +384,36 @@  discard block
 block discarded – undo
384 384
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385 385
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
386 386
 			$data['latitude'] = $line[5]; // lat
387
-	        	$data['longitude'] = $line[6]; // long
388
-	        	$data['verticalrate'] = ''; // vertical rate
389
-	        	$data['squawk'] = ''; // squawk
390
-	        	$data['emergency'] = ''; // emergency
391
-	        	$data['waypoints'] = $line[30];
387
+				$data['longitude'] = $line[6]; // long
388
+				$data['verticalrate'] = ''; // vertical rate
389
+				$data['squawk'] = ''; // squawk
390
+				$data['emergency'] = ''; // emergency
391
+				$data['waypoints'] = $line[30];
392 392
 			$data['datetime'] = date('Y-m-d H:i:s');
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395
-		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
-		        $data['arrival_airport_icao'] = $line[13];
395
+				$data['departure_airport_icao'] = $line[11];
396
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397
+				$data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
400 400
 			$data['range'] = $line[19];
401 401
 			if (isset($line[35])) $data['info'] = $line[35];
402
-    			$data['id_source'] = $id_source;
403
-	    		//$data['arrival_airport_time'] = ;
404
-	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
406
-	    		    if (isset($aircraft_data[1])) {
407
-	    			$data['aircraft_icao'] = $aircraft_data[1];
408
-	    		    }
409
-        		}
410
-	    		/*
402
+				$data['id_source'] = $id_source;
403
+				//$data['arrival_airport_time'] = ;
404
+				if ($line[9] != '') {
405
+					$aircraft_data = explode('/',$line[9]);
406
+					if (isset($aircraft_data[1])) {
407
+					$data['aircraft_icao'] = $aircraft_data[1];
408
+					}
409
+				}
410
+				/*
411 411
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
412 412
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 413
 	    		*/
414
-	    		$data['format_source'] = $value['format'];
414
+				$data['format_source'] = $value['format'];
415 415
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
416
+				if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419 419
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -431,240 +431,240 @@  discard block
 block discarded – undo
431 431
 				
432 432
 				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']);
433 433
 			}
434
-    			unset($data);
435
-    		    }
436
-    		}
437
-    	    }
438
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
-    	    $last_exec[$id]['last'] = time();
441
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
444
-	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
446
-	    if (isset($all_data['acList'])) {
434
+				unset($data);
435
+				}
436
+			}
437
+			}
438
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
439
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
440
+			$last_exec[$id]['last'] = time();
441
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
444
+		if ($buffer != '') {
445
+		$all_data = json_decode($buffer,true);
446
+		if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448
-		    $data = array();
449
-		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
-		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
-		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
-		    /*
448
+			$data = array();
449
+			$data['hex'] = $line['Icao']; // hex
450
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
456
+			//$data['verticalrate'] = $line['']; // verticale rate
457
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
458
+			$data['emergency'] = ''; // emergency
459
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
460
+			/*
461 461
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 462
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 463
 		    */
464
-		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
-	    	    $data['format_source'] = 'aircraftlistjson';
467
-		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
470
-		    unset($data);
464
+			$data['datetime'] = date('Y-m-d H:i:s');
465
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
466
+				$data['format_source'] = 'aircraftlistjson';
467
+			$data['id_source'] = $id_source;
468
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
+			if (isset($data['datetime'])) $SI->add($data);
470
+			unset($data);
471 471
 		}
472
-	    } else {
472
+		} else {
473 473
 		foreach ($all_data as $line) {
474
-		    $data = array();
475
-		    $data['hex'] = $line['hex']; // hex
476
-		    $data['ident'] = $line['flight']; // ident
477
-		    $data['altitude'] = $line['altitude']; // altitude
478
-		    $data['speed'] = $line['speed']; // speed
479
-		    $data['heading'] = $line['track']; // heading
480
-		    $data['latitude'] = $line['lat']; // lat
481
-		    $data['longitude'] = $line['lon']; // long
482
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
483
-		    $data['squawk'] = $line['squawk']; // squawk
484
-		    $data['emergency'] = ''; // emergency
485
-		    $data['datetime'] = date('Y-m-d H:i:s');
486
-	    	    $data['format_source'] = 'aircraftlistjson';
487
-    		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
-		    $SI->add($data);
490
-		    unset($data);
474
+			$data = array();
475
+			$data['hex'] = $line['hex']; // hex
476
+			$data['ident'] = $line['flight']; // ident
477
+			$data['altitude'] = $line['altitude']; // altitude
478
+			$data['speed'] = $line['speed']; // speed
479
+			$data['heading'] = $line['track']; // heading
480
+			$data['latitude'] = $line['lat']; // lat
481
+			$data['longitude'] = $line['lon']; // long
482
+			$data['verticalrate'] = $line['vrt']; // verticale rate
483
+			$data['squawk'] = $line['squawk']; // squawk
484
+			$data['emergency'] = ''; // emergency
485
+			$data['datetime'] = date('Y-m-d H:i:s');
486
+				$data['format_source'] = 'aircraftlistjson';
487
+				$data['id_source'] = $id_source;
488
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
489
+			$SI->add($data);
490
+			unset($data);
491
+		}
492
+		}
491 493
 		}
492
-	    }
493
-	    }
494
-    	    //$last_exec['aircraftlistjson'] = time();
495
-    	    $last_exec[$id]['last'] = time();
496
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
-	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
500
-	    if (isset($all_data['planes'])) {
494
+			//$last_exec['aircraftlistjson'] = time();
495
+			$last_exec[$id]['last'] = time();
496
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498
+		$buffer = $Common->getData($value['host']);
499
+		$all_data = json_decode($buffer,true);
500
+		if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502
-		    $data = array();
503
-		    $data['hex'] = $key; // hex
504
-		    $data['ident'] = $line[3]; // ident
505
-		    $data['altitude'] = $line[6]; // altitude
506
-		    $data['speed'] = $line[8]; // speed
507
-		    $data['heading'] = $line[7]; // heading
508
-		    $data['latitude'] = $line[4]; // lat
509
-		    $data['longitude'] = $line[5]; // long
510
-		    //$data['verticalrate'] = $line[]; // verticale rate
511
-		    $data['squawk'] = $line[10]; // squawk
512
-		    $data['emergency'] = ''; // emergency
513
-		    $data['registration'] = $line[2];
514
-		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
516
-		    if (count($deparr) == 2) {
502
+			$data = array();
503
+			$data['hex'] = $key; // hex
504
+			$data['ident'] = $line[3]; // ident
505
+			$data['altitude'] = $line[6]; // altitude
506
+			$data['speed'] = $line[8]; // speed
507
+			$data['heading'] = $line[7]; // heading
508
+			$data['latitude'] = $line[4]; // lat
509
+			$data['longitude'] = $line[5]; // long
510
+			//$data['verticalrate'] = $line[]; // verticale rate
511
+			$data['squawk'] = $line[10]; // squawk
512
+			$data['emergency'] = ''; // emergency
513
+			$data['registration'] = $line[2];
514
+			$data['aircraft_icao'] = $line[0];
515
+			$deparr = explode('-',$line[1]);
516
+			if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519
-		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
-	    	    $data['format_source'] = 'planeupdatefaa';
522
-    		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
-		    $SI->add($data);
525
-		    unset($data);
519
+			}
520
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521
+				$data['format_source'] = 'planeupdatefaa';
522
+				$data['id_source'] = $id_source;
523
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
524
+			$SI->add($data);
525
+			unset($data);
526 526
 		}
527
-	    }
528
-    	    //$last_exec['planeupdatefaa'] = time();
529
-    	    $last_exec[$id]['last'] = time();
530
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
-	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
533
-	    if (isset($all_data['states'])) {
527
+		}
528
+			//$last_exec['planeupdatefaa'] = time();
529
+			$last_exec[$id]['last'] = time();
530
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531
+		$buffer = $Common->getData($value['host']);
532
+		$all_data = json_decode($buffer,true);
533
+		if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535
-		    $data = array();
536
-		    $data['hex'] = $line[0]; // hex
537
-		    $data['ident'] = trim($line[1]); // ident
538
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
539
-		    $data['speed'] = round($line[9]*1.94384); // speed
540
-		    $data['heading'] = round($line[10]); // heading
541
-		    $data['latitude'] = $line[5]; // lat
542
-		    $data['longitude'] = $line[6]; // long
543
-		    $data['verticalrate'] = $line[11]; // verticale rate
544
-		    //$data['squawk'] = $line[10]; // squawk
545
-		    //$data['emergency'] = ''; // emergency
546
-		    //$data['registration'] = $line[2];
547
-		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
-	    	    $data['format_source'] = 'opensky';
550
-    		    $data['id_source'] = $id_source;
551
-		    $SI->add($data);
552
-		    unset($data);
535
+			$data = array();
536
+			$data['hex'] = $line[0]; // hex
537
+			$data['ident'] = trim($line[1]); // ident
538
+			$data['altitude'] = round($line[7]*3.28084); // altitude
539
+			$data['speed'] = round($line[9]*1.94384); // speed
540
+			$data['heading'] = round($line[10]); // heading
541
+			$data['latitude'] = $line[5]; // lat
542
+			$data['longitude'] = $line[6]; // long
543
+			$data['verticalrate'] = $line[11]; // verticale rate
544
+			//$data['squawk'] = $line[10]; // squawk
545
+			//$data['emergency'] = ''; // emergency
546
+			//$data['registration'] = $line[2];
547
+			//$data['aircraft_icao'] = $line[0];
548
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
549
+				$data['format_source'] = 'opensky';
550
+				$data['id_source'] = $id_source;
551
+			$SI->add($data);
552
+			unset($data);
553 553
 		}
554
-	    }
555
-    	    //$last_exec['planeupdatefaa'] = time();
556
-    	    $last_exec[$id]['last'] = time();
557
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
-	    //$buffer = $Common->getData($hosts[$id]);
560
-	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
562
-	    foreach ($all_data as $key => $line) {
554
+		}
555
+			//$last_exec['planeupdatefaa'] = time();
556
+			$last_exec[$id]['last'] = time();
557
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
558
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559
+		//$buffer = $Common->getData($hosts[$id]);
560
+		$buffer = $Common->getData($value['host']);
561
+		$all_data = json_decode($buffer,true);
562
+		foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564
-		    $data = array();
565
-		    $data['hex'] = $line[0];
566
-		    $data['ident'] = $line[16]; //$line[13]
567
-	    	    $data['altitude'] = $line[4]; // altitude
568
-	    	    $data['speed'] = $line[5]; // speed
569
-	    	    $data['heading'] = $line[3]; // heading
570
-	    	    $data['latitude'] = $line[1]; // lat
571
-	    	    $data['longitude'] = $line[2]; // long
572
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
573
-	    	    $data['squawk'] = $line[6]; // squawk
574
-	    	    $data['aircraft_icao'] = $line[8];
575
-	    	    $data['registration'] = $line[9];
576
-		    $data['departure_airport_iata'] = $line[11];
577
-		    $data['arrival_airport_iata'] = $line[12];
578
-	    	    $data['emergency'] = ''; // emergency
579
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
-	    	    $data['format_source'] = 'fr24json';
581
-    		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
-		    $SI->add($data);
584
-		    unset($data);
564
+			$data = array();
565
+			$data['hex'] = $line[0];
566
+			$data['ident'] = $line[16]; //$line[13]
567
+				$data['altitude'] = $line[4]; // altitude
568
+				$data['speed'] = $line[5]; // speed
569
+				$data['heading'] = $line[3]; // heading
570
+				$data['latitude'] = $line[1]; // lat
571
+				$data['longitude'] = $line[2]; // long
572
+				$data['verticalrate'] = $line[15]; // verticale rate
573
+				$data['squawk'] = $line[6]; // squawk
574
+				$data['aircraft_icao'] = $line[8];
575
+				$data['registration'] = $line[9];
576
+			$data['departure_airport_iata'] = $line[11];
577
+			$data['arrival_airport_iata'] = $line[12];
578
+				$data['emergency'] = ''; // emergency
579
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580
+				$data['format_source'] = 'fr24json';
581
+				$data['id_source'] = $id_source;
582
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
583
+			$SI->add($data);
584
+			unset($data);
585 585
 		}
586
-	    }
587
-    	    //$last_exec['fr24json'] = time();
588
-    	    $last_exec[$id]['last'] = time();
589
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
593
-	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
597
-	    if (json_last_error() != JSON_ERROR_NONE) {
586
+		}
587
+			//$last_exec['fr24json'] = time();
588
+			$last_exec[$id]['last'] = time();
589
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
593
+		//echo $buffer;
594
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
595
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
+		$all_data = json_decode($buffer,true);
597
+		if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599
-	    }
600
-	    if (isset($all_data['mrkrs'])) {
599
+		}
600
+		if (isset($all_data['mrkrs'])) {
601 601
 		foreach ($all_data['mrkrs'] as $key => $line) {
602
-		    if (isset($line['inf'])) {
602
+			if (isset($line['inf'])) {
603 603
 			$data = array();
604 604
 			$data['hex'] = $line['inf']['ia'];
605 605
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
606
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
-	    		$data['latitude'] = $line['pt'][0]; // lat
610
-	    		$data['longitude'] = $line['pt'][1]; // long
611
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
-	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
606
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
609
+				$data['latitude'] = $line['pt'][0]; // lat
610
+				$data['longitude'] = $line['pt'][1]; // long
611
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
613
+				//$data['aircraft_icao'] = $line[8];
614
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617
-	    		//$data['emergency'] = ''; // emergency
617
+				//$data['emergency'] = ''; // emergency
618 618
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619
-	    		$data['format_source'] = 'radarvirtueljson';
620
-    			$data['id_source'] = $id_source;
619
+				$data['format_source'] = 'radarvirtueljson';
620
+				$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
622 622
 			$SI->add($data);
623 623
 			unset($data);
624
-		    }
624
+			}
625 625
 		}
626
-	    }
627
-    	    //$last_exec['radarvirtueljson'] = time();
628
-    	    $last_exec[$id]['last'] = time();
629
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
-	    //$buffer = $Common->getData($hosts[$id]);
632
-	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
626
+		}
627
+			//$last_exec['radarvirtueljson'] = time();
628
+			$last_exec[$id]['last'] = time();
629
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
630
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631
+		//$buffer = $Common->getData($hosts[$id]);
632
+		$buffer = $Common->getData($value['host'].'?'.time());
633
+		$all_data = json_decode(utf8_encode($buffer),true);
634 634
 	    
635
-	    if (isset($all_data['pireps'])) {
636
-	        foreach ($all_data['pireps'] as $line) {
637
-		    $data = array();
638
-		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
-		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
-		    $data['latitude'] = $line['lat']; // lat
648
-		    $data['longitude'] = $line['lon']; // long
649
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650
-		    //$data['squawk'] = $line['squawk']; // squawk
651
-		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
-		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
660
-		    $data['format_source'] = 'pireps';
661
-    		    $data['id_source'] = $id_source;
662
-		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
-		    if ($line['icon'] == 'plane') {
635
+		if (isset($all_data['pireps'])) {
636
+			foreach ($all_data['pireps'] as $line) {
637
+			$data = array();
638
+			$data['id'] = $line['id'];
639
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640
+			$data['ident'] = $line['callsign']; // ident
641
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
647
+			$data['latitude'] = $line['lat']; // lat
648
+			$data['longitude'] = $line['lon']; // long
649
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
650
+			//$data['squawk'] = $line['squawk']; // squawk
651
+			//$data['emergency'] = ''; // emergency
652
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
655
+			//$data['arrival_airport_time'] = $line['arrtime'];
656
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
659
+			else $data['info'] = '';
660
+			$data['format_source'] = 'pireps';
661
+				$data['id_source'] = $id_source;
662
+			$data['datetime'] = date('Y-m-d H:i:s');
663
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
664
+			if ($line['icon'] == 'plane') {
665 665
 			$SI->add($data);
666
-		    //    print_r($data);
667
-    		    } elseif ($line['icon'] == 'ct') {
666
+			//    print_r($data);
667
+				} elseif ($line['icon'] == 'ct') {
668 668
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669 669
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 670
 			$typec = substr($data['ident'],-3);
@@ -679,158 +679,158 @@  discard block
 block discarded – undo
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681 681
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682
-		    }
683
-		    unset($data);
682
+			}
683
+			unset($data);
684 684
 		}
685
-	    }
686
-    	    //$last_exec['pirepsjson'] = time();
687
-    	    $last_exec[$id]['last'] = time();
688
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
-	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
692
-	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
694
-	    if ($buffer != '' && is_array($all_data)) {
685
+		}
686
+			//$last_exec['pirepsjson'] = time();
687
+			$last_exec[$id]['last'] = time();
688
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690
+		//$buffer = $Common->getData($hosts[$id]);
691
+		if ($globalDebug) echo 'Get Data...'."\n";
692
+		$buffer = $Common->getData($value['host']);
693
+		$all_data = json_decode($buffer,true);
694
+		if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696
-	    	    $data = array();
697
-	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
-	    	    $data['ident'] = $line['flightnum']; // ident
703
-	    	    $data['altitude'] = $line['alt']; // altitude
704
-	    	    $data['speed'] = $line['gs']; // speed
705
-	    	    $data['heading'] = $line['heading']; // heading
706
-	    	    $data['latitude'] = $line['lat']; // lat
707
-	    	    $data['longitude'] = $line['lng']; // long
708
-	    	    $data['verticalrate'] = ''; // verticale rate
709
-	    	    $data['squawk'] = ''; // squawk
710
-	    	    $data['emergency'] = ''; // emergency
711
-	    	    //$data['datetime'] = $line['lastupdate'];
712
-	    	    $data['last_update'] = $line['lastupdate'];
713
-		    $data['datetime'] = date('Y-m-d H:i:s');
714
-	    	    $data['departure_airport_icao'] = $line['depicao'];
715
-	    	    $data['departure_airport_time'] = $line['deptime'];
716
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
717
-    		    $data['arrival_airport_time'] = $line['arrtime'];
718
-    		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
-		    if (isset($line['aircraftname'])) {
696
+				$data = array();
697
+				//$data['id'] = $line['id']; // id not usable
698
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702
+				$data['ident'] = $line['flightnum']; // ident
703
+				$data['altitude'] = $line['alt']; // altitude
704
+				$data['speed'] = $line['gs']; // speed
705
+				$data['heading'] = $line['heading']; // heading
706
+				$data['latitude'] = $line['lat']; // lat
707
+				$data['longitude'] = $line['lng']; // long
708
+				$data['verticalrate'] = ''; // verticale rate
709
+				$data['squawk'] = ''; // squawk
710
+				$data['emergency'] = ''; // emergency
711
+				//$data['datetime'] = $line['lastupdate'];
712
+				$data['last_update'] = $line['lastupdate'];
713
+			$data['datetime'] = date('Y-m-d H:i:s');
714
+				$data['departure_airport_icao'] = $line['depicao'];
715
+				$data['departure_airport_time'] = $line['deptime'];
716
+				$data['arrival_airport_icao'] = $line['arricao'];
717
+				$data['arrival_airport_time'] = $line['arrtime'];
718
+				$data['registration'] = $line['aircraft'];
719
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720
+			if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 722
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730
-	    		}
731
-	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
-    		    $data['id_source'] = $id_source;
734
-	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
-		    $SI->add($data);
737
-		    unset($data);
723
+				$aircraft_data = explode('-',$line['aircraftname']);
724
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
+				else {
727
+					$aircraft_data = explode(' ',$line['aircraftname']);
728
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
+					else $data['aircraft_icao'] = $line['aircraftname'];
730
+				}
731
+				}
732
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
733
+				$data['id_source'] = $id_source;
734
+				$data['format_source'] = 'phpvmacars';
735
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
736
+			$SI->add($data);
737
+			unset($data);
738 738
 		}
739 739
 		if ($globalDebug) echo 'No more data...'."\n";
740 740
 		unset($buffer);
741 741
 		unset($all_data);
742
-	    }
743
-    	    //$last_exec['phpvmacars'] = time();
744
-    	    $last_exec[$id]['last'] = time();
745
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
-	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
748
-	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
750
-	    if ($buffer != '' && is_array($all_data)) {
742
+		}
743
+			//$last_exec['phpvmacars'] = time();
744
+			$last_exec[$id]['last'] = time();
745
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746
+		//$buffer = $Common->getData($hosts[$id]);
747
+		if ($globalDebug) echo 'Get Data...'."\n";
748
+		$buffer = $Common->getData($value['host']);
749
+		$all_data = json_decode($buffer,true);
750
+		if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752
-	    	    $data = array();
753
-	    	    //$data['id'] = $line['id']; // id not usable
754
-	    	    $data['id'] = $line['flight_id'];
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
-	    	    $data['pilot_name'] = $line['pilot_name'];
757
-	    	    $data['pilot_id'] = $line['pilot_id'];
758
-	    	    $data['ident'] = $line['callsign']; // ident
759
-	    	    $data['altitude'] = $line['altitude']; // altitude
760
-	    	    $data['speed'] = $line['gs']; // speed
761
-	    	    $data['heading'] = $line['heading']; // heading
762
-	    	    $data['latitude'] = $line['latitude']; // lat
763
-	    	    $data['longitude'] = $line['longitude']; // long
764
-	    	    $data['verticalrate'] = ''; // verticale rate
765
-	    	    $data['squawk'] = ''; // squawk
766
-	    	    $data['emergency'] = ''; // emergency
767
-	    	    //$data['datetime'] = $line['lastupdate'];
768
-	    	    $data['last_update'] = $line['last_update'];
769
-		    $data['datetime'] = date('Y-m-d H:i:s');
770
-	    	    $data['departure_airport_icao'] = $line['departure'];
771
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
772
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
773
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
774
-    		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
-	    	    $data['aircraft_icao'] = $line['plane_type'];
777
-    		    $data['id_source'] = $id_source;
778
-	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
-		    $SI->add($data);
781
-		    unset($data);
752
+				$data = array();
753
+				//$data['id'] = $line['id']; // id not usable
754
+				$data['id'] = $line['flight_id'];
755
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
756
+				$data['pilot_name'] = $line['pilot_name'];
757
+				$data['pilot_id'] = $line['pilot_id'];
758
+				$data['ident'] = $line['callsign']; // ident
759
+				$data['altitude'] = $line['altitude']; // altitude
760
+				$data['speed'] = $line['gs']; // speed
761
+				$data['heading'] = $line['heading']; // heading
762
+				$data['latitude'] = $line['latitude']; // lat
763
+				$data['longitude'] = $line['longitude']; // long
764
+				$data['verticalrate'] = ''; // verticale rate
765
+				$data['squawk'] = ''; // squawk
766
+				$data['emergency'] = ''; // emergency
767
+				//$data['datetime'] = $line['lastupdate'];
768
+				$data['last_update'] = $line['last_update'];
769
+			$data['datetime'] = date('Y-m-d H:i:s');
770
+				$data['departure_airport_icao'] = $line['departure'];
771
+				//$data['departure_airport_time'] = $line['departure_time'];
772
+				$data['arrival_airport_icao'] = $line['arrival'];
773
+				//$data['arrival_airport_time'] = $line['arrival_time'];
774
+				//$data['registration'] = $line['aircraft'];
775
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
776
+				$data['aircraft_icao'] = $line['plane_type'];
777
+				$data['id_source'] = $id_source;
778
+				$data['format_source'] = 'vam';
779
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
780
+			$SI->add($data);
781
+			unset($data);
782 782
 		}
783 783
 		if ($globalDebug) echo 'No more data...'."\n";
784 784
 		unset($buffer);
785 785
 		unset($all_data);
786
-	    }
787
-    	    //$last_exec['phpvmacars'] = time();
788
-    	    $last_exec[$id]['last'] = time();
786
+		}
787
+			//$last_exec['phpvmacars'] = time();
788
+			$last_exec[$id]['last'] = time();
789 789
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 790
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
-    	    //$last_exec[$id]['last'] = time();
791
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
792
+			//$last_exec[$id]['last'] = time();
793 793
 
794
-	    //$read = array( $sockets[$id] );
795
-	    $read = $sockets;
796
-	    $write = NULL;
797
-	    $e = NULL;
798
-	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
800
-	    if ($n > 0) {
794
+		//$read = array( $sockets[$id] );
795
+		$read = $sockets;
796
+		$write = NULL;
797
+		$e = NULL;
798
+		$n = socket_select($read, $write, $e, $timeout);
799
+		if ($e != NULL) var_dump($e);
800
+		if ($n > 0) {
801 801
 		foreach ($read as $nb => $r) {
802
-		    //$value = $formats[$nb];
803
-		    $format = $globalSources[$nb]['format'];
804
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
-        	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
-	    	    }
809
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
-        	    //echo $buffer."\n";
811
-		    // lets play nice and handle signals such as ctrl-c/kill properly
812
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
-		    $error = false;
814
-		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
-		    // SBS format is CSV format
817
-		    if ($buffer != '') {
802
+			//$value = $formats[$nb];
803
+			$format = $globalSources[$nb]['format'];
804
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
806
+				} else {
807
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
808
+				}
809
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810
+				//echo $buffer."\n";
811
+			// lets play nice and handle signals such as ctrl-c/kill properly
812
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813
+			$error = false;
814
+			//$SI::del();
815
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
816
+			// SBS format is CSV format
817
+			if ($buffer != '') {
818 818
 			$tt[$format] = 0;
819 819
 			if ($format == 'acarssbs3') {
820
-			    echo $buffer."\n";
820
+				echo $buffer."\n";
821 821
 			} elseif ($format == 'raw') {
822
-			    // AVR format
823
-			    $data = $SBS->parse($buffer);
824
-			    if (is_array($data)) {
822
+				// AVR format
823
+				$data = $SBS->parse($buffer);
824
+				if (is_array($data)) {
825 825
 				$data['datetime'] = date('Y-m-d H:i:s');
826 826
 				$data['format_source'] = 'raw';
827 827
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
828
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
-                            }
831
-                        } elseif ($format == 'flightgearsp') {
832
-                    	    //echo $buffer."\n";
833
-                    	    if (strlen($buffer) > 5) {
828
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
830
+							}
831
+						} elseif ($format == 'flightgearsp') {
832
+							//echo $buffer."\n";
833
+							if (strlen($buffer) > 5) {
834 834
 				$line = explode(',',$buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -846,114 +846,114 @@  discard block
 block discarded – undo
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848 848
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
849
-			    }
850
-                        } elseif ($format == 'acars') {
851
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
-			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
-			    $ACARS->deleteLiveAcarsData();
849
+				}
850
+						} elseif ($format == 'acars') {
851
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852
+				$ACARS->add(trim($buffer));
853
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854
+				$ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+				if (substr($buffer,0,1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859 859
 				$line = explode(' ',$buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
-				    $data['ident'] = $userserver[0];
864
-				    $data['registration'] = $userserver[0];
865
-				    $data['latitude'] = $line[4];
866
-				    $data['longitude'] = $line[5];
867
-				    $data['altitude'] = $line[6];
868
-				    $data['datetime'] = date('Y-m-d H:i:s');
869
-				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
861
+					$userserver = explode('@',$line[0]);
862
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
863
+					$data['ident'] = $userserver[0];
864
+					$data['registration'] = $userserver[0];
865
+					$data['latitude'] = $line[4];
866
+					$data['longitude'] = $line[5];
867
+					$data['altitude'] = $line[6];
868
+					$data['datetime'] = date('Y-m-d H:i:s');
869
+					$aircraft_type = $line[10];
870
+					$aircraft_type = preg_split(':/:',$aircraft_type);
871
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873
+				}
873 874
 				}
874
-			    }
875 875
 			} elseif ($format == 'beast') {
876
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
-			    die;
876
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877
+				die;
878 878
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
879
-			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
879
+				$line = explode("\t", $buffer);
880
+				for($k = 0; $k < count($line); $k=$k+2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
883
-			    }
884
-    			    if (count($lined) > 3) {
885
-    				$data['hex'] = $lined['hexid'];
886
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
888
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
-    				$data['id_source'] = $id_source;
896
-    				$data['format_source'] = 'tsv';
897
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
-    				unset($lined);
901
-    				unset($data);
902
-    			    } else $error = true;
882
+					$lined[$key] = $line[$k+1];
883
+				}
884
+					if (count($lined) > 3) {
885
+					$data['hex'] = $lined['hexid'];
886
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
+					$data['datetime'] = date('Y-m-d H:i:s');;
888
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
895
+					$data['id_source'] = $id_source;
896
+					$data['format_source'] = 'tsv';
897
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
900
+					unset($lined);
901
+					unset($data);
902
+					} else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904
-			    if ($aprs_connect == 0) {
904
+				if ($aprs_connect == 0) {
905 905
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
906 906
 				$aprs_connect = 1;
907
-			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
907
+				}
908
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911 911
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
912
-			    }
913
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
912
+				}
913
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
+				$buffer = str_replace('APRS <- ','',$buffer);
915
+				$buffer = str_replace('APRS -> ','',$buffer);
916
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919
-				    $data = array();
920
-				    //print_r($line);
921
-				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
-				    //$data['datetime'] = date('Y-m-d H:i:s');
924
-				    $data['ident'] = $line['ident'];
925
-				    $data['latitude'] = $line['latitude'];
926
-				    $data['longitude'] = $line['longitude'];
927
-				    //$data['verticalrate'] = $line[16];
928
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
-				    else $data['speed'] = 0;
930
-				    $data['altitude'] = $line['altitude'];
931
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
932
-				    //else $data['heading'] = 0;
933
-				    $data['aircraft_type'] = $line['stealth'];
934
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
-    				    $data['id_source'] = $id_source;
936
-				    $data['format_source'] = 'aprs';
937
-				    $data['source_name'] = $line['source'];
938
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
-				    $currentdate = date('Y-m-d H:i:s');
940
-				    $aprsdate = strtotime($data['datetime']);
941
-				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
-				    else {
919
+					$data = array();
920
+					//print_r($line);
921
+					$data['hex'] = $line['address'];
922
+					$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
923
+					//$data['datetime'] = date('Y-m-d H:i:s');
924
+					$data['ident'] = $line['ident'];
925
+					$data['latitude'] = $line['latitude'];
926
+					$data['longitude'] = $line['longitude'];
927
+					//$data['verticalrate'] = $line[16];
928
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
+					else $data['speed'] = 0;
930
+					$data['altitude'] = $line['altitude'];
931
+					if (isset($line['course'])) $data['heading'] = $line['course'];
932
+					//else $data['heading'] = 0;
933
+					$data['aircraft_type'] = $line['stealth'];
934
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
935
+						$data['id_source'] = $id_source;
936
+					$data['format_source'] = 'aprs';
937
+					$data['source_name'] = $line['source'];
938
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
939
+					$currentdate = date('Y-m-d H:i:s');
940
+					$aprsdate = strtotime($data['datetime']);
941
+					// Accept data if time <= system time + 20s
942
+					if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
+					else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
946
-				    }
947
-				    unset($data);
946
+					}
947
+					unset($data);
948 948
 				} 
949 949
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
950 950
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
951
-			    }
951
+				}
952 952
 			} else {
953
-			    $line = explode(',', $buffer);
954
-    			    if (count($line) > 20) {
955
-    			    	$data['hex'] = $line[4];
956
-    				/*
953
+				$line = explode(',', $buffer);
954
+					if (count($line) > 20) {
955
+						$data['hex'] = $line[4];
956
+					/*
957 957
     				$data['datetime'] = $line[6].' '.$line[7];
958 958
     					date_default_timezone_set($globalTimezone);
959 959
     					$datetime = new DateTime($data['datetime']);
@@ -961,28 +961,28 @@  discard block
 block discarded – undo
961 961
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
962 962
     					date_default_timezone_set('UTC');
963 963
     				*/
964
-    				// Force datetime to current UTC datetime
965
-    				$data['datetime'] = date('Y-m-d H:i:s');
966
-    				$data['ident'] = trim($line[10]);
967
-    				$data['latitude'] = $line[14];
968
-    				$data['longitude'] = $line[15];
969
-    				$data['verticalrate'] = $line[16];
970
-    				$data['emergency'] = $line[20];
971
-    				$data['speed'] = $line[12];
972
-    				$data['squawk'] = $line[17];
973
-    				$data['altitude'] = $line[11];
974
-    				$data['heading'] = $line[13];
975
-    				$data['ground'] = $line[21];
976
-    				$data['emergency'] = $line[19];
977
-    				$data['format_source'] = 'sbs';
964
+					// Force datetime to current UTC datetime
965
+					$data['datetime'] = date('Y-m-d H:i:s');
966
+					$data['ident'] = trim($line[10]);
967
+					$data['latitude'] = $line[14];
968
+					$data['longitude'] = $line[15];
969
+					$data['verticalrate'] = $line[16];
970
+					$data['emergency'] = $line[20];
971
+					$data['speed'] = $line[12];
972
+					$data['squawk'] = $line[17];
973
+					$data['altitude'] = $line[11];
974
+					$data['heading'] = $line[13];
975
+					$data['ground'] = $line[21];
976
+					$data['emergency'] = $line[19];
977
+					$data['format_source'] = 'sbs';
978 978
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
979
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
-    				$data['id_source'] = $id_source;
981
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
-    				else $error = true;
983
-    				unset($data);
984
-    			    } else $error = true;
985
-			    if ($error) {
979
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
980
+					$data['id_source'] = $id_source;
981
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
+					else $error = true;
983
+					unset($data);
984
+					} else $error = true;
985
+				if ($error) {
986 986
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
987 987
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
988 988
 				} else {
@@ -998,13 +998,13 @@  discard block
 block discarded – undo
998 998
 					connect_all($sourceer);
999 999
 					$sourceer = array();
1000 1000
 				}
1001
-			    }
1001
+				}
1002 1002
 			}
1003 1003
 			// Sleep for xxx microseconds
1004 1004
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1005
-		    } else {
1005
+			} else {
1006 1006
 			if ($format == 'flightgearmp') {
1007
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1007
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1008 1008
 				//@socket_close($r);
1009 1009
 				sleep($globalMinFetch);
1010 1010
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1013,9 +1013,9 @@  discard block
 block discarded – undo
1013 1013
 				break;
1014 1014
 				
1015 1015
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1016
-			    if (isset($tt[$format])) $tt[$format]++;
1017
-			    else $tt[$format] = 0;
1018
-			    if ($tt[$format] > 30) {
1016
+				if (isset($tt[$format])) $tt[$format]++;
1017
+				else $tt[$format] = 0;
1018
+				if ($tt[$format] > 30) {
1019 1019
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1020 1020
 				//@socket_close($r);
1021 1021
 				sleep(2);
@@ -1026,40 +1026,40 @@  discard block
 block discarded – undo
1026 1026
 				//connect_all($globalSources);
1027 1027
 				$tt[$format]=0;
1028 1028
 				break;
1029
-			    }
1029
+				}
1030
+			}
1030 1031
 			}
1031
-		    }
1032 1032
 		}
1033
-	    } else {
1033
+		} else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035 1035
 		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
1039 1039
 			if (is_array($sockets)) {
1040
-			    if ($globalDebug) echo "Shutdown all sockets...";
1040
+				if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042
-			    foreach ($sockets as $sock) {
1042
+				foreach ($sockets as $sock) {
1043 1043
 				@socket_shutdown($sock,2);
1044 1044
 				@socket_close($sock);
1045
-			    }
1045
+				}
1046 1046
 			    
1047 1047
 			}
1048
-			    if ($globalDebug) echo "Restart all connections...";
1049
-			    sleep(2);
1050
-			    $time = time();
1051
-			    //connect_all($hosts);
1052
-			    $aprs_connect = 0;
1053
-			    connect_all($globalSources);
1048
+				if ($globalDebug) echo "Restart all connections...";
1049
+				sleep(2);
1050
+				$time = time();
1051
+				//connect_all($hosts);
1052
+				$aprs_connect = 0;
1053
+				connect_all($globalSources);
1054 1054
 
1055 1055
 		}
1056
-	    }
1056
+		}
1057 1057
 	}
1058 1058
 	if ($globalDaemon === false) {
1059
-	    if ($globalDebug) echo 'Check all...'."\n";
1060
-	    $SI->checkAll();
1059
+		if ($globalDebug) echo 'Check all...'."\n";
1060
+		$SI->checkAll();
1061
+	}
1061 1062
 	}
1062
-    }
1063 1063
 }
1064 1064
 
1065 1065
 ?>
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	    die;
38 38
 	}
39 39
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
40
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
40
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
41 41
     }
42 42
 }
43 43
 
44
-$options = getopt('s::',array('source::','server','idsource::'));
44
+$options = getopt('s::', array('source::', 'server', 'idsource::'));
45 45
 //if (isset($options['s'])) $hosts = array($options['s']);
46 46
 //elseif (isset($options['source'])) $hosts = array($options['source']);
47 47
 if (isset($options['s'])) {
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 else $id_source = 1;
57 57
 if (isset($globalServer) && $globalServer) {
58 58
     if ($globalDebug) echo "Using Server Mode\n";
59
-    $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
59
+    $SI = new SpotterServer();
60
+} else $SI = new SpotterImport($Connection->db);
61 61
 //$APRS=new APRS($Connection->db);
62
-$SBS=new SBS();
63
-$ACARS=new ACARS($Connection->db);
64
-$Common=new Common();
62
+$SBS = new SBS();
63
+$ACARS = new ACARS($Connection->db);
64
+$Common = new Common();
65 65
 date_default_timezone_set('UTC');
66 66
 //$servertz = system('date +%Z');
67 67
 // signal handler - playing nice with sockets and dump1090
68 68
 if (function_exists('pcntl_fork')) {
69
-    pcntl_signal(SIGINT,  function() {
69
+    pcntl_signal(SIGINT, function() {
70 70
         global $sockets;
71 71
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
72 72
         die("Bye!\n");
@@ -109,34 +109,34 @@  discard block
 block discarded – undo
109 109
 
110 110
 function connect_all($hosts) {
111 111
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
-    global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112
+    global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs;
113 113
     if ($globalDebug) echo 'Connect to all...'."\n";
114 114
     foreach ($hosts as $id => $value) {
115 115
 	$host = $value['host'];
116 116
 	$globalSources[$id]['last_exec'] = 0;
117 117
 	// Here we check type of source(s)
118
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
-            if (preg_match('/deltadb.txt$/i',$host)) {
118
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
119
+            if (preg_match('/deltadb.txt$/i', $host)) {
120 120
         	//$formats[$id] = 'deltadbtxt';
121 121
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 122
         	//$last_exec['deltadbtxt'] = 0;
123 123
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
124
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
124
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'vatsimtxt';
126 126
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 127
         	//$last_exec['vatsimtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
129
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
129
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
130 130
         	//$formats[$id] = 'aircraftlistjson';
131 131
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 132
         	//$last_exec['aircraftlistjson'] = 0;
133 133
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
134
-    	    } else if (preg_match('/opensky/i',$host)) {
134
+    	    } else if (preg_match('/opensky/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'opensky';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
139
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
139
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
140 140
         	//$formats[$id] = 'radarvirtueljson';
141 141
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 142
         	//$last_exec['radarvirtueljson'] = 0;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 146
         	    exit(0);
147 147
         	}
148
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
148
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
149 149
         	//$formats[$id] = 'planeupdatefaa';
150 150
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 151
         	//$last_exec['planeupdatefaa'] = 0;
@@ -154,26 +154,26 @@  discard block
 block discarded – undo
154 154
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 155
         	    exit(0);
156 156
         	}
157
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
157
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
158 158
         	//$formats[$id] = 'phpvmacars';
159 159
         	$globalSources[$id]['format'] = 'phpvmacars';
160 160
         	//$last_exec['phpvmacars'] = 0;
161 161
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
162
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
162
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
163 163
         	//$formats[$id] = 'phpvmacars';
164 164
         	$globalSources[$id]['format'] = 'vam';
165 165
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
166
-            } else if (preg_match('/whazzup/i',$host)) {
166
+            } else if (preg_match('/whazzup/i', $host)) {
167 167
         	//$formats[$id] = 'whazzup';
168 168
         	$globalSources[$id]['format'] = 'whazzup';
169 169
         	//$last_exec['whazzup'] = 0;
170 170
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
171
-            } else if (preg_match('/recentpireps/i',$host)) {
171
+            } else if (preg_match('/recentpireps/i', $host)) {
172 172
         	//$formats[$id] = 'pirepsjson';
173 173
         	$globalSources[$id]['format'] = 'pirepsjson';
174 174
         	//$last_exec['pirepsjson'] = 0;
175 175
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
176
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
176
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
177 177
         	//$formats[$id] = 'fr24json';
178 178
         	$globalSources[$id]['format'] = 'fr24json';
179 179
         	//$last_exec['fr24json'] = 0;
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
         	    exit(0);
184 184
         	}
185 185
             //} else if (preg_match('/10001/',$host)) {
186
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
186
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 187
         	//$formats[$id] = 'tsv';
188 188
         	$globalSources[$id]['format'] = 'tsv';
189 189
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
190 190
             }
191
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
191
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
192 192
         	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
193
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194
-	    $hostport = explode(':',$host);
193
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
194
+	    $hostport = explode(':', $host);
195 195
 	    if (isset($hostport[1])) {
196 196
 		$port = $hostport[1];
197 197
 		$hostn = $hostport[0];
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 		$hostn = $globalSources[$id]['host'];
201 201
 	    }
202 202
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
203
-        	$s = create_socket($hostn,$port, $errno, $errstr);
203
+        	$s = create_socket($hostn, $port, $errno, $errstr);
204 204
     	    } else {
205
-        	$s = create_socket_udp($hostn,$port, $errno, $errstr);
205
+        	$s = create_socket_udp($hostn, $port, $errno, $errstr);
206 206
 	    }
207 207
 	    if ($s) {
208 208
     	        $sockets[$id] = $s;
209 209
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
210
-		    if (preg_match('/aprs/',$hostn)) {
210
+		    if (preg_match('/aprs/', $hostn)) {
211 211
 			//$formats[$id] = 'aprs';
212 212
 			$globalSources[$id]['format'] = 'aprs';
213 213
 			//$aprs_connect = 0;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249 249
 else $timeout = 20;
250 250
 $errno = '';
251
-$errstr='';
251
+$errstr = '';
252 252
 
253 253
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
254 254
 /* Initiate connections to all the hosts simultaneously */
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 
278 278
 if ($use_aprs) {
279 279
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
280
-	$APRS=new APRS();
280
+	$APRS = new APRS();
281 281
 	$aprs_connect = 0;
282 282
 	$aprs_keep = 120;
283 283
 	$aprs_last_tx = time();
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	else $aprs_ssid = 'FAM';
289 289
 	//else $aprs_ssid = 'PerlEx';
290 290
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
291
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292 292
 	if ($aprs_full) $aprs_filter = '';
293 293
 	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294 294
 	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
@@ -299,12 +299,12 @@  discard block
 block discarded – undo
299 299
 sleep(1);
300 300
 if ($globalDebug) echo "SCAN MODE \n\n";
301 301
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
302
-$endtime = time()+$globalCronEnd;
302
+$endtime = time() + $globalCronEnd;
303 303
 $i = 1;
304 304
 $tt = array();
305 305
 // Delete all ATC
306 306
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
307
-	$ATC=new ATC($Connection->db);
307
+	$ATC = new ATC($Connection->db);
308 308
 }
309 309
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
310 310
 	$ATC->deleteAll();
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 314
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
315
+    if (!$globalDaemon) $i = $endtime - time();
316 316
     // Delete old ATC
317 317
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318 318
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 	if ($max != $globalMinFetch) {
328 328
 	    if ($globalDebug) echo 'Sleeping...'."\n";
329
-	    sleep($globalMinFetch-$max+2);
329
+	    sleep($globalMinFetch - $max + 2);
330 330
 	}
331 331
     }
332 332
 
@@ -337,8 +337,8 @@  discard block
 block discarded – undo
337 337
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 338
 	    //$buffer = $Common->getData($hosts[$id]);
339 339
 	    $buffer = $Common->getData($value['host']);
340
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
341
-	    $buffer = explode('\n',$buffer);
340
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
341
+	    $buffer = explode('\n', $buffer);
342 342
 	    foreach ($buffer as $line) {
343 343
     		if ($line != '') {
344 344
     		    $line = explode(',', $line);
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $value[' last_exec'] > $globalMinFetch))) {
368 368
 	    //$buffer = $Common->getData($hosts[$id]);
369 369
 	    $buffer = $Common->getData($value['host']);
370
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
371
-	    $buffer = explode('\n',$buffer);
370
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
371
+	    $buffer = explode('\n', $buffer);
372 372
 	    foreach ($buffer as $line) {
373 373
     		if ($line != '') {
374 374
     		    $line = explode(':', $line);
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$data['id'] = $line[1].'-'.$line[0];
378 378
 			$data['pilot_id'] = $line[1];
379 379
 			$data['pilot_name'] = $line[2];
380
-			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
380
+			$data['hex'] = str_pad(dechex($line[1]), 6, '000000', STR_PAD_LEFT);
381 381
 			$data['ident'] = $line[0]; // ident
382 382
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
383 383
 			$data['speed'] = $line[8]; // speed
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394 394
 			if (isset($line[37])) $data['last_update'] = $line[37];
395 395
 		        $data['departure_airport_icao'] = $line[11];
396
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
396
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
397 397
 		        $data['arrival_airport_icao'] = $line[13];
398 398
 			$data['frequency'] = $line[4];
399 399
 			$data['type'] = $line[18];
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
     			$data['id_source'] = $id_source;
403 403
 	    		//$data['arrival_airport_time'] = ;
404 404
 	    		if ($line[9] != '') {
405
-	    		    $aircraft_data = explode('/',$line[9]);
405
+	    		    $aircraft_data = explode('/', $line[9]);
406 406
 	    		    if (isset($aircraft_data[1])) {
407 407
 	    			$data['aircraft_icao'] = $aircraft_data[1];
408 408
 	    		    }
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
     			if ($line[3] == 'PILOT') $SI->add($data);
417 417
 			elseif ($line[3] == 'ATC') {
418 418
 				//print_r($data);
419
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421
-				$typec = substr($data['ident'],-3);
419
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
420
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
421
+				$typec = substr($data['ident'], -3);
422 422
 				if ($typec == 'APP') $data['type'] = 'Approach';
423 423
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424 424
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430 430
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
431 431
 				
432
-				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']);
432
+				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']);
433 433
 			}
434 434
     			unset($data);
435 435
     		    }
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
     	    $last_exec[$id]['last'] = time();
441 441
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
442 442
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
443
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
443
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
444 444
 	    if ($buffer != '') {
445
-	    $all_data = json_decode($buffer,true);
445
+	    $all_data = json_decode($buffer, true);
446 446
 	    if (isset($all_data['acList'])) {
447 447
 		foreach ($all_data['acList'] as $line) {
448 448
 		    $data = array();
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
497 497
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
498 498
 	    $buffer = $Common->getData($value['host']);
499
-	    $all_data = json_decode($buffer,true);
499
+	    $all_data = json_decode($buffer, true);
500 500
 	    if (isset($all_data['planes'])) {
501 501
 		foreach ($all_data['planes'] as $key => $line) {
502 502
 		    $data = array();
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 		    $data['emergency'] = ''; // emergency
513 513
 		    $data['registration'] = $line[2];
514 514
 		    $data['aircraft_icao'] = $line[0];
515
-		    $deparr = explode('-',$line[1]);
515
+		    $deparr = explode('-', $line[1]);
516 516
 		    if (count($deparr) == 2) {
517 517
 			$data['departure_airport_icao'] = $deparr[0];
518 518
 			$data['arrival_airport_icao'] = $deparr[1];
519 519
 		    }
520
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
520
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
521 521
 	    	    $data['format_source'] = 'planeupdatefaa';
522 522
     		    $data['id_source'] = $id_source;
523 523
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     	    $last_exec[$id]['last'] = time();
530 530
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
531 531
 	    $buffer = $Common->getData($value['host']);
532
-	    $all_data = json_decode($buffer,true);
532
+	    $all_data = json_decode($buffer, true);
533 533
 	    if (isset($all_data['states'])) {
534 534
 		foreach ($all_data['states'] as $key => $line) {
535 535
 		    $data = array();
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		    //$data['emergency'] = ''; // emergency
546 546
 		    //$data['registration'] = $line[2];
547 547
 		    //$data['aircraft_icao'] = $line[0];
548
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
548
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
549 549
 	    	    $data['format_source'] = 'opensky';
550 550
     		    $data['id_source'] = $id_source;
551 551
 		    $SI->add($data);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
559 559
 	    //$buffer = $Common->getData($hosts[$id]);
560 560
 	    $buffer = $Common->getData($value['host']);
561
-	    $all_data = json_decode($buffer,true);
561
+	    $all_data = json_decode($buffer, true);
562 562
 	    foreach ($all_data as $key => $line) {
563 563
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
564 564
 		    $data = array();
@@ -589,11 +589,11 @@  discard block
 block discarded – undo
589 589
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
590 590
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
591 591
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
592
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
592
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
593 593
 	    //echo $buffer;
594
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
595
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
596
-	    $all_data = json_decode($buffer,true);
594
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
595
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
596
+	    $all_data = json_decode($buffer, true);
597 597
 	    if (json_last_error() != JSON_ERROR_NONE) {
598 598
 		die(json_last_error_msg());
599 599
 	    }
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 			//$data['departure_airport_iata'] = $line[11];
616 616
 			//$data['arrival_airport_iata'] = $line[12];
617 617
 	    		//$data['emergency'] = ''; // emergency
618
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
618
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
619 619
 	    		$data['format_source'] = 'radarvirtueljson';
620 620
     			$data['id_source'] = $id_source;
621 621
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -630,13 +630,13 @@  discard block
 block discarded – undo
630 630
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
631 631
 	    //$buffer = $Common->getData($hosts[$id]);
632 632
 	    $buffer = $Common->getData($value['host'].'?'.time());
633
-	    $all_data = json_decode(utf8_encode($buffer),true);
633
+	    $all_data = json_decode(utf8_encode($buffer), true);
634 634
 	    
635 635
 	    if (isset($all_data['pireps'])) {
636 636
 	        foreach ($all_data['pireps'] as $line) {
637 637
 		    $data = array();
638 638
 		    $data['id'] = $line['id'];
639
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
639
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
640 640
 		    $data['ident'] = $line['callsign']; // ident
641 641
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642 642
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 			$SI->add($data);
666 666
 		    //    print_r($data);
667 667
     		    } elseif ($line['icon'] == 'ct') {
668
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
669
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670
-			$typec = substr($data['ident'],-3);
668
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
669
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
670
+			$typec = substr($data['ident'], -3);
671 671
 			$data['type'] = '';
672 672
 			if ($typec == 'APP') $data['type'] = 'Approach';
673 673
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679 679
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680 680
 			else $data['type'] = 'Observer';
681
-			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
681
+			echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name']);
682 682
 		    }
683 683
 		    unset($data);
684 684
 		}
@@ -690,13 +690,13 @@  discard block
 block discarded – undo
690 690
 	    //$buffer = $Common->getData($hosts[$id]);
691 691
 	    if ($globalDebug) echo 'Get Data...'."\n";
692 692
 	    $buffer = $Common->getData($value['host']);
693
-	    $all_data = json_decode($buffer,true);
693
+	    $all_data = json_decode($buffer, true);
694 694
 	    if ($buffer != '' && is_array($all_data)) {
695 695
 		foreach ($all_data as $line) {
696 696
 	    	    $data = array();
697 697
 	    	    //$data['id'] = $line['id']; // id not usable
698 698
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
699
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
699
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
700 700
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701 701
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
702 702
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
720 720
 		    if (isset($line['aircraftname'])) {
721 721
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723
-	    		$aircraft_data = explode('-',$line['aircraftname']);
722
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
723
+	    		$aircraft_data = explode('-', $line['aircraftname']);
724 724
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725 725
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726 726
 	    		else {
727
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
727
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
728 728
 	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729 729
 	    		    else $data['aircraft_icao'] = $line['aircraftname'];
730 730
 	    		}
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 	    //$buffer = $Common->getData($hosts[$id]);
747 747
 	    if ($globalDebug) echo 'Get Data...'."\n";
748 748
 	    $buffer = $Common->getData($value['host']);
749
-	    $all_data = json_decode($buffer,true);
749
+	    $all_data = json_decode($buffer, true);
750 750
 	    if ($buffer != '' && is_array($all_data)) {
751 751
 		foreach ($all_data as $line) {
752 752
 	    	    $data = array();
753 753
 	    	    //$data['id'] = $line['id']; // id not usable
754 754
 	    	    $data['id'] = $line['flight_id'];
755
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
755
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
756 756
 	    	    $data['pilot_name'] = $line['pilot_name'];
757 757
 	    	    $data['pilot_id'] = $line['pilot_id'];
758 758
 	    	    $data['ident'] = $line['callsign']; // ident
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 		    //$value = $formats[$nb];
803 803
 		    $format = $globalSources[$nb]['format'];
804 804
         	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv') {
805
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
805
+        		$buffer = socket_read($r, 6000, PHP_NORMAL_READ);
806 806
         	    } else {
807
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
807
+	    	        $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
808 808
 	    	    }
809 809
         	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
810 810
         	    //echo $buffer."\n";
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
813 813
 		    $error = false;
814 814
 		    //$SI::del();
815
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
815
+		    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
816 816
 		    // SBS format is CSV format
817 817
 		    if ($buffer != '') {
818 818
 			$tt[$format] = 0;
@@ -831,10 +831,10 @@  discard block
 block discarded – undo
831 831
                         } elseif ($format == 'flightgearsp') {
832 832
                     	    //echo $buffer."\n";
833 833
                     	    if (strlen($buffer) > 5) {
834
-				$line = explode(',',$buffer);
834
+				$line = explode(',', $buffer);
835 835
 				$data = array();
836 836
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
837
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
837
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
838 838
 				$data['ident'] = $line[6];
839 839
 				$data['aircraft_name'] = $line[7];
840 840
 				$data['longitude'] = $line[1];
@@ -845,21 +845,21 @@  discard block
 block discarded – undo
845 845
 				$data['datetime'] = date('Y-m-d H:i:s');
846 846
 				$data['format_source'] = 'flightgearsp';
847 847
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
848
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
848
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
849 849
 			    }
850 850
                         } elseif ($format == 'acars') {
851 851
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
852 852
 			    $ACARS->add(trim($buffer));
853
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
853
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
854 854
 			    $ACARS->deleteLiveAcarsData();
855 855
 			} elseif ($format == 'flightgearmp') {
856
-			    if (substr($buffer,0,1) != '#') {
856
+			    if (substr($buffer, 0, 1) != '#') {
857 857
 				$data = array();
858 858
 				//echo $buffer."\n";
859
-				$line = explode(' ',$buffer);
859
+				$line = explode(' ', $buffer);
860 860
 				if (count($line) == 11) {
861
-				    $userserver = explode('@',$line[0]);
862
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
861
+				    $userserver = explode('@', $line[0]);
862
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
863 863
 				    $data['ident'] = $userserver[0];
864 864
 				    $data['registration'] = $userserver[0];
865 865
 				    $data['latitude'] = $line[4];
@@ -867,24 +867,24 @@  discard block
 block discarded – undo
867 867
 				    $data['altitude'] = $line[6];
868 868
 				    $data['datetime'] = date('Y-m-d H:i:s');
869 869
 				    $aircraft_type = $line[10];
870
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
871
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
870
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
871
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
872 872
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
873 873
 				}
874 874
 			    }
875 875
 			} elseif ($format == 'beast') {
876 876
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
877 877
 			    die;
878
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
878
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
879 879
 			    $line = explode("\t", $buffer);
880
-			    for($k = 0; $k < count($line); $k=$k+2) {
880
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
881 881
 				$key = $line[$k];
882
-			        $lined[$key] = $line[$k+1];
882
+			        $lined[$key] = $line[$k + 1];
883 883
 			    }
884 884
     			    if (count($lined) > 3) {
885 885
     				$data['hex'] = $lined['hexid'];
886 886
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887
-    				$data['datetime'] = date('Y-m-d H:i:s');;
887
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
888 888
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889 889
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890 890
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -902,24 +902,24 @@  discard block
 block discarded – undo
902 902
     			    } else $error = true;
903 903
 			} elseif ($format == 'aprs' && $use_aprs) {
904 904
 			    if ($aprs_connect == 0) {
905
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
905
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
906 906
 				$aprs_connect = 1;
907 907
 			    }
908
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
908
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
909 909
 				$aprs_last_tx = time();
910 910
 				$data_aprs = "# Keep alive";
911
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
911
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
912 912
 			    }
913 913
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
914
-			    $buffer = str_replace('APRS <- ','',$buffer);
915
-			    $buffer = str_replace('APRS -> ','',$buffer);
916
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
914
+			    $buffer = str_replace('APRS <- ', '', $buffer);
915
+			    $buffer = str_replace('APRS -> ', '', $buffer);
916
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
917 917
 				$line = $APRS->parse($buffer);
918 918
 				if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
919 919
 				    $data = array();
920 920
 				    //print_r($line);
921 921
 				    $data['hex'] = $line['address'];
922
-				    $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
922
+				    $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
923 923
 				    //$data['datetime'] = date('Y-m-d H:i:s');
924 924
 				    $data['ident'] = $line['ident'];
925 925
 				    $data['latitude'] = $line['latitude'];
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 				    $currentdate = date('Y-m-d H:i:s');
940 940
 				    $aprsdate = strtotime($data['datetime']);
941 941
 				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
942
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943 943
 				    else {
944 944
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945 945
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 				connect_all($sourceee);
1025 1025
 				$sourceee = array();
1026 1026
 				//connect_all($globalSources);
1027
-				$tt[$format]=0;
1027
+				$tt[$format] = 0;
1028 1028
 				break;
1029 1029
 			    }
1030 1030
 			}
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 		}
1033 1033
 	    } else {
1034 1034
 		$error = socket_strerror(socket_last_error());
1035
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1035
+		if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1036 1036
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037 1037
 			if (isset($globalDebug)) echo "Restarting...\n";
1038 1038
 			// Restart the script if possible
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 			    if ($globalDebug) echo "Shutdown all sockets...";
1041 1041
 			    
1042 1042
 			    foreach ($sockets as $sock) {
1043
-				@socket_shutdown($sock,2);
1043
+				@socket_shutdown($sock, 2);
1044 1044
 				@socket_close($sock);
1045 1045
 			    }
1046 1046
 			    
Please login to merge, or discard this patch.
Braces   +509 added lines, -176 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 
17
-if (!isset($globalDebug)) $globalDebug = FALSE;
17
+if (!isset($globalDebug)) {
18
+	$globalDebug = FALSE;
19
+}
18 20
 
19 21
 // Check if schema is at latest version
20 22
 $Connection = new Connection();
@@ -51,13 +53,22 @@  discard block
 block discarded – undo
51 53
     $globalSources = array();
52 54
     $globalSources[] = array('host' => $options['source']);
53 55
 }
54
-if (isset($options['server'])) $globalServer = TRUE;
55
-if (isset($options['idsource'])) $id_source = $options['idsource'];
56
-else $id_source = 1;
56
+if (isset($options['server'])) {
57
+	$globalServer = TRUE;
58
+}
59
+if (isset($options['idsource'])) {
60
+	$id_source = $options['idsource'];
61
+} else {
62
+	$id_source = 1;
63
+}
57 64
 if (isset($globalServer) && $globalServer) {
58
-    if ($globalDebug) echo "Using Server Mode\n";
65
+    if ($globalDebug) {
66
+    	echo "Using Server Mode\n";
67
+    }
59 68
     $SI=new SpotterServer();
60
-} else $SI=new SpotterImport($Connection->db);
69
+} else {
70
+	$SI=new SpotterImport($Connection->db);
71
+}
61 72
 //$APRS=new APRS($Connection->db);
62 73
 $SBS=new SBS();
63 74
 $ACARS=new ACARS($Connection->db);
@@ -75,7 +86,9 @@  discard block
 block discarded – undo
75 86
 }
76 87
 
77 88
 // let's try and connect
78
-if ($globalDebug) echo "Connecting...\n";
89
+if ($globalDebug) {
90
+	echo "Connecting...\n";
91
+}
79 92
 $use_aprs = false;
80 93
 $aprs_full = false;
81 94
 
@@ -83,7 +96,9 @@  discard block
 block discarded – undo
83 96
     $ip = gethostbyname($host);
84 97
     $s = socket_create(AF_INET, SOCK_STREAM, 0);
85 98
     $r = @socket_connect($s, $ip, $port);
86
-    if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n";
99
+    if (!socket_set_nonblock($s)) {
100
+    	echo "Unable to set nonblock on socket\n";
101
+    }
87 102
     if ($r || socket_last_error() == 114 || socket_last_error() == 115) {
88 103
         return $s;
89 104
     }
@@ -110,7 +125,9 @@  discard block
 block discarded – undo
110 125
 function connect_all($hosts) {
111 126
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
112 127
     global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
113
-    if ($globalDebug) echo 'Connect to all...'."\n";
128
+    if ($globalDebug) {
129
+    	echo 'Connect to all...'."\n";
130
+    }
114 131
     foreach ($hosts as $id => $value) {
115 132
 	$host = $value['host'];
116 133
 	$globalSources[$id]['last_exec'] = 0;
@@ -120,27 +137,37 @@  discard block
 block discarded – undo
120 137
         	//$formats[$id] = 'deltadbtxt';
121 138
         	$globalSources[$id]['format'] = 'deltadbtxt';
122 139
         	//$last_exec['deltadbtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
140
+        	if ($globalDebug) {
141
+        		echo "Connect to deltadb source (".$host.")...\n";
142
+        	}
124 143
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
125 144
         	//$formats[$id] = 'vatsimtxt';
126 145
         	$globalSources[$id]['format'] = 'vatsimtxt';
127 146
         	//$last_exec['vatsimtxt'] = 0;
128
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
147
+        	if ($globalDebug) {
148
+        		echo "Connect to vatsim source (".$host.")...\n";
149
+        	}
129 150
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
130 151
         	//$formats[$id] = 'aircraftlistjson';
131 152
         	$globalSources[$id]['format'] = 'aircraftlistjson';
132 153
         	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
154
+        	if ($globalDebug) {
155
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
156
+        	}
134 157
     	    } else if (preg_match('/opensky/i',$host)) {
135 158
         	//$formats[$id] = 'aircraftlistjson';
136 159
         	$globalSources[$id]['format'] = 'opensky';
137 160
         	//$last_exec['aircraftlistjson'] = 0;
138
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to opensky source (".$host.")...\n";
163
+        	}
139 164
     	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
140 165
         	//$formats[$id] = 'radarvirtueljson';
141 166
         	$globalSources[$id]['format'] = 'radarvirtueljson';
142 167
         	//$last_exec['radarvirtueljson'] = 0;
143
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
170
+        	}
144 171
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
145 172
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
146 173
         	    exit(0);
@@ -149,7 +176,9 @@  discard block
 block discarded – undo
149 176
         	//$formats[$id] = 'planeupdatefaa';
150 177
         	$globalSources[$id]['format'] = 'planeupdatefaa';
151 178
         	//$last_exec['planeupdatefaa'] = 0;
152
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
179
+        	if ($globalDebug) {
180
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
181
+        	}
153 182
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
154 183
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
155 184
         	    exit(0);
@@ -158,26 +187,36 @@  discard block
 block discarded – undo
158 187
         	//$formats[$id] = 'phpvmacars';
159 188
         	$globalSources[$id]['format'] = 'phpvmacars';
160 189
         	//$last_exec['phpvmacars'] = 0;
161
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
190
+        	if ($globalDebug) {
191
+        		echo "Connect to phpvmacars source (".$host.")...\n";
192
+        	}
162 193
             } else if (preg_match('/VAM-json.php$/i',$host)) {
163 194
         	//$formats[$id] = 'phpvmacars';
164 195
         	$globalSources[$id]['format'] = 'vam';
165
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
196
+        	if ($globalDebug) {
197
+        		echo "Connect to Vam source (".$host.")...\n";
198
+        	}
166 199
             } else if (preg_match('/whazzup/i',$host)) {
167 200
         	//$formats[$id] = 'whazzup';
168 201
         	$globalSources[$id]['format'] = 'whazzup';
169 202
         	//$last_exec['whazzup'] = 0;
170
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
203
+        	if ($globalDebug) {
204
+        		echo "Connect to whazzup source (".$host.")...\n";
205
+        	}
171 206
             } else if (preg_match('/recentpireps/i',$host)) {
172 207
         	//$formats[$id] = 'pirepsjson';
173 208
         	$globalSources[$id]['format'] = 'pirepsjson';
174 209
         	//$last_exec['pirepsjson'] = 0;
175
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
210
+        	if ($globalDebug) {
211
+        		echo "Connect to pirepsjson source (".$host.")...\n";
212
+        	}
176 213
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
177 214
         	//$formats[$id] = 'fr24json';
178 215
         	$globalSources[$id]['format'] = 'fr24json';
179 216
         	//$last_exec['fr24json'] = 0;
180
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
217
+        	if ($globalDebug) {
218
+        		echo "Connect to fr24 source (".$host.")...\n";
219
+        	}
181 220
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
182 221
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
183 222
         	    exit(0);
@@ -186,10 +225,14 @@  discard block
 block discarded – undo
186 225
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
187 226
         	//$formats[$id] = 'tsv';
188 227
         	$globalSources[$id]['format'] = 'tsv';
189
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
228
+        	if ($globalDebug) {
229
+        		echo "Connect to tsv source (".$host.")...\n";
230
+        	}
190 231
             }
191 232
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
192
-        	if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
233
+        	if ($globalDebug) {
234
+        		echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
235
+        	}
193 236
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
194 237
 	    $hostport = explode(':',$host);
195 238
 	    if (isset($hostport[1])) {
@@ -226,17 +269,25 @@  discard block
 block discarded – undo
226 269
         		//$formats[$id] = 'beast';
227 270
         		$globalSources[$id]['format'] = 'beast';
228 271
 		    //} else $formats[$id] = 'sbs';
229
-		    } else $globalSources[$id]['format'] = 'sbs';
272
+		    } else {
273
+		    	$globalSources[$id]['format'] = 'sbs';
274
+		    }
230 275
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
231 276
 		}
232
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
277
+		if ($globalDebug) {
278
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
279
+		}
233 280
             } else {
234
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
281
+		if ($globalDebug) {
282
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
283
+		}
235 284
     	    }
236 285
         }
237 286
     }
238 287
 }
239
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
288
+if (!isset($globalMinFetch)) {
289
+	$globalMinFetch = 15;
290
+}
240 291
 
241 292
 // Initialize all
242 293
 $status = array();
@@ -244,13 +295,19 @@  discard block
 block discarded – undo
244 295
 $formats = array();
245 296
 $last_exec = array();
246 297
 $time = time();
247
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
248
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
249
-else $timeout = 20;
298
+if (isset($globalSourcesTimeout)) {
299
+	$timeout = $globalSourcesTimeOut;
300
+} else if (isset($globalSBS1TimeOut)) {
301
+	$timeout = $globalSBS1TimeOut;
302
+} else {
303
+	$timeout = 20;
304
+}
250 305
 $errno = '';
251 306
 $errstr='';
252 307
 
253
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
308
+if (!isset($globalDaemon)) {
309
+	$globalDaemon = TRUE;
310
+}
254 311
 /* Initiate connections to all the hosts simultaneously */
255 312
 //connect_all($hosts);
256 313
 //connect_all($globalSources);
@@ -270,7 +327,9 @@  discard block
 block discarded – undo
270 327
     if (isset($source['format']) && $source['format'] == 'aprs') {
271 328
 	$aprs_connect = 0;
272 329
 	$use_aprs = true;
273
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
330
+	if (isset($source['port']) && $source['port'] == '10152') {
331
+		$aprs_full = true;
332
+	}
274 333
 	break;
275 334
     }
276 335
 }
@@ -281,24 +340,44 @@  discard block
 block discarded – undo
281 340
 	$aprs_connect = 0;
282 341
 	$aprs_keep = 120;
283 342
 	$aprs_last_tx = time();
284
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
285
-	else $aprs_version = $globalName.' using FlightAirMap';
343
+	if (isset($globalAPRSversion)) {
344
+		$aprs_version = $globalAPRSversion;
345
+	} else {
346
+		$aprs_version = $globalName.' using FlightAirMap';
347
+	}
286 348
 	//else $aprs_version = 'Perl Example App';
287
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
288
-	else $aprs_ssid = 'FAM';
349
+	if (isset($globalAPRSssid)) {
350
+		$aprs_ssid = $globalAPRSssid;
351
+	} else {
352
+		$aprs_ssid = 'FAM';
353
+	}
289 354
 	//else $aprs_ssid = 'PerlEx';
290
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
291
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
292
-	if ($aprs_full) $aprs_filter = '';
293
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
294
-	else $aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
295
-}
355
+	if (isset($globalAPRSfilter)) {
356
+		$aprs_filter = $globalAPRSfilter;
357
+	} else {
358
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
359
+	}
360
+	if ($aprs_full) {
361
+		$aprs_filter = '';
362
+	}
363
+	if ($aprs_filter != '') {
364
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version} filter {$aprs_filter}\n";
365
+	} else {
366
+		$aprs_login = "user {$aprs_ssid} appid {$aprs_version}\n";
367
+	}
368
+	}
296 369
 
297 370
 // connected - lets do some work
298
-if ($globalDebug) echo "Connected!\n";
371
+if ($globalDebug) {
372
+	echo "Connected!\n";
373
+}
299 374
 sleep(1);
300
-if ($globalDebug) echo "SCAN MODE \n\n";
301
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
375
+if ($globalDebug) {
376
+	echo "SCAN MODE \n\n";
377
+}
378
+if (!isset($globalCronEnd)) {
379
+	$globalCronEnd = 60;
380
+}
302 381
 $endtime = time()+$globalCronEnd;
303 382
 $i = 1;
304 383
 $tt = array();
@@ -312,20 +391,28 @@  discard block
 block discarded – undo
312 391
 
313 392
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
314 393
 while ($i > 0) {
315
-    if (!$globalDaemon) $i = $endtime-time();
394
+    if (!$globalDaemon) {
395
+    	$i = $endtime-time();
396
+    }
316 397
     // Delete old ATC
317 398
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
318
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
399
+	if ($globalDebug) {
400
+		echo 'Delete old ATC...'."\n";
401
+	}
319 402
         $ATC->deleteOldATC();
320 403
     }
321 404
     
322 405
     if (count($last_exec) > 0) {
323 406
 	$max = $globalMinFetch;
324 407
 	foreach ($last_exec as $last) {
325
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
408
+	    if ((time() - $last['last']) < $max) {
409
+	    	$max = time() - $last['last'];
410
+	    }
326 411
 	}
327 412
 	if ($max != $globalMinFetch) {
328
-	    if ($globalDebug) echo 'Sleeping...'."\n";
413
+	    if ($globalDebug) {
414
+	    	echo 'Sleeping...'."\n";
415
+	    }
329 416
 	    sleep($globalMinFetch-$max+2);
330 417
 	}
331 418
     }
@@ -333,7 +420,9 @@  discard block
 block discarded – undo
333 420
     
334 421
     //foreach ($formats as $id => $value) {
335 422
     foreach ($globalSources as $id => $value) {
336
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
423
+	if (!isset($last_exec[$id]['last'])) {
424
+		$last_exec[$id]['last'] = 0;
425
+	}
337 426
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
338 427
 	    //$buffer = $Common->getData($hosts[$id]);
339 428
 	    $buffer = $Common->getData($value['host']);
@@ -356,8 +445,12 @@  discard block
 block discarded – undo
356 445
 		    $data['datetime'] = date('Y-m-d H:i:s');
357 446
 		    $data['format_source'] = 'deltadbtxt';
358 447
     		    $data['id_source'] = $id_source;
359
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
360
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
448
+		    if (isset($value['name']) && $value['name'] != '') {
449
+		    	$data['source_name'] = $value['name'];
450
+		    }
451
+		    if (isset($value['sourcestats'])) {
452
+		    	$data['sourcestats'] = $value['sourcestats'];
453
+		    }
361 454
     		    $SI->add($data);
362 455
 		    unset($data);
363 456
     		}
@@ -379,10 +472,19 @@  discard block
 block discarded – undo
379 472
 			$data['pilot_name'] = $line[2];
380 473
 			$data['hex'] = str_pad(dechex($line[1]),6,'000000',STR_PAD_LEFT);
381 474
 			$data['ident'] = $line[0]; // ident
382
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
475
+			if ($line[7] != '' && $line[7] != 0) {
476
+				$data['altitude'] = $line[7];
477
+			}
478
+			// altitude
383 479
 			$data['speed'] = $line[8]; // speed
384
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
385
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
480
+			if (isset($line[45])) {
481
+				$data['heading'] = $line[45];
482
+			}
483
+			// heading
484
+			elseif (isset($line[38])) {
485
+				$data['heading'] = $line[38];
486
+			}
487
+			// heading
386 488
 			$data['latitude'] = $line[5]; // lat
387 489
 	        	$data['longitude'] = $line[6]; // long
388 490
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -391,14 +493,18 @@  discard block
 block discarded – undo
391 493
 	        	$data['waypoints'] = $line[30];
392 494
 			$data['datetime'] = date('Y-m-d H:i:s');
393 495
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
394
-			if (isset($line[37])) $data['last_update'] = $line[37];
496
+			if (isset($line[37])) {
497
+				$data['last_update'] = $line[37];
498
+			}
395 499
 		        $data['departure_airport_icao'] = $line[11];
396 500
 		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
397 501
 		        $data['arrival_airport_icao'] = $line[13];
398 502
 			$data['frequency'] = $line[4];
399 503
 			$data['type'] = $line[18];
400 504
 			$data['range'] = $line[19];
401
-			if (isset($line[35])) $data['info'] = $line[35];
505
+			if (isset($line[35])) {
506
+				$data['info'] = $line[35];
507
+			}
402 508
     			$data['id_source'] = $id_source;
403 509
 	    		//$data['arrival_airport_time'] = ;
404 510
 	    		if ($line[9] != '') {
@@ -412,22 +518,35 @@  discard block
 block discarded – undo
412 518
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
413 519
 	    		*/
414 520
 	    		$data['format_source'] = $value['format'];
415
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
416
-    			if ($line[3] == 'PILOT') $SI->add($data);
417
-			elseif ($line[3] == 'ATC') {
521
+			if (isset($value['name']) && $value['name'] != '') {
522
+				$data['source_name'] = $value['name'];
523
+			}
524
+    			if ($line[3] == 'PILOT') {
525
+    				$SI->add($data);
526
+    			} elseif ($line[3] == 'ATC') {
418 527
 				//print_r($data);
419 528
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
420 529
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
421 530
 				$typec = substr($data['ident'],-3);
422
-				if ($typec == 'APP') $data['type'] = 'Approach';
423
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
424
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
425
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
426
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
427
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
428
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
429
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
430
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
531
+				if ($typec == 'APP') {
532
+					$data['type'] = 'Approach';
533
+				} elseif ($typec == 'TWR') {
534
+					$data['type'] = 'Tower';
535
+				} elseif ($typec == 'OBS') {
536
+					$data['type'] = 'Observer';
537
+				} elseif ($typec == 'GND') {
538
+					$data['type'] = 'Ground';
539
+				} elseif ($typec == 'DEL') {
540
+					$data['type'] = 'Delivery';
541
+				} elseif ($typec == 'DEP') {
542
+					$data['type'] = 'Departure';
543
+				} elseif ($typec == 'FSS') {
544
+					$data['type'] = 'Flight Service Station';
545
+				} elseif ($typec == 'CTR') {
546
+					$data['type'] = 'Control Radar or Centre';
547
+				} elseif ($data['type'] == '') {
548
+					$data['type'] = 'Observer';
549
+				}
431 550
 				
432 551
 				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']);
433 552
 			}
@@ -447,26 +566,55 @@  discard block
 block discarded – undo
447 566
 		foreach ($all_data['acList'] as $line) {
448 567
 		    $data = array();
449 568
 		    $data['hex'] = $line['Icao']; // hex
450
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
451
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
452
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
453
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
454
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
455
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
569
+		    if (isset($line['Call'])) {
570
+		    	$data['ident'] = $line['Call'];
571
+		    }
572
+		    // ident
573
+		    if (isset($line['Alt'])) {
574
+		    	$data['altitude'] = $line['Alt'];
575
+		    }
576
+		    // altitude
577
+		    if (isset($line['Spd'])) {
578
+		    	$data['speed'] = $line['Spd'];
579
+		    }
580
+		    // speed
581
+		    if (isset($line['Trak'])) {
582
+		    	$data['heading'] = $line['Trak'];
583
+		    }
584
+		    // heading
585
+		    if (isset($line['Lat'])) {
586
+		    	$data['latitude'] = $line['Lat'];
587
+		    }
588
+		    // lat
589
+		    if (isset($line['Long'])) {
590
+		    	$data['longitude'] = $line['Long'];
591
+		    }
592
+		    // long
456 593
 		    //$data['verticalrate'] = $line['']; // verticale rate
457
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
594
+		    if (isset($line['Sqk'])) {
595
+		    	$data['squawk'] = $line['Sqk'];
596
+		    }
597
+		    // squawk
458 598
 		    $data['emergency'] = ''; // emergency
459
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
599
+		    if (isset($line['Reg'])) {
600
+		    	$data['registration'] = $line['Reg'];
601
+		    }
460 602
 		    /*
461 603
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
462 604
 		    else $data['datetime'] = date('Y-m-d H:i:s');
463 605
 		    */
464 606
 		    $data['datetime'] = date('Y-m-d H:i:s');
465
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
607
+		    if (isset($line['Type'])) {
608
+		    	$data['aircraft_icao'] = $line['Type'];
609
+		    }
466 610
 	    	    $data['format_source'] = 'aircraftlistjson';
467 611
 		    $data['id_source'] = $id_source;
468
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
469
-		    if (isset($data['datetime'])) $SI->add($data);
612
+		    if (isset($value['name']) && $value['name'] != '') {
613
+		    	$data['source_name'] = $value['name'];
614
+		    }
615
+		    if (isset($data['datetime'])) {
616
+		    	$SI->add($data);
617
+		    }
470 618
 		    unset($data);
471 619
 		}
472 620
 	    } else {
@@ -485,7 +633,9 @@  discard block
 block discarded – undo
485 633
 		    $data['datetime'] = date('Y-m-d H:i:s');
486 634
 	    	    $data['format_source'] = 'aircraftlistjson';
487 635
     		    $data['id_source'] = $id_source;
488
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
636
+		    if (isset($value['name']) && $value['name'] != '') {
637
+		    	$data['source_name'] = $value['name'];
638
+		    }
489 639
 		    $SI->add($data);
490 640
 		    unset($data);
491 641
 		}
@@ -520,7 +670,9 @@  discard block
 block discarded – undo
520 670
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
521 671
 	    	    $data['format_source'] = 'planeupdatefaa';
522 672
     		    $data['id_source'] = $id_source;
523
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
673
+		    if (isset($value['name']) && $value['name'] != '') {
674
+		    	$data['source_name'] = $value['name'];
675
+		    }
524 676
 		    $SI->add($data);
525 677
 		    unset($data);
526 678
 		}
@@ -579,7 +731,9 @@  discard block
 block discarded – undo
579 731
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
580 732
 	    	    $data['format_source'] = 'fr24json';
581 733
     		    $data['id_source'] = $id_source;
582
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
734
+		    if (isset($value['name']) && $value['name'] != '') {
735
+		    	$data['source_name'] = $value['name'];
736
+		    }
583 737
 		    $SI->add($data);
584 738
 		    unset($data);
585 739
 		}
@@ -602,23 +756,39 @@  discard block
 block discarded – undo
602 756
 		    if (isset($line['inf'])) {
603 757
 			$data = array();
604 758
 			$data['hex'] = $line['inf']['ia'];
605
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
759
+			if (isset($line['inf']['cs'])) {
760
+				$data['ident'] = $line['inf']['cs'];
761
+			}
762
+			//$line[13]
606 763
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
607
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
608
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
764
+	    		if (isset($line['inf']['gs'])) {
765
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
766
+	    		}
767
+	    		// speed
768
+	    		if (isset($line['inf']['tr'])) {
769
+	    			$data['heading'] = $line['inf']['tr'];
770
+	    		}
771
+	    		// heading
609 772
 	    		$data['latitude'] = $line['pt'][0]; // lat
610 773
 	    		$data['longitude'] = $line['pt'][1]; // long
611 774
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
612
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
775
+	    		if (isset($line['inf']['sq'])) {
776
+	    			$data['squawk'] = $line['inf']['sq'];
777
+	    		}
778
+	    		// squawk
613 779
 	    		//$data['aircraft_icao'] = $line[8];
614
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
780
+	    		if (isset($line['inf']['rc'])) {
781
+	    			$data['registration'] = $line['inf']['rc'];
782
+	    		}
615 783
 			//$data['departure_airport_iata'] = $line[11];
616 784
 			//$data['arrival_airport_iata'] = $line[12];
617 785
 	    		//$data['emergency'] = ''; // emergency
618 786
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
619 787
 	    		$data['format_source'] = 'radarvirtueljson';
620 788
     			$data['id_source'] = $id_source;
621
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
789
+			if (isset($value['name']) && $value['name'] != '') {
790
+				$data['source_name'] = $value['name'];
791
+			}
622 792
 			$SI->add($data);
623 793
 			unset($data);
624 794
 		    }
@@ -638,29 +808,62 @@  discard block
 block discarded – undo
638 808
 		    $data['id'] = $line['id'];
639 809
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
640 810
 		    $data['ident'] = $line['callsign']; // ident
641
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
642
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
643
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
644
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
645
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
646
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
811
+		    if (isset($line['pilotid'])) {
812
+		    	$data['pilot_id'] = $line['pilotid'];
813
+		    }
814
+		    // pilot id
815
+		    if (isset($line['name'])) {
816
+		    	$data['pilot_name'] = $line['name'];
817
+		    }
818
+		    // pilot name
819
+		    if (isset($line['alt'])) {
820
+		    	$data['altitude'] = $line['alt'];
821
+		    }
822
+		    // altitude
823
+		    if (isset($line['gs'])) {
824
+		    	$data['speed'] = $line['gs'];
825
+		    }
826
+		    // speed
827
+		    if (isset($line['heading'])) {
828
+		    	$data['heading'] = $line['heading'];
829
+		    }
830
+		    // heading
831
+		    if (isset($line['route'])) {
832
+		    	$data['waypoints'] = $line['route'];
833
+		    }
834
+		    // route
647 835
 		    $data['latitude'] = $line['lat']; // lat
648 836
 		    $data['longitude'] = $line['lon']; // long
649 837
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
650 838
 		    //$data['squawk'] = $line['squawk']; // squawk
651 839
 		    //$data['emergency'] = ''; // emergency
652
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
653
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
654
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
840
+		    if (isset($line['depicao'])) {
841
+		    	$data['departure_airport_icao'] = $line['depicao'];
842
+		    }
843
+		    if (isset($line['deptime'])) {
844
+		    	$data['departure_airport_time'] = $line['deptime'];
845
+		    }
846
+		    if (isset($line['arricao'])) {
847
+		    	$data['arrival_airport_icao'] = $line['arricao'];
848
+		    }
655 849
 		    //$data['arrival_airport_time'] = $line['arrtime'];
656
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
657
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
658
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
659
-		    else $data['info'] = '';
850
+		    if (isset($line['aircraft'])) {
851
+		    	$data['aircraft_icao'] = $line['aircraft'];
852
+		    }
853
+		    if (isset($line['transponder'])) {
854
+		    	$data['squawk'] = $line['transponder'];
855
+		    }
856
+		    if (isset($line['atis'])) {
857
+		    	$data['info'] = $line['atis'];
858
+		    } else {
859
+		    	$data['info'] = '';
860
+		    }
660 861
 		    $data['format_source'] = 'pireps';
661 862
     		    $data['id_source'] = $id_source;
662 863
 		    $data['datetime'] = date('Y-m-d H:i:s');
663
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
864
+		    if (isset($value['name']) && $value['name'] != '') {
865
+		    	$data['source_name'] = $value['name'];
866
+		    }
664 867
 		    if ($line['icon'] == 'plane') {
665 868
 			$SI->add($data);
666 869
 		    //    print_r($data);
@@ -669,15 +872,25 @@  discard block
 block discarded – undo
669 872
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
670 873
 			$typec = substr($data['ident'],-3);
671 874
 			$data['type'] = '';
672
-			if ($typec == 'APP') $data['type'] = 'Approach';
673
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
674
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
675
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
676
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
677
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
678
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
679
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
680
-			else $data['type'] = 'Observer';
875
+			if ($typec == 'APP') {
876
+				$data['type'] = 'Approach';
877
+			} elseif ($typec == 'TWR') {
878
+				$data['type'] = 'Tower';
879
+			} elseif ($typec == 'OBS') {
880
+				$data['type'] = 'Observer';
881
+			} elseif ($typec == 'GND') {
882
+				$data['type'] = 'Ground';
883
+			} elseif ($typec == 'DEL') {
884
+				$data['type'] = 'Delivery';
885
+			} elseif ($typec == 'DEP') {
886
+				$data['type'] = 'Departure';
887
+			} elseif ($typec == 'FSS') {
888
+				$data['type'] = 'Flight Service Station';
889
+			} elseif ($typec == 'CTR') {
890
+				$data['type'] = 'Control Radar or Centre';
891
+			} else {
892
+				$data['type'] = 'Observer';
893
+			}
681 894
 			echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name']);
682 895
 		    }
683 896
 		    unset($data);
@@ -688,17 +901,25 @@  discard block
 block discarded – undo
688 901
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
689 902
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
690 903
 	    //$buffer = $Common->getData($hosts[$id]);
691
-	    if ($globalDebug) echo 'Get Data...'."\n";
904
+	    if ($globalDebug) {
905
+	    	echo 'Get Data...'."\n";
906
+	    }
692 907
 	    $buffer = $Common->getData($value['host']);
693 908
 	    $all_data = json_decode($buffer,true);
694 909
 	    if ($buffer != '' && is_array($all_data)) {
695 910
 		foreach ($all_data as $line) {
696 911
 	    	    $data = array();
697 912
 	    	    //$data['id'] = $line['id']; // id not usable
698
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
913
+	    	    if (isset($line['pilotid'])) {
914
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
915
+	    	    }
699 916
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
700
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
701
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
917
+	    	    if (isset($line['pilotname'])) {
918
+	    	    	$data['pilot_name'] = $line['pilotname'];
919
+	    	    }
920
+	    	    if (isset($line['pilotid'])) {
921
+	    	    	$data['pilot_id'] = $line['pilotid'];
922
+	    	    }
702 923
 	    	    $data['ident'] = $line['flightnum']; // ident
703 924
 	    	    $data['altitude'] = $line['alt']; // altitude
704 925
 	    	    $data['speed'] = $line['gs']; // speed
@@ -716,27 +937,41 @@  discard block
 block discarded – undo
716 937
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
717 938
     		    $data['arrival_airport_time'] = $line['arrtime'];
718 939
     		    $data['registration'] = $line['aircraft'];
719
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
940
+		    if (isset($line['route'])) {
941
+		    	$data['waypoints'] = $line['route'];
942
+		    }
943
+		    // route
720 944
 		    if (isset($line['aircraftname'])) {
721 945
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
722 946
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
723 947
 	    		$aircraft_data = explode('-',$line['aircraftname']);
724
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
725
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
726
-	    		else {
948
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) {
949
+	    			$data['aircraft_icao'] = $aircraft_data[0];
950
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) {
951
+	    			$data['aircraft_icao'] = $aircraft_data[1];
952
+	    		} else {
727 953
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
728
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
729
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
954
+	    		    if (isset($aircraft_data[1])) {
955
+	    		    	$data['aircraft_icao'] = $aircraft_data[1];
956
+	    		    } else {
957
+	    		    	$data['aircraft_icao'] = $line['aircraftname'];
958
+	    		    }
730 959
 	    		}
731 960
 	    	    }
732
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
961
+    		    if (isset($line['route'])) {
962
+    		    	$data['waypoints'] = $line['route'];
963
+    		    }
733 964
     		    $data['id_source'] = $id_source;
734 965
 	    	    $data['format_source'] = 'phpvmacars';
735
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
966
+		    if (isset($value['name']) && $value['name'] != '') {
967
+		    	$data['source_name'] = $value['name'];
968
+		    }
736 969
 		    $SI->add($data);
737 970
 		    unset($data);
738 971
 		}
739
-		if ($globalDebug) echo 'No more data...'."\n";
972
+		if ($globalDebug) {
973
+			echo 'No more data...'."\n";
974
+		}
740 975
 		unset($buffer);
741 976
 		unset($all_data);
742 977
 	    }
@@ -744,7 +979,9 @@  discard block
 block discarded – undo
744 979
     	    $last_exec[$id]['last'] = time();
745 980
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
746 981
 	    //$buffer = $Common->getData($hosts[$id]);
747
-	    if ($globalDebug) echo 'Get Data...'."\n";
982
+	    if ($globalDebug) {
983
+	    	echo 'Get Data...'."\n";
984
+	    }
748 985
 	    $buffer = $Common->getData($value['host']);
749 986
 	    $all_data = json_decode($buffer,true);
750 987
 	    if ($buffer != '' && is_array($all_data)) {
@@ -772,15 +1009,22 @@  discard block
 block discarded – undo
772 1009
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
773 1010
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
774 1011
     		    //$data['registration'] = $line['aircraft'];
775
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1012
+		    if (isset($line['route'])) {
1013
+		    	$data['waypoints'] = $line['route'];
1014
+		    }
1015
+		    // route
776 1016
 	    	    $data['aircraft_icao'] = $line['plane_type'];
777 1017
     		    $data['id_source'] = $id_source;
778 1018
 	    	    $data['format_source'] = 'vam';
779
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1019
+		    if (isset($value['name']) && $value['name'] != '') {
1020
+		    	$data['source_name'] = $value['name'];
1021
+		    }
780 1022
 		    $SI->add($data);
781 1023
 		    unset($data);
782 1024
 		}
783
-		if ($globalDebug) echo 'No more data...'."\n";
1025
+		if ($globalDebug) {
1026
+			echo 'No more data...'."\n";
1027
+		}
784 1028
 		unset($buffer);
785 1029
 		unset($all_data);
786 1030
 	    }
@@ -788,7 +1032,9 @@  discard block
 block discarded – undo
788 1032
     	    $last_exec[$id]['last'] = time();
789 1033
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
790 1034
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars') {
791
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1035
+	    if (function_exists('pcntl_fork')) {
1036
+	    	pcntl_signal_dispatch();
1037
+	    }
792 1038
     	    //$last_exec[$id]['last'] = time();
793 1039
 
794 1040
 	    //$read = array( $sockets[$id] );
@@ -796,7 +1042,9 @@  discard block
 block discarded – undo
796 1042
 	    $write = NULL;
797 1043
 	    $e = NULL;
798 1044
 	    $n = socket_select($read, $write, $e, $timeout);
799
-	    if ($e != NULL) var_dump($e);
1045
+	    if ($e != NULL) {
1046
+	    	var_dump($e);
1047
+	    }
800 1048
 	    if ($n > 0) {
801 1049
 		foreach ($read as $nb => $r) {
802 1050
 		    //$value = $formats[$nb];
@@ -824,9 +1072,15 @@  discard block
 block discarded – undo
824 1072
 			    if (is_array($data)) {
825 1073
 				$data['datetime'] = date('Y-m-d H:i:s');
826 1074
 				$data['format_source'] = 'raw';
827
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
828
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
829
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1075
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1076
+					$data['source_name'] = $globalSources[$nb]['name'];
1077
+				}
1078
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1079
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1080
+    				}
1081
+                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1082
+                                	$SI->add($data);
1083
+                                }
830 1084
                             }
831 1085
                         } elseif ($format == 'flightgearsp') {
832 1086
                     	    //echo $buffer."\n";
@@ -844,11 +1098,15 @@  discard block
 block discarded – undo
844 1098
 				$data['speed'] = round($line[5]*1.94384);
845 1099
 				$data['datetime'] = date('Y-m-d H:i:s');
846 1100
 				$data['format_source'] = 'flightgearsp';
847
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1101
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1102
+					$SI->add($data);
1103
+				}
848 1104
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
849 1105
 			    }
850 1106
                         } elseif ($format == 'acars') {
851
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1107
+                    	    if ($globalDebug) {
1108
+                    	    	echo 'ACARS : '.$buffer."\n";
1109
+                    	    }
852 1110
 			    $ACARS->add(trim($buffer));
853 1111
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
854 1112
 			    $ACARS->deleteLiveAcarsData();
@@ -869,7 +1127,9 @@  discard block
 block discarded – undo
869 1127
 				    $aircraft_type = $line[10];
870 1128
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
871 1129
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
872
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1130
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1131
+				    	$SI->add($data);
1132
+				    }
873 1133
 				}
874 1134
 			    }
875 1135
 			} elseif ($format == 'beast') {
@@ -885,21 +1145,43 @@  discard block
 block discarded – undo
885 1145
     				$data['hex'] = $lined['hexid'];
886 1146
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
887 1147
     				$data['datetime'] = date('Y-m-d H:i:s');;
888
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
889
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
890
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
891
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
892
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
893
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
894
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1148
+    				if (isset($lined['ident'])) {
1149
+    					$data['ident'] = $lined['ident'];
1150
+    				}
1151
+    				if (isset($lined['lat'])) {
1152
+    					$data['latitude'] = $lined['lat'];
1153
+    				}
1154
+    				if (isset($lined['lon'])) {
1155
+    					$data['longitude'] = $lined['lon'];
1156
+    				}
1157
+    				if (isset($lined['speed'])) {
1158
+    					$data['speed'] = $lined['speed'];
1159
+    				}
1160
+    				if (isset($lined['squawk'])) {
1161
+    					$data['squawk'] = $lined['squawk'];
1162
+    				}
1163
+    				if (isset($lined['alt'])) {
1164
+    					$data['altitude'] = $lined['alt'];
1165
+    				}
1166
+    				if (isset($lined['heading'])) {
1167
+    					$data['heading'] = $lined['heading'];
1168
+    				}
895 1169
     				$data['id_source'] = $id_source;
896 1170
     				$data['format_source'] = 'tsv';
897
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
898
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
899
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1172
+    					$data['source_name'] = $globalSources[$nb]['name'];
1173
+    				}
1174
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1175
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1176
+    				}
1177
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1178
+    					$SI->add($data);
1179
+    				}
900 1180
     				unset($lined);
901 1181
     				unset($data);
902
-    			    } else $error = true;
1182
+    			    } else {
1183
+    			    	$error = true;
1184
+    			    }
903 1185
 			} elseif ($format == 'aprs' && $use_aprs) {
904 1186
 			    if ($aprs_connect == 0) {
905 1187
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -925,29 +1207,44 @@  discard block
 block discarded – undo
925 1207
 				    $data['latitude'] = $line['latitude'];
926 1208
 				    $data['longitude'] = $line['longitude'];
927 1209
 				    //$data['verticalrate'] = $line[16];
928
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
929
-				    else $data['speed'] = 0;
1210
+				    if (isset($line['speed'])) {
1211
+				    	$data['speed'] = $line['speed'];
1212
+				    } else {
1213
+				    	$data['speed'] = 0;
1214
+				    }
930 1215
 				    $data['altitude'] = $line['altitude'];
931
-				    if (isset($line['course'])) $data['heading'] = $line['course'];
1216
+				    if (isset($line['course'])) {
1217
+				    	$data['heading'] = $line['course'];
1218
+				    }
932 1219
 				    //else $data['heading'] = 0;
933 1220
 				    $data['aircraft_type'] = $line['stealth'];
934
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1221
+				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) {
1222
+				    	$data['noarchive'] = true;
1223
+				    }
935 1224
     				    $data['id_source'] = $id_source;
936 1225
 				    $data['format_source'] = 'aprs';
937 1226
 				    $data['source_name'] = $line['source'];
938
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1227
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1228
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1229
+    				    }
939 1230
 				    $currentdate = date('Y-m-d H:i:s');
940 1231
 				    $aprsdate = strtotime($data['datetime']);
941 1232
 				    // Accept data if time <= system time + 20s
942
-				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) $send = $SI->add($data);
943
-				    else {
944
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
945
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1233
+				    if ($line['stealth'] == 0 && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1234
+				    	$send = $SI->add($data);
1235
+				    } else {
1236
+					if ($line['stealth'] != 0) {
1237
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1238
+					} else {
1239
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1240
+					}
946 1241
 				    }
947 1242
 				    unset($data);
948 1243
 				} 
949 1244
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
950
-				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1245
+				elseif ($line == true && $globalDebug) {
1246
+					echo '!! Failed : '.$buffer."!!\n";
1247
+				}
951 1248
 			    }
952 1249
 			} else {
953 1250
 			    $line = explode(',', $buffer);
@@ -975,25 +1272,42 @@  discard block
 block discarded – undo
975 1272
     				$data['ground'] = $line[21];
976 1273
     				$data['emergency'] = $line[19];
977 1274
     				$data['format_source'] = 'sbs';
978
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
979
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1275
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1276
+					$data['source_name'] = $globalSources[$nb]['name'];
1277
+				}
1278
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1279
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1280
+    				}
980 1281
     				$data['id_source'] = $id_source;
981
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
982
-    				else $error = true;
1282
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1283
+    					$send = $SI->add($data);
1284
+    				} else {
1285
+    					$error = true;
1286
+    				}
983 1287
     				unset($data);
984
-    			    } else $error = true;
1288
+    			    } else {
1289
+    			    	$error = true;
1290
+    			    }
985 1291
 			    if ($error) {
986 1292
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
987
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1293
+					if ($globalDebug) {
1294
+						echo "Not a message. Ignoring... \n";
1295
+					}
988 1296
 				} else {
989
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1297
+					if ($globalDebug) {
1298
+						echo "Wrong line format. Ignoring... \n";
1299
+					}
990 1300
 					if ($globalDebug) {
991 1301
 						echo $buffer;
992 1302
 						print_r($line);
993 1303
 					}
994 1304
 					//socket_close($r);
995
-					if ($globalDebug) echo "Reconnect after an error...\n";
996
-					if ($format == 'aprs') $aprs_connect = 0;
1305
+					if ($globalDebug) {
1306
+						echo "Reconnect after an error...\n";
1307
+					}
1308
+					if ($format == 'aprs') {
1309
+						$aprs_connect = 0;
1310
+					}
997 1311
 					$sourceer[$nb] = $globalSources[$nb];
998 1312
 					connect_all($sourceer);
999 1313
 					$sourceer = array();
@@ -1001,10 +1315,14 @@  discard block
 block discarded – undo
1001 1315
 			    }
1002 1316
 			}
1003 1317
 			// Sleep for xxx microseconds
1004
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1318
+			if (isset($globalSBSSleep)) {
1319
+				usleep($globalSBSSleep);
1320
+			}
1005 1321
 		    } else {
1006 1322
 			if ($format == 'flightgearmp') {
1007
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1323
+			    	if ($globalDebug) {
1324
+			    		echo "Reconnect FlightGear MP...";
1325
+			    	}
1008 1326
 				//@socket_close($r);
1009 1327
 				sleep($globalMinFetch);
1010 1328
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1013,10 +1331,15 @@  discard block
 block discarded – undo
1013 1331
 				break;
1014 1332
 				
1015 1333
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1016
-			    if (isset($tt[$format])) $tt[$format]++;
1017
-			    else $tt[$format] = 0;
1334
+			    if (isset($tt[$format])) {
1335
+			    	$tt[$format]++;
1336
+			    } else {
1337
+			    	$tt[$format] = 0;
1338
+			    }
1018 1339
 			    if ($tt[$format] > 30) {
1019
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1340
+				if ($globalDebug) {
1341
+					echo "ERROR : Reconnect ".$format."...";
1342
+				}
1020 1343
 				//@socket_close($r);
1021 1344
 				sleep(2);
1022 1345
 				$aprs_connect = 0;
@@ -1032,12 +1355,18 @@  discard block
 block discarded – undo
1032 1355
 		}
1033 1356
 	    } else {
1034 1357
 		$error = socket_strerror(socket_last_error());
1035
-		if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1358
+		if ($globalDebug) {
1359
+			echo "ERROR : socket_select give this error ".$error . "\n";
1360
+		}
1036 1361
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) || time() - $time >= $timeout) {
1037
-			if (isset($globalDebug)) echo "Restarting...\n";
1362
+			if (isset($globalDebug)) {
1363
+				echo "Restarting...\n";
1364
+			}
1038 1365
 			// Restart the script if possible
1039 1366
 			if (is_array($sockets)) {
1040
-			    if ($globalDebug) echo "Shutdown all sockets...";
1367
+			    if ($globalDebug) {
1368
+			    	echo "Shutdown all sockets...";
1369
+			    }
1041 1370
 			    
1042 1371
 			    foreach ($sockets as $sock) {
1043 1372
 				@socket_shutdown($sock,2);
@@ -1045,7 +1374,9 @@  discard block
 block discarded – undo
1045 1374
 			    }
1046 1375
 			    
1047 1376
 			}
1048
-			    if ($globalDebug) echo "Restart all connections...";
1377
+			    if ($globalDebug) {
1378
+			    	echo "Restart all connections...";
1379
+			    }
1049 1380
 			    sleep(2);
1050 1381
 			    $time = time();
1051 1382
 			    //connect_all($hosts);
@@ -1056,7 +1387,9 @@  discard block
 block discarded – undo
1056 1387
 	    }
1057 1388
 	}
1058 1389
 	if ($globalDaemon === false) {
1059
-	    if ($globalDebug) echo 'Check all...'."\n";
1390
+	    if ($globalDebug) {
1391
+	    	echo 'Check all...'."\n";
1392
+	    }
1060 1393
 	    $SI->checkAll();
1061 1394
 	}
1062 1395
     }
Please login to merge, or discard this patch.