Completed
Push — master ( 179cf7...3d8cb5 )
by Yannick
06:45
created
require/class.Spotter.php 1 patch
Indentation   +1455 added lines, -1455 removed lines patch added patch discarded remove patch
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	/**
58
-	* Get SQL query part for filter used
59
-	* @param Array $filter the filter
60
-	* @return Array the SQL part
61
-	*/
58
+	 * Get SQL query part for filter used
59
+	 * @param Array $filter the filter
60
+	 * @return Array the SQL part
61
+	 */
62 62
 	public function getFilter($filter = array(),$where = false,$and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	}
167 167
 
168 168
 	/**
169
-	* Executes the SQL statements to get the spotter information
170
-	*
171
-	* @param String $query the SQL query
172
-	* @param Array $params parameter of the query
173
-	* @param String $limitQuery the limit query
174
-	* @return Array the spotter information
175
-	*
176
-	*/
169
+	 * Executes the SQL statements to get the spotter information
170
+	 *
171
+	 * @param String $query the SQL query
172
+	 * @param Array $params parameter of the query
173
+	 * @param String $limitQuery the limit query
174
+	 * @return Array the spotter information
175
+	 *
176
+	 */
177 177
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 343
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344 344
 					} else $temp_array['aircraft_shadow'] = 'default.png';
345
-                                } else {
346
-                            		$temp_array['aircraft_shadow'] = 'default.png';
345
+								} else {
346
+									$temp_array['aircraft_shadow'] = 'default.png';
347 347
 					$temp_array['aircraft_name'] = 'N/A';
348 348
 					$temp_array['aircraft_manufacturer'] = 'N/A';
349
-                            	}
349
+								}
350 350
 			}
351 351
 			$fromsource = NULL;
352 352
 			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 	
543 543
 	
544 544
 	/**
545
-	* Gets all the spotter information
546
-	*
547
-	* @return Array the spotter information
548
-	*
549
-	*/
545
+	 * Gets all the spotter information
546
+	 *
547
+	 * @return Array the spotter information
548
+	 *
549
+	 */
550 550
 	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 = '',$filters = array())
551 551
 	{
552 552
 		global $globalTimezone, $globalDBdriver;
@@ -893,11 +893,11 @@  discard block
 block discarded – undo
893 893
 	
894 894
 	
895 895
 	/**
896
-	* Gets all the spotter information based on the latest data entry
897
-	*
898
-	* @return Array the spotter information
899
-	*
900
-	*/
896
+	 * Gets all the spotter information based on the latest data entry
897
+	 *
898
+	 * @return Array the spotter information
899
+	 *
900
+	 */
901 901
 	public function getLatestSpotterData($limit = '', $sort = '', $filter = array())
902 902
 	{
903 903
 		global $global_query;
@@ -936,12 +936,12 @@  discard block
 block discarded – undo
936 936
 	}
937 937
     
938 938
     
939
-    /**
940
-	* Gets all the spotter information based on a user's latitude and longitude
941
-	*
942
-	* @return Array the spotter information
943
-	*
944
-	*/
939
+	/**
940
+	 * Gets all the spotter information based on a user's latitude and longitude
941
+	 *
942
+	 * @return Array the spotter information
943
+	 *
944
+	 */
945 945
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
946 946
 	{
947 947
 		date_default_timezone_set('UTC');
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				return false;
970 970
 			}
971 971
 		}
972
-    		$additional_query = '';
972
+			$additional_query = '';
973 973
 		if ($interval != "")
974 974
 		{
975 975
 			if (!is_string($interval))
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 	}
1010 1010
     
1011 1011
     
1012
-    /**
1013
-	* Gets all the spotter information sorted by the newest aircraft type
1014
-	*
1015
-	* @return Array the spotter information
1016
-	*
1017
-	*/
1012
+	/**
1013
+	 * Gets all the spotter information sorted by the newest aircraft type
1014
+	 *
1015
+	 * @return Array the spotter information
1016
+	 *
1017
+	 */
1018 1018
 	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
@@ -1055,11 +1055,11 @@  discard block
 block discarded – undo
1055 1055
     
1056 1056
     
1057 1057
 	/**
1058
-	* Gets all the spotter information sorted by the newest aircraft registration
1059
-	*
1060
-	* @return Array the spotter information
1061
-	*
1062
-	*/
1058
+	 * Gets all the spotter information sorted by the newest aircraft registration
1059
+	 *
1060
+	 * @return Array the spotter information
1061
+	 *
1062
+	 */
1063 1063
 	public function getNewestSpotterDataSortedByAircraftRegistration($limit = '', $sort = '', $filter = array())
1064 1064
 	{
1065 1065
 		global $global_query;
@@ -1099,11 +1099,11 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 
1101 1101
 	/**
1102
-	* Gets all the spotter information sorted by the newest airline
1103
-	*
1104
-	* @return Array the spotter information
1105
-	*
1106
-	*/
1102
+	 * Gets all the spotter information sorted by the newest airline
1103
+	 *
1104
+	 * @return Array the spotter information
1105
+	 *
1106
+	 */
1107 1107
 	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
@@ -1142,12 +1142,12 @@  discard block
 block discarded – undo
1142 1142
 	}
1143 1143
     
1144 1144
     
1145
-    /**
1146
-	* Gets all the spotter information sorted by the newest departure airport
1147
-	*
1148
-	* @return Array the spotter information
1149
-	*
1150
-	*/
1145
+	/**
1146
+	 * Gets all the spotter information sorted by the newest departure airport
1147
+	 *
1148
+	 * @return Array the spotter information
1149
+	 *
1150
+	 */
1151 1151
 	public function getNewestSpotterDataSortedByDepartureAirport($limit = '', $sort = '', $filter = array())
1152 1152
 	{
1153 1153
 		global $global_query;
@@ -1189,11 +1189,11 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 
1191 1191
 	/**
1192
-	* Gets all the spotter information sorted by the newest arrival airport
1193
-	*
1194
-	* @return Array the spotter information
1195
-	*
1196
-	*/
1192
+	 * Gets all the spotter information sorted by the newest arrival airport
1193
+	 *
1194
+	 * @return Array the spotter information
1195
+	 *
1196
+	 */
1197 1197
 	public function getNewestSpotterDataSortedByArrivalAirport($limit = '', $sort = '', $filter = array())
1198 1198
 	{
1199 1199
 		global $global_query;
@@ -1232,11 +1232,11 @@  discard block
 block discarded – undo
1232 1232
 	
1233 1233
 
1234 1234
 	/**
1235
-	* Gets all the spotter information based on the spotter id
1236
-	*
1237
-	* @return Array the spotter information
1238
-	*
1239
-	*/
1235
+	 * Gets all the spotter information based on the spotter id
1236
+	 *
1237
+	 * @return Array the spotter information
1238
+	 *
1239
+	 */
1240 1240
 	public function getSpotterDataByID($id = '')
1241 1241
 	{
1242 1242
 		global $global_query;
@@ -1258,11 +1258,11 @@  discard block
 block discarded – undo
1258 1258
 	
1259 1259
 	
1260 1260
 	/**
1261
-	* Gets all the spotter information based on the callsign
1262
-	*
1263
-	* @return Array the spotter information
1264
-	*
1265
-	*/
1261
+	 * Gets all the spotter information based on the callsign
1262
+	 *
1263
+	 * @return Array the spotter information
1264
+	 *
1265
+	 */
1266 1266
 	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
1267 1267
 	{
1268 1268
 		global $global_query;
@@ -1314,11 +1314,11 @@  discard block
 block discarded – undo
1314 1314
 	}
1315 1315
 	
1316 1316
 	/**
1317
-	* Gets all the spotter information based on the owner
1318
-	*
1319
-	* @return Array the spotter information
1320
-	*
1321
-	*/
1317
+	 * Gets all the spotter information based on the owner
1318
+	 *
1319
+	 * @return Array the spotter information
1320
+	 *
1321
+	 */
1322 1322
 	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1323 1323
 	{
1324 1324
 		global $global_query;
@@ -1371,11 +1371,11 @@  discard block
 block discarded – undo
1371 1371
 	}
1372 1372
 	
1373 1373
 	/**
1374
-	* Gets all the spotter information based on the pilot
1375
-	*
1376
-	* @return Array the spotter information
1377
-	*
1378
-	*/
1374
+	 * Gets all the spotter information based on the pilot
1375
+	 *
1376
+	 * @return Array the spotter information
1377
+	 *
1378
+	 */
1379 1379
 	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1380 1380
 	{
1381 1381
 		global $global_query;
@@ -1424,11 +1424,11 @@  discard block
 block discarded – undo
1424 1424
 	
1425 1425
 	
1426 1426
 	/**
1427
-	* Gets all the spotter information based on the aircraft type
1428
-	*
1429
-	* @return Array the spotter information
1430
-	*
1431
-	*/
1427
+	 * Gets all the spotter information based on the aircraft type
1428
+	 *
1429
+	 * @return Array the spotter information
1430
+	 *
1431
+	 */
1432 1432
 	public function getSpotterDataByAircraft($aircraft_type = '', $limit = '', $sort = '', $filter = array())
1433 1433
 	{
1434 1434
 		global $global_query;
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
 	
1483 1483
 	
1484 1484
 	/**
1485
-	* Gets all the spotter information based on the aircraft registration
1486
-	*
1487
-	* @return Array the spotter information
1488
-	*
1489
-	*/
1485
+	 * Gets all the spotter information based on the aircraft registration
1486
+	 *
1487
+	 * @return Array the spotter information
1488
+	 *
1489
+	 */
1490 1490
 	public function getSpotterDataByRegistration($registration = '', $limit = '', $sort = '', $filter = array())
1491 1491
 	{
1492 1492
 		global $global_query;
@@ -1543,11 +1543,11 @@  discard block
 block discarded – undo
1543 1543
 	
1544 1544
 	
1545 1545
 	/**
1546
-	* Gets all the spotter information based on the airline
1547
-	*
1548
-	* @return Array the spotter information
1549
-	*
1550
-	*/
1546
+	 * Gets all the spotter information based on the airline
1547
+	 *
1548
+	 * @return Array the spotter information
1549
+	 *
1550
+	 */
1551 1551
 	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
@@ -1600,11 +1600,11 @@  discard block
 block discarded – undo
1600 1600
 	
1601 1601
 	
1602 1602
 	/**
1603
-	* Gets all the spotter information based on the airport
1604
-	*
1605
-	* @return Array the spotter information
1606
-	*
1607
-	*/
1603
+	 * Gets all the spotter information based on the airport
1604
+	 *
1605
+	 * @return Array the spotter information
1606
+	 *
1607
+	 */
1608 1608
 	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
@@ -1658,11 +1658,11 @@  discard block
 block discarded – undo
1658 1658
 
1659 1659
 
1660 1660
 	/**
1661
-	* Gets all the spotter information based on the date
1662
-	*
1663
-	* @return Array the spotter information
1664
-	*
1665
-	*/
1661
+	 * Gets all the spotter information based on the date
1662
+	 *
1663
+	 * @return Array the spotter information
1664
+	 *
1665
+	 */
1666 1666
 	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
@@ -1726,11 +1726,11 @@  discard block
 block discarded – undo
1726 1726
 
1727 1727
 
1728 1728
 	/**
1729
-	* Gets all the spotter information based on the country name
1730
-	*
1731
-	* @return Array the spotter information
1732
-	*
1733
-	*/
1729
+	 * Gets all the spotter information based on the country name
1730
+	 *
1731
+	 * @return Array the spotter information
1732
+	 *
1733
+	 */
1734 1734
 	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
@@ -1784,11 +1784,11 @@  discard block
 block discarded – undo
1784 1784
 	
1785 1785
 	
1786 1786
 	/**
1787
-	* Gets all the spotter information based on the manufacturer name
1788
-	*
1789
-	* @return Array the spotter information
1790
-	*
1791
-	*/
1787
+	 * Gets all the spotter information based on the manufacturer name
1788
+	 *
1789
+	 * @return Array the spotter information
1790
+	 *
1791
+	 */
1792 1792
 	public function getSpotterDataByManufacturer($aircraft_manufacturer = '', $limit = '', $sort = '', $filters = array())
1793 1793
 	{
1794 1794
 		global $global_query;
@@ -1844,13 +1844,13 @@  discard block
 block discarded – undo
1844 1844
   
1845 1845
   
1846 1846
 	/**
1847
-	* Gets a list of all aircraft that take a route
1848
-	*
1849
-	* @param String $departure_airport_icao ICAO code of departure airport
1850
-	* @param String $arrival_airport_icao ICAO code of arrival airport
1851
-	* @return Array the spotter information
1852
-	*
1853
-	*/
1847
+	 * Gets a list of all aircraft that take a route
1848
+	 *
1849
+	 * @param String $departure_airport_icao ICAO code of departure airport
1850
+	 * @param String $arrival_airport_icao ICAO code of arrival airport
1851
+	 * @return Array the spotter information
1852
+	 *
1853
+	 */
1854 1854
 	public function getSpotterDataByRoute($departure_airport_icao = '', $arrival_airport_icao = '', $limit = '', $sort = '', $filters = array())
1855 1855
 	{
1856 1856
 		global $global_query;
@@ -1919,11 +1919,11 @@  discard block
 block discarded – undo
1919 1919
 	
1920 1920
 	
1921 1921
 	/**
1922
-	* Gets all the spotter information based on the special column in the table
1923
-	*
1924
-	* @return Array the spotter information
1925
-	*
1926
-	*/
1922
+	 * Gets all the spotter information based on the special column in the table
1923
+	 *
1924
+	 * @return Array the spotter information
1925
+	 *
1926
+	 */
1927 1927
 	public function getSpotterDataByHighlight($limit = '', $sort = '', $filter = array())
1928 1928
 	{
1929 1929
 		global $global_query;
@@ -1962,11 +1962,11 @@  discard block
 block discarded – undo
1962 1962
 	}
1963 1963
 
1964 1964
 	/**
1965
-	* Gets all the highlight based on a aircraft registration
1966
-	*
1967
-	* @return String the highlight text
1968
-	*
1969
-	*/
1965
+	 * Gets all the highlight based on a aircraft registration
1966
+	 *
1967
+	 * @return String the highlight text
1968
+	 *
1969
+	 */
1970 1970
 	public function getHighlightByRegistration($registration,$filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
@@ -1988,13 +1988,13 @@  discard block
 block discarded – undo
1988 1988
 
1989 1989
 	
1990 1990
 	/**
1991
-	* Gets the squawk usage from squawk code
1992
-	*
1993
-	* @param String $squawk squawk code
1994
-	* @param String $country country
1995
-	* @return String usage
1996
-	*
1997
-	*/
1991
+	 * Gets the squawk usage from squawk code
1992
+	 *
1993
+	 * @param String $squawk squawk code
1994
+	 * @param String $country country
1995
+	 * @return String usage
1996
+	 *
1997
+	 */
1998 1998
 	public function getSquawkUsage($squawk = '',$country = 'FR')
1999 1999
 	{
2000 2000
 		
@@ -2015,12 +2015,12 @@  discard block
 block discarded – undo
2015 2015
 	}
2016 2016
 
2017 2017
 	/**
2018
-	* Gets the airport icao from the iata
2019
-	*
2020
-	* @param String $airport_iata the iata code of the airport
2021
-	* @return String airport iata
2022
-	*
2023
-	*/
2018
+	 * Gets the airport icao from the iata
2019
+	 *
2020
+	 * @param String $airport_iata the iata code of the airport
2021
+	 * @return String airport iata
2022
+	 *
2023
+	 */
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
@@ -2040,14 +2040,14 @@  discard block
 block discarded – undo
2040 2040
 	}
2041 2041
 
2042 2042
 	/**
2043
-	* Gets the airport distance
2044
-	*
2045
-	* @param String $airport_icao the icao code of the airport
2046
-	* @param Float $latitude the latitude
2047
-	* @param Float $longitude the longitude
2048
-	* @return Float distance to the airport
2049
-	*
2050
-	*/
2043
+	 * Gets the airport distance
2044
+	 *
2045
+	 * @param String $airport_icao the icao code of the airport
2046
+	 * @param Float $latitude the latitude
2047
+	 * @param Float $longitude the longitude
2048
+	 * @return Float distance to the airport
2049
+	 *
2050
+	 */
2051 2051
 	public function getAirportDistance($airport_icao,$latitude,$longitude)
2052 2052
 	{
2053 2053
 		
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
 	}
2069 2069
 	
2070 2070
 	/**
2071
-	* Gets the airport info based on the icao
2072
-	*
2073
-	* @param String $airport the icao code of the airport
2074
-	* @return Array airport information
2075
-	*
2076
-	*/
2071
+	 * Gets the airport info based on the icao
2072
+	 *
2073
+	 * @param String $airport the icao code of the airport
2074
+	 * @return Array airport information
2075
+	 *
2076
+	 */
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
@@ -2119,12 +2119,12 @@  discard block
 block discarded – undo
2119 2119
 	}
2120 2120
 	
2121 2121
 	/**
2122
-	* Gets the airport info based on the country
2123
-	*
2124
-	* @param Array $countries Airports countries
2125
-	* @return Array airport information
2126
-	*
2127
-	*/
2122
+	 * Gets the airport info based on the country
2123
+	 *
2124
+	 * @param Array $countries Airports countries
2125
+	 * @return Array airport information
2126
+	 *
2127
+	 */
2128 2128
 	public function getAllAirportInfobyCountry($countries)
2129 2129
 	{
2130 2130
 		$lst_countries = '';
@@ -2162,12 +2162,12 @@  discard block
 block discarded – undo
2162 2162
 	}
2163 2163
 	
2164 2164
 	/**
2165
-	* Gets airports info based on the coord
2166
-	*
2167
-	* @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
-	* @return Array airport information
2169
-	*
2170
-	*/
2165
+	 * Gets airports info based on the coord
2166
+	 *
2167
+	 * @param Array $coord Airports longitude min,latitude min, longitude max, latitude max
2168
+	 * @return Array airport information
2169
+	 *
2170
+	 */
2171 2171
 	public function getAllAirportInfobyCoord($coord)
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
@@ -2198,12 +2198,12 @@  discard block
 block discarded – undo
2198 2198
 	}
2199 2199
 
2200 2200
 	/**
2201
-	* Gets waypoints info based on the coord
2202
-	*
2203
-	* @param Array $coord waypoints coord
2204
-	* @return Array airport information
2205
-	*
2206
-	*/
2201
+	 * Gets waypoints info based on the coord
2202
+	 *
2203
+	 * @param Array $coord waypoints coord
2204
+	 * @return Array airport information
2205
+	 *
2206
+	 */
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
@@ -2237,12 +2237,12 @@  discard block
 block discarded – undo
2237 2237
 	
2238 2238
 	
2239 2239
 	/**
2240
-	* Gets the airline info based on the icao code or iata code
2241
-	*
2242
-	* @param String $airline_icao the iata code of the airport
2243
-	* @return Array airport information
2244
-	*
2245
-	*/
2240
+	 * Gets the airline info based on the icao code or iata code
2241
+	 *
2242
+	 * @param String $airline_icao the iata code of the airport
2243
+	 * @return Array airport information
2244
+	 *
2245
+	 */
2246 2246
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
@@ -2273,7 +2273,7 @@  discard block
 block discarded – undo
2273 2273
 			} else {
2274 2274
 				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2275 2275
 			}
2276
-                        /*
2276
+						/*
2277 2277
 			$airline_array = array();
2278 2278
 			$temp_array = array();
2279 2279
 		
@@ -2306,12 +2306,12 @@  discard block
 block discarded – undo
2306 2306
 	}
2307 2307
 	
2308 2308
 	/**
2309
-	* Gets the airline info based on the airline name
2310
-	*
2311
-	* @param String $airline_name the name of the airline
2312
-	* @return Array airline information
2313
-	*
2314
-	*/
2309
+	 * Gets the airline info based on the airline name
2310
+	 *
2311
+	 * @param String $airline_name the name of the airline
2312
+	 * @return Array airline information
2313
+	 *
2314
+	 */
2315 2315
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
@@ -2339,12 +2339,12 @@  discard block
 block discarded – undo
2339 2339
 	
2340 2340
 	
2341 2341
 	/**
2342
-	* Gets the aircraft info based on the aircraft type
2343
-	*
2344
-	* @param String $aircraft_type the aircraft type
2345
-	* @return Array aircraft information
2346
-	*
2347
-	*/
2342
+	 * Gets the aircraft info based on the aircraft type
2343
+	 *
2344
+	 * @param String $aircraft_type the aircraft type
2345
+	 * @return Array aircraft information
2346
+	 *
2347
+	 */
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350 2350
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2376,12 +2376,12 @@  discard block
 block discarded – undo
2376 2376
 	}
2377 2377
 
2378 2378
 	/**
2379
-	* Gets the aircraft icao based on the aircraft name/type
2380
-	*
2381
-	* @param String $aircraft_type the aircraft type
2382
-	* @return String aircraft information
2383
-	*
2384
-	*/
2379
+	 * Gets the aircraft icao based on the aircraft name/type
2380
+	 *
2381
+	 * @param String $aircraft_type the aircraft type
2382
+	 * @return String aircraft information
2383
+	 *
2384
+	 */
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387 2387
 		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
@@ -2406,12 +2406,12 @@  discard block
 block discarded – undo
2406 2406
 	}
2407 2407
 	
2408 2408
 	/**
2409
-	* Gets the aircraft info based on the aircraft modes
2410
-	*
2411
-	* @param String $aircraft_modes the aircraft ident (hex)
2412
-	* @return String aircraft type
2413
-	*
2414
-	*/
2409
+	 * Gets the aircraft info based on the aircraft modes
2410
+	 *
2411
+	 * @param String $aircraft_modes the aircraft ident (hex)
2412
+	 * @return String aircraft type
2413
+	 *
2414
+	 */
2415 2415
 	public function getAllAircraftType($aircraft_modes,$source_type = '')
2416 2416
 	{
2417 2417
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -2438,12 +2438,12 @@  discard block
 block discarded – undo
2438 2438
 	}
2439 2439
 
2440 2440
 	/**
2441
-	* Gets the aircraft info based on the aircraft registration
2442
-	*
2443
-	* @param String $registration the aircraft registration
2444
-	* @return String aircraft type
2445
-	*
2446
-	*/
2441
+	 * Gets the aircraft info based on the aircraft registration
2442
+	 *
2443
+	 * @param String $registration the aircraft registration
2444
+	 * @return String aircraft type
2445
+	 *
2446
+	 */
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449 2449
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2461,12 +2461,12 @@  discard block
 block discarded – undo
2461 2461
 	}
2462 2462
 
2463 2463
 	/**
2464
-	* Gets the spotter_id and flightaware_id based on the aircraft registration
2465
-	*
2466
-	* @param String $registration the aircraft registration
2467
-	* @return Array spotter_id and flightaware_id
2468
-	*
2469
-	*/
2464
+	 * Gets the spotter_id and flightaware_id based on the aircraft registration
2465
+	 *
2466
+	 * @param String $registration the aircraft registration
2467
+	 * @return Array spotter_id and flightaware_id
2468
+	 *
2469
+	 */
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472 2472
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2485,12 +2485,12 @@  discard block
 block discarded – undo
2485 2485
 	}
2486 2486
 
2487 2487
 	/**
2488
-	* Gets correct aircraft operator code
2489
-	*
2490
-	* @param String $operator the aircraft operator code (callsign)
2491
-	* @return String aircraft operator code
2492
-	*
2493
-	*/
2488
+	 * Gets correct aircraft operator code
2489
+	 *
2490
+	 * @param String $operator the aircraft operator code (callsign)
2491
+	 * @return String aircraft operator code
2492
+	 *
2493
+	 */
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496 2496
 		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
@@ -2507,16 +2507,16 @@  discard block
 block discarded – undo
2507 2507
 	}
2508 2508
 
2509 2509
 	/**
2510
-	* Gets the aircraft route based on the aircraft callsign
2511
-	*
2512
-	* @param String $callsign the aircraft callsign
2513
-	* @return Array aircraft type
2514
-	*
2515
-	*/
2510
+	 * Gets the aircraft route based on the aircraft callsign
2511
+	 *
2512
+	 * @param String $callsign the aircraft callsign
2513
+	 * @return Array aircraft type
2514
+	 *
2515
+	 */
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518 2518
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2519
+				if ($callsign == '') return array();
2520 2520
 		$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";
2521 2521
 		
2522 2522
 		$sth = $this->db->prepare($query);
@@ -2530,12 +2530,12 @@  discard block
 block discarded – undo
2530 2530
 	}
2531 2531
 	
2532 2532
 	/**
2533
-	* Gets the aircraft info based on the aircraft registration
2534
-	*
2535
-	* @param String $registration the aircraft registration
2536
-	* @return Array aircraft information
2537
-	*
2538
-	*/
2533
+	 * Gets the aircraft info based on the aircraft registration
2534
+	 *
2535
+	 * @param String $registration the aircraft registration
2536
+	 * @return Array aircraft information
2537
+	 *
2538
+	 */
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541 2541
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2562,12 +2562,12 @@  discard block
 block discarded – undo
2562 2562
 	}
2563 2563
 	
2564 2564
 	/**
2565
-	* Gets the aircraft owner & base based on the aircraft registration
2566
-	*
2567
-	* @param String $registration the aircraft registration
2568
-	* @return Array aircraft information
2569
-	*
2570
-	*/
2565
+	 * Gets the aircraft owner & base based on the aircraft registration
2566
+	 *
2567
+	 * @param String $registration the aircraft registration
2568
+	 * @return Array aircraft information
2569
+	 *
2570
+	 */
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573 2573
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -2584,11 +2584,11 @@  discard block
 block discarded – undo
2584 2584
 	
2585 2585
   
2586 2586
   /**
2587
-	* Gets all flights (but with only little info)
2588
-	*
2589
-	* @return Array basic flight information
2590
-	*
2591
-	*/
2587
+   * Gets all flights (but with only little info)
2588
+   *
2589
+   * @return Array basic flight information
2590
+   *
2591
+   */
2592 2592
 	public function getAllFlightsforSitemap()
2593 2593
 	{
2594 2594
 		//$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 ";
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
2599
-                  /*
2599
+				  /*
2600 2600
 		$flight_array = array();
2601 2601
 		$temp_array = array();
2602 2602
 		
@@ -2618,11 +2618,11 @@  discard block
 block discarded – undo
2618 2618
 	}
2619 2619
   
2620 2620
 	/**
2621
-	* Gets a list of all aircraft manufacturers
2622
-	*
2623
-	* @return Array list of aircraft types
2624
-	*
2625
-	*/
2621
+	 * Gets a list of all aircraft manufacturers
2622
+	 *
2623
+	 * @return Array list of aircraft types
2624
+	 *
2625
+	 */
2626 2626
 	public function getAllManufacturers()
2627 2627
 	{
2628 2628
 		/*
@@ -2651,11 +2651,11 @@  discard block
 block discarded – undo
2651 2651
   
2652 2652
   
2653 2653
   /**
2654
-	* Gets a list of all aircraft types
2655
-	*
2656
-	* @return Array list of aircraft types
2657
-	*
2658
-	*/
2654
+   * Gets a list of all aircraft types
2655
+   *
2656
+   * @return Array list of aircraft types
2657
+   *
2658
+   */
2659 2659
 	public function getAllAircraftTypes($filters = array())
2660 2660
 	{
2661 2661
 		/*
@@ -2690,11 +2690,11 @@  discard block
 block discarded – undo
2690 2690
 	
2691 2691
 	
2692 2692
 	/**
2693
-	* Gets a list of all aircraft registrations
2694
-	*
2695
-	* @return Array list of aircraft registrations
2696
-	*
2697
-	*/
2693
+	 * Gets a list of all aircraft registrations
2694
+	 *
2695
+	 * @return Array list of aircraft registrations
2696
+	 *
2697
+	 */
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700 2700
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2719,12 +2719,12 @@  discard block
 block discarded – undo
2719 2719
 	}
2720 2720
 
2721 2721
 	/**
2722
-	* Gets all source name
2723
-	*
2724
-	* @param String type format of source
2725
-	* @return Array list of source name
2726
-	*
2727
-	*/
2722
+	 * Gets all source name
2723
+	 *
2724
+	 * @param String type format of source
2725
+	 * @return Array list of source name
2726
+	 *
2727
+	 */
2728 2728
 	public function getAllSourceName($type = '',$filters = array())
2729 2729
 	{
2730 2730
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2755,11 +2755,11 @@  discard block
 block discarded – undo
2755 2755
 
2756 2756
 
2757 2757
 	/**
2758
-	* Gets a list of all airline names
2759
-	*
2760
-	* @return Array list of airline names
2761
-	*
2762
-	*/
2758
+	 * Gets a list of all airline names
2759
+	 *
2760
+	 * @return Array list of airline names
2761
+	 *
2762
+	 */
2763 2763
 	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2764 2764
 	{
2765 2765
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2808,11 +2808,11 @@  discard block
 block discarded – undo
2808 2808
 	}
2809 2809
 	
2810 2810
 	/**
2811
-	* Gets a list of all alliance names
2812
-	*
2813
-	* @return Array list of alliance names
2814
-	*
2815
-	*/
2811
+	 * Gets a list of all alliance names
2812
+	 *
2813
+	 * @return Array list of alliance names
2814
+	 *
2815
+	 */
2816 2816
 	public function getAllAllianceNames($forsource = NULL,$filters = array())
2817 2817
 	{
2818 2818
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
@@ -2837,11 +2837,11 @@  discard block
 block discarded – undo
2837 2837
 	}
2838 2838
 	
2839 2839
 	/**
2840
-	* Gets a list of all airline countries
2841
-	*
2842
-	* @return Array list of airline countries
2843
-	*
2844
-	*/
2840
+	 * Gets a list of all airline countries
2841
+	 *
2842
+	 * @return Array list of airline countries
2843
+	 *
2844
+	 */
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847 2847
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2869,11 +2869,11 @@  discard block
 block discarded – undo
2869 2869
 	
2870 2870
 	
2871 2871
 	/**
2872
-	* Gets a list of all departure & arrival names
2873
-	*
2874
-	* @return Array list of airport names
2875
-	*
2876
-	*/
2872
+	 * Gets a list of all departure & arrival names
2873
+	 *
2874
+	 * @return Array list of airport names
2875
+	 *
2876
+	 */
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879 2879
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2921,11 +2921,11 @@  discard block
 block discarded – undo
2921 2921
 	} 
2922 2922
 
2923 2923
 	/**
2924
-	* Gets a list of all owner names
2925
-	*
2926
-	* @return Array list of owner names
2927
-	*
2928
-	*/
2924
+	 * Gets a list of all owner names
2925
+	 *
2926
+	 * @return Array list of owner names
2927
+	 *
2928
+	 */
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931 2931
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2939,11 +2939,11 @@  discard block
 block discarded – undo
2939 2939
 	} 
2940 2940
 
2941 2941
 	/**
2942
-	* Gets a list of all pilot names and pilot ids
2943
-	*
2944
-	* @return Array list of pilot names and pilot ids
2945
-	*
2946
-	*/
2942
+	 * Gets a list of all pilot names and pilot ids
2943
+	 *
2944
+	 * @return Array list of pilot names and pilot ids
2945
+	 *
2946
+	 */
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949 2949
 		$filter_query = $this->getFilter($filters,true,true);
@@ -2958,11 +2958,11 @@  discard block
 block discarded – undo
2958 2958
 	
2959 2959
 	
2960 2960
 	/**
2961
-	* Gets a list of all departure & arrival airport countries
2962
-	*
2963
-	* @return Array list of airport countries
2964
-	*
2965
-	*/
2961
+	 * Gets a list of all departure & arrival airport countries
2962
+	 *
2963
+	 * @return Array list of airport countries
2964
+	 *
2965
+	 */
2966 2966
 	public function getAllAirportCountries($filters = array())
2967 2967
 	{
2968 2968
 		$airport_array = array();
@@ -3010,11 +3010,11 @@  discard block
 block discarded – undo
3010 3010
 	
3011 3011
 	
3012 3012
 	/**
3013
-	* Gets a list of all countries (airline, departure airport & arrival airport)
3014
-	*
3015
-	* @return Array list of countries
3016
-	*
3017
-	*/
3013
+	 * Gets a list of all countries (airline, departure airport & arrival airport)
3014
+	 *
3015
+	 * @return Array list of countries
3016
+	 *
3017
+	 */
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020 3020
 		$Connection= new Connection($this->db);
@@ -3091,11 +3091,11 @@  discard block
 block discarded – undo
3091 3091
 	
3092 3092
 	
3093 3093
 	/**
3094
-	* Gets a list of all idents/callsigns
3095
-	*
3096
-	* @return Array list of ident/callsign names
3097
-	*
3098
-	*/
3094
+	 * Gets a list of all idents/callsigns
3095
+	 *
3096
+	 * @return Array list of ident/callsign names
3097
+	 *
3098
+	 */
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101 3101
 		$filter_query = $this->getFilter($filters,true,true);
@@ -3119,9 +3119,9 @@  discard block
 block discarded – undo
3119 3119
 	}
3120 3120
 
3121 3121
 	/**
3122
-	* Get a list of flights from airport since 7 days
3123
-	* @return Array number, icao, name and city of airports
3124
-	*/
3122
+	 * Get a list of flights from airport since 7 days
3123
+	 * @return Array number, icao, name and city of airports
3124
+	 */
3125 3125
 
3126 3126
 	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
@@ -3152,9 +3152,9 @@  discard block
 block discarded – undo
3152 3152
 	}
3153 3153
 
3154 3154
 	/**
3155
-	* Get a list of flights from airport since 7 days
3156
-	* @return Array number, icao, name and city of airports
3157
-	*/
3155
+	 * Get a list of flights from airport since 7 days
3156
+	 * @return Array number, icao, name and city of airports
3157
+	 */
3158 3158
 
3159 3159
 	public function getLast7DaysAirportsDepartureByAirlines($airport_icao = '') {
3160 3160
 		global $globalTimezone, $globalDBdriver;
@@ -3184,9 +3184,9 @@  discard block
 block discarded – undo
3184 3184
 	}
3185 3185
 
3186 3186
 	/**
3187
-	* Get a list of flights from detected airport since 7 days
3188
-	* @return Array number, icao, name and city of airports
3189
-	*/
3187
+	 * Get a list of flights from detected airport since 7 days
3188
+	 * @return Array number, icao, name and city of airports
3189
+	 */
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
@@ -3224,9 +3224,9 @@  discard block
 block discarded – undo
3224 3224
 	}
3225 3225
 
3226 3226
 	/**
3227
-	* Get a list of flights from detected airport since 7 days
3228
-	* @return Array number, icao, name and city of airports
3229
-	*/
3227
+	 * Get a list of flights from detected airport since 7 days
3228
+	 * @return Array number, icao, name and city of airports
3229
+	 */
3230 3230
 
3231 3231
 	public function getLast7DaysDetectedAirportsDepartureByAirlines($airport_icao = '') {
3232 3232
 		global $globalTimezone, $globalDBdriver;
@@ -3268,9 +3268,9 @@  discard block
 block discarded – undo
3268 3268
 
3269 3269
 
3270 3270
 	/**
3271
-	* Get a list of flights to airport since 7 days
3272
-	* @return Array number, icao, name and city of airports
3273
-	*/
3271
+	 * Get a list of flights to airport since 7 days
3272
+	 * @return Array number, icao, name and city of airports
3273
+	 */
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
@@ -3303,9 +3303,9 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
 
3305 3305
 	/**
3306
-	* Get a list of flights detected to airport since 7 days
3307
-	* @return Array number, icao, name and city of airports
3308
-	*/
3306
+	 * Get a list of flights detected to airport since 7 days
3307
+	 * @return Array number, icao, name and city of airports
3308
+	 */
3309 3309
 
3310 3310
 	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
@@ -3346,9 +3346,9 @@  discard block
 block discarded – undo
3346 3346
 
3347 3347
 
3348 3348
 	/**
3349
-	* Get a list of flights to airport since 7 days
3350
-	* @return Array number, icao, name and city of airports
3351
-	*/
3349
+	 * Get a list of flights to airport since 7 days
3350
+	 * @return Array number, icao, name and city of airports
3351
+	 */
3352 3352
 
3353 3353
 	public function getLast7DaysAirportsArrivalByAirlines($airport_icao = '') {
3354 3354
 		global $globalTimezone, $globalDBdriver;
@@ -3380,9 +3380,9 @@  discard block
 block discarded – undo
3380 3380
 
3381 3381
 
3382 3382
 	/**
3383
-	* Get a list of flights detected to airport since 7 days
3384
-	* @return Array number, icao, name and city of airports
3385
-	*/
3383
+	 * Get a list of flights detected to airport since 7 days
3384
+	 * @return Array number, icao, name and city of airports
3385
+	 */
3386 3386
 
3387 3387
 	public function getLast7DaysDetectedAirportsArrivalByAirlines($airport_icao = '') {
3388 3388
 		global $globalTimezone, $globalDBdriver;
@@ -3426,11 +3426,11 @@  discard block
 block discarded – undo
3426 3426
 
3427 3427
 
3428 3428
 	/**
3429
-	* Gets a list of all dates
3430
-	*
3431
-	* @return Array list of date names
3432
-	*
3433
-	*/
3429
+	 * Gets a list of all dates
3430
+	 *
3431
+	 * @return Array list of date names
3432
+	 *
3433
+	 */
3434 3434
 	public function getAllDates()
3435 3435
 	{
3436 3436
 		global $globalTimezone, $globalDBdriver;
@@ -3471,11 +3471,11 @@  discard block
 block discarded – undo
3471 3471
 	
3472 3472
 	
3473 3473
 	/**
3474
-	* Gets all route combinations
3475
-	*
3476
-	* @return Array the route list
3477
-	*
3478
-	*/
3474
+	 * Gets all route combinations
3475
+	 *
3476
+	 * @return Array the route list
3477
+	 *
3478
+	 */
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
3481 3481
 		$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 
@@ -3501,13 +3501,13 @@  discard block
 block discarded – undo
3501 3501
 	}
3502 3502
 
3503 3503
 	/**
3504
-	* Update ident spotter data
3505
-	*
3506
-	* @param String $flightaware_id the ID from flightaware
3507
-	* @param String $ident the flight ident
3508
-	* @return String success or false
3509
-	*
3510
-	*/	
3504
+	 * Update ident spotter data
3505
+	 *
3506
+	 * @param String $flightaware_id the ID from flightaware
3507
+	 * @param String $ident the flight ident
3508
+	 * @return String success or false
3509
+	 *
3510
+	 */	
3511 3511
 	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
@@ -3528,14 +3528,14 @@  discard block
 block discarded – undo
3528 3528
 		} else {
3529 3529
 			$airline_array = $this->getAllAirlineInfo("NA");
3530 3530
 		}
3531
-                $airline_name = $airline_array[0]['name'];
3532
-                $airline_icao = $airline_array[0]['icao'];
3533
-                $airline_country = $airline_array[0]['country'];
3534
-                $airline_type = $airline_array[0]['type'];
3531
+				$airline_name = $airline_array[0]['name'];
3532
+				$airline_icao = $airline_array[0]['icao'];
3533
+				$airline_country = $airline_array[0]['country'];
3534
+				$airline_type = $airline_array[0]['type'];
3535 3535
 
3536 3536
 
3537 3537
 		$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';
3538
-                $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);
3538
+				$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);
3539 3539
 
3540 3540
 		try {
3541 3541
 			$sth = $this->db->prepare($query);
@@ -3548,19 +3548,19 @@  discard block
 block discarded – undo
3548 3548
 
3549 3549
 	}
3550 3550
 	/**
3551
-	* Update latest spotter data
3552
-	*
3553
-	* @param String $flightaware_id the ID from flightaware
3554
-	* @param String $ident the flight ident
3555
-	* @param String $arrival_airport_icao the arrival airport
3556
-	* @return String success or false
3557
-	*
3558
-	*/	
3551
+	 * Update latest spotter data
3552
+	 *
3553
+	 * @param String $flightaware_id the ID from flightaware
3554
+	 * @param String $ident the flight ident
3555
+	 * @param String $arrival_airport_icao the arrival airport
3556
+	 * @return String success or false
3557
+	 *
3558
+	 */	
3559 3559
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3560
 	{
3561 3561
 		if ($groundspeed == '') $groundspeed = NULL;
3562 3562
 		$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';
3563
-                $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);
3563
+				$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);
3564 3564
 
3565 3565
 		try {
3566 3566
 			$sth = $this->db->prepare($query);
@@ -3574,32 +3574,32 @@  discard block
 block discarded – undo
3574 3574
 	}
3575 3575
 
3576 3576
 	/**
3577
-	* Adds a new spotter data
3578
-	*
3579
-	* @param String $flightaware_id the ID from flightaware
3580
-	* @param String $ident the flight ident
3581
-	* @param String $aircraft_icao the aircraft type
3582
-	* @param String $departure_airport_icao the departure airport
3583
-	* @param String $arrival_airport_icao the arrival airport
3584
-	* @param String $latitude latitude of flight
3585
-	* @param String $longitude latitude of flight
3586
-	* @param String $waypoints waypoints of flight
3587
-	* @param String $altitude altitude of flight
3588
-	* @param String $heading heading of flight
3589
-	* @param String $groundspeed speed of flight
3590
-	* @param String $date date of flight
3591
-	* @param String $departure_airport_time departure time of flight
3592
-	* @param String $arrival_airport_time arrival time of flight
3593
-	* @param String $squawk squawk code of flight
3594
-	* @param String $route_stop route stop of flight
3595
-	* @param String $highlight highlight or not
3596
-	* @param String $ModeS ModesS code of flight
3597
-	* @param String $registration registration code of flight
3598
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
3599
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
3600
-	* @param String $verticalrate vertival rate of flight
3601
-	* @return String success or false
3602
-	*/
3577
+	 * Adds a new spotter data
3578
+	 *
3579
+	 * @param String $flightaware_id the ID from flightaware
3580
+	 * @param String $ident the flight ident
3581
+	 * @param String $aircraft_icao the aircraft type
3582
+	 * @param String $departure_airport_icao the departure airport
3583
+	 * @param String $arrival_airport_icao the arrival airport
3584
+	 * @param String $latitude latitude of flight
3585
+	 * @param String $longitude latitude of flight
3586
+	 * @param String $waypoints waypoints of flight
3587
+	 * @param String $altitude altitude of flight
3588
+	 * @param String $heading heading of flight
3589
+	 * @param String $groundspeed speed of flight
3590
+	 * @param String $date date of flight
3591
+	 * @param String $departure_airport_time departure time of flight
3592
+	 * @param String $arrival_airport_time arrival time of flight
3593
+	 * @param String $squawk squawk code of flight
3594
+	 * @param String $route_stop route stop of flight
3595
+	 * @param String $highlight highlight or not
3596
+	 * @param String $ModeS ModesS code of flight
3597
+	 * @param String $registration registration code of flight
3598
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
3599
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
3600
+	 * @param String $verticalrate vertival rate of flight
3601
+	 * @return String success or false
3602
+	 */
3603 3603
 	public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$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 = '',$source_type = '')
3604 3604
 	{
3605 3605
 		global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM;
@@ -3814,8 +3814,8 @@  discard block
 block discarded – undo
3814 3814
     
3815 3815
 		if ($globalIVAO && $aircraft_icao != '')
3816 3816
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
3817
+					if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
+					else $airline_icao = '';
3819 3819
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
@@ -3846,53 +3846,53 @@  discard block
 block discarded – undo
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
3849
-                        $airline_array = $this->getAllAirlineInfo('NA');
3850
-                }
3851
-                if (count($aircraft_array) == 0) 
3852
-                {
3853
-                        $aircraft_array = $this->getAllAircraftInfo('NA');
3854
-                }
3855
-                if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
-                {
3857
-                        $departure_airport_array = $this->getAllAirportInfo('NA');
3858
-                }
3859
-                if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
-                {
3861
-                        $arrival_airport_array = $this->getAllAirportInfo('NA');
3862
-                }
3863
-                if ($registration == '') $registration = 'NA';
3864
-                if ($latitude == '' && $longitude == '') {
3865
-            		$latitude = 0;
3866
-            		$longitude = 0;
3867
-            	}
3868
-                if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
-                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
-                if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
-                $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) 
3849
+						$airline_array = $this->getAllAirlineInfo('NA');
3850
+				}
3851
+				if (count($aircraft_array) == 0) 
3852
+				{
3853
+						$aircraft_array = $this->getAllAircraftInfo('NA');
3854
+				}
3855
+				if (count($departure_airport_array) == 0 || $departure_airport_array[0]['icao'] == '' || $departure_airport_icao == '') 
3856
+				{
3857
+						$departure_airport_array = $this->getAllAirportInfo('NA');
3858
+				}
3859
+				if (count($arrival_airport_array) == 0 || $arrival_airport_array[0]['icao'] == '' || $arrival_airport_icao == '') 
3860
+				{
3861
+						$arrival_airport_array = $this->getAllAirportInfo('NA');
3862
+				}
3863
+				if ($registration == '') $registration = 'NA';
3864
+				if ($latitude == '' && $longitude == '') {
3865
+					$latitude = 0;
3866
+					$longitude = 0;
3867
+				}
3868
+				if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
3869
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
3870
+				if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872
+				if (!isset($aircraft_owner)) $aircraft_owner = NULL;
3873
+				$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) 
3874 3874
                 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)";
3875 3875
 
3876
-                $airline_name = $airline_array[0]['name'];
3877
-                $airline_icao = $airline_array[0]['icao'];
3878
-                $airline_country = $airline_array[0]['country'];
3879
-                $airline_type = $airline_array[0]['type'];
3876
+				$airline_name = $airline_array[0]['name'];
3877
+				$airline_icao = $airline_array[0]['icao'];
3878
+				$airline_country = $airline_array[0]['country'];
3879
+				$airline_type = $airline_array[0]['type'];
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883 3883
 			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3884 3884
 		}
3885 3885
 		if ($airline_type == null) $airline_type = '';
3886
-                $aircraft_type = $aircraft_array[0]['type'];
3887
-                $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
-                $departure_airport_name = $departure_airport_array[0]['name'];
3889
-	        $departure_airport_city = $departure_airport_array[0]['city'];
3890
-            	$departure_airport_country = $departure_airport_array[0]['country'];
3886
+				$aircraft_type = $aircraft_array[0]['type'];
3887
+				$aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888
+				$departure_airport_name = $departure_airport_array[0]['name'];
3889
+			$departure_airport_city = $departure_airport_array[0]['city'];
3890
+				$departure_airport_country = $departure_airport_array[0]['country'];
3891 3891
                 
3892
-                $arrival_airport_name = $arrival_airport_array[0]['name'];
3893
-                $arrival_airport_city = $arrival_airport_array[0]['city'];
3894
-                $arrival_airport_country = $arrival_airport_array[0]['country'];
3895
-                $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);
3892
+				$arrival_airport_name = $arrival_airport_array[0]['name'];
3893
+				$arrival_airport_city = $arrival_airport_array[0]['city'];
3894
+				$arrival_airport_country = $arrival_airport_array[0]['country'];
3895
+				$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);
3896 3896
 
3897 3897
 		try {
3898 3898
 		        
@@ -3900,7 +3900,7 @@  discard block
 block discarded – undo
3900 3900
 			$sth->execute($query_values);
3901 3901
 			$this->db = null;
3902 3902
 		} catch (PDOException $e) {
3903
-		    return "error : ".$e->getMessage();
3903
+			return "error : ".$e->getMessage();
3904 3904
 		}
3905 3905
 		
3906 3906
 		return "success";
@@ -3909,11 +3909,11 @@  discard block
 block discarded – undo
3909 3909
 	
3910 3910
   
3911 3911
 	/**
3912
-	* Gets the aircraft ident within the last hour
3913
-	*
3914
-	* @return String the ident
3915
-	*
3916
-	*/
3912
+	 * Gets the aircraft ident within the last hour
3913
+	 *
3914
+	 * @return String the ident
3915
+	 *
3916
+	 */
3917 3917
 	public function getIdentFromLastHour($ident)
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
@@ -3929,11 +3929,11 @@  discard block
 block discarded – undo
3929 3929
 								AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
3930 3930
 								AND spotter_output.date < now() AT TIME ZONE 'UTC'";
3931 3931
 			$query_data = array(':ident' => $ident);
3932
-    		}
3932
+			}
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3936
+			$ident_result='';
3937 3937
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
@@ -3944,11 +3944,11 @@  discard block
 block discarded – undo
3944 3944
 	
3945 3945
 	
3946 3946
 	/**
3947
-	* Gets the aircraft data from the last 20 seconds
3948
-	*
3949
-	* @return Array the spotter data
3950
-	*
3951
-	*/
3947
+	 * Gets the aircraft data from the last 20 seconds
3948
+	 *
3949
+	 * @return Array the spotter data
3950
+	 *
3951
+	 */
3952 3952
 	public function getRealTimeData($q = '')
3953 3953
 	{
3954 3954
 		global $globalDBdriver;
@@ -3992,11 +3992,11 @@  discard block
 block discarded – undo
3992 3992
 	
3993 3993
 	
3994 3994
 	 /**
3995
-	* Gets all airlines that have flown over
3996
-	*
3997
-	* @return Array the airline list
3998
-	*
3999
-	*/
3995
+	  * Gets all airlines that have flown over
3996
+	  *
3997
+	  * @return Array the airline list
3998
+	  *
3999
+	  */
4000 4000
 	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
@@ -4010,7 +4010,7 @@  discard block
 block discarded – undo
4010 4010
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4011 4011
 			}
4012 4012
 		}
4013
-                if ($sincedate != '') {
4013
+				if ($sincedate != '') {
4014 4014
 			if ($globalDBdriver == 'mysql') {
4015 4015
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4016 4016
 			} else {
@@ -4064,26 +4064,26 @@  discard block
 block discarded – undo
4064 4064
 	}
4065 4065
 
4066 4066
 	 /**
4067
-	* Gets all pilots that have flown over
4068
-	*
4069
-	* @return Array the pilots list
4070
-	*
4071
-	*/
4067
+	  * Gets all pilots that have flown over
4068
+	  *
4069
+	  * @return Array the pilots list
4070
+	  *
4071
+	  */
4072 4072
 	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075 4075
 		$filter_query = $this->getFilter($filters,true,true);
4076 4076
 		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4077 4077
 			FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''";
4078
-                if ($olderthanmonths > 0) {
4079
-            		if ($globalDBdriver == 'mysql') {
4078
+				if ($olderthanmonths > 0) {
4079
+					if ($globalDBdriver == 'mysql') {
4080 4080
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4081 4081
 			} else {
4082 4082
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4083 4083
 			}
4084 4084
 		}
4085
-                if ($sincedate != '') {
4086
-            		if ($globalDBdriver == 'mysql') {
4085
+				if ($sincedate != '') {
4086
+					if ($globalDBdriver == 'mysql') {
4087 4087
 				$query .= " AND spotter_output.date > '".$sincedate."'";
4088 4088
 			} else {
4089 4089
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4138,25 +4138,25 @@  discard block
 block discarded – undo
4138 4138
 	}
4139 4139
 	
4140 4140
 	/**
4141
-	* Gets all pilots that have flown over
4142
-	*
4143
-	* @return Array the pilots list
4144
-	*
4145
-	*/
4141
+	 * Gets all pilots that have flown over
4142
+	 *
4143
+	 * @return Array the pilots list
4144
+	 *
4145
+	 */
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
4149 4149
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4150 4150
 		 			FROM spotter_output WHERE spotter_output.pilot_id <> '' ";
4151
-                if ($olderthanmonths > 0) {
4152
-            		if ($globalDBdriver == 'mysql') {
4151
+				if ($olderthanmonths > 0) {
4152
+					if ($globalDBdriver == 'mysql') {
4153 4153
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4154 4154
 			} else {
4155 4155
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4156 4156
 			}
4157 4157
 		}
4158
-                if ($sincedate != '') {
4159
-            		if ($globalDBdriver == 'mysql') {
4158
+				if ($sincedate != '') {
4159
+					if ($globalDBdriver == 'mysql') {
4160 4160
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4161 4161
 			} else {
4162 4162
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4185,26 +4185,26 @@  discard block
 block discarded – undo
4185 4185
 	}
4186 4186
 	
4187 4187
 	 /**
4188
-	* Gets all owner that have flown over
4189
-	*
4190
-	* @return Array the pilots list
4191
-	*
4192
-	*/
4188
+	  * Gets all owner that have flown over
4189
+	  *
4190
+	  * @return Array the pilots list
4191
+	  *
4192
+	  */
4193 4193
 	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196 4196
 		$filter_query = $this->getFilter($filters,true,true);
4197 4197
 		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4198 4198
 					FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL";
4199
-                if ($olderthanmonths > 0) {
4200
-            		if ($globalDBdriver == 'mysql') {
4199
+				if ($olderthanmonths > 0) {
4200
+					if ($globalDBdriver == 'mysql') {
4201 4201
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
4202 4202
 			} else {
4203 4203
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
4204 4204
 			}
4205 4205
 		}
4206
-                if ($sincedate != '') {
4207
-            		if ($globalDBdriver == 'mysql') {
4206
+				if ($sincedate != '') {
4207
+					if ($globalDBdriver == 'mysql') {
4208 4208
 				$query .= " AND spotter_output.date > '".$sincedate."' ";
4209 4209
 			} else {
4210 4210
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4255,26 +4255,26 @@  discard block
 block discarded – undo
4255 4255
 	}
4256 4256
 	
4257 4257
 	 /**
4258
-	* Gets all owner that have flown over
4259
-	*
4260
-	* @return Array the pilots list
4261
-	*
4262
-	*/
4258
+	  * Gets all owner that have flown over
4259
+	  *
4260
+	  * @return Array the pilots list
4261
+	  *
4262
+	  */
4263 4263
 	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266 4266
 		$filter_query = $this->getFilter($filters,true,true);
4267 4267
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4268 4268
 		 			FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL ";
4269
-                if ($olderthanmonths > 0) {
4270
-            		if ($globalDBdriver == 'mysql') {
4269
+				if ($olderthanmonths > 0) {
4270
+					if ($globalDBdriver == 'mysql') {
4271 4271
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
4272 4272
 			} else {
4273 4273
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
4274 4274
 			}
4275 4275
 		}
4276
-                if ($sincedate != '') {
4277
-            		if ($globalDBdriver == 'mysql') {
4276
+				if ($sincedate != '') {
4277
+					if ($globalDBdriver == 'mysql') {
4278 4278
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
4279 4279
 			} else {
4280 4280
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -4301,11 +4301,11 @@  discard block
 block discarded – undo
4301 4301
 	}
4302 4302
 
4303 4303
 	/**
4304
-	* Gets all airlines that have flown over by aircraft
4305
-	*
4306
-	* @return Array the airline list
4307
-	*
4308
-	*/
4304
+	 * Gets all airlines that have flown over by aircraft
4305
+	 *
4306
+	 * @return Array the airline list
4307
+	 *
4308
+	 */
4309 4309
 	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4310 4310
 	{
4311 4311
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4337,11 +4337,11 @@  discard block
 block discarded – undo
4337 4337
 
4338 4338
 
4339 4339
 	/**
4340
-	* Gets all airline countries that have flown over by aircraft
4341
-	*
4342
-	* @return Array the airline country list
4343
-	*
4344
-	*/
4340
+	 * Gets all airline countries that have flown over by aircraft
4341
+	 *
4342
+	 * @return Array the airline country list
4343
+	 *
4344
+	 */
4345 4345
 	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4346 4346
 	{
4347 4347
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
@@ -4373,11 +4373,11 @@  discard block
 block discarded – undo
4373 4373
 	
4374 4374
 	
4375 4375
 	/**
4376
-	* Gets all airlines that have flown over by airport
4377
-	*
4378
-	* @return Array the airline list
4379
-	*
4380
-	*/
4376
+	 * Gets all airlines that have flown over by airport
4377
+	 *
4378
+	 * @return Array the airline list
4379
+	 *
4380
+	 */
4381 4381
 	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4382 4382
 	{
4383 4383
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4408,11 +4408,11 @@  discard block
 block discarded – undo
4408 4408
 
4409 4409
 
4410 4410
 	/**
4411
-	* Gets all airline countries that have flown over by airport icao
4412
-	*
4413
-	* @return Array the airline country list
4414
-	*
4415
-	*/
4411
+	 * Gets all airline countries that have flown over by airport icao
4412
+	 *
4413
+	 * @return Array the airline country list
4414
+	 *
4415
+	 */
4416 4416
 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4417 4417
 	{
4418 4418
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4442,11 +4442,11 @@  discard block
 block discarded – undo
4442 4442
 
4443 4443
 
4444 4444
 	/**
4445
-	* Gets all airlines that have flown over by aircraft manufacturer
4446
-	*
4447
-	* @return Array the airline list
4448
-	*
4449
-	*/
4445
+	 * Gets all airlines that have flown over by aircraft manufacturer
4446
+	 *
4447
+	 * @return Array the airline list
4448
+	 *
4449
+	 */
4450 4450
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4451 4451
 	{
4452 4452
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4477,11 +4477,11 @@  discard block
 block discarded – undo
4477 4477
 
4478 4478
 
4479 4479
 	/**
4480
-	* Gets all airline countries that have flown over by aircraft manufacturer
4481
-	*
4482
-	* @return Array the airline country list
4483
-	*
4484
-	*/
4480
+	 * Gets all airline countries that have flown over by aircraft manufacturer
4481
+	 *
4482
+	 * @return Array the airline country list
4483
+	 *
4484
+	 */
4485 4485
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4486 4486
 	{
4487 4487
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4510,11 +4510,11 @@  discard block
 block discarded – undo
4510 4510
 
4511 4511
 
4512 4512
 	/**
4513
-	* Gets all airlines that have flown over by date
4514
-	*
4515
-	* @return Array the airline list
4516
-	*
4517
-	*/
4513
+	 * Gets all airlines that have flown over by date
4514
+	 *
4515
+	 * @return Array the airline list
4516
+	 *
4517
+	 */
4518 4518
 	public function countAllAirlinesByDate($date,$filters = array())
4519 4519
 	{
4520 4520
 		global $globalTimezone, $globalDBdriver;
@@ -4558,11 +4558,11 @@  discard block
 block discarded – undo
4558 4558
 	
4559 4559
 	
4560 4560
 	/**
4561
-	* Gets all airline countries that have flown over by date
4562
-	*
4563
-	* @return Array the airline country list
4564
-	*
4565
-	*/
4561
+	 * Gets all airline countries that have flown over by date
4562
+	 *
4563
+	 * @return Array the airline country list
4564
+	 *
4565
+	 */
4566 4566
 	public function countAllAirlineCountriesByDate($date,$filters = array())
4567 4567
 	{
4568 4568
 		global $globalTimezone, $globalDBdriver;
@@ -4605,11 +4605,11 @@  discard block
 block discarded – undo
4605 4605
 
4606 4606
 
4607 4607
 	/**
4608
-	* Gets all airlines that have flown over by ident/callsign
4609
-	*
4610
-	* @return Array the airline list
4611
-	*
4612
-	*/
4608
+	 * Gets all airlines that have flown over by ident/callsign
4609
+	 *
4610
+	 * @return Array the airline list
4611
+	 *
4612
+	 */
4613 4613
 	public function countAllAirlinesByIdent($ident,$filters = array())
4614 4614
 	{
4615 4615
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4626,11 +4626,11 @@  discard block
 block discarded – undo
4626 4626
 	}
4627 4627
 
4628 4628
 	/**
4629
-	* Gets all airlines by owner
4630
-	*
4631
-	* @return Array the airline list
4632
-	*
4633
-	*/
4629
+	 * Gets all airlines by owner
4630
+	 *
4631
+	 * @return Array the airline list
4632
+	 *
4633
+	 */
4634 4634
 	public function countAllAirlinesByOwner($owner,$filters = array())
4635 4635
 	{
4636 4636
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4647,11 +4647,11 @@  discard block
 block discarded – undo
4647 4647
 	}
4648 4648
 
4649 4649
 	/**
4650
-	* Gets flight duration by owner
4651
-	*
4652
-	* @return String Duration of all flights
4653
-	*
4654
-	*/
4650
+	 * Gets flight duration by owner
4651
+	 *
4652
+	 * @return String Duration of all flights
4653
+	 *
4654
+	 */
4655 4655
 	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4656 4656
 	{
4657 4657
 		global $globalDBdriver;
@@ -4698,11 +4698,11 @@  discard block
 block discarded – undo
4698 4698
 	}
4699 4699
 
4700 4700
 	/**
4701
-	* Count flights by owner
4702
-	*
4703
-	* @return String Duration of all flights
4704
-	*
4705
-	*/
4701
+	 * Count flights by owner
4702
+	 *
4703
+	 * @return String Duration of all flights
4704
+	 *
4705
+	 */
4706 4706
 	public function countFlightsByOwner($owner,$filters = array())
4707 4707
 	{
4708 4708
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4718,11 +4718,11 @@  discard block
 block discarded – undo
4718 4718
 	}
4719 4719
 
4720 4720
 	/**
4721
-	* Count flights by pilot
4722
-	*
4723
-	* @return String Duration of all flights
4724
-	*
4725
-	*/
4721
+	 * Count flights by pilot
4722
+	 *
4723
+	 * @return String Duration of all flights
4724
+	 *
4725
+	 */
4726 4726
 	public function countFlightsByPilot($pilot,$filters = array())
4727 4727
 	{
4728 4728
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4738,11 +4738,11 @@  discard block
 block discarded – undo
4738 4738
 	}
4739 4739
 
4740 4740
 	/**
4741
-	* Gets flight duration by pilot
4742
-	*
4743
-	* @return String Duration of all flights
4744
-	*
4745
-	*/
4741
+	 * Gets flight duration by pilot
4742
+	 *
4743
+	 * @return String Duration of all flights
4744
+	 *
4745
+	 */
4746 4746
 	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4747 4747
 	{
4748 4748
 		global $globalDBdriver;
@@ -4788,11 +4788,11 @@  discard block
 block discarded – undo
4788 4788
 	}
4789 4789
 
4790 4790
 	/**
4791
-	* Gets all airlines used by pilot
4792
-	*
4793
-	* @return Array the airline list
4794
-	*
4795
-	*/
4791
+	 * Gets all airlines used by pilot
4792
+	 *
4793
+	 * @return Array the airline list
4794
+	 *
4795
+	 */
4796 4796
 	public function countAllAirlinesByPilot($pilot,$filters = array())
4797 4797
 	{
4798 4798
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4809,11 +4809,11 @@  discard block
 block discarded – undo
4809 4809
 	}
4810 4810
 
4811 4811
 	/**
4812
-	* Gets all airlines that have flown over by route
4813
-	*
4814
-	* @return Array the airline list
4815
-	*
4816
-	*/
4812
+	 * Gets all airlines that have flown over by route
4813
+	 *
4814
+	 * @return Array the airline list
4815
+	 *
4816
+	 */
4817 4817
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4818 4818
 	{
4819 4819
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4845,11 +4845,11 @@  discard block
 block discarded – undo
4845 4845
 	}
4846 4846
 
4847 4847
 	/**
4848
-	* Gets all airline countries that have flown over by route
4849
-	*
4850
-	* @return Array the airline country list
4851
-	*
4852
-	*/
4848
+	 * Gets all airline countries that have flown over by route
4849
+	 *
4850
+	 * @return Array the airline country list
4851
+	 *
4852
+	 */
4853 4853
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4854 4854
 	{
4855 4855
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
 
4882 4882
 
4883 4883
 	/**
4884
-	* Gets all airlines that have flown over by country
4885
-	*
4886
-	* @return Array the airline list
4887
-	*
4888
-	*/
4884
+	 * Gets all airlines that have flown over by country
4885
+	 *
4886
+	 * @return Array the airline list
4887
+	 *
4888
+	 */
4889 4889
 	public function countAllAirlinesByCountry($country,$filters = array())
4890 4890
 	{
4891 4891
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4915,11 +4915,11 @@  discard block
 block discarded – undo
4915 4915
 
4916 4916
 
4917 4917
 	/**
4918
-	* Gets all airline countries that have flown over by country
4919
-	*
4920
-	* @return Array the airline country list
4921
-	*
4922
-	*/
4918
+	 * Gets all airline countries that have flown over by country
4919
+	 *
4920
+	 * @return Array the airline country list
4921
+	 *
4922
+	 */
4923 4923
 	public function countAllAirlineCountriesByCountry($country,$filters = array())
4924 4924
 	{
4925 4925
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4948,11 +4948,11 @@  discard block
 block discarded – undo
4948 4948
 
4949 4949
 
4950 4950
 	/**
4951
-	* Gets all airlines countries
4952
-	*
4953
-	* @return Array the airline country list
4954
-	*
4955
-	*/
4951
+	 * Gets all airlines countries
4952
+	 *
4953
+	 * @return Array the airline country list
4954
+	 *
4955
+	 */
4956 4956
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4957 4957
 	{
4958 4958
 		global $globalDBdriver;
@@ -5007,11 +5007,11 @@  discard block
 block discarded – undo
5007 5007
 	}
5008 5008
 
5009 5009
 	/**
5010
-	* Gets all number of flight over countries
5011
-	*
5012
-	* @return Array the airline country list
5013
-	*
5014
-	*/
5010
+	 * Gets all number of flight over countries
5011
+	 *
5012
+	 * @return Array the airline country list
5013
+	 *
5014
+	 */
5015 5015
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5016 5016
 	{
5017 5017
 		global $globalDBdriver;
@@ -5033,15 +5033,15 @@  discard block
 block discarded – undo
5033 5033
 		$SpotterLive = new SpotterLive();
5034 5034
 		$filter_query = $SpotterLive->getFilter($filters,true,true);
5035 5035
 		$filter_query .= ' over_country IS NOT NULL';
5036
-                if ($olderthanmonths > 0) {
5036
+				if ($olderthanmonths > 0) {
5037 5037
 			if ($globalDBdriver == 'mysql') {
5038 5038
 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5039 5039
 			} else {
5040 5040
 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5041 5041
 			}
5042 5042
 		}
5043
-                if ($sincedate != '') {
5044
-            		if ($globalDBdriver == 'mysql') {
5043
+				if ($sincedate != '') {
5044
+					if ($globalDBdriver == 'mysql') {
5045 5045
 				$filter_query .= " AND spotter_live.date > '".$sincedate."' ";
5046 5046
 			} else {
5047 5047
 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5071,11 +5071,11 @@  discard block
 block discarded – undo
5071 5071
 	
5072 5072
 	
5073 5073
 	/**
5074
-	* Gets all aircraft types that have flown over
5075
-	*
5076
-	* @return Array the aircraft list
5077
-	*
5078
-	*/
5074
+	 * Gets all aircraft types that have flown over
5075
+	 *
5076
+	 * @return Array the aircraft list
5077
+	 *
5078
+	 */
5079 5079
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5080 5080
 	{
5081 5081
 		global $globalDBdriver;
@@ -5145,11 +5145,11 @@  discard block
 block discarded – undo
5145 5145
 	}
5146 5146
 
5147 5147
 	/**
5148
-	* Gets all aircraft types that have flown over by airline
5149
-	*
5150
-	* @return Array the aircraft list
5151
-	*
5152
-	*/
5148
+	 * Gets all aircraft types that have flown over by airline
5149
+	 *
5150
+	 * @return Array the aircraft list
5151
+	 *
5152
+	 */
5153 5153
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5154 5154
 	{
5155 5155
 		global $globalDBdriver;
@@ -5220,11 +5220,11 @@  discard block
 block discarded – undo
5220 5220
 	}
5221 5221
 
5222 5222
 	/**
5223
-	* Gets all aircraft types that have flown over by months
5224
-	*
5225
-	* @return Array the aircraft list
5226
-	*
5227
-	*/
5223
+	 * Gets all aircraft types that have flown over by months
5224
+	 *
5225
+	 * @return Array the aircraft list
5226
+	 *
5227
+	 */
5228 5228
 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5229 5229
 	{
5230 5230
 		global $globalDBdriver;
@@ -5268,11 +5268,11 @@  discard block
 block discarded – undo
5268 5268
 
5269 5269
 
5270 5270
 	/**
5271
-	* Gets all aircraft registration that have flown over by aircaft icao
5272
-	*
5273
-	* @return Array the aircraft list
5274
-	*
5275
-	*/
5271
+	 * Gets all aircraft registration that have flown over by aircaft icao
5272
+	 *
5273
+	 * @return Array the aircraft list
5274
+	 *
5275
+	 */
5276 5276
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5277 5277
 	{
5278 5278
 		$Image = new Image($this->db);
@@ -5311,11 +5311,11 @@  discard block
 block discarded – undo
5311 5311
 
5312 5312
 
5313 5313
 	/**
5314
-	* Gets all aircraft types that have flown over by airline icao
5315
-	*
5316
-	* @return Array the aircraft list
5317
-	*
5318
-	*/
5314
+	 * Gets all aircraft types that have flown over by airline icao
5315
+	 *
5316
+	 * @return Array the aircraft list
5317
+	 *
5318
+	 */
5319 5319
 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5320 5320
 	{
5321 5321
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5344,11 +5344,11 @@  discard block
 block discarded – undo
5344 5344
 
5345 5345
 
5346 5346
 	/**
5347
-	* Gets all aircraft registration that have flown over by airline icao
5348
-	*
5349
-	* @return Array the aircraft list
5350
-	*
5351
-	*/
5347
+	 * Gets all aircraft registration that have flown over by airline icao
5348
+	 *
5349
+	 * @return Array the aircraft list
5350
+	 *
5351
+	 */
5352 5352
 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5353 5353
 	{
5354 5354
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5386,11 +5386,11 @@  discard block
 block discarded – undo
5386 5386
 
5387 5387
 
5388 5388
 	/**
5389
-	* Gets all aircraft manufacturer that have flown over by airline icao
5390
-	*
5391
-	* @return Array the aircraft list
5392
-	*
5393
-	*/
5389
+	 * Gets all aircraft manufacturer that have flown over by airline icao
5390
+	 *
5391
+	 * @return Array the aircraft list
5392
+	 *
5393
+	 */
5394 5394
 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5395 5395
 	{
5396 5396
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5418,11 +5418,11 @@  discard block
 block discarded – undo
5418 5418
 
5419 5419
 
5420 5420
 	/**
5421
-	* Gets all aircraft types that have flown over by airline icao
5422
-	*
5423
-	* @return Array the aircraft list
5424
-	*
5425
-	*/
5421
+	 * Gets all aircraft types that have flown over by airline icao
5422
+	 *
5423
+	 * @return Array the aircraft list
5424
+	 *
5425
+	 */
5426 5426
 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5427 5427
 	{
5428 5428
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5451,11 +5451,11 @@  discard block
 block discarded – undo
5451 5451
 
5452 5452
 
5453 5453
 	/**
5454
-	* Gets all aircraft registration that have flown over by airport icao
5455
-	*
5456
-	* @return Array the aircraft list
5457
-	*
5458
-	*/
5454
+	 * Gets all aircraft registration that have flown over by airport icao
5455
+	 *
5456
+	 * @return Array the aircraft list
5457
+	 *
5458
+	 */
5459 5459
 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5460 5460
 	{
5461 5461
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5492,11 +5492,11 @@  discard block
 block discarded – undo
5492 5492
 	
5493 5493
 	
5494 5494
 	/**
5495
-	* Gets all aircraft manufacturer that have flown over by airport icao
5496
-	*
5497
-	* @return Array the aircraft list
5498
-	*
5499
-	*/
5495
+	 * Gets all aircraft manufacturer that have flown over by airport icao
5496
+	 *
5497
+	 * @return Array the aircraft list
5498
+	 *
5499
+	 */
5500 5500
 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5501 5501
 	{
5502 5502
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5522,11 +5522,11 @@  discard block
 block discarded – undo
5522 5522
 	}
5523 5523
 
5524 5524
 	/**
5525
-	* Gets all aircraft types that have flown over by aircraft manufacturer
5526
-	*
5527
-	* @return Array the aircraft list
5528
-	*
5529
-	*/
5525
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
5526
+	 *
5527
+	 * @return Array the aircraft list
5528
+	 *
5529
+	 */
5530 5530
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5531 5531
 	{
5532 5532
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5553,11 +5553,11 @@  discard block
 block discarded – undo
5553 5553
 
5554 5554
 
5555 5555
 	/**
5556
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
5557
-	*
5558
-	* @return Array the aircraft list
5559
-	*
5560
-	*/
5556
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
5557
+	 *
5558
+	 * @return Array the aircraft list
5559
+	 *
5560
+	 */
5561 5561
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5562 5562
 	{
5563 5563
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5593,11 +5593,11 @@  discard block
 block discarded – undo
5593 5593
 	}
5594 5594
 
5595 5595
 	/**
5596
-	* Gets all aircraft types that have flown over by date
5597
-	*
5598
-	* @return Array the aircraft list
5599
-	*
5600
-	*/
5596
+	 * Gets all aircraft types that have flown over by date
5597
+	 *
5598
+	 * @return Array the aircraft list
5599
+	 *
5600
+	 */
5601 5601
 	public function countAllAircraftTypesByDate($date,$filters = array())
5602 5602
 	{
5603 5603
 		global $globalTimezone, $globalDBdriver;
@@ -5639,11 +5639,11 @@  discard block
 block discarded – undo
5639 5639
 
5640 5640
 
5641 5641
 	/**
5642
-	* Gets all aircraft registration that have flown over by date
5643
-	*
5644
-	* @return Array the aircraft list
5645
-	*
5646
-	*/
5642
+	 * Gets all aircraft registration that have flown over by date
5643
+	 *
5644
+	 * @return Array the aircraft list
5645
+	 *
5646
+	 */
5647 5647
 	public function countAllAircraftRegistrationByDate($date,$filters = array())
5648 5648
 	{
5649 5649
 		global $globalTimezone, $globalDBdriver;
@@ -5694,11 +5694,11 @@  discard block
 block discarded – undo
5694 5694
 
5695 5695
 
5696 5696
 	/**
5697
-	* Gets all aircraft manufacturer that have flown over by date
5698
-	*
5699
-	* @return Array the aircraft manufacturer list
5700
-	*
5701
-	*/
5697
+	 * Gets all aircraft manufacturer that have flown over by date
5698
+	 *
5699
+	 * @return Array the aircraft manufacturer list
5700
+	 *
5701
+	 */
5702 5702
 	public function countAllAircraftManufacturerByDate($date,$filters = array())
5703 5703
 	{
5704 5704
 		global $globalTimezone, $globalDBdriver;
@@ -5740,11 +5740,11 @@  discard block
 block discarded – undo
5740 5740
 
5741 5741
 
5742 5742
 	/**
5743
-	* Gets all aircraft types that have flown over by ident/callsign
5744
-	*
5745
-	* @return Array the aircraft list
5746
-	*
5747
-	*/
5743
+	 * Gets all aircraft types that have flown over by ident/callsign
5744
+	 *
5745
+	 * @return Array the aircraft list
5746
+	 *
5747
+	 */
5748 5748
 	public function countAllAircraftTypesByIdent($ident,$filters = array())
5749 5749
 	{
5750 5750
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5772,11 +5772,11 @@  discard block
 block discarded – undo
5772 5772
 	}
5773 5773
 
5774 5774
 	/**
5775
-	* Gets all aircraft types that have flown over by pilot
5776
-	*
5777
-	* @return Array the aircraft list
5778
-	*
5779
-	*/
5775
+	 * Gets all aircraft types that have flown over by pilot
5776
+	 *
5777
+	 * @return Array the aircraft list
5778
+	 *
5779
+	 */
5780 5780
 	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5781 5781
 	{
5782 5782
 		global $globalDBdriver;
@@ -5822,11 +5822,11 @@  discard block
 block discarded – undo
5822 5822
 	}
5823 5823
 
5824 5824
 	/**
5825
-	* Gets all aircraft types that have flown over by owner
5826
-	*
5827
-	* @return Array the aircraft list
5828
-	*
5829
-	*/
5825
+	 * Gets all aircraft types that have flown over by owner
5826
+	 *
5827
+	 * @return Array the aircraft list
5828
+	 *
5829
+	 */
5830 5830
 	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5831 5831
 	{
5832 5832
 		global $globalDBdriver;
@@ -5871,11 +5871,11 @@  discard block
 block discarded – undo
5871 5871
 	}
5872 5872
 
5873 5873
 	/**
5874
-	* Gets all aircraft registration that have flown over by ident/callsign
5875
-	*
5876
-	* @return Array the aircraft list
5877
-	*
5878
-	*/
5874
+	 * Gets all aircraft registration that have flown over by ident/callsign
5875
+	 *
5876
+	 * @return Array the aircraft list
5877
+	 *
5878
+	 */
5879 5879
 	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5880 5880
 	{
5881 5881
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5914,11 +5914,11 @@  discard block
 block discarded – undo
5914 5914
 	}
5915 5915
 
5916 5916
 	/**
5917
-	* Gets all aircraft registration that have flown over by owner
5918
-	*
5919
-	* @return Array the aircraft list
5920
-	*
5921
-	*/
5917
+	 * Gets all aircraft registration that have flown over by owner
5918
+	 *
5919
+	 * @return Array the aircraft list
5920
+	 *
5921
+	 */
5922 5922
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5923 5923
 	{
5924 5924
 		global $globalDBdriver;
@@ -5989,11 +5989,11 @@  discard block
 block discarded – undo
5989 5989
 	}
5990 5990
 
5991 5991
 	/**
5992
-	* Gets all aircraft registration that have flown over by pilot
5993
-	*
5994
-	* @return Array the aircraft list
5995
-	*
5996
-	*/
5992
+	 * Gets all aircraft registration that have flown over by pilot
5993
+	 *
5994
+	 * @return Array the aircraft list
5995
+	 *
5996
+	 */
5997 5997
 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5998 5998
 	{
5999 5999
 		global $globalDBdriver;
@@ -6065,11 +6065,11 @@  discard block
 block discarded – undo
6065 6065
 
6066 6066
 
6067 6067
 	/**
6068
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
6069
-	*
6070
-	* @return Array the aircraft manufacturer list
6071
-	*
6072
-	*/
6068
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
6069
+	 *
6070
+	 * @return Array the aircraft manufacturer list
6071
+	 *
6072
+	 */
6073 6073
 	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6074 6074
 	{
6075 6075
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6094,11 +6094,11 @@  discard block
 block discarded – undo
6094 6094
 	}
6095 6095
 
6096 6096
 	/**
6097
-	* Gets all aircraft manufacturer that have flown over by owner
6098
-	*
6099
-	* @return Array the aircraft manufacturer list
6100
-	*
6101
-	*/
6097
+	 * Gets all aircraft manufacturer that have flown over by owner
6098
+	 *
6099
+	 * @return Array the aircraft manufacturer list
6100
+	 *
6101
+	 */
6102 6102
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6103 6103
 	{
6104 6104
 		global $globalDBdriver;
@@ -6146,11 +6146,11 @@  discard block
 block discarded – undo
6146 6146
 	}
6147 6147
 
6148 6148
 	/**
6149
-	* Gets all aircraft manufacturer that have flown over by pilot
6150
-	*
6151
-	* @return Array the aircraft manufacturer list
6152
-	*
6153
-	*/
6149
+	 * Gets all aircraft manufacturer that have flown over by pilot
6150
+	 *
6151
+	 * @return Array the aircraft manufacturer list
6152
+	 *
6153
+	 */
6154 6154
 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6155 6155
 	{
6156 6156
 		global $globalDBdriver;
@@ -6199,11 +6199,11 @@  discard block
 block discarded – undo
6199 6199
 
6200 6200
 
6201 6201
 	/**
6202
-	* Gets all aircraft types that have flown over by route
6203
-	*
6204
-	* @return Array the aircraft list
6205
-	*
6206
-	*/
6202
+	 * Gets all aircraft types that have flown over by route
6203
+	 *
6204
+	 * @return Array the aircraft list
6205
+	 *
6206
+	 */
6207 6207
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6208 6208
 	{
6209 6209
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6232,11 +6232,11 @@  discard block
 block discarded – undo
6232 6232
 	}
6233 6233
 
6234 6234
 	/**
6235
-	* Gets all aircraft registration that have flown over by route
6236
-	*
6237
-	* @return Array the aircraft list
6238
-	*
6239
-	*/
6235
+	 * Gets all aircraft registration that have flown over by route
6236
+	 *
6237
+	 * @return Array the aircraft list
6238
+	 *
6239
+	 */
6240 6240
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6241 6241
 	{
6242 6242
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6278,11 +6278,11 @@  discard block
 block discarded – undo
6278 6278
 	
6279 6279
 	
6280 6280
 	/**
6281
-	* Gets all aircraft manufacturer that have flown over by route
6282
-	*
6283
-	* @return Array the aircraft manufacturer list
6284
-	*
6285
-	*/
6281
+	 * Gets all aircraft manufacturer that have flown over by route
6282
+	 *
6283
+	 * @return Array the aircraft manufacturer list
6284
+	 *
6285
+	 */
6286 6286
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6287 6287
 	{
6288 6288
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6316,11 +6316,11 @@  discard block
 block discarded – undo
6316 6316
 	
6317 6317
 	
6318 6318
 	/**
6319
-	* Gets all aircraft types that have flown over by country
6320
-	*
6321
-	* @return Array the aircraft list
6322
-	*
6323
-	*/
6319
+	 * Gets all aircraft types that have flown over by country
6320
+	 *
6321
+	 * @return Array the aircraft list
6322
+	 *
6323
+	 */
6324 6324
 	public function countAllAircraftTypesByCountry($country,$filters = array())
6325 6325
 	{
6326 6326
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6351,11 +6351,11 @@  discard block
 block discarded – undo
6351 6351
 
6352 6352
 
6353 6353
 	/**
6354
-	* Gets all aircraft registration that have flown over by country
6355
-	*
6356
-	* @return Array the aircraft list
6357
-	*
6358
-	*/
6354
+	 * Gets all aircraft registration that have flown over by country
6355
+	 *
6356
+	 * @return Array the aircraft list
6357
+	 *
6358
+	 */
6359 6359
 	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6360 6360
 	{
6361 6361
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6395,11 +6395,11 @@  discard block
 block discarded – undo
6395 6395
 	
6396 6396
 	
6397 6397
 	/**
6398
-	* Gets all aircraft manufacturer that have flown over by country
6399
-	*
6400
-	* @return Array the aircraft manufacturer list
6401
-	*
6402
-	*/
6398
+	 * Gets all aircraft manufacturer that have flown over by country
6399
+	 *
6400
+	 * @return Array the aircraft manufacturer list
6401
+	 *
6402
+	 */
6403 6403
 	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6404 6404
 	{
6405 6405
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6430,18 +6430,18 @@  discard block
 block discarded – undo
6430 6430
 	
6431 6431
 	
6432 6432
 	/**
6433
-	* Gets all aircraft manufacturers that have flown over
6434
-	*
6435
-	* @return Array the aircraft list
6436
-	*
6437
-	*/
6433
+	 * Gets all aircraft manufacturers that have flown over
6434
+	 *
6435
+	 * @return Array the aircraft list
6436
+	 *
6437
+	 */
6438 6438
 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6439 6439
 	{
6440 6440
 		global $globalDBdriver;
6441 6441
 		$filter_query = $this->getFilter($filters,true,true);
6442 6442
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443 6443
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6444
-                $query_values = array();
6444
+				$query_values = array();
6445 6445
 		if ($year != '') {
6446 6446
 			if ($globalDBdriver == 'mysql') {
6447 6447
 				$query .= " AND YEAR(spotter_output.date) = :year";
@@ -6494,11 +6494,11 @@  discard block
 block discarded – undo
6494 6494
 	
6495 6495
 	
6496 6496
 	/**
6497
-	* Gets all aircraft registrations that have flown over
6498
-	*
6499
-	* @return Array the aircraft list
6500
-	*
6501
-	*/
6497
+	 * Gets all aircraft registrations that have flown over
6498
+	 *
6499
+	 * @return Array the aircraft list
6500
+	 *
6501
+	 */
6502 6502
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6503 6503
 	{
6504 6504
 		global $globalDBdriver;
@@ -6506,15 +6506,15 @@  discard block
 block discarded – undo
6506 6506
 		$filter_query = $this->getFilter($filters,true,true);
6507 6507
 		$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    
6508 6508
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6509
-                if ($olderthanmonths > 0) {
6510
-            		if ($globalDBdriver == 'mysql') {
6509
+				if ($olderthanmonths > 0) {
6510
+					if ($globalDBdriver == 'mysql') {
6511 6511
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6512 6512
 			} else {
6513 6513
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6514 6514
 			}
6515 6515
 		}
6516
-                if ($sincedate != '') {
6517
-            		if ($globalDBdriver == 'mysql') {
6516
+				if ($sincedate != '') {
6517
+					if ($globalDBdriver == 'mysql') {
6518 6518
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6519 6519
 			} else {
6520 6520
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6579,11 +6579,11 @@  discard block
 block discarded – undo
6579 6579
 
6580 6580
 
6581 6581
 	/**
6582
-	* Gets all aircraft registrations that have flown over
6583
-	*
6584
-	* @return Array the aircraft list
6585
-	*
6586
-	*/
6582
+	 * Gets all aircraft registrations that have flown over
6583
+	 *
6584
+	 * @return Array the aircraft list
6585
+	 *
6586
+	 */
6587 6587
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6588 6588
 	{
6589 6589
 		global $globalDBdriver;
@@ -6591,15 +6591,15 @@  discard block
 block discarded – undo
6591 6591
 		$Image = new Image($this->db);
6592 6592
 		$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    
6593 6593
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6594
-                if ($olderthanmonths > 0) {
6595
-            		if ($globalDBdriver == 'mysql') {
6594
+				if ($olderthanmonths > 0) {
6595
+					if ($globalDBdriver == 'mysql') {
6596 6596
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6597 6597
 			} else {
6598 6598
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6599 6599
 			}
6600 6600
 		}
6601
-                if ($sincedate != '') {
6602
-            		if ($globalDBdriver == 'mysql') {
6601
+				if ($sincedate != '') {
6602
+					if ($globalDBdriver == 'mysql') {
6603 6603
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6604 6604
 			} else {
6605 6605
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6608,7 +6608,7 @@  discard block
 block discarded – undo
6608 6608
 
6609 6609
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6610 6610
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6611
-                $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";
6611
+				$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";
6612 6612
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6613 6613
 		
6614 6614
 		$sth = $this->db->prepare($query);
@@ -6640,26 +6640,26 @@  discard block
 block discarded – undo
6640 6640
 	
6641 6641
 	
6642 6642
 	/**
6643
-	* Gets all departure airports of the airplanes that have flown over
6644
-	*
6645
-	* @return Array the airport list
6646
-	*
6647
-	*/
6643
+	 * Gets all departure airports of the airplanes that have flown over
6644
+	 *
6645
+	 * @return Array the airport list
6646
+	 *
6647
+	 */
6648 6648
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6649 6649
 	{
6650 6650
 		global $globalDBdriver;
6651 6651
 		$filter_query = $this->getFilter($filters,true,true);
6652 6652
 		$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 
6653 6653
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6654
-                if ($olderthanmonths > 0) {
6655
-            		if ($globalDBdriver == 'mysql') {
6654
+				if ($olderthanmonths > 0) {
6655
+					if ($globalDBdriver == 'mysql') {
6656 6656
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6657 6657
 			} else {
6658 6658
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6659 6659
 			}
6660
-                }
6661
-                if ($sincedate != '') {
6662
-            		if ($globalDBdriver == 'mysql') {
6660
+				}
6661
+				if ($sincedate != '') {
6662
+					if ($globalDBdriver == 'mysql') {
6663 6663
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6664 6664
 			} else {
6665 6665
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6693,7 +6693,7 @@  discard block
 block discarded – undo
6693 6693
 				$query_values = array_merge($query_values,array(':day' => $day));
6694 6694
 			}
6695 6695
 		}
6696
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6696
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6697 6697
 				ORDER BY airport_departure_icao_count DESC";
6698 6698
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6699 6699
 
@@ -6716,35 +6716,35 @@  discard block
 block discarded – undo
6716 6716
 	}
6717 6717
 
6718 6718
 	/**
6719
-	* Gets all departure airports of the airplanes that have flown over
6720
-	*
6721
-	* @return Array the airport list
6722
-	*
6723
-	*/
6719
+	 * Gets all departure airports of the airplanes that have flown over
6720
+	 *
6721
+	 * @return Array the airport list
6722
+	 *
6723
+	 */
6724 6724
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6725 6725
 	{
6726 6726
 		global $globalDBdriver;
6727 6727
 		$filter_query = $this->getFilter($filters,true,true);
6728 6728
 		$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 
6729 6729
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' ";
6730
-                if ($olderthanmonths > 0) {
6731
-            		if ($globalDBdriver == 'mysql') {
6730
+				if ($olderthanmonths > 0) {
6731
+					if ($globalDBdriver == 'mysql') {
6732 6732
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6733 6733
 			} else {
6734 6734
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6735 6735
 			}
6736
-                }
6737
-                if ($sincedate != '') {
6738
-            		if ($globalDBdriver == 'mysql') {
6736
+				}
6737
+				if ($sincedate != '') {
6738
+					if ($globalDBdriver == 'mysql') {
6739 6739
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6740 6740
 			} else {
6741 6741
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6742 6742
 			}
6743 6743
 		}
6744 6744
 
6745
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
-                $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
6745
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6746
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6747
+				$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
6748 6748
 				ORDER BY airport_departure_icao_count DESC";
6749 6749
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6750 6750
       
@@ -6769,26 +6769,26 @@  discard block
 block discarded – undo
6769 6769
 	}
6770 6770
 
6771 6771
 	/**
6772
-	* Gets all detected departure airports of the airplanes that have flown over
6773
-	*
6774
-	* @return Array the airport list
6775
-	*
6776
-	*/
6772
+	 * Gets all detected departure airports of the airplanes that have flown over
6773
+	 *
6774
+	 * @return Array the airport list
6775
+	 *
6776
+	 */
6777 6777
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6778 6778
 	{
6779 6779
 		global $globalDBdriver;
6780 6780
 		$filter_query = $this->getFilter($filters,true,true);
6781 6781
 		$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
6782 6782
 				FROM airport, spotter_output".$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";
6783
-                if ($olderthanmonths > 0) {
6784
-            		if ($globalDBdriver == 'mysql') {
6783
+				if ($olderthanmonths > 0) {
6784
+					if ($globalDBdriver == 'mysql') {
6785 6785
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6786 6786
 			} else {
6787 6787
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6788 6788
 			}
6789
-                }
6790
-                if ($sincedate != '') {
6791
-            		if ($globalDBdriver == 'mysql') {
6789
+				}
6790
+				if ($sincedate != '') {
6791
+					if ($globalDBdriver == 'mysql') {
6792 6792
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6793 6793
 			} else {
6794 6794
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6822,10 +6822,10 @@  discard block
 block discarded – undo
6822 6822
 				$query_values = array_merge($query_values,array(':day' => $day));
6823 6823
 			}
6824 6824
 		}
6825
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6825
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6826 6826
 				ORDER BY airport_departure_icao_count DESC";
6827 6827
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6828
-    		//echo $query;
6828
+			//echo $query;
6829 6829
 		$sth = $this->db->prepare($query);
6830 6830
 		$sth->execute($query_values);
6831 6831
       
@@ -6846,35 +6846,35 @@  discard block
 block discarded – undo
6846 6846
 	}
6847 6847
 	
6848 6848
 	/**
6849
-	* Gets all detected departure airports of the airplanes that have flown over
6850
-	*
6851
-	* @return Array the airport list
6852
-	*
6853
-	*/
6849
+	 * Gets all detected departure airports of the airplanes that have flown over
6850
+	 *
6851
+	 * @return Array the airport list
6852
+	 *
6853
+	 */
6854 6854
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6855 6855
 	{
6856 6856
 		global $globalDBdriver;
6857 6857
 		$filter_query = $this->getFilter($filters,true,true);
6858 6858
 		$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
6859 6859
 				FROM airport, spotter_output".$filter_query." 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 ";
6860
-                if ($olderthanmonths > 0) {
6861
-            		if ($globalDBdriver == 'mysql') {
6860
+				if ($olderthanmonths > 0) {
6861
+					if ($globalDBdriver == 'mysql') {
6862 6862
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6863 6863
 			} else {
6864 6864
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6865 6865
 			}
6866
-                }
6867
-                if ($sincedate != '') {
6868
-            		if ($globalDBdriver == 'mysql') {
6866
+				}
6867
+				if ($sincedate != '') {
6868
+					if ($globalDBdriver == 'mysql') {
6869 6869
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6870 6870
 			} else {
6871 6871
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
6872 6872
 			}
6873 6873
 		}
6874 6874
 
6875
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6875
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6876
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6877
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6878 6878
 				ORDER BY airport_departure_icao_count DESC";
6879 6879
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6880 6880
       
@@ -6899,11 +6899,11 @@  discard block
 block discarded – undo
6899 6899
 	}	
6900 6900
 	
6901 6901
 	/**
6902
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
-	*
6904
-	* @return Array the airport list
6905
-	*
6906
-	*/
6902
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
6903
+	 *
6904
+	 * @return Array the airport list
6905
+	 *
6906
+	 */
6907 6907
 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6908 6908
 	{
6909 6909
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6937,11 +6937,11 @@  discard block
 block discarded – undo
6937 6937
 	
6938 6938
 	
6939 6939
 	/**
6940
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
-	*
6942
-	* @return Array the airport list
6943
-	*
6944
-	*/
6940
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6941
+	 *
6942
+	 * @return Array the airport list
6943
+	 *
6944
+	 */
6945 6945
 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6946 6946
 	{
6947 6947
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6972,11 +6972,11 @@  discard block
 block discarded – undo
6972 6972
 	
6973 6973
 	
6974 6974
 	/**
6975
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
-	*
6977
-	* @return Array the airport list
6978
-	*
6979
-	*/
6975
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6976
+	 *
6977
+	 * @return Array the airport list
6978
+	 *
6979
+	 */
6980 6980
 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6981 6981
 	{
6982 6982
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7009,11 +7009,11 @@  discard block
 block discarded – undo
7009 7009
 	
7010 7010
 	
7011 7011
 	/**
7012
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
-	*
7014
-	* @return Array the airport list
7015
-	*
7016
-	*/
7012
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7013
+	 *
7014
+	 * @return Array the airport list
7015
+	 *
7016
+	 */
7017 7017
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7018 7018
 	{
7019 7019
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7043,11 +7043,11 @@  discard block
 block discarded – undo
7043 7043
 	
7044 7044
 	
7045 7045
 	/**
7046
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
-	*
7048
-	* @return Array the airport list
7049
-	*
7050
-	*/
7046
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7047
+	 *
7048
+	 * @return Array the airport list
7049
+	 *
7050
+	 */
7051 7051
 	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7052 7052
 	{
7053 7053
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7080,11 +7080,11 @@  discard block
 block discarded – undo
7080 7080
 	
7081 7081
 	
7082 7082
 	/**
7083
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
-	*
7085
-	* @return Array the airport list
7086
-	*
7087
-	*/
7083
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7084
+	 *
7085
+	 * @return Array the airport list
7086
+	 *
7087
+	 */
7088 7088
 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7089 7089
 	{
7090 7090
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7114,11 +7114,11 @@  discard block
 block discarded – undo
7114 7114
 	
7115 7115
 	
7116 7116
 	/**
7117
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
-	*
7119
-	* @return Array the airport list
7120
-	*
7121
-	*/
7117
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7118
+	 *
7119
+	 * @return Array the airport list
7120
+	 *
7121
+	 */
7122 7122
 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7123 7123
 	{
7124 7124
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7151,11 +7151,11 @@  discard block
 block discarded – undo
7151 7151
 	
7152 7152
 	
7153 7153
 	/**
7154
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
-	*
7156
-	* @return Array the airport list
7157
-	*
7158
-	*/
7154
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7155
+	 *
7156
+	 * @return Array the airport list
7157
+	 *
7158
+	 */
7159 7159
 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7160 7160
 	{
7161 7161
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7186,11 +7186,11 @@  discard block
 block discarded – undo
7186 7186
 	
7187 7187
 	
7188 7188
 	/**
7189
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
-	*
7191
-	* @return Array the airport list
7192
-	*
7193
-	*/
7189
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7190
+	 *
7191
+	 * @return Array the airport list
7192
+	 *
7193
+	 */
7194 7194
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7195 7195
 	{
7196 7196
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7223,11 +7223,11 @@  discard block
 block discarded – undo
7223 7223
 	
7224 7224
 	
7225 7225
 	/**
7226
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
-	*
7228
-	* @return Array the airport list
7229
-	*
7230
-	*/
7226
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7227
+	 *
7228
+	 * @return Array the airport list
7229
+	 *
7230
+	 */
7231 7231
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7232 7232
 	{
7233 7233
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7257,11 +7257,11 @@  discard block
 block discarded – undo
7257 7257
 	
7258 7258
 	
7259 7259
 	/**
7260
-	* Gets all departure airports of the airplanes that have flown over based on a date
7261
-	*
7262
-	* @return Array the airport list
7263
-	*
7264
-	*/
7260
+	 * Gets all departure airports of the airplanes that have flown over based on a date
7261
+	 *
7262
+	 * @return Array the airport list
7263
+	 *
7264
+	 */
7265 7265
 	public function countAllDepartureAirportsByDate($date,$filters = array())
7266 7266
 	{
7267 7267
 		global $globalTimezone, $globalDBdriver;
@@ -7307,11 +7307,11 @@  discard block
 block discarded – undo
7307 7307
 	
7308 7308
 	
7309 7309
 	/**
7310
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
7311
-	*
7312
-	* @return Array the airport list
7313
-	*
7314
-	*/
7310
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
7311
+	 *
7312
+	 * @return Array the airport list
7313
+	 *
7314
+	 */
7315 7315
 	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7316 7316
 	{
7317 7317
 		global $globalTimezone, $globalDBdriver;
@@ -7354,11 +7354,11 @@  discard block
 block discarded – undo
7354 7354
 	
7355 7355
 	
7356 7356
 	/**
7357
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
-	*
7359
-	* @return Array the airport list
7360
-	*
7361
-	*/
7357
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7358
+	 *
7359
+	 * @return Array the airport list
7360
+	 *
7361
+	 */
7362 7362
 	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7363 7363
 	{
7364 7364
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7390,11 +7390,11 @@  discard block
 block discarded – undo
7390 7390
 	}
7391 7391
 	
7392 7392
 	/**
7393
-	* Gets all departure airports of the airplanes that have flown over based on a owner
7394
-	*
7395
-	* @return Array the airport list
7396
-	*
7397
-	*/
7393
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
7394
+	 *
7395
+	 * @return Array the airport list
7396
+	 *
7397
+	 */
7398 7398
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7399 7399
 	{
7400 7400
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7426,11 +7426,11 @@  discard block
 block discarded – undo
7426 7426
 	}
7427 7427
 	
7428 7428
 	/**
7429
-	* Gets all departure airports of the airplanes that have flown over based on a pilot
7430
-	*
7431
-	* @return Array the airport list
7432
-	*
7433
-	*/
7429
+	 * Gets all departure airports of the airplanes that have flown over based on a pilot
7430
+	 *
7431
+	 * @return Array the airport list
7432
+	 *
7433
+	 */
7434 7434
 	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7435 7435
 	{
7436 7436
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7463,11 +7463,11 @@  discard block
 block discarded – undo
7463 7463
 	
7464 7464
 	
7465 7465
 	/**
7466
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
-	*
7468
-	* @return Array the airport list
7469
-	*
7470
-	*/
7466
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7467
+	 *
7468
+	 * @return Array the airport list
7469
+	 *
7470
+	 */
7471 7471
 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7472 7472
 	{
7473 7473
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7496,11 +7496,11 @@  discard block
 block discarded – undo
7496 7496
 	}
7497 7497
 	
7498 7498
 	/**
7499
-	* Gets all departure airports by country of the airplanes that have flown over based on owner
7500
-	*
7501
-	* @return Array the airport list
7502
-	*
7503
-	*/
7499
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
7500
+	 *
7501
+	 * @return Array the airport list
7502
+	 *
7503
+	 */
7504 7504
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7505 7505
 	{
7506 7506
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7516,11 +7516,11 @@  discard block
 block discarded – undo
7516 7516
 	}
7517 7517
 	
7518 7518
 	/**
7519
-	* Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
-	*
7521
-	* @return Array the airport list
7522
-	*
7523
-	*/
7519
+	 * Gets all departure airports by country of the airplanes that have flown over based on pilot
7520
+	 *
7521
+	 * @return Array the airport list
7522
+	 *
7523
+	 */
7524 7524
 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7525 7525
 	{
7526 7526
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7538,11 +7538,11 @@  discard block
 block discarded – undo
7538 7538
 	
7539 7539
 	
7540 7540
 	/**
7541
-	* Gets all departure airports of the airplanes that have flown over based on a country
7542
-	*
7543
-	* @return Array the airport list
7544
-	*
7545
-	*/
7541
+	 * Gets all departure airports of the airplanes that have flown over based on a country
7542
+	 *
7543
+	 * @return Array the airport list
7544
+	 *
7545
+	 */
7546 7546
 	public function countAllDepartureAirportsByCountry($country,$filters = array())
7547 7547
 	{
7548 7548
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7576,11 +7576,11 @@  discard block
 block discarded – undo
7576 7576
 
7577 7577
 
7578 7578
 	/**
7579
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
-	*
7581
-	* @return Array the airport list
7582
-	*
7583
-	*/
7579
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7580
+	 *
7581
+	 * @return Array the airport list
7582
+	 *
7583
+	 */
7584 7584
 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7585 7585
 	{
7586 7586
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7610,31 +7610,31 @@  discard block
 block discarded – undo
7610 7610
 	
7611 7611
 
7612 7612
 	/**
7613
-	* Gets all arrival airports of the airplanes that have flown over
7614
-	*
7615
-	* @param Boolean $limit Limit result to 10 or not
7616
-	* @param Integer $olderthanmonths Only show result older than x months
7617
-	* @param String $sincedate Only show result since x date
7618
-	* @param Boolean $icaoaskey Show result by ICAO
7619
-	* @param Array $filters Filter used here
7620
-	* @return Array the airport list
7621
-	*
7622
-	*/
7613
+	 * Gets all arrival airports of the airplanes that have flown over
7614
+	 *
7615
+	 * @param Boolean $limit Limit result to 10 or not
7616
+	 * @param Integer $olderthanmonths Only show result older than x months
7617
+	 * @param String $sincedate Only show result since x date
7618
+	 * @param Boolean $icaoaskey Show result by ICAO
7619
+	 * @param Array $filters Filter used here
7620
+	 * @return Array the airport list
7621
+	 *
7622
+	 */
7623 7623
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7624 7624
 	{
7625 7625
 		global $globalDBdriver;
7626 7626
 		$filter_query = $this->getFilter($filters,true,true);
7627 7627
 		$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 
7628 7628
 				FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7629
-                if ($olderthanmonths > 0) {
7630
-            		if ($globalDBdriver == 'mysql') {
7629
+				if ($olderthanmonths > 0) {
7630
+					if ($globalDBdriver == 'mysql') {
7631 7631
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7632 7632
 			} else {
7633 7633
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7634 7634
 			}
7635 7635
 		}
7636
-                if ($sincedate != '') {
7637
-            		if ($globalDBdriver == 'mysql') {
7636
+				if ($sincedate != '') {
7637
+					if ($globalDBdriver == 'mysql') {
7638 7638
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7639 7639
 			} else {
7640 7640
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7668,7 +7668,7 @@  discard block
 block discarded – undo
7668 7668
 				$query_values = array_merge($query_values,array(':day' => $day));
7669 7669
 			}
7670 7670
 		}
7671
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7671
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7672 7672
 					ORDER BY airport_arrival_icao_count DESC";
7673 7673
 		if ($limit) $query .= " LIMIT 10";
7674 7674
       
@@ -7697,35 +7697,35 @@  discard block
 block discarded – undo
7697 7697
 	}
7698 7698
 
7699 7699
 	/**
7700
-	* Gets all arrival airports of the airplanes that have flown over
7701
-	*
7702
-	* @return Array the airport list
7703
-	*
7704
-	*/
7700
+	 * Gets all arrival airports of the airplanes that have flown over
7701
+	 *
7702
+	 * @return Array the airport list
7703
+	 *
7704
+	 */
7705 7705
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7706 7706
 	{
7707 7707
 		global $globalDBdriver;
7708 7708
 		$filter_query = $this->getFilter($filters,true,true);
7709 7709
 		$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 
7710 7710
 			FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7711
-                if ($olderthanmonths > 0) {
7712
-            		if ($globalDBdriver == 'mysql') {
7711
+				if ($olderthanmonths > 0) {
7712
+					if ($globalDBdriver == 'mysql') {
7713 7713
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7714 7714
 			} else {
7715 7715
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7716 7716
 			}
7717 7717
 		}
7718
-                if ($sincedate != '') {
7719
-            		if ($globalDBdriver == 'mysql') {
7718
+				if ($sincedate != '') {
7719
+					if ($globalDBdriver == 'mysql') {
7720 7720
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7721 7721
 			} else {
7722 7722
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7723 7723
 			}
7724 7724
 		}
7725 7725
 
7726
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
-                $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
7726
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7727
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7728
+				$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
7729 7729
 					ORDER BY airport_arrival_icao_count DESC";
7730 7730
 		if ($limit) $query .= " LIMIT 10";
7731 7731
       
@@ -7756,26 +7756,26 @@  discard block
 block discarded – undo
7756 7756
 
7757 7757
 
7758 7758
 	/**
7759
-	* Gets all detected arrival airports of the airplanes that have flown over
7760
-	*
7761
-	* @return Array the airport list
7762
-	*
7763
-	*/
7759
+	 * Gets all detected arrival airports of the airplanes that have flown over
7760
+	 *
7761
+	 * @return Array the airport list
7762
+	 *
7763
+	 */
7764 7764
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7765 7765
 	{
7766 7766
 		global $globalDBdriver;
7767 7767
 		$filter_query = $this->getFilter($filters,true,true);
7768 7768
 		$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 
7769 7769
 			FROM airport,spotter_output".$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";
7770
-                if ($olderthanmonths > 0) {
7771
-            		if ($globalDBdriver == 'mysql') {
7770
+				if ($olderthanmonths > 0) {
7771
+					if ($globalDBdriver == 'mysql') {
7772 7772
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7773 7773
 			} else {
7774 7774
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7775 7775
 			}
7776 7776
 		}
7777
-                if ($sincedate != '') {
7778
-            		if ($globalDBdriver == 'mysql') {
7777
+				if ($sincedate != '') {
7778
+					if ($globalDBdriver == 'mysql') {
7779 7779
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7780 7780
 			} else {
7781 7781
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7809,7 +7809,7 @@  discard block
 block discarded – undo
7809 7809
 				$query_values = array_merge($query_values,array(':day' => $day));
7810 7810
 			}
7811 7811
 		}
7812
-                $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7812
+				$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7813 7813
 					ORDER BY airport_arrival_icao_count DESC";
7814 7814
 		if ($limit) $query .= " LIMIT 10";
7815 7815
       
@@ -7837,35 +7837,35 @@  discard block
 block discarded – undo
7837 7837
 	}
7838 7838
 	
7839 7839
 	/**
7840
-	* Gets all detected arrival airports of the airplanes that have flown over
7841
-	*
7842
-	* @return Array the airport list
7843
-	*
7844
-	*/
7840
+	 * Gets all detected arrival airports of the airplanes that have flown over
7841
+	 *
7842
+	 * @return Array the airport list
7843
+	 *
7844
+	 */
7845 7845
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7846 7846
 	{
7847 7847
 		global $globalDBdriver;
7848 7848
 		$filter_query = $this->getFilter($filters,true,true);
7849 7849
 		$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 
7850 7850
 			FROM airport,spotter_output".$filter_query." 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 ";
7851
-                if ($olderthanmonths > 0) {
7852
-            		if ($globalDBdriver == 'mysql') {
7851
+				if ($olderthanmonths > 0) {
7852
+					if ($globalDBdriver == 'mysql') {
7853 7853
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7854 7854
 			} else {
7855 7855
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7856 7856
 			}
7857 7857
 		}
7858
-                if ($sincedate != '') {
7859
-            		if ($globalDBdriver == 'mysql') {
7858
+				if ($sincedate != '') {
7859
+					if ($globalDBdriver == 'mysql') {
7860 7860
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7861 7861
 			} else {
7862 7862
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7863 7863
 			}
7864 7864
 		}
7865 7865
 
7866
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7866
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7867
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7868
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7869 7869
 					ORDER BY airport_arrival_icao_count DESC";
7870 7870
 		if ($limit) $query .= " LIMIT 10";
7871 7871
       
@@ -7895,11 +7895,11 @@  discard block
 block discarded – undo
7895 7895
 	}	
7896 7896
 	
7897 7897
 	/**
7898
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
-	*
7900
-	* @return Array the airport list
7901
-	*
7902
-	*/
7898
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
7899
+	 *
7900
+	 * @return Array the airport list
7901
+	 *
7902
+	 */
7903 7903
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7904 7904
 	{
7905 7905
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7931,11 +7931,11 @@  discard block
 block discarded – undo
7931 7931
 	
7932 7932
 	
7933 7933
 	/**
7934
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
-	*
7936
-	* @return Array the airport list
7937
-	*
7938
-	*/
7934
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7935
+	 *
7936
+	 * @return Array the airport list
7937
+	 *
7938
+	 */
7939 7939
 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7940 7940
 	{
7941 7941
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7966,11 +7966,11 @@  discard block
 block discarded – undo
7966 7966
 	
7967 7967
 	
7968 7968
 	/**
7969
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
-	*
7971
-	* @return Array the airport list
7972
-	*
7973
-	*/
7969
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7970
+	 *
7971
+	 * @return Array the airport list
7972
+	 *
7973
+	 */
7974 7974
 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7975 7975
 	{
7976 7976
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8004,11 +8004,11 @@  discard block
 block discarded – undo
8004 8004
 	
8005 8005
 	
8006 8006
 	/**
8007
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
-	*
8009
-	* @return Array the airport list
8010
-	*
8011
-	*/
8007
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8008
+	 *
8009
+	 * @return Array the airport list
8010
+	 *
8011
+	 */
8012 8012
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8013 8013
 	{
8014 8014
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8038,11 +8038,11 @@  discard block
 block discarded – undo
8038 8038
 	
8039 8039
 	
8040 8040
 	/**
8041
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
-	*
8043
-	* @return Array the airport list
8044
-	*
8045
-	*/
8041
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8042
+	 *
8043
+	 * @return Array the airport list
8044
+	 *
8045
+	 */
8046 8046
 	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8047 8047
 	{
8048 8048
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8076,11 +8076,11 @@  discard block
 block discarded – undo
8076 8076
 	
8077 8077
 	
8078 8078
 	/**
8079
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
-	*
8081
-	* @return Array the airport list
8082
-	*
8083
-	*/
8079
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8080
+	 *
8081
+	 * @return Array the airport list
8082
+	 *
8083
+	 */
8084 8084
 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8085 8085
 	{
8086 8086
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8111,11 +8111,11 @@  discard block
 block discarded – undo
8111 8111
 	
8112 8112
 	
8113 8113
 	/**
8114
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
-	*
8116
-	* @return Array the airport list
8117
-	*
8118
-	*/
8114
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
8115
+	 *
8116
+	 * @return Array the airport list
8117
+	 *
8118
+	 */
8119 8119
 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8120 8120
 	{
8121 8121
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8148,11 +8148,11 @@  discard block
 block discarded – undo
8148 8148
 	
8149 8149
 	
8150 8150
 	/**
8151
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
-	*
8153
-	* @return Array the airport list
8154
-	*
8155
-	*/
8151
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8152
+	 *
8153
+	 * @return Array the airport list
8154
+	 *
8155
+	 */
8156 8156
 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8157 8157
 	{
8158 8158
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8182,11 +8182,11 @@  discard block
 block discarded – undo
8182 8182
 	
8183 8183
 	
8184 8184
 	/**
8185
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
-	*
8187
-	* @return Array the airport list
8188
-	*
8189
-	*/
8185
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8186
+	 *
8187
+	 * @return Array the airport list
8188
+	 *
8189
+	 */
8190 8190
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8191 8191
 	{
8192 8192
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8220,11 +8220,11 @@  discard block
 block discarded – undo
8220 8220
 	
8221 8221
 	
8222 8222
 	/**
8223
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
-	*
8225
-	* @return Array the airport list
8226
-	*
8227
-	*/
8223
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8224
+	 *
8225
+	 * @return Array the airport list
8226
+	 *
8227
+	 */
8228 8228
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8229 8229
 	{
8230 8230
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8255,11 +8255,11 @@  discard block
 block discarded – undo
8255 8255
 	
8256 8256
 	
8257 8257
 	/**
8258
-	* Gets all arrival airports of the airplanes that have flown over based on a date
8259
-	*
8260
-	* @return Array the airport list
8261
-	*
8262
-	*/
8258
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
8259
+	 *
8260
+	 * @return Array the airport list
8261
+	 *
8262
+	 */
8263 8263
 	public function countAllArrivalAirportsByDate($date,$filters = array())
8264 8264
 	{
8265 8265
 		global $globalTimezone, $globalDBdriver;
@@ -8305,11 +8305,11 @@  discard block
 block discarded – undo
8305 8305
 	
8306 8306
 	
8307 8307
 	/**
8308
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
-	*
8310
-	* @return Array the airport list
8311
-	*
8312
-	*/
8308
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
8309
+	 *
8310
+	 * @return Array the airport list
8311
+	 *
8312
+	 */
8313 8313
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8314 8314
 	{
8315 8315
 		global $globalTimezone, $globalDBdriver;
@@ -8352,11 +8352,11 @@  discard block
 block discarded – undo
8352 8352
 	
8353 8353
 	
8354 8354
 	/**
8355
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
-	*
8357
-	* @return Array the airport list
8358
-	*
8359
-	*/
8355
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8356
+	 *
8357
+	 * @return Array the airport list
8358
+	 *
8359
+	 */
8360 8360
 	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8361 8361
 	{
8362 8362
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8388,11 +8388,11 @@  discard block
 block discarded – undo
8388 8388
 	}
8389 8389
 	
8390 8390
 	/**
8391
-	* Gets all arrival airports of the airplanes that have flown over based on a owner
8392
-	*
8393
-	* @return Array the airport list
8394
-	*
8395
-	*/
8391
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
8392
+	 *
8393
+	 * @return Array the airport list
8394
+	 *
8395
+	 */
8396 8396
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8397 8397
 	{
8398 8398
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8423,11 +8423,11 @@  discard block
 block discarded – undo
8423 8423
 	}
8424 8424
 
8425 8425
 	/**
8426
-	* Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
-	*
8428
-	* @return Array the airport list
8429
-	*
8430
-	*/
8426
+	 * Gets all arrival airports of the airplanes that have flown over based on a pilot
8427
+	 *
8428
+	 * @return Array the airport list
8429
+	 *
8430
+	 */
8431 8431
 	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8432 8432
 	{
8433 8433
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8458,11 +8458,11 @@  discard block
 block discarded – undo
8458 8458
 	}
8459 8459
 	
8460 8460
 	/**
8461
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
-	*
8463
-	* @return Array the airport list
8464
-	*
8465
-	*/
8461
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8462
+	 *
8463
+	 * @return Array the airport list
8464
+	 *
8465
+	 */
8466 8466
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8467 8467
 	{
8468 8468
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8491,11 +8491,11 @@  discard block
 block discarded – undo
8491 8491
 	}
8492 8492
 	
8493 8493
 	/**
8494
-	* Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
-	*
8496
-	* @return Array the airport list
8497
-	*
8498
-	*/
8494
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
8495
+	 *
8496
+	 * @return Array the airport list
8497
+	 *
8498
+	 */
8499 8499
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8500 8500
 	{
8501 8501
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8511,11 +8511,11 @@  discard block
 block discarded – undo
8511 8511
 	}
8512 8512
 	
8513 8513
 	/**
8514
-	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
-	*
8516
-	* @return Array the airport list
8517
-	*
8518
-	*/
8514
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8515
+	 *
8516
+	 * @return Array the airport list
8517
+	 *
8518
+	 */
8519 8519
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8520 8520
 	{
8521 8521
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8533,11 +8533,11 @@  discard block
 block discarded – undo
8533 8533
 	
8534 8534
 	
8535 8535
 	/**
8536
-	* Gets all arrival airports of the airplanes that have flown over based on a country
8537
-	*
8538
-	* @return Array the airport list
8539
-	*
8540
-	*/
8536
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
8537
+	 *
8538
+	 * @return Array the airport list
8539
+	 *
8540
+	 */
8541 8541
 	public function countAllArrivalAirportsByCountry($country,$filters = array())
8542 8542
 	{
8543 8543
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8570,11 +8570,11 @@  discard block
 block discarded – undo
8570 8570
 	
8571 8571
 	
8572 8572
 	/**
8573
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
-	*
8575
-	* @return Array the airport list
8576
-	*
8577
-	*/
8573
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
8574
+	 *
8575
+	 * @return Array the airport list
8576
+	 *
8577
+	 */
8578 8578
 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8579 8579
 	{
8580 8580
 		global $globalDBdriver;
@@ -8606,11 +8606,11 @@  discard block
 block discarded – undo
8606 8606
 
8607 8607
 
8608 8608
 	/**
8609
-	* Counts all airport departure countries
8610
-	*
8611
-	* @return Array the airport departure list
8612
-	*
8613
-	*/
8609
+	 * Counts all airport departure countries
8610
+	 *
8611
+	 * @return Array the airport departure list
8612
+	 *
8613
+	 */
8614 8614
 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8615 8615
 	{
8616 8616
 		global $globalDBdriver;
@@ -8669,11 +8669,11 @@  discard block
 block discarded – undo
8669 8669
 	
8670 8670
 	
8671 8671
 	/**
8672
-	* Counts all airport arrival countries
8673
-	*
8674
-	* @return Array the airport arrival list
8675
-	*
8676
-	*/
8672
+	 * Counts all airport arrival countries
8673
+	 *
8674
+	 * @return Array the airport arrival list
8675
+	 *
8676
+	 */
8677 8677
 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8678 8678
 	{
8679 8679
 		global $globalDBdriver;
@@ -8735,11 +8735,11 @@  discard block
 block discarded – undo
8735 8735
 
8736 8736
 
8737 8737
 	/**
8738
-	* Gets all route combinations
8739
-	*
8740
-	* @return Array the route list
8741
-	*
8742
-	*/
8738
+	 * Gets all route combinations
8739
+	 *
8740
+	 * @return Array the route list
8741
+	 *
8742
+	 */
8743 8743
 	public function countAllRoutes($filters = array())
8744 8744
 	{
8745 8745
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8778,11 +8778,11 @@  discard block
 block discarded – undo
8778 8778
 	
8779 8779
 	
8780 8780
 	/**
8781
-	* Gets all route combinations based on an aircraft
8782
-	*
8783
-	* @return Array the route list
8784
-	*
8785
-	*/
8781
+	 * Gets all route combinations based on an aircraft
8782
+	 *
8783
+	 * @return Array the route list
8784
+	 *
8785
+	 */
8786 8786
 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8787 8787
 	{
8788 8788
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8818,11 +8818,11 @@  discard block
 block discarded – undo
8818 8818
 	
8819 8819
 	
8820 8820
 	/**
8821
-	* Gets all route combinations based on an aircraft registration
8822
-	*
8823
-	* @return Array the route list
8824
-	*
8825
-	*/
8821
+	 * Gets all route combinations based on an aircraft registration
8822
+	 *
8823
+	 * @return Array the route list
8824
+	 *
8825
+	 */
8826 8826
 	public function countAllRoutesByRegistration($registration, $filters = array())
8827 8827
 	{
8828 8828
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8860,11 +8860,11 @@  discard block
 block discarded – undo
8860 8860
 	
8861 8861
 	
8862 8862
 	/**
8863
-	* Gets all route combinations based on an airline
8864
-	*
8865
-	* @return Array the route list
8866
-	*
8867
-	*/
8863
+	 * Gets all route combinations based on an airline
8864
+	 *
8865
+	 * @return Array the route list
8866
+	 *
8867
+	 */
8868 8868
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8869 8869
 	{
8870 8870
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8902,11 +8902,11 @@  discard block
 block discarded – undo
8902 8902
 	
8903 8903
 	
8904 8904
 	/**
8905
-	* Gets all route combinations based on an airport
8906
-	*
8907
-	* @return Array the route list
8908
-	*
8909
-	*/
8905
+	 * Gets all route combinations based on an airport
8906
+	 *
8907
+	 * @return Array the route list
8908
+	 *
8909
+	 */
8910 8910
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8911 8911
 	{
8912 8912
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8943,11 +8943,11 @@  discard block
 block discarded – undo
8943 8943
 	
8944 8944
 	
8945 8945
 	/**
8946
-	* Gets all route combinations based on an country
8947
-	*
8948
-	* @return Array the route list
8949
-	*
8950
-	*/
8946
+	 * Gets all route combinations based on an country
8947
+	 *
8948
+	 * @return Array the route list
8949
+	 *
8950
+	 */
8951 8951
 	public function countAllRoutesByCountry($country, $filters = array())
8952 8952
 	{
8953 8953
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8983,11 +8983,11 @@  discard block
 block discarded – undo
8983 8983
 
8984 8984
 
8985 8985
 	/**
8986
-	* Gets all route combinations based on an date
8987
-	*
8988
-	* @return Array the route list
8989
-	*
8990
-	*/
8986
+	 * Gets all route combinations based on an date
8987
+	 *
8988
+	 * @return Array the route list
8989
+	 *
8990
+	 */
8991 8991
 	public function countAllRoutesByDate($date, $filters = array())
8992 8992
 	{
8993 8993
 		global $globalTimezone, $globalDBdriver;
@@ -9037,11 +9037,11 @@  discard block
 block discarded – undo
9037 9037
 	
9038 9038
 	
9039 9039
 	/**
9040
-	* Gets all route combinations based on an ident/callsign
9041
-	*
9042
-	* @return Array the route list
9043
-	*
9044
-	*/
9040
+	 * Gets all route combinations based on an ident/callsign
9041
+	 *
9042
+	 * @return Array the route list
9043
+	 *
9044
+	 */
9045 9045
 	public function countAllRoutesByIdent($ident, $filters = array())
9046 9046
 	{
9047 9047
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9077,11 +9077,11 @@  discard block
 block discarded – undo
9077 9077
 	}
9078 9078
 	
9079 9079
 	/**
9080
-	* Gets all route combinations based on an owner
9081
-	*
9082
-	* @return Array the route list
9083
-	*
9084
-	*/
9080
+	 * Gets all route combinations based on an owner
9081
+	 *
9082
+	 * @return Array the route list
9083
+	 *
9084
+	 */
9085 9085
 	public function countAllRoutesByOwner($owner,$filters = array())
9086 9086
 	{
9087 9087
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9117,11 +9117,11 @@  discard block
 block discarded – undo
9117 9117
 	}
9118 9118
 	
9119 9119
 	/**
9120
-	* Gets all route combinations based on a pilot
9121
-	*
9122
-	* @return Array the route list
9123
-	*
9124
-	*/
9120
+	 * Gets all route combinations based on a pilot
9121
+	 *
9122
+	 * @return Array the route list
9123
+	 *
9124
+	 */
9125 9125
 	public function countAllRoutesByPilot($pilot,$filters = array())
9126 9126
 	{
9127 9127
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9158,11 +9158,11 @@  discard block
 block discarded – undo
9158 9158
 	
9159 9159
 	
9160 9160
 	/**
9161
-	* Gets all route combinations based on an manufacturer
9162
-	*
9163
-	* @return Array the route list
9164
-	*
9165
-	*/
9161
+	 * Gets all route combinations based on an manufacturer
9162
+	 *
9163
+	 * @return Array the route list
9164
+	 *
9165
+	 */
9166 9166
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9167 9167
 	{
9168 9168
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9200,11 +9200,11 @@  discard block
 block discarded – undo
9200 9200
 	
9201 9201
 	
9202 9202
 	/**
9203
-	* Gets all route combinations with waypoints
9204
-	*
9205
-	* @return Array the route list
9206
-	*
9207
-	*/
9203
+	 * Gets all route combinations with waypoints
9204
+	 *
9205
+	 * @return Array the route list
9206
+	 *
9207
+	 */
9208 9208
 	public function countAllRoutesWithWaypoints($filters = array())
9209 9209
 	{
9210 9210
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9241,11 +9241,11 @@  discard block
 block discarded – undo
9241 9241
 	}
9242 9242
 	
9243 9243
 	/**
9244
-	* Gets all callsigns that have flown over
9245
-	*
9246
-	* @return Array the callsign list
9247
-	*
9248
-	*/
9244
+	 * Gets all callsigns that have flown over
9245
+	 *
9246
+	 * @return Array the callsign list
9247
+	 *
9248
+	 */
9249 9249
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9250 9250
 	{
9251 9251
 		global $globalDBdriver;
@@ -9311,11 +9311,11 @@  discard block
 block discarded – undo
9311 9311
 	}
9312 9312
 
9313 9313
 	/**
9314
-	* Gets all callsigns that have flown over
9315
-	*
9316
-	* @return Array the callsign list
9317
-	*
9318
-	*/
9314
+	 * Gets all callsigns that have flown over
9315
+	 *
9316
+	 * @return Array the callsign list
9317
+	 *
9318
+	 */
9319 9319
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9320 9320
 	{
9321 9321
 		global $globalDBdriver;
@@ -9356,11 +9356,11 @@  discard block
 block discarded – undo
9356 9356
 
9357 9357
 
9358 9358
 	/**
9359
-	* Counts all dates
9360
-	*
9361
-	* @return Array the date list
9362
-	*
9363
-	*/
9359
+	 * Counts all dates
9360
+	 *
9361
+	 * @return Array the date list
9362
+	 *
9363
+	 */
9364 9364
 	public function countAllDates($filters = array())
9365 9365
 	{
9366 9366
 		global $globalTimezone, $globalDBdriver;
@@ -9405,11 +9405,11 @@  discard block
 block discarded – undo
9405 9405
 	}
9406 9406
 	
9407 9407
 	/**
9408
-	* Counts all dates
9409
-	*
9410
-	* @return Array the date list
9411
-	*
9412
-	*/
9408
+	 * Counts all dates
9409
+	 *
9410
+	 * @return Array the date list
9411
+	 *
9412
+	 */
9413 9413
 	public function countAllDatesByAirlines($filters = array())
9414 9414
 	{
9415 9415
 		global $globalTimezone, $globalDBdriver;
@@ -9454,11 +9454,11 @@  discard block
 block discarded – undo
9454 9454
 	}	
9455 9455
 	
9456 9456
 	/**
9457
-	* Counts all dates during the last 7 days
9458
-	*
9459
-	* @return Array the date list
9460
-	*
9461
-	*/
9457
+	 * Counts all dates during the last 7 days
9458
+	 *
9459
+	 * @return Array the date list
9460
+	 *
9461
+	 */
9462 9462
 	public function countAllDatesLast7Days($filters = array())
9463 9463
 	{
9464 9464
 		global $globalTimezone, $globalDBdriver;
@@ -9480,7 +9480,7 @@  discard block
 block discarded – undo
9480 9480
 			$query .= " GROUP BY date_name 
9481 9481
 								ORDER BY date_name ASC";
9482 9482
 			$query_data = array(':offset' => $offset);
9483
-    		}
9483
+			}
9484 9484
 		
9485 9485
 		$sth = $this->db->prepare($query);
9486 9486
 		$sth->execute($query_data);
@@ -9500,11 +9500,11 @@  discard block
 block discarded – undo
9500 9500
 	}
9501 9501
 
9502 9502
 	/**
9503
-	* Counts all dates during the last month
9504
-	*
9505
-	* @return Array the date list
9506
-	*
9507
-	*/
9503
+	 * Counts all dates during the last month
9504
+	 *
9505
+	 * @return Array the date list
9506
+	 *
9507
+	 */
9508 9508
 	public function countAllDatesLastMonth($filters = array())
9509 9509
 	{
9510 9510
 		global $globalTimezone, $globalDBdriver;
@@ -9526,7 +9526,7 @@  discard block
 block discarded – undo
9526 9526
 			$query .= " GROUP BY date_name 
9527 9527
 								ORDER BY date_name ASC";
9528 9528
 			$query_data = array(':offset' => $offset);
9529
-    		}
9529
+			}
9530 9530
 		
9531 9531
 		$sth = $this->db->prepare($query);
9532 9532
 		$sth->execute($query_data);
@@ -9547,11 +9547,11 @@  discard block
 block discarded – undo
9547 9547
 
9548 9548
 
9549 9549
 	/**
9550
-	* Counts all dates during the last month
9551
-	*
9552
-	* @return Array the date list
9553
-	*
9554
-	*/
9550
+	 * Counts all dates during the last month
9551
+	 *
9552
+	 * @return Array the date list
9553
+	 *
9554
+	 */
9555 9555
 	public function countAllDatesLastMonthByAirlines($filters = array())
9556 9556
 	{
9557 9557
 		global $globalTimezone, $globalDBdriver;
@@ -9574,7 +9574,7 @@  discard block
 block discarded – undo
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY date_name ASC";
9576 9576
 			$query_data = array(':offset' => $offset);
9577
-    		}
9577
+			}
9578 9578
 		
9579 9579
 		$sth = $this->db->prepare($query);
9580 9580
 		$sth->execute($query_data);
@@ -9596,11 +9596,11 @@  discard block
 block discarded – undo
9596 9596
 	
9597 9597
 
9598 9598
 	/**
9599
-	* Counts all month
9600
-	*
9601
-	* @return Array the month list
9602
-	*
9603
-	*/
9599
+	 * Counts all month
9600
+	 *
9601
+	 * @return Array the month list
9602
+	 *
9603
+	 */
9604 9604
 	public function countAllMonths($filters = array())
9605 9605
 	{
9606 9606
 		global $globalTimezone, $globalDBdriver;
@@ -9642,11 +9642,11 @@  discard block
 block discarded – undo
9642 9642
 	}
9643 9643
 
9644 9644
 	/**
9645
-	* Counts all month
9646
-	*
9647
-	* @return Array the month list
9648
-	*
9649
-	*/
9645
+	 * Counts all month
9646
+	 *
9647
+	 * @return Array the month list
9648
+	 *
9649
+	 */
9650 9650
 	public function countAllMonthsByAirlines($filters = array())
9651 9651
 	{
9652 9652
 		global $globalTimezone, $globalDBdriver;
@@ -9691,11 +9691,11 @@  discard block
 block discarded – undo
9691 9691
 	}
9692 9692
 
9693 9693
 	/**
9694
-	* Counts all military month
9695
-	*
9696
-	* @return Array the month list
9697
-	*
9698
-	*/
9694
+	 * Counts all military month
9695
+	 *
9696
+	 * @return Array the month list
9697
+	 *
9698
+	 */
9699 9699
 	public function countAllMilitaryMonths($filters = array())
9700 9700
 	{
9701 9701
 		global $globalTimezone, $globalDBdriver;
@@ -9736,11 +9736,11 @@  discard block
 block discarded – undo
9736 9736
 	}
9737 9737
 	
9738 9738
 	/**
9739
-	* Counts all month owners
9740
-	*
9741
-	* @return Array the month list
9742
-	*
9743
-	*/
9739
+	 * Counts all month owners
9740
+	 *
9741
+	 * @return Array the month list
9742
+	 *
9743
+	 */
9744 9744
 	public function countAllMonthsOwners($filters = array())
9745 9745
 	{
9746 9746
 		global $globalTimezone, $globalDBdriver;
@@ -9782,11 +9782,11 @@  discard block
 block discarded – undo
9782 9782
 	}
9783 9783
 	
9784 9784
 	/**
9785
-	* Counts all month owners
9786
-	*
9787
-	* @return Array the month list
9788
-	*
9789
-	*/
9785
+	 * Counts all month owners
9786
+	 *
9787
+	 * @return Array the month list
9788
+	 *
9789
+	 */
9790 9790
 	public function countAllMonthsOwnersByAirlines($filters = array())
9791 9791
 	{
9792 9792
 		global $globalTimezone, $globalDBdriver;
@@ -9829,11 +9829,11 @@  discard block
 block discarded – undo
9829 9829
 	}
9830 9830
 
9831 9831
 	/**
9832
-	* Counts all month pilot
9833
-	*
9834
-	* @return Array the month list
9835
-	*
9836
-	*/
9832
+	 * Counts all month pilot
9833
+	 *
9834
+	 * @return Array the month list
9835
+	 *
9836
+	 */
9837 9837
 	public function countAllMonthsPilots($filters = array())
9838 9838
 	{
9839 9839
 		global $globalTimezone, $globalDBdriver;
@@ -9875,11 +9875,11 @@  discard block
 block discarded – undo
9875 9875
 	}
9876 9876
 	
9877 9877
 	/**
9878
-	* Counts all month pilot
9879
-	*
9880
-	* @return Array the month list
9881
-	*
9882
-	*/
9878
+	 * Counts all month pilot
9879
+	 *
9880
+	 * @return Array the month list
9881
+	 *
9882
+	 */
9883 9883
 	public function countAllMonthsPilotsByAirlines($filters = array())
9884 9884
 	{
9885 9885
 		global $globalTimezone, $globalDBdriver;
@@ -9922,11 +9922,11 @@  discard block
 block discarded – undo
9922 9922
 	}
9923 9923
 
9924 9924
 	/**
9925
-	* Counts all month airline
9926
-	*
9927
-	* @return Array the month list
9928
-	*
9929
-	*/
9925
+	 * Counts all month airline
9926
+	 *
9927
+	 * @return Array the month list
9928
+	 *
9929
+	 */
9930 9930
 	public function countAllMonthsAirlines($filters = array())
9931 9931
 	{
9932 9932
 		global $globalTimezone, $globalDBdriver;
@@ -9968,11 +9968,11 @@  discard block
 block discarded – undo
9968 9968
 	}
9969 9969
 	
9970 9970
 	/**
9971
-	* Counts all month aircraft
9972
-	*
9973
-	* @return Array the month list
9974
-	*
9975
-	*/
9971
+	 * Counts all month aircraft
9972
+	 *
9973
+	 * @return Array the month list
9974
+	 *
9975
+	 */
9976 9976
 	public function countAllMonthsAircrafts($filters = array())
9977 9977
 	{
9978 9978
 		global $globalTimezone, $globalDBdriver;
@@ -10015,11 +10015,11 @@  discard block
 block discarded – undo
10015 10015
 	
10016 10016
 
10017 10017
 	/**
10018
-	* Counts all month aircraft
10019
-	*
10020
-	* @return Array the month list
10021
-	*
10022
-	*/
10018
+	 * Counts all month aircraft
10019
+	 *
10020
+	 * @return Array the month list
10021
+	 *
10022
+	 */
10023 10023
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10024 10024
 	{
10025 10025
 		global $globalTimezone, $globalDBdriver;
@@ -10062,11 +10062,11 @@  discard block
 block discarded – undo
10062 10062
 	}
10063 10063
 
10064 10064
 	/**
10065
-	* Counts all month real arrival
10066
-	*
10067
-	* @return Array the month list
10068
-	*
10069
-	*/
10065
+	 * Counts all month real arrival
10066
+	 *
10067
+	 * @return Array the month list
10068
+	 *
10069
+	 */
10070 10070
 	public function countAllMonthsRealArrivals($filters = array())
10071 10071
 	{
10072 10072
 		global $globalTimezone, $globalDBdriver;
@@ -10109,11 +10109,11 @@  discard block
 block discarded – undo
10109 10109
 	
10110 10110
 
10111 10111
 	/**
10112
-	* Counts all month real arrival
10113
-	*
10114
-	* @return Array the month list
10115
-	*
10116
-	*/
10112
+	 * Counts all month real arrival
10113
+	 *
10114
+	 * @return Array the month list
10115
+	 *
10116
+	 */
10117 10117
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10118 10118
 	{
10119 10119
 		global $globalTimezone, $globalDBdriver;
@@ -10157,11 +10157,11 @@  discard block
 block discarded – undo
10157 10157
 	
10158 10158
 
10159 10159
 	/**
10160
-	* Counts all dates during the last year
10161
-	*
10162
-	* @return Array the date list
10163
-	*
10164
-	*/
10160
+	 * Counts all dates during the last year
10161
+	 *
10162
+	 * @return Array the date list
10163
+	 *
10164
+	 */
10165 10165
 	public function countAllMonthsLastYear($filters)
10166 10166
 	{
10167 10167
 		global $globalTimezone, $globalDBdriver;
@@ -10183,7 +10183,7 @@  discard block
 block discarded – undo
10183 10183
 			$query .= " GROUP BY year_name, month_name
10184 10184
 								ORDER BY year_name, month_name ASC";
10185 10185
 			$query_data = array(':offset' => $offset);
10186
-    		}
10186
+			}
10187 10187
 		
10188 10188
 		$sth = $this->db->prepare($query);
10189 10189
 		$sth->execute($query_data);
@@ -10206,11 +10206,11 @@  discard block
 block discarded – undo
10206 10206
 	
10207 10207
 	
10208 10208
 	/**
10209
-	* Counts all hours
10210
-	*
10211
-	* @return Array the hour list
10212
-	*
10213
-	*/
10209
+	 * Counts all hours
10210
+	 *
10211
+	 * @return Array the hour list
10212
+	 *
10213
+	 */
10214 10214
 	public function countAllHours($orderby,$filters = array())
10215 10215
 	{
10216 10216
 		global $globalTimezone, $globalDBdriver;
@@ -10271,11 +10271,11 @@  discard block
 block discarded – undo
10271 10271
 	}
10272 10272
 	
10273 10273
 	/**
10274
-	* Counts all hours
10275
-	*
10276
-	* @return Array the hour list
10277
-	*
10278
-	*/
10274
+	 * Counts all hours
10275
+	 *
10276
+	 * @return Array the hour list
10277
+	 *
10278
+	 */
10279 10279
 	public function countAllHoursByAirlines($orderby, $filters = array())
10280 10280
 	{
10281 10281
 		global $globalTimezone, $globalDBdriver;
@@ -10338,11 +10338,11 @@  discard block
 block discarded – undo
10338 10338
 
10339 10339
 
10340 10340
 	/**
10341
-	* Counts all hours by airline
10342
-	*
10343
-	* @return Array the hour list
10344
-	*
10345
-	*/
10341
+	 * Counts all hours by airline
10342
+	 *
10343
+	 * @return Array the hour list
10344
+	 *
10345
+	 */
10346 10346
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10347 10347
 	{
10348 10348
 		global $globalTimezone, $globalDBdriver;
@@ -10388,11 +10388,11 @@  discard block
 block discarded – undo
10388 10388
 	
10389 10389
 	
10390 10390
 	/**
10391
-	* Counts all hours by aircraft
10392
-	*
10393
-	* @return Array the hour list
10394
-	*
10395
-	*/
10391
+	 * Counts all hours by aircraft
10392
+	 *
10393
+	 * @return Array the hour list
10394
+	 *
10395
+	 */
10396 10396
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10397 10397
 	{
10398 10398
 		global $globalTimezone, $globalDBdriver;
@@ -10435,11 +10435,11 @@  discard block
 block discarded – undo
10435 10435
 	
10436 10436
 	
10437 10437
 	/**
10438
-	* Counts all hours by aircraft registration
10439
-	*
10440
-	* @return Array the hour list
10441
-	*
10442
-	*/
10438
+	 * Counts all hours by aircraft registration
10439
+	 *
10440
+	 * @return Array the hour list
10441
+	 *
10442
+	 */
10443 10443
 	public function countAllHoursByRegistration($registration, $filters = array())
10444 10444
 	{
10445 10445
 		global $globalTimezone, $globalDBdriver;
@@ -10482,11 +10482,11 @@  discard block
 block discarded – undo
10482 10482
 	
10483 10483
 	
10484 10484
 	/**
10485
-	* Counts all hours by airport
10486
-	*
10487
-	* @return Array the hour list
10488
-	*
10489
-	*/
10485
+	 * Counts all hours by airport
10486
+	 *
10487
+	 * @return Array the hour list
10488
+	 *
10489
+	 */
10490 10490
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10491 10491
 	{
10492 10492
 		global $globalTimezone, $globalDBdriver;
@@ -10530,11 +10530,11 @@  discard block
 block discarded – undo
10530 10530
 	
10531 10531
 	
10532 10532
 	/**
10533
-	* Counts all hours by manufacturer
10534
-	*
10535
-	* @return Array the hour list
10536
-	*
10537
-	*/
10533
+	 * Counts all hours by manufacturer
10534
+	 *
10535
+	 * @return Array the hour list
10536
+	 *
10537
+	 */
10538 10538
 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10539 10539
 	{
10540 10540
 		global $globalTimezone, $globalDBdriver;
@@ -10578,11 +10578,11 @@  discard block
 block discarded – undo
10578 10578
 	
10579 10579
 	
10580 10580
 	/**
10581
-	* Counts all hours by date
10582
-	*
10583
-	* @return Array the hour list
10584
-	*
10585
-	*/
10581
+	 * Counts all hours by date
10582
+	 *
10583
+	 * @return Array the hour list
10584
+	 *
10585
+	 */
10586 10586
 	public function countAllHoursByDate($date, $filters = array())
10587 10587
 	{
10588 10588
 		global $globalTimezone, $globalDBdriver;
@@ -10626,11 +10626,11 @@  discard block
 block discarded – undo
10626 10626
 	
10627 10627
 	
10628 10628
 	/**
10629
-	* Counts all hours by a ident/callsign
10630
-	*
10631
-	* @return Array the hour list
10632
-	*
10633
-	*/
10629
+	 * Counts all hours by a ident/callsign
10630
+	 *
10631
+	 * @return Array the hour list
10632
+	 *
10633
+	 */
10634 10634
 	public function countAllHoursByIdent($ident, $filters = array())
10635 10635
 	{
10636 10636
 		global $globalTimezone, $globalDBdriver;
@@ -10673,11 +10673,11 @@  discard block
 block discarded – undo
10673 10673
 	}
10674 10674
 	
10675 10675
 	/**
10676
-	* Counts all hours by a owner
10677
-	*
10678
-	* @return Array the hour list
10679
-	*
10680
-	*/
10676
+	 * Counts all hours by a owner
10677
+	 *
10678
+	 * @return Array the hour list
10679
+	 *
10680
+	 */
10681 10681
 	public function countAllHoursByOwner($owner, $filters = array())
10682 10682
 	{
10683 10683
 		global $globalTimezone, $globalDBdriver;
@@ -10720,11 +10720,11 @@  discard block
 block discarded – undo
10720 10720
 	}
10721 10721
 	
10722 10722
 	/**
10723
-	* Counts all hours by a pilot
10724
-	*
10725
-	* @return Array the hour list
10726
-	*
10727
-	*/
10723
+	 * Counts all hours by a pilot
10724
+	 *
10725
+	 * @return Array the hour list
10726
+	 *
10727
+	 */
10728 10728
 	public function countAllHoursByPilot($pilot, $filters = array())
10729 10729
 	{
10730 10730
 		global $globalTimezone, $globalDBdriver;
@@ -10769,11 +10769,11 @@  discard block
 block discarded – undo
10769 10769
 	
10770 10770
 	
10771 10771
 	/**
10772
-	* Counts all hours by route
10773
-	*
10774
-	* @return Array the hour list
10775
-	*
10776
-	*/
10772
+	 * Counts all hours by route
10773
+	 *
10774
+	 * @return Array the hour list
10775
+	 *
10776
+	 */
10777 10777
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10778 10778
 	{
10779 10779
 		global $globalTimezone, $globalDBdriver;
@@ -10817,11 +10817,11 @@  discard block
 block discarded – undo
10817 10817
 	
10818 10818
 	
10819 10819
 	/**
10820
-	* Counts all hours by country
10821
-	*
10822
-	* @return Array the hour list
10823
-	*
10824
-	*/
10820
+	 * Counts all hours by country
10821
+	 *
10822
+	 * @return Array the hour list
10823
+	 *
10824
+	 */
10825 10825
 	public function countAllHoursByCountry($country, $filters = array())
10826 10826
 	{
10827 10827
 		global $globalTimezone, $globalDBdriver;
@@ -10866,11 +10866,11 @@  discard block
 block discarded – undo
10866 10866
 
10867 10867
 
10868 10868
 	/**
10869
-	* Counts all aircraft that have flown over
10870
-	*
10871
-	* @return Integer the number of aircrafts
10872
-	*
10873
-	*/
10869
+	 * Counts all aircraft that have flown over
10870
+	 *
10871
+	 * @return Integer the number of aircrafts
10872
+	 *
10873
+	 */
10874 10874
 	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10875 10875
 	{
10876 10876
 		global $globalDBdriver;
@@ -10903,11 +10903,11 @@  discard block
 block discarded – undo
10903 10903
 	}
10904 10904
 
10905 10905
 	/**
10906
-	* Counts all flight that really arrival
10907
-	*
10908
-	* @return Integer the number of aircrafts
10909
-	*
10910
-	*/
10906
+	 * Counts all flight that really arrival
10907
+	 *
10908
+	 * @return Integer the number of aircrafts
10909
+	 *
10910
+	 */
10911 10911
 	public function countOverallArrival($filters = array(),$year = '',$month = '')
10912 10912
 	{
10913 10913
 		global $globalDBdriver;
@@ -10940,11 +10940,11 @@  discard block
 block discarded – undo
10940 10940
 	}
10941 10941
 
10942 10942
 	/**
10943
-	* Counts all pilots that have flown over
10944
-	*
10945
-	* @return Integer the number of pilots
10946
-	*
10947
-	*/
10943
+	 * Counts all pilots that have flown over
10944
+	 *
10945
+	 * @return Integer the number of pilots
10946
+	 *
10947
+	 */
10948 10948
 	public function countOverallPilots($filters = array(),$year = '',$month = '')
10949 10949
 	{
10950 10950
 		global $globalDBdriver;
@@ -10976,11 +10976,11 @@  discard block
 block discarded – undo
10976 10976
 	}
10977 10977
 
10978 10978
 	/**
10979
-	* Counts all owners that have flown over
10980
-	*
10981
-	* @return Integer the number of owners
10982
-	*
10983
-	*/
10979
+	 * Counts all owners that have flown over
10980
+	 *
10981
+	 * @return Integer the number of owners
10982
+	 *
10983
+	 */
10984 10984
 	public function countOverallOwners($filters = array(),$year = '',$month = '')
10985 10985
 	{
10986 10986
 		global $globalDBdriver;
@@ -11013,11 +11013,11 @@  discard block
 block discarded – undo
11013 11013
 	
11014 11014
 	
11015 11015
 	/**
11016
-	* Counts all flights that have flown over
11017
-	*
11018
-	* @return Integer the number of flights
11019
-	*
11020
-	*/
11016
+	 * Counts all flights that have flown over
11017
+	 *
11018
+	 * @return Integer the number of flights
11019
+	 *
11020
+	 */
11021 11021
 	public function countOverallFlights($filters = array(),$year = '',$month = '')
11022 11022
 	{
11023 11023
 		global $globalDBdriver;
@@ -11051,11 +11051,11 @@  discard block
 block discarded – undo
11051 11051
 	}
11052 11052
 	
11053 11053
 	/**
11054
-	* Counts all military flights that have flown over
11055
-	*
11056
-	* @return Integer the number of flights
11057
-	*
11058
-	*/
11054
+	 * Counts all military flights that have flown over
11055
+	 *
11056
+	 * @return Integer the number of flights
11057
+	 *
11058
+	 */
11059 11059
 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11060 11060
 	{
11061 11061
 		global $globalDBdriver;
@@ -11090,11 +11090,11 @@  discard block
 block discarded – undo
11090 11090
 	
11091 11091
 	
11092 11092
 	/**
11093
-	* Counts all airlines that have flown over
11094
-	*
11095
-	* @return Integer the number of airlines
11096
-	*
11097
-	*/
11093
+	 * Counts all airlines that have flown over
11094
+	 *
11095
+	 * @return Integer the number of airlines
11096
+	 *
11097
+	 */
11098 11098
 	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11099 11099
 	{
11100 11100
 		global $globalDBdriver;
@@ -11121,8 +11121,8 @@  discard block
 block discarded – undo
11121 11121
 				$query_values = array_merge($query_values,array(':month' => $month));
11122 11122
 			}
11123 11123
 		}
11124
-                if ($query == '') $queryi .= $this->getFilter($filters);
11125
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11124
+				if ($query == '') $queryi .= $this->getFilter($filters);
11125
+				else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11126 11126
 
11127 11127
 
11128 11128
 		$sth = $this->db->prepare($queryi);
@@ -11132,11 +11132,11 @@  discard block
 block discarded – undo
11132 11132
 
11133 11133
   
11134 11134
 	/**
11135
-	* Counts all hours of today
11136
-	*
11137
-	* @return Array the hour list
11138
-	*
11139
-	*/
11135
+	 * Counts all hours of today
11136
+	 *
11137
+	 * @return Array the hour list
11138
+	 *
11139
+	 */
11140 11140
 	public function countAllHoursFromToday($filters = array())
11141 11141
 	{
11142 11142
 		global $globalTimezone, $globalDBdriver;
@@ -11176,11 +11176,11 @@  discard block
 block discarded – undo
11176 11176
 	}
11177 11177
     
11178 11178
 	/**
11179
-	* Gets all the spotter information based on calculated upcoming flights
11180
-	*
11181
-	* @return Array the spotter information
11182
-	*
11183
-	*/
11179
+	 * Gets all the spotter information based on calculated upcoming flights
11180
+	 *
11181
+	 * @return Array the spotter information
11182
+	 *
11183
+	 */
11184 11184
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11185 11185
 	{
11186 11186
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -11255,12 +11255,12 @@  discard block
 block discarded – undo
11255 11255
 	}
11256 11256
     
11257 11257
     
11258
-     /**
11259
-	* Gets the Barrie Spotter ID based on the FlightAware ID
11260
-	*
11261
-	* @return Integer the Barrie Spotter ID
11258
+	 /**
11259
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
11260
+	  *
11261
+	  * @return Integer the Barrie Spotter ID
11262 11262
 q	*
11263
-	*/
11263
+	  */
11264 11264
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11265 11265
 	{
11266 11266
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -11281,13 +11281,13 @@  discard block
 block discarded – undo
11281 11281
   
11282 11282
  
11283 11283
 	/**
11284
-	* Parses a date string
11285
-	*
11286
-	* @param String $dateString the date string
11287
-	* @param String $timezone the timezone of a user
11288
-	* @return Array the time information
11289
-	*
11290
-	*/
11284
+	 * Parses a date string
11285
+	 *
11286
+	 * @param String $dateString the date string
11287
+	 * @param String $timezone the timezone of a user
11288
+	 * @return Array the time information
11289
+	 *
11290
+	 */
11291 11291
 	public function parseDateString($dateString, $timezone = '')
11292 11292
 	{
11293 11293
 		$time_array = array();
@@ -11323,12 +11323,12 @@  discard block
 block discarded – undo
11323 11323
 	
11324 11324
 	
11325 11325
 	/**
11326
-	* Parses the direction degrees to working
11327
-	*
11328
-	* @param Float $direction the direction in degrees
11329
-	* @return Array the direction information
11330
-	*
11331
-	*/
11326
+	 * Parses the direction degrees to working
11327
+	 *
11328
+	 * @param Float $direction the direction in degrees
11329
+	 * @return Array the direction information
11330
+	 *
11331
+	 */
11332 11332
 	public function parseDirection($direction = 0)
11333 11333
 	{
11334 11334
 		if ($direction == '') $direction = 0;
@@ -11407,12 +11407,12 @@  discard block
 block discarded – undo
11407 11407
 	
11408 11408
 	
11409 11409
 	/**
11410
-	* Gets the aircraft registration
11411
-	*
11412
-	* @param String $flightaware_id the flight aware id
11413
-	* @return String the aircraft registration
11414
-	*
11415
-	*/
11410
+	 * Gets the aircraft registration
11411
+	 *
11412
+	 * @param String $flightaware_id the flight aware id
11413
+	 * @return String the aircraft registration
11414
+	 *
11415
+	 */
11416 11416
 	
11417 11417
 	public function getAircraftRegistration($flightaware_id)
11418 11418
 	{
@@ -11441,12 +11441,12 @@  discard block
 block discarded – undo
11441 11441
 
11442 11442
 
11443 11443
 	/**
11444
-	* Gets the aircraft registration from ModeS
11445
-	*
11446
-	* @param String $aircraft_modes the flight ModeS in hex
11447
-	* @return String the aircraft registration
11448
-	*
11449
-	*/
11444
+	 * Gets the aircraft registration from ModeS
11445
+	 *
11446
+	 * @param String $aircraft_modes the flight ModeS in hex
11447
+	 * @return String the aircraft registration
11448
+	 *
11449
+	 */
11450 11450
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11451 11451
 	{
11452 11452
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11462,8 +11462,8 @@  discard block
 block discarded – undo
11462 11462
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11463 11463
 		$sth->closeCursor();
11464 11464
 		if (count($row) > 0) {
11465
-		    //return $row['Registration'];
11466
-		    return $row['registration'];
11465
+			//return $row['Registration'];
11466
+			return $row['registration'];
11467 11467
 		} elseif ($source_type == 'flarm') {
11468 11468
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11469 11469
 		} else return '';
@@ -11471,12 +11471,12 @@  discard block
 block discarded – undo
11471 11471
 	}
11472 11472
 
11473 11473
 	/**
11474
-	* Gets the aircraft type from ModeS
11475
-	*
11476
-	* @param String $aircraft_modes the flight ModeS in hex
11477
-	* @return String the aircraft type
11478
-	*
11479
-	*/
11474
+	 * Gets the aircraft type from ModeS
11475
+	 *
11476
+	 * @param String $aircraft_modes the flight ModeS in hex
11477
+	 * @return String the aircraft type
11478
+	 *
11479
+	 */
11480 11480
 	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11481 11481
 	{
11482 11482
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11502,12 +11502,12 @@  discard block
 block discarded – undo
11502 11502
 	}
11503 11503
 
11504 11504
 	/**
11505
-	* Gets Country from latitude/longitude
11506
-	*
11507
-	* @param Float $latitude latitute of the flight
11508
-	* @param Float $longitude longitute of the flight
11509
-	* @return String the countrie
11510
-	*/
11505
+	 * Gets Country from latitude/longitude
11506
+	 *
11507
+	 * @param Float $latitude latitute of the flight
11508
+	 * @param Float $longitude longitute of the flight
11509
+	 * @return String the countrie
11510
+	 */
11511 11511
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11512 11512
 	{
11513 11513
 		global $globalDBdriver, $globalDebug;
@@ -11544,11 +11544,11 @@  discard block
 block discarded – undo
11544 11544
 	}
11545 11545
 
11546 11546
 	/**
11547
-	* Gets Country from iso2
11548
-	*
11549
-	* @param String $iso2 ISO2 country code
11550
-	* @return String the countrie
11551
-	*/
11547
+	 * Gets Country from iso2
11548
+	 *
11549
+	 * @param String $iso2 ISO2 country code
11550
+	 * @return String the countrie
11551
+	 */
11552 11552
 	public function getCountryFromISO2($iso2)
11553 11553
 	{
11554 11554
 		global $globalDBdriver, $globalDebug;
@@ -11576,12 +11576,12 @@  discard block
 block discarded – undo
11576 11576
 	}
11577 11577
 
11578 11578
 	/**
11579
-	* converts the registration code using the country prefix
11580
-	*
11581
-	* @param String $registration the aircraft registration
11582
-	* @return String the aircraft registration
11583
-	*
11584
-	*/
11579
+	 * converts the registration code using the country prefix
11580
+	 *
11581
+	 * @param String $registration the aircraft registration
11582
+	 * @return String the aircraft registration
11583
+	 *
11584
+	 */
11585 11585
 	public function convertAircraftRegistration($registration)
11586 11586
 	{
11587 11587
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11633,12 +11633,12 @@  discard block
 block discarded – undo
11633 11633
 	}
11634 11634
 
11635 11635
 	/**
11636
-	* Country from the registration code
11637
-	*
11638
-	* @param String $registration the aircraft registration
11639
-	* @return String the country
11640
-	*
11641
-	*/
11636
+	 * Country from the registration code
11637
+	 *
11638
+	 * @param String $registration the aircraft registration
11639
+	 * @return String the country
11640
+	 *
11641
+	 */
11642 11642
 	public function countryFromAircraftRegistration($registration)
11643 11643
 	{
11644 11644
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11657,8 +11657,8 @@  discard block
 block discarded – undo
11657 11657
 				$country = $row['country'];
11658 11658
 			}
11659 11659
 		} else {
11660
-    			$registration_1 = substr($registration, 0, 1);
11661
-		        $registration_2 = substr($registration, 0, 2);
11660
+				$registration_1 = substr($registration, 0, 1);
11661
+				$registration_2 = substr($registration, 0, 2);
11662 11662
 
11663 11663
 			$country = '';
11664 11664
 			//first get the prefix based on two characters
@@ -11694,12 +11694,12 @@  discard block
 block discarded – undo
11694 11694
 	}
11695 11695
 
11696 11696
 	/**
11697
-	* Registration prefix from the registration code
11698
-	*
11699
-	* @param String $registration the aircraft registration
11700
-	* @return String the registration prefix
11701
-	*
11702
-	*/
11697
+	 * Registration prefix from the registration code
11698
+	 *
11699
+	 * @param String $registration the aircraft registration
11700
+	 * @return String the registration prefix
11701
+	 *
11702
+	 */
11703 11703
 	public function registrationPrefixFromAircraftRegistration($registration)
11704 11704
 	{
11705 11705
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11718,8 +11718,8 @@  discard block
 block discarded – undo
11718 11718
 				//$country = $row['country'];
11719 11719
 			}
11720 11720
 		} else {
11721
-    			$registration_1 = substr($registration, 0, 1);
11722
-		        $registration_2 = substr($registration, 0, 2);
11721
+				$registration_1 = substr($registration, 0, 1);
11722
+				$registration_2 = substr($registration, 0, 2);
11723 11723
 
11724 11724
 			//first get the prefix based on two characters
11725 11725
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
@@ -11755,12 +11755,12 @@  discard block
 block discarded – undo
11755 11755
 
11756 11756
 
11757 11757
 	/**
11758
-	* Country from the registration code
11759
-	*
11760
-	* @param String $registration the aircraft registration
11761
-	* @return String the country
11762
-	*
11763
-	*/
11758
+	 * Country from the registration code
11759
+	 *
11760
+	 * @param String $registration the aircraft registration
11761
+	 * @return String the country
11762
+	 *
11763
+	 */
11764 11764
 	public function countryFromAircraftRegistrationCode($registration)
11765 11765
 	{
11766 11766
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11777,11 +11777,11 @@  discard block
 block discarded – undo
11777 11777
 	}
11778 11778
 	
11779 11779
 	/**
11780
-	* Set a new highlight value for a flight
11781
-	*
11782
-	* @param String $flightaware_id flightaware_id from spotter_output table
11783
-	* @param String $highlight New highlight value
11784
-	*/
11780
+	 * Set a new highlight value for a flight
11781
+	 *
11782
+	 * @param String $flightaware_id flightaware_id from spotter_output table
11783
+	 * @param String $highlight New highlight value
11784
+	 */
11785 11785
 	public function setHighlightFlight($flightaware_id,$highlight) {
11786 11786
 		
11787 11787
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -11790,12 +11790,12 @@  discard block
 block discarded – undo
11790 11790
 	}
11791 11791
 
11792 11792
 	/**
11793
-	* Set a new highlight value for a flight by Registration
11794
-	*
11795
-	* @param String $registration Registration of the aircraft
11796
-	* @param String $date Date of spotted aircraft
11797
-	* @param String $highlight New highlight value
11798
-	*/
11793
+	 * Set a new highlight value for a flight by Registration
11794
+	 *
11795
+	 * @param String $registration Registration of the aircraft
11796
+	 * @param String $date Date of spotted aircraft
11797
+	 * @param String $highlight New highlight value
11798
+	 */
11799 11799
 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11800 11800
 		if ($date == '') {
11801 11801
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
@@ -11809,12 +11809,12 @@  discard block
 block discarded – undo
11809 11809
 	}
11810 11810
 	
11811 11811
 	/**
11812
-	* Gets the short url from bit.ly
11813
-	*
11814
-	* @param String $url the full url
11815
-	* @return String the bit.ly url
11816
-	*
11817
-	*/
11812
+	 * Gets the short url from bit.ly
11813
+	 *
11814
+	 * @param String $url the full url
11815
+	 * @return String the bit.ly url
11816
+	 *
11817
+	 */
11818 11818
 	public function getBitlyURL($url)
11819 11819
 	{
11820 11820
 		global $globalBitlyAccessToken;
@@ -12103,11 +12103,11 @@  discard block
 block discarded – undo
12103 12103
 			$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 
12104 12104
 	                      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)) 
12105 12105
 	                      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;";
12106
-                } else {
12106
+				} else {
12107 12107
 			$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 
12108 12108
 	                      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)) 
12109 12109
 	                      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;";
12110
-    		}
12110
+			}
12111 12111
 		$sth = $this->db->prepare($query);
12112 12112
 		$sth->execute();
12113 12113
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Indentation   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -2,10 +2,10 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 class aprs {
5
-    private $socket;
6
-    private $connected = false;
5
+	private $socket;
6
+	private $connected = false;
7 7
 
8
-    protected $symbols = array('!' => 'Police',
8
+	protected $symbols = array('!' => 'Police',
9 9
 	'#' => 'DIGI',
10 10
 	'$' => 'Phone',
11 11
 	'%' => 'DX Cluster',
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	'y' => 'Yagi At QTH');
90 90
 	
91 91
 
92
-    private function urshift($n, $s) {
92
+	private function urshift($n, $s) {
93 93
 	return ($n >= 0) ? ($n >> $s) :
94
-	    (($n & 0x7fffffff) >> $s) | 
94
+		(($n & 0x7fffffff) >> $s) | 
95 95
 		(0x40000000 >> ($s - 1));
96
-    }
96
+	}
97 97
 
98
-    public function parse($input) {
98
+	public function parse($input) {
99 99
 	global $globalDebug;
100 100
 	$debug = false;
101 101
 	$result = array();
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 	
108 108
 	/* Check that end was found and body has at least one byte. */
109 109
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
110
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
-	    return false;
110
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
111
+		return false;
112 112
 	}
113 113
 	
114 114
 	if ($debug) echo 'input : '.$input."\n";
@@ -122,31 +122,31 @@  discard block
 block discarded – undo
122 122
 	/* Parse source, target and path. */
123 123
 	//FLRDF0A52>APRS,qAS,LSTB
124 124
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
125
-	    $ident = $matches[1];
126
-	    $all_elements = $matches[2];
127
-	    if ($ident == 'AIRCRAFT') {
125
+		$ident = $matches[1];
126
+		$all_elements = $matches[2];
127
+		if ($ident == 'AIRCRAFT') {
128 128
 		$result['format_source'] = 'famaprs';
129 129
 		$result['source_type'] = 'modes';
130
-	    } elseif ($ident == 'MARINE') {
130
+		} elseif ($ident == 'MARINE') {
131 131
 		$result['format_source'] = 'famaprs';
132 132
 		$result['source_type'] = 'ais';
133
-	    } else {
133
+		} else {
134 134
 		if ($debug) echo 'ident : '.$ident."\n";
135 135
 		$result['ident'] = $ident;
136
-	    }
136
+		}
137 137
 	} else return false;
138 138
 	$elements = explode(',',$all_elements);
139 139
 	$source = end($elements);
140 140
 	$result['source'] = $source;
141 141
 	foreach ($elements as $element) {
142
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
-	        //echo "ok";
144
-	        //if ($element == 'TCPIP*') return false;
145
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
142
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
143
+			//echo "ok";
144
+			//if ($element == 'TCPIP*') return false;
145
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
146 146
 		if ($debug) echo 'element : '.$element."\n";
147 147
 		return false;
148
-	    }
149
-	    /*
148
+		}
149
+		/*
150 150
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
151 151
 		//echo "ok";
152 152
 	    } else {
@@ -171,49 +171,49 @@  discard block
 block discarded – undo
171 171
 	$body_parse = substr($body,1);
172 172
 	//echo 'Body : '.$body."\n";
173 173
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
174
-	    $body_parse = substr($body_parse,10);
175
-	    $find = true;
176
-	    //echo $body_parse."\n";
174
+		$body_parse = substr($body_parse,10);
175
+		$find = true;
176
+		//echo $body_parse."\n";
177 177
 	}
178 178
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
179
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
180
-	    $find = true;
181
-	    //echo $body_parse."\n";
179
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
180
+		$find = true;
181
+		//echo $body_parse."\n";
182 182
 	}
183 183
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
184
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
185
-	    $find = true;
186
-	    //echo $body_parse."\n";
184
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
185
+		$find = true;
186
+		//echo $body_parse."\n";
187 187
 	}
188 188
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
189
-	    $find = true;
190
-	    //print_r($matches);
191
-	    $timestamp = $matches[0];
192
-	    if ($matches[4] == 'h') {
189
+		$find = true;
190
+		//print_r($matches);
191
+		$timestamp = $matches[0];
192
+		if ($matches[4] == 'h') {
193 193
 		$timestamp = strtotime($matches[1].':'.$matches[2].':'.$matches[3]);
194 194
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
195 195
 		/*
196 196
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
197 197
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
198 198
 		*/
199
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
199
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
200 200
 		// This work or not ?
201 201
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
202
-	    }
203
-	    $body_parse = substr($body_parse,7);
204
-	    $result['timestamp'] = $timestamp;
205
-	    //echo date('Ymd H:i:s',$timestamp);
202
+		}
203
+		$body_parse = substr($body_parse,7);
204
+		$result['timestamp'] = $timestamp;
205
+		//echo date('Ymd H:i:s',$timestamp);
206 206
 	}
207 207
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
208
-	    $find = true;
209
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
210
-	    $body_parse = substr($body_parse,8);
211
-	    $result['timestamp'] = $timestamp;
212
-	    //echo date('Ymd H:i:s',$timestamp);
208
+		$find = true;
209
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
210
+		$body_parse = substr($body_parse,8);
211
+		$result['timestamp'] = $timestamp;
212
+		//echo date('Ymd H:i:s',$timestamp);
213 213
 	}
214 214
 	//if (strlen($body_parse) > 19) {
215
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
216
-	    $find = true;
215
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
216
+		$find = true;
217 217
 		// 4658.70N/00707.78Ez
218 218
 		//print_r(str_split($body_parse));
219 219
 		
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 		$lon = intval($lon_deg);
231 231
 		if ($lat > 89 || $lon > 179) return false;
232 232
 	    
233
-	    /*
233
+		/*
234 234
 	    $tmp_5b = str_replace('.','',$lat_min);
235 235
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
236 236
 	        print_r($matches);
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 		$result['longitude'] = $longitude;
245 245
 		$body_parse = substr($body_parse,18);
246 246
 		$body_parse_len = strlen($body_parse);
247
-	    }
248
-	    $body_parse_len = strlen($body_parse);
249
-	    if ($body_parse_len > 0) {
247
+		}
248
+		$body_parse_len = strlen($body_parse);
249
+		if ($body_parse_len > 0) {
250 250
 		/*
251 251
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
252 252
 			$body_split = str_split($body);
@@ -276,86 +276,86 @@  discard block
 block discarded – undo
276 276
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
277 277
 			if ($symbol_code != '_') {
278 278
 			}
279
-		    //$body_parse = substr($body_parse,1);
280
-		    //$body_parse = trim($body_parse);
281
-		    //$body_parse_len = strlen($body_parse);
282
-		    if ($body_parse_len >= 7) {
279
+			//$body_parse = substr($body_parse,1);
280
+			//$body_parse = trim($body_parse);
281
+			//$body_parse_len = strlen($body_parse);
282
+			if ($body_parse_len >= 7) {
283 283
 			
284
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285
-		    	    $course = substr($body_parse,0,3);
286
-		    	    $tmp_s = intval($course);
287
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
288
-		    	    $speed = substr($body_parse,4,3);
289
-		    	    if ($speed != '...') {
290
-		    		//$result['speed'] = round($speed*1.852);
291
-		    		$result['speed'] = intval($speed);
292
-		    	    }
293
-		    	    $body_parse = substr($body_parse,7);
294
-		        }
295
-		        // Check PHGR, PHG, RNG
296
-		    } 
297
-		    /*
284
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
285
+					$course = substr($body_parse,0,3);
286
+					$tmp_s = intval($course);
287
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
288
+					$speed = substr($body_parse,4,3);
289
+					if ($speed != '...') {
290
+					//$result['speed'] = round($speed*1.852);
291
+					$result['speed'] = intval($speed);
292
+					}
293
+					$body_parse = substr($body_parse,7);
294
+				}
295
+				// Check PHGR, PHG, RNG
296
+			} 
297
+			/*
298 298
 		    else if ($body_parse_len > 0) {
299 299
 			$rest = $body_parse;
300 300
 		    }
301 301
 		    */
302
-		    if (strlen($body_parse) > 0) {
303
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
-		            $altitude = intval($matches[1]);
305
-		            //$result['altitude'] = round($altitude*0.3048);
306
-		            $result['altitude'] = $altitude;
307
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
308
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
-		        }
310
-		    }
302
+			if (strlen($body_parse) > 0) {
303
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
304
+					$altitude = intval($matches[1]);
305
+					//$result['altitude'] = round($altitude*0.3048);
306
+					$result['altitude'] = $altitude;
307
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
308
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
309
+				}
310
+			}
311 311
 		    
312
-		    // Telemetry
313
-		    /*
312
+			// Telemetry
313
+			/*
314 314
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
315 315
 		        // Nothing yet...
316 316
 		    }
317 317
 		    */
318
-		    // DAO
319
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
320
-			    $dao = $matches[1];
321
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
318
+			// DAO
319
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
320
+				$dao = $matches[1];
321
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
322 322
 				$dao_split = str_split($dao);
323
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
324
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
323
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
324
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
325 325
 			    
326 326
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
327 327
 				else $result['latitude'] += $lat_off;
328 328
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
329 329
 				else $result['longitude'] += $lon_off;
330
-			    }
331
-		            $body_parse = substr($body_parse,6);
332
-		    }
330
+				}
331
+					$body_parse = substr($body_parse,6);
332
+			}
333 333
 		    
334
-		    if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
334
+			if (preg_match('/CS=([0-9A-Z]*)/',$body_parse,$matches)) {
335 335
 			$result['ident'] = $matches[1];
336
-		    }
337
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
336
+			}
337
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
338 338
 			$result['squawk'] = $matches[1];
339
-		    }
340
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
339
+			}
340
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
341 341
 			$result['aircraft_icao'] = $matches[1];
342
-		    }
343
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
342
+			}
343
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
344 344
 			$result['typeid'] = $matches[1];
345
-		    }
346
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
345
+			}
346
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
347 347
 			$result['imo'] = $matches[1];
348
-		    }
349
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
348
+			}
349
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
350 350
 			$result['arrival_date'] = $matches[1];
351
-		    }
352
-		    if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
351
+			}
352
+			if (preg_match('/AC=([0-9A-Z]*)/',$body_parse,$matches)) {
353 353
 			$result['arrival_code'] = $matches[1];
354
-		    }
355
-		    // OGN comment
354
+			}
355
+			// OGN comment
356 356
 		   // echo "Before OGN : ".$body_parse."\n";
357
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
358
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
357
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
358
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
359 359
 			$id = $matches[1];
360 360
 			//$mode = substr($id,0,2);
361 361
 			$address = substr($id,2);
@@ -385,53 +385,53 @@  discard block
 block discarded – undo
385 385
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
386 386
 			$result['stealth'] = $stealth;
387 387
 			$result['address'] = $address;
388
-		    }
388
+			}
389 389
 		    
390
-		    //Comment
391
-		    $result['comment'] = trim($body_parse);
390
+			//Comment
391
+			$result['comment'] = trim($body_parse);
392 392
 		} else {
393
-		    // parse weather
394
-		    //$body_parse = substr($body_parse,1);
395
-		    //$body_parse_len = strlen($body_parse);
393
+			// parse weather
394
+			//$body_parse = substr($body_parse,1);
395
+			//$body_parse_len = strlen($body_parse);
396 396
 
397
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
398
-			    $result['wind_dir'] = intval($matches[1]);
399
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
400
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
401
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
402
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
403
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
397
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
398
+				$result['wind_dir'] = intval($matches[1]);
399
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
400
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
401
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
402
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
403
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
404 404
 			$result['wind_dir'] = intval($matches[1]);
405 405
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
406 406
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
407 407
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
408
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
409
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
408
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
409
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
410 410
 			$result['wind_dir'] = intval($matches[1]);
411 411
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
412 412
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
413
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
414
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
413
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
414
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
415 415
 			$result['wind_dir'] = intval($matches[1]);
416 416
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
417 417
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
418
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
419
-		    }
420
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
418
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
419
+			}
420
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
421 421
 			$result['temp'] = round(5/9*(($matches[1])-32),1);
422
-		    }
422
+			}
423 423
 		}
424 424
 		} else $result['comment'] = trim($body_parse);
425 425
 
426
-	    }
426
+		}
427 427
 	//}
428 428
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
429 429
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
430 430
 	if ($debug) print_r($result);
431 431
 	return $result;
432
-    }
432
+	}
433 433
     
434
-    function connect() {
434
+	function connect() {
435 435
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
436 436
 	$aprs_connect = 0;
437 437
 	$aprs_keep = 120;
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
 		$send = socket_send( $this->socket  , $aprs_login , strlen($aprs_login) , 0 );
455 455
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
456 456
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
457
-			    echo 'APRS user verified !'."\n";
458
-			    $this->connected = true;
459
-			    return true;
460
-			    break;
457
+				echo 'APRS user verified !'."\n";
458
+				$this->connected = true;
459
+				return true;
460
+				break;
461 461
 			}
462 462
 			if (time()-$authstart > 5) {
463
-			    echo 'APRS timeout'."\n";
464
-			    break;
463
+				echo 'APRS timeout'."\n";
464
+				break;
465 465
 			}
466 466
 		}
467 467
 	}
468
-    }
468
+	}
469 469
     
470
-    function send($data) {
470
+	function send($data) {
471 471
 	if ($this->connected === false) $this->connect();
472 472
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
473 473
 	if ($send === FALSE) $this->connect();
474
-    }
474
+	}
475 475
 }
476 476
 
477 477
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Indentation   +859 added lines, -859 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,40 +24,40 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	$globalSources[] = array('host' => $options['s']);
58 58
 } elseif (isset($options['source'])) {
59
-    $globalSources = array();
60
-    $globalSources[] = array('host' => $options['source']);
59
+	$globalSources = array();
60
+	$globalSources[] = array('host' => $options['source']);
61 61
 }
62 62
 if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
63 63
 if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 if (isset($options['idsource'])) $id_source = $options['idsource'];
67 67
 else $id_source = 1;
68 68
 if (isset($globalServer) && $globalServer) {
69
-    if ($globalDebug) echo "Using Server Mode\n";
70
-    $SI=new SpotterServer();
69
+	if ($globalDebug) echo "Using Server Mode\n";
70
+	$SI=new SpotterServer();
71 71
 /*
72 72
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
73 73
     $SI = new adsb2aprs();
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 } else $SI=new SpotterImport($Connection->db);
77 77
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
78 78
 if (isset($globalMarine) && $globalMarine) {
79
-    $AIS = new AIS();
80
-    $MI = new MarineImport($Connection->db);
79
+	$AIS = new AIS();
80
+	$MI = new MarineImport($Connection->db);
81 81
 }
82 82
 //$APRS=new APRS($Connection->db);
83 83
 $SBS=new SBS();
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 //$servertz = system('date +%Z');
88 88
 // signal handler - playing nice with sockets and dump1090
89 89
 if (function_exists('pcntl_fork')) {
90
-    pcntl_signal(SIGINT,  function() {
91
-        global $sockets;
92
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
93
-        die("Bye!\n");
94
-    });
95
-    pcntl_signal_dispatch();
90
+	pcntl_signal(SIGINT,  function() {
91
+		global $sockets;
92
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
93
+		die("Bye!\n");
94
+	});
95
+	pcntl_signal_dispatch();
96 96
 }
97 97
 
98 98
 // let's try and connect
@@ -102,153 +102,153 @@  discard block
 block discarded – undo
102 102
 $reset = 0;
103 103
 
104 104
 function connect_all($hosts) {
105
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107
-    $reset++;
108
-    if ($globalDebug) echo 'Connect to all...'."\n";
109
-    foreach ($hosts as $id => $value) {
105
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
106
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
107
+	$reset++;
108
+	if ($globalDebug) echo 'Connect to all...'."\n";
109
+	foreach ($hosts as $id => $value) {
110 110
 	$host = $value['host'];
111 111
 	$globalSources[$id]['last_exec'] = 0;
112 112
 	// Here we check type of source(s)
113 113
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
114
-            if (preg_match('/deltadb.txt$/i',$host)) {
115
-        	//$formats[$id] = 'deltadbtxt';
116
-        	$globalSources[$id]['format'] = 'deltadbtxt';
117
-        	//$last_exec['deltadbtxt'] = 0;
118
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
119
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
120
-        	//$formats[$id] = 'vatsimtxt';
121
-        	$globalSources[$id]['format'] = 'vatsimtxt';
122
-        	//$last_exec['vatsimtxt'] = 0;
123
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
124
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
125
-        	//$formats[$id] = 'aircraftlistjson';
126
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
127
-        	//$last_exec['aircraftlistjson'] = 0;
128
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
129
-    	    } else if (preg_match('/opensky/i',$host)) {
130
-        	//$formats[$id] = 'aircraftlistjson';
131
-        	$globalSources[$id]['format'] = 'opensky';
132
-        	//$last_exec['aircraftlistjson'] = 0;
133
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
134
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135
-        	//$formats[$id] = 'radarvirtueljson';
136
-        	$globalSources[$id]['format'] = 'radarvirtueljson';
137
-        	//$last_exec['radarvirtueljson'] = 0;
138
-        	if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
139
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141
-        	    exit(0);
142
-        	}
143
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
144
-        	//$formats[$id] = 'planeupdatefaa';
145
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
146
-        	//$last_exec['planeupdatefaa'] = 0;
147
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
148
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150
-        	    exit(0);
151
-        	}
152
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
153
-        	//$formats[$id] = 'phpvmacars';
154
-        	$globalSources[$id]['format'] = 'phpvmacars';
155
-        	//$last_exec['phpvmacars'] = 0;
156
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
157
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
158
-        	//$formats[$id] = 'phpvmacars';
159
-        	$globalSources[$id]['format'] = 'vam';
160
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
161
-            } else if (preg_match('/whazzup/i',$host)) {
162
-        	//$formats[$id] = 'whazzup';
163
-        	$globalSources[$id]['format'] = 'whazzup';
164
-        	//$last_exec['whazzup'] = 0;
165
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
166
-            } else if (preg_match('/recentpireps/i',$host)) {
167
-        	//$formats[$id] = 'pirepsjson';
168
-        	$globalSources[$id]['format'] = 'pirepsjson';
169
-        	//$last_exec['pirepsjson'] = 0;
170
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
171
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172
-        	//$formats[$id] = 'fr24json';
173
-        	$globalSources[$id]['format'] = 'fr24json';
174
-        	//$last_exec['fr24json'] = 0;
175
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
176
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178
-        	    exit(0);
179
-        	}
180
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
181
-        	//$formats[$id] = 'fr24json';
182
-        	$globalSources[$id]['format'] = 'myshiptracking';
183
-        	//$last_exec['fr24json'] = 0;
184
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
185
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187
-        	    exit(0);
188
-        	}
189
-            //} else if (preg_match('/10001/',$host)) {
190
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
-        	//$formats[$id] = 'tsv';
192
-        	$globalSources[$id]['format'] = 'tsv';
193
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
194
-            }
195
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
198
-    		    if ($idf !== false) {
199
-    			$httpfeeds[$id] = $idf;
200
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
201
-    		    }
202
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
204
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205
-	    $hostport = explode(':',$host);
206
-	    if (isset($hostport[1])) {
114
+			if (preg_match('/deltadb.txt$/i',$host)) {
115
+			//$formats[$id] = 'deltadbtxt';
116
+			$globalSources[$id]['format'] = 'deltadbtxt';
117
+			//$last_exec['deltadbtxt'] = 0;
118
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
119
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
120
+			//$formats[$id] = 'vatsimtxt';
121
+			$globalSources[$id]['format'] = 'vatsimtxt';
122
+			//$last_exec['vatsimtxt'] = 0;
123
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
124
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
125
+			//$formats[$id] = 'aircraftlistjson';
126
+			$globalSources[$id]['format'] = 'aircraftlistjson';
127
+			//$last_exec['aircraftlistjson'] = 0;
128
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
129
+			} else if (preg_match('/opensky/i',$host)) {
130
+			//$formats[$id] = 'aircraftlistjson';
131
+			$globalSources[$id]['format'] = 'opensky';
132
+			//$last_exec['aircraftlistjson'] = 0;
133
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
134
+			} else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
135
+			//$formats[$id] = 'radarvirtueljson';
136
+			$globalSources[$id]['format'] = 'radarvirtueljson';
137
+			//$last_exec['radarvirtueljson'] = 0;
138
+			if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n";
139
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
140
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
141
+				exit(0);
142
+			}
143
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
144
+			//$formats[$id] = 'planeupdatefaa';
145
+			$globalSources[$id]['format'] = 'planeupdatefaa';
146
+			//$last_exec['planeupdatefaa'] = 0;
147
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
148
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
149
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
150
+				exit(0);
151
+			}
152
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
153
+			//$formats[$id] = 'phpvmacars';
154
+			$globalSources[$id]['format'] = 'phpvmacars';
155
+			//$last_exec['phpvmacars'] = 0;
156
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
157
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
158
+			//$formats[$id] = 'phpvmacars';
159
+			$globalSources[$id]['format'] = 'vam';
160
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
161
+			} else if (preg_match('/whazzup/i',$host)) {
162
+			//$formats[$id] = 'whazzup';
163
+			$globalSources[$id]['format'] = 'whazzup';
164
+			//$last_exec['whazzup'] = 0;
165
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
166
+			} else if (preg_match('/recentpireps/i',$host)) {
167
+			//$formats[$id] = 'pirepsjson';
168
+			$globalSources[$id]['format'] = 'pirepsjson';
169
+			//$last_exec['pirepsjson'] = 0;
170
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
171
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
172
+			//$formats[$id] = 'fr24json';
173
+			$globalSources[$id]['format'] = 'fr24json';
174
+			//$last_exec['fr24json'] = 0;
175
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
176
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
177
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
178
+				exit(0);
179
+			}
180
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
181
+			//$formats[$id] = 'fr24json';
182
+			$globalSources[$id]['format'] = 'myshiptracking';
183
+			//$last_exec['fr24json'] = 0;
184
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
185
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
186
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
187
+				exit(0);
188
+			}
189
+			//} else if (preg_match('/10001/',$host)) {
190
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
191
+			//$formats[$id] = 'tsv';
192
+			$globalSources[$id]['format'] = 'tsv';
193
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
194
+			}
195
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
196
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
197
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
198
+				if ($idf !== false) {
199
+				$httpfeeds[$id] = $idf;
200
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
201
+				}
202
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
203
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
204
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
205
+		$hostport = explode(':',$host);
206
+		if (isset($hostport[1])) {
207 207
 		$port = $hostport[1];
208 208
 		$hostn = $hostport[0];
209
-	    } else {
209
+		} else {
210 210
 		$port = $globalSources[$id]['port'];
211 211
 		$hostn = $globalSources[$id]['host'];
212
-	    }
213
-	    $Common = new Common();
214
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
215
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
216
-    	    } else {
217
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
218
-	    }
219
-	    if ($s) {
220
-    	        $sockets[$id] = $s;
221
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
222
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
212
+		}
213
+		$Common = new Common();
214
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
215
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
216
+			} else {
217
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
218
+		}
219
+		if ($s) {
220
+				$sockets[$id] = $s;
221
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
222
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
223 223
 			//$formats[$id] = 'aprs';
224 224
 			$globalSources[$id]['format'] = 'aprs';
225 225
 			//$aprs_connect = 0;
226 226
 			//$use_aprs = true;
227
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
227
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
228 228
 			$globalSources[$id]['format'] = 'vrstcp';
229
-    		    } elseif ($port == '10001') {
230
-        		//$formats[$id] = 'tsv';
231
-        		$globalSources[$id]['format'] = 'tsv';
232
-		    } elseif ($port == '30002') {
233
-        		//$formats[$id] = 'raw';
234
-        		$globalSources[$id]['format'] = 'raw';
235
-		    } elseif ($port == '5001') {
236
-        		//$formats[$id] = 'raw';
237
-        		$globalSources[$id]['format'] = 'flightgearmp';
238
-		    } elseif ($port == '30005') {
229
+				} elseif ($port == '10001') {
230
+				//$formats[$id] = 'tsv';
231
+				$globalSources[$id]['format'] = 'tsv';
232
+			} elseif ($port == '30002') {
233
+				//$formats[$id] = 'raw';
234
+				$globalSources[$id]['format'] = 'raw';
235
+			} elseif ($port == '5001') {
236
+				//$formats[$id] = 'raw';
237
+				$globalSources[$id]['format'] = 'flightgearmp';
238
+			} elseif ($port == '30005') {
239 239
 			// Not yet supported
240
-        		//$formats[$id] = 'beast';
241
-        		$globalSources[$id]['format'] = 'beast';
242
-		    //} else $formats[$id] = 'sbs';
243
-		    } else $globalSources[$id]['format'] = 'sbs';
244
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
240
+				//$formats[$id] = 'beast';
241
+				$globalSources[$id]['format'] = 'beast';
242
+			//} else $formats[$id] = 'sbs';
243
+			} else $globalSources[$id]['format'] = 'sbs';
244
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
245 245
 		}
246 246
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
247
-            } else {
247
+			} else {
248 248
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
249
-    	    }
250
-        }
251
-    }
249
+			}
250
+		}
251
+	}
252 252
 }
253 253
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
254 254
 
@@ -271,9 +271,9 @@  discard block
 block discarded – undo
271 271
 //connect_all($globalSources);
272 272
 
273 273
 if (isset($globalProxy) && $globalProxy) {
274
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
274
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
275 275
 } else {
276
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
276
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
277 277
 }
278 278
 
279 279
 // APRS Configuration
@@ -282,18 +282,18 @@  discard block
 block discarded – undo
282 282
 	die;
283 283
 }
284 284
 foreach ($globalSources as $key => $source) {
285
-    if (!isset($source['format'])) {
286
-        $globalSources[$key]['format'] = 'auto';
287
-    }
285
+	if (!isset($source['format'])) {
286
+		$globalSources[$key]['format'] = 'auto';
287
+	}
288 288
 }
289 289
 connect_all($globalSources);
290 290
 foreach ($globalSources as $key => $source) {
291
-    if (isset($source['format']) && $source['format'] == 'aprs') {
291
+	if (isset($source['format']) && $source['format'] == 'aprs') {
292 292
 	$aprs_connect = 0;
293 293
 	$use_aprs = true;
294 294
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
295 295
 	break;
296
-    }
296
+	}
297 297
 }
298 298
 
299 299
 if ($use_aprs) {
@@ -335,152 +335,152 @@  discard block
 block discarded – undo
335 335
 
336 336
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
337 337
 while ($i > 0) {
338
-    if (!$globalDaemon) $i = $endtime-time();
339
-    // Delete old ATC
340
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
338
+	if (!$globalDaemon) $i = $endtime-time();
339
+	// Delete old ATC
340
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
341 341
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
342
-        $ATC->deleteOldATC();
343
-    }
342
+		$ATC->deleteOldATC();
343
+	}
344 344
     
345
-    //if (count($last_exec) > 0) {
346
-    if (count($last_exec) == count($globalSources)) {
345
+	//if (count($last_exec) > 0) {
346
+	if (count($last_exec) == count($globalSources)) {
347 347
 	$max = $globalMinFetch;
348 348
 	foreach ($last_exec as $last) {
349
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
349
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
350 350
 	}
351 351
 	if ($max != $globalMinFetch) {
352
-	    if ($globalDebug) echo 'Sleeping...'."\n";
353
-	    sleep($globalMinFetch-$max+2);
352
+		if ($globalDebug) echo 'Sleeping...'."\n";
353
+		sleep($globalMinFetch-$max+2);
354
+	}
354 355
 	}
355
-    }
356 356
 
357 357
     
358
-    //foreach ($formats as $id => $value) {
359
-    foreach ($globalSources as $id => $value) {
358
+	//foreach ($formats as $id => $value) {
359
+	foreach ($globalSources as $id => $value) {
360 360
 	date_default_timezone_set('UTC');
361 361
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
362 362
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
363
-	    //$buffer = $Common->getData($hosts[$id]);
364
-	    $buffer = $Common->getData($value['host']);
365
-	    if ($buffer != '') $reset = 0;
366
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367
-	    $buffer = explode('\n',$buffer);
368
-	    foreach ($buffer as $line) {
369
-    		if ($line != '' && count($line) > 7) {
370
-    		    $line = explode(',', $line);
371
-	            $data = array();
372
-	            $data['hex'] = $line[1]; // hex
373
-	            $data['ident'] = $line[2]; // ident
374
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
379
-	            $data['verticalrate'] = ''; // vertical rate
380
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381
-	            $data['emergency'] = ''; // emergency
382
-		    $data['datetime'] = date('Y-m-d H:i:s');
383
-		    $data['format_source'] = 'deltadbtxt';
384
-    		    $data['id_source'] = $id_source;
385
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
387
-    		    $SI->add($data);
388
-		    unset($data);
389
-    		}
390
-    	    }
391
-    	    $last_exec[$id]['last'] = time();
363
+		//$buffer = $Common->getData($hosts[$id]);
364
+		$buffer = $Common->getData($value['host']);
365
+		if ($buffer != '') $reset = 0;
366
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
367
+		$buffer = explode('\n',$buffer);
368
+		foreach ($buffer as $line) {
369
+			if ($line != '' && count($line) > 7) {
370
+				$line = explode(',', $line);
371
+				$data = array();
372
+				$data['hex'] = $line[1]; // hex
373
+				$data['ident'] = $line[2]; // ident
374
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
375
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
376
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
377
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
378
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
379
+				$data['verticalrate'] = ''; // vertical rate
380
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
381
+				$data['emergency'] = ''; // emergency
382
+			$data['datetime'] = date('Y-m-d H:i:s');
383
+			$data['format_source'] = 'deltadbtxt';
384
+				$data['id_source'] = $id_source;
385
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
386
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
387
+				$SI->add($data);
388
+			unset($data);
389
+			}
390
+			}
391
+			$last_exec[$id]['last'] = time();
392 392
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
393
-	    date_default_timezone_set('CET');
394
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395
-	    date_default_timezone_set('UTC');
396
-	    if ($buffer != '') $reset = 0;
397
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398
-	    $buffer = explode('\n',$buffer);
399
-	    foreach ($buffer as $line) {
393
+		date_default_timezone_set('CET');
394
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
395
+		date_default_timezone_set('UTC');
396
+		if ($buffer != '') $reset = 0;
397
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
398
+		$buffer = explode('\n',$buffer);
399
+		foreach ($buffer as $line) {
400 400
 		if ($line != '') {
401
-		    echo "'".$line."'\n";
402
-		    $add = false;
403
-		    $ais_data = $AIS->parse_line(trim($line));
404
-		    $data = array();
405
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
415
-		    if (isset($ais_data['timestamp'])) {
401
+			echo "'".$line."'\n";
402
+			$add = false;
403
+			$ais_data = $AIS->parse_line(trim($line));
404
+			$data = array();
405
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
406
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
407
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
408
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
409
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
410
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
411
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
412
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
413
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
414
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
415
+			if (isset($ais_data['timestamp'])) {
416 416
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
417 417
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
418
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
419
-			    $add = true;
418
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
419
+				$add = true;
420 420
 			}
421
-		    } else {
421
+			} else {
422 422
 			$data['datetime'] = date('Y-m-d H:i:s');
423 423
 			$add = true;
424
-		    }
425
-		    $data['format_source'] = 'aisnmeatxt';
426
-    		    $data['id_source'] = $id_source;
427
-		    print_r($data);
428
-		    echo 'Add...'."\n";
429
-		    if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
430
-		    unset($data);
424
+			}
425
+			$data['format_source'] = 'aisnmeatxt';
426
+				$data['id_source'] = $id_source;
427
+			print_r($data);
428
+			echo 'Add...'."\n";
429
+			if ($add && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
430
+			unset($data);
431 431
 		}
432
-    	    }
433
-    	    $last_exec[$id]['last'] = time();
432
+			}
433
+			$last_exec[$id]['last'] = time();
434 434
 	} elseif ($value['format'] == 'aisnmeahttp') {
435
-	    $arr = $httpfeeds;
436
-	    $w = $e = null;
435
+		$arr = $httpfeeds;
436
+		$w = $e = null;
437 437
 	    
438
-	    if (isset($arr[$id])) {
439
-	    $nn = stream_select($arr,$w,$e,$timeout);
440
-	    if ($nn > 0) {
438
+		if (isset($arr[$id])) {
439
+		$nn = stream_select($arr,$w,$e,$timeout);
440
+		if ($nn > 0) {
441 441
 		foreach ($httpfeeds as $feed) {
442
-		    $buffer = stream_get_line($feed,2000,"\n");
443
-		    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
444
-		    $buffer = explode('\n',$buffer);
445
-		    foreach ($buffer as $line) {
442
+			$buffer = stream_get_line($feed,2000,"\n");
443
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
444
+			$buffer = explode('\n',$buffer);
445
+			foreach ($buffer as $line) {
446 446
 			if ($line != '') {
447
-			    $ais_data = $AIS->parse_line(trim($line));
448
-			    $data = array();
449
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
461
-			    if (isset($ais_data['timestamp'])) {
447
+				$ais_data = $AIS->parse_line(trim($line));
448
+				$data = array();
449
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
450
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
451
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
452
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
453
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
454
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
455
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
456
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
457
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
458
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
459
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
460
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
461
+				if (isset($ais_data['timestamp'])) {
462 462
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
463
-			    } else {
463
+				} else {
464 464
 				$data['datetime'] = date('Y-m-d H:i:s');
465
-			    }
466
-			    $data['format_source'] = 'aisnmeahttp';
467
-			    $data['id_source'] = $id_source;
468
-			    if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
469
-			    unset($data);
465
+				}
466
+				$data['format_source'] = 'aisnmeahttp';
467
+				$data['id_source'] = $id_source;
468
+				if ($ais_data['mmsi_type'] == 'Ship') $MI->add($data);
469
+				unset($data);
470 470
 			}
471
-		    }
471
+			}
472
+		}
472 473
 		}
473 474
 		}
474
-	    }
475 475
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
476
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
477
-	    if ($buffer != '') {
476
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
477
+		if ($buffer != '') {
478 478
 		//echo $buffer;
479 479
 		$all_data = json_decode($buffer,true);
480 480
 		//print_r($all_data);
481 481
 		if (isset($all_data[0]['DATA'])) {
482 482
 		foreach ($all_data[0]['DATA'] as $line) {
483
-		    if ($line != '') {
483
+			if ($line != '') {
484 484
 			$data = array();
485 485
 			$data['ident'] = $line['NAME'];
486 486
 			$data['mmsi'] = $line['MMSI'];
@@ -496,87 +496,87 @@  discard block
 block discarded – undo
496 496
 			$data['id_source'] = $id_source;
497 497
 			$MI->add($data);
498 498
 			unset($data);
499
-		    }
499
+			}
500 500
 		}
501 501
 		}
502 502
 		
503
-	    }
504
-    	    $last_exec[$id]['last'] = time();
503
+		}
504
+			$last_exec[$id]['last'] = time();
505 505
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
506
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
507
-	    if ($buffer != '') {
506
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
507
+		if ($buffer != '') {
508 508
 		$all_data = json_decode($buffer,true);
509 509
 		if (isset($all_data[0]['mmsi'])) {
510
-		    foreach ($all_data as $line) {
510
+			foreach ($all_data as $line) {
511 511
 			if ($line != '') {
512
-			    $data = array();
513
-			    $data['ident'] = $line['shipname'];
514
-			    $data['callsign'] = $line['callsign'];
515
-			    $data['mmsi'] = $line['mmsi'];
516
-			    $data['speed'] = $line['sog'];
517
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
518
-			    $data['latitude'] = $line['latitude'];
519
-			    $data['longitude'] = $line['longitude'];
520
-			    $data['type_id'] = $line['shiptype'];
521
-			    $data['arrival_code'] = $line['destination'];
522
-			    $data['datetime'] = $line['time'];
523
-			    $data['format_source'] = 'boatbeaconapp';
524
-			    $data['id_source'] = $id_source;
525
-			    $MI->add($data);
526
-			    unset($data);
512
+				$data = array();
513
+				$data['ident'] = $line['shipname'];
514
+				$data['callsign'] = $line['callsign'];
515
+				$data['mmsi'] = $line['mmsi'];
516
+				$data['speed'] = $line['sog'];
517
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
518
+				$data['latitude'] = $line['latitude'];
519
+				$data['longitude'] = $line['longitude'];
520
+				$data['type_id'] = $line['shiptype'];
521
+				$data['arrival_code'] = $line['destination'];
522
+				$data['datetime'] = $line['time'];
523
+				$data['format_source'] = 'boatbeaconapp';
524
+				$data['id_source'] = $id_source;
525
+				$MI->add($data);
526
+				unset($data);
527
+			}
527 528
 			}
528
-		    }
529 529
 		}
530 530
 		
531
-	    }
532
-    	    $last_exec[$id]['last'] = time();
531
+		}
532
+			$last_exec[$id]['last'] = time();
533 533
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
534
-	    echo 'download...';
535
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536
-	    echo 'done !'."\n";
537
-	    if ($buffer != '') $reset = 0;
538
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
-	    $buffer = explode('\n',$buffer);
540
-	    foreach ($buffer as $line) {
534
+		echo 'download...';
535
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
536
+		echo 'done !'."\n";
537
+		if ($buffer != '') $reset = 0;
538
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
539
+		$buffer = explode('\n',$buffer);
540
+		foreach ($buffer as $line) {
541 541
 		if ($line != '') {
542
-		    $data = array();
543
-		    $data['mmsi'] = (int)substr($line,0,9);
544
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
545
-		    //$data['status'] = substr($line,21,2);
546
-		    //$data['type'] = substr($line,24,3);
547
-		    $data['latitude'] = substr($line,29,9);
548
-		    $data['longitude'] = substr($line,41,9);
549
-		    $data['speed'] = round(substr($line,51,5));
550
-		    //$data['course'] = substr($line,57,5);
551
-		    $data['heading'] = round(substr($line,63,3));
552
-		    //$data['draft'] = substr($line,67,4);
553
-		    //$data['length'] = substr($line,72,3);
554
-		    //$data['beam'] = substr($line,76,2);
555
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
556
-		    //$data['callsign'] = trim(substr($line,100,7);
557
-		    //$data['dest'] = substr($line,108,20);
558
-		    //$data['etaDate'] = substr($line,129,5);
559
-		    //$data['etaTime'] = substr($line,135,5);
560
-		    $data['format_source'] = 'shipplotter';
561
-    		    $data['id_source'] = $id_source;
562
-		    print_r($data);
563
-		    echo 'Add...'."\n";
564
-		    $MI->add($data);
565
-		    unset($data);
542
+			$data = array();
543
+			$data['mmsi'] = (int)substr($line,0,9);
544
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
545
+			//$data['status'] = substr($line,21,2);
546
+			//$data['type'] = substr($line,24,3);
547
+			$data['latitude'] = substr($line,29,9);
548
+			$data['longitude'] = substr($line,41,9);
549
+			$data['speed'] = round(substr($line,51,5));
550
+			//$data['course'] = substr($line,57,5);
551
+			$data['heading'] = round(substr($line,63,3));
552
+			//$data['draft'] = substr($line,67,4);
553
+			//$data['length'] = substr($line,72,3);
554
+			//$data['beam'] = substr($line,76,2);
555
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
556
+			//$data['callsign'] = trim(substr($line,100,7);
557
+			//$data['dest'] = substr($line,108,20);
558
+			//$data['etaDate'] = substr($line,129,5);
559
+			//$data['etaTime'] = substr($line,135,5);
560
+			$data['format_source'] = 'shipplotter';
561
+				$data['id_source'] = $id_source;
562
+			print_r($data);
563
+			echo 'Add...'."\n";
564
+			$MI->add($data);
565
+			unset($data);
566 566
 		}
567
-    	    }
568
-    	    $last_exec[$id]['last'] = time();
567
+			}
568
+			$last_exec[$id]['last'] = time();
569 569
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
570 570
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
571
-	    //$buffer = $Common->getData($hosts[$id]);
572
-	    $buffer = $Common->getData($value['host']);
573
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
574
-	    $buffer = explode('\n',$buffer);
575
-	    $reset = 0;
576
-	    foreach ($buffer as $line) {
577
-    		if ($line != '') {
578
-    		    $line = explode(':', $line);
579
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
571
+		//$buffer = $Common->getData($hosts[$id]);
572
+		$buffer = $Common->getData($value['host']);
573
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
574
+		$buffer = explode('\n',$buffer);
575
+		$reset = 0;
576
+		foreach ($buffer as $line) {
577
+			if ($line != '') {
578
+				$line = explode(':', $line);
579
+				if (count($line) > 30 && $line[0] != 'callsign') {
580 580
 			$data = array();
581 581
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
582 582
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -589,36 +589,36 @@  discard block
 block discarded – undo
589 589
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
590 590
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
591 591
 			$data['latitude'] = $line[5]; // lat
592
-	        	$data['longitude'] = $line[6]; // long
593
-	        	$data['verticalrate'] = ''; // vertical rate
594
-	        	$data['squawk'] = ''; // squawk
595
-	        	$data['emergency'] = ''; // emergency
596
-	        	$data['waypoints'] = $line[30];
592
+				$data['longitude'] = $line[6]; // long
593
+				$data['verticalrate'] = ''; // vertical rate
594
+				$data['squawk'] = ''; // squawk
595
+				$data['emergency'] = ''; // emergency
596
+				$data['waypoints'] = $line[30];
597 597
 			$data['datetime'] = date('Y-m-d H:i:s');
598 598
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
599 599
 			//if (isset($line[37])) $data['last_update'] = $line[37];
600
-		        $data['departure_airport_icao'] = $line[11];
601
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
602
-		        $data['arrival_airport_icao'] = $line[13];
600
+				$data['departure_airport_icao'] = $line[11];
601
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
602
+				$data['arrival_airport_icao'] = $line[13];
603 603
 			$data['frequency'] = $line[4];
604 604
 			$data['type'] = $line[18];
605 605
 			$data['range'] = $line[19];
606 606
 			if (isset($line[35])) $data['info'] = $line[35];
607
-    			$data['id_source'] = $id_source;
608
-	    		//$data['arrival_airport_time'] = ;
609
-	    		if ($line[9] != '') {
610
-	    		    $aircraft_data = explode('/',$line[9]);
611
-	    		    if (isset($aircraft_data[1])) {
612
-	    			$data['aircraft_icao'] = $aircraft_data[1];
613
-	    		    }
614
-        		}
615
-	    		/*
607
+				$data['id_source'] = $id_source;
608
+				//$data['arrival_airport_time'] = ;
609
+				if ($line[9] != '') {
610
+					$aircraft_data = explode('/',$line[9]);
611
+					if (isset($aircraft_data[1])) {
612
+					$data['aircraft_icao'] = $aircraft_data[1];
613
+					}
614
+				}
615
+				/*
616 616
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
617 617
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
618 618
 	    		*/
619
-	    		$data['format_source'] = $value['format'];
619
+				$data['format_source'] = $value['format'];
620 620
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
621
-    			if ($line[3] == 'PILOT') $SI->add($data);
621
+				if ($line[3] == 'PILOT') $SI->add($data);
622 622
 			elseif ($line[3] == 'ATC') {
623 623
 				//print_r($data);
624 624
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -636,247 +636,247 @@  discard block
 block discarded – undo
636 636
 				if (!isset($data['source_name'])) $data['source_name'] = '';
637 637
 				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
638 638
 			}
639
-    			unset($data);
640
-    		    }
641
-    		}
642
-    	    }
643
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
644
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
645
-    	    $last_exec[$id]['last'] = time();
646
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
647
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
648
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
649
-	    if ($buffer != '') {
650
-	    $all_data = json_decode($buffer,true);
651
-	    if (isset($all_data['acList'])) {
639
+				unset($data);
640
+				}
641
+			}
642
+			}
643
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
644
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
645
+			$last_exec[$id]['last'] = time();
646
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
647
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
648
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
649
+		if ($buffer != '') {
650
+		$all_data = json_decode($buffer,true);
651
+		if (isset($all_data['acList'])) {
652 652
 		$reset = 0;
653 653
 		foreach ($all_data['acList'] as $line) {
654
-		    $data = array();
655
-		    $data['hex'] = $line['Icao']; // hex
656
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
662
-		    //$data['verticalrate'] = $line['']; // verticale rate
663
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
664
-		    $data['emergency'] = ''; // emergency
665
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
666
-		    /*
654
+			$data = array();
655
+			$data['hex'] = $line['Icao']; // hex
656
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
657
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
658
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
659
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
660
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
661
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
662
+			//$data['verticalrate'] = $line['']; // verticale rate
663
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
664
+			$data['emergency'] = ''; // emergency
665
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
666
+			/*
667 667
 		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
668 668
 		    else $data['datetime'] = date('Y-m-d H:i:s');
669 669
 		    */
670
-		    $data['datetime'] = date('Y-m-d H:i:s');
671
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
672
-	    	    $data['format_source'] = 'aircraftlistjson';
673
-		    $data['id_source'] = $id_source;
674
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
-		    if (isset($data['latitude'])) $SI->add($data);
676
-		    unset($data);
670
+			$data['datetime'] = date('Y-m-d H:i:s');
671
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
672
+				$data['format_source'] = 'aircraftlistjson';
673
+			$data['id_source'] = $id_source;
674
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
675
+			if (isset($data['latitude'])) $SI->add($data);
676
+			unset($data);
677 677
 		}
678
-	    } elseif (is_array($all_data)) {
678
+		} elseif (is_array($all_data)) {
679 679
 		$reset = 0;
680 680
 		foreach ($all_data as $line) {
681
-		    $data = array();
682
-		    $data['hex'] = $line['hex']; // hex
683
-		    $data['ident'] = $line['flight']; // ident
684
-		    $data['altitude'] = $line['altitude']; // altitude
685
-		    $data['speed'] = $line['speed']; // speed
686
-		    $data['heading'] = $line['track']; // heading
687
-		    $data['latitude'] = $line['lat']; // lat
688
-		    $data['longitude'] = $line['lon']; // long
689
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
690
-		    $data['squawk'] = $line['squawk']; // squawk
691
-		    $data['emergency'] = ''; // emergency
692
-		    $data['datetime'] = date('Y-m-d H:i:s');
693
-	    	    $data['format_source'] = 'aircraftlistjson';
694
-    		    $data['id_source'] = $id_source;
695
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
696
-		    $SI->add($data);
697
-		    unset($data);
681
+			$data = array();
682
+			$data['hex'] = $line['hex']; // hex
683
+			$data['ident'] = $line['flight']; // ident
684
+			$data['altitude'] = $line['altitude']; // altitude
685
+			$data['speed'] = $line['speed']; // speed
686
+			$data['heading'] = $line['track']; // heading
687
+			$data['latitude'] = $line['lat']; // lat
688
+			$data['longitude'] = $line['lon']; // long
689
+			$data['verticalrate'] = $line['vrt']; // verticale rate
690
+			$data['squawk'] = $line['squawk']; // squawk
691
+			$data['emergency'] = ''; // emergency
692
+			$data['datetime'] = date('Y-m-d H:i:s');
693
+				$data['format_source'] = 'aircraftlistjson';
694
+				$data['id_source'] = $id_source;
695
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
696
+			$SI->add($data);
697
+			unset($data);
698
+		}
698 699
 		}
699
-	    }
700
-	    }
701
-    	    //$last_exec['aircraftlistjson'] = time();
702
-    	    $last_exec[$id]['last'] = time();
703
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
704
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
-	    $buffer = $Common->getData($value['host']);
706
-	    $all_data = json_decode($buffer,true);
707
-	    if (isset($all_data['planes'])) {
700
+		}
701
+			//$last_exec['aircraftlistjson'] = time();
702
+			$last_exec[$id]['last'] = time();
703
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
704
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
705
+		$buffer = $Common->getData($value['host']);
706
+		$all_data = json_decode($buffer,true);
707
+		if (isset($all_data['planes'])) {
708 708
 		$reset = 0;
709 709
 		foreach ($all_data['planes'] as $key => $line) {
710
-		    $data = array();
711
-		    $data['hex'] = $key; // hex
712
-		    $data['ident'] = $line[3]; // ident
713
-		    $data['altitude'] = $line[6]; // altitude
714
-		    $data['speed'] = $line[8]; // speed
715
-		    $data['heading'] = $line[7]; // heading
716
-		    $data['latitude'] = $line[4]; // lat
717
-		    $data['longitude'] = $line[5]; // long
718
-		    //$data['verticalrate'] = $line[]; // verticale rate
719
-		    $data['squawk'] = $line[10]; // squawk
720
-		    $data['emergency'] = ''; // emergency
721
-		    $data['registration'] = $line[2];
722
-		    $data['aircraft_icao'] = $line[0];
723
-		    $deparr = explode('-',$line[1]);
724
-		    if (count($deparr) == 2) {
710
+			$data = array();
711
+			$data['hex'] = $key; // hex
712
+			$data['ident'] = $line[3]; // ident
713
+			$data['altitude'] = $line[6]; // altitude
714
+			$data['speed'] = $line[8]; // speed
715
+			$data['heading'] = $line[7]; // heading
716
+			$data['latitude'] = $line[4]; // lat
717
+			$data['longitude'] = $line[5]; // long
718
+			//$data['verticalrate'] = $line[]; // verticale rate
719
+			$data['squawk'] = $line[10]; // squawk
720
+			$data['emergency'] = ''; // emergency
721
+			$data['registration'] = $line[2];
722
+			$data['aircraft_icao'] = $line[0];
723
+			$deparr = explode('-',$line[1]);
724
+			if (count($deparr) == 2) {
725 725
 			$data['departure_airport_icao'] = $deparr[0];
726 726
 			$data['arrival_airport_icao'] = $deparr[1];
727
-		    }
728
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729
-	    	    $data['format_source'] = 'planeupdatefaa';
730
-    		    $data['id_source'] = $id_source;
731
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
732
-		    $SI->add($data);
733
-		    unset($data);
727
+			}
728
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
729
+				$data['format_source'] = 'planeupdatefaa';
730
+				$data['id_source'] = $id_source;
731
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
732
+			$SI->add($data);
733
+			unset($data);
734
+		}
734 735
 		}
735
-	    }
736
-    	    //$last_exec['planeupdatefaa'] = time();
737
-    	    $last_exec[$id]['last'] = time();
738
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
739
-	    $buffer = $Common->getData($value['host']);
740
-	    $all_data = json_decode($buffer,true);
741
-	    if (isset($all_data['states'])) {
736
+			//$last_exec['planeupdatefaa'] = time();
737
+			$last_exec[$id]['last'] = time();
738
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
739
+		$buffer = $Common->getData($value['host']);
740
+		$all_data = json_decode($buffer,true);
741
+		if (isset($all_data['states'])) {
742 742
 		$reset = 0;
743 743
 		foreach ($all_data['states'] as $key => $line) {
744
-		    $data = array();
745
-		    $data['hex'] = $line[0]; // hex
746
-		    $data['ident'] = trim($line[1]); // ident
747
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
748
-		    $data['speed'] = round($line[9]*1.94384); // speed
749
-		    $data['heading'] = round($line[10]); // heading
750
-		    $data['latitude'] = $line[5]; // lat
751
-		    $data['longitude'] = $line[6]; // long
752
-		    $data['verticalrate'] = $line[11]; // verticale rate
753
-		    //$data['squawk'] = $line[10]; // squawk
754
-		    //$data['emergency'] = ''; // emergency
755
-		    //$data['registration'] = $line[2];
756
-		    //$data['aircraft_icao'] = $line[0];
757
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
758
-	    	    $data['format_source'] = 'opensky';
759
-    		    $data['id_source'] = $id_source;
760
-		    $SI->add($data);
761
-		    unset($data);
744
+			$data = array();
745
+			$data['hex'] = $line[0]; // hex
746
+			$data['ident'] = trim($line[1]); // ident
747
+			$data['altitude'] = round($line[7]*3.28084); // altitude
748
+			$data['speed'] = round($line[9]*1.94384); // speed
749
+			$data['heading'] = round($line[10]); // heading
750
+			$data['latitude'] = $line[5]; // lat
751
+			$data['longitude'] = $line[6]; // long
752
+			$data['verticalrate'] = $line[11]; // verticale rate
753
+			//$data['squawk'] = $line[10]; // squawk
754
+			//$data['emergency'] = ''; // emergency
755
+			//$data['registration'] = $line[2];
756
+			//$data['aircraft_icao'] = $line[0];
757
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
758
+				$data['format_source'] = 'opensky';
759
+				$data['id_source'] = $id_source;
760
+			$SI->add($data);
761
+			unset($data);
762
+		}
762 763
 		}
763
-	    }
764
-    	    //$last_exec['planeupdatefaa'] = time();
765
-    	    $last_exec[$id]['last'] = time();
766
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
767
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
-	    //$buffer = $Common->getData($hosts[$id]);
769
-	    $buffer = $Common->getData($value['host']);
770
-	    $all_data = json_decode($buffer,true);
771
-	    if (!empty($all_data)) $reset = 0;
772
-	    foreach ($all_data as $key => $line) {
764
+			//$last_exec['planeupdatefaa'] = time();
765
+			$last_exec[$id]['last'] = time();
766
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
767
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
+		//$buffer = $Common->getData($hosts[$id]);
769
+		$buffer = $Common->getData($value['host']);
770
+		$all_data = json_decode($buffer,true);
771
+		if (!empty($all_data)) $reset = 0;
772
+		foreach ($all_data as $key => $line) {
773 773
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
774
-		    $data = array();
775
-		    $data['hex'] = $line[0];
776
-		    $data['ident'] = $line[16]; //$line[13]
777
-	    	    $data['altitude'] = $line[4]; // altitude
778
-	    	    $data['speed'] = $line[5]; // speed
779
-	    	    $data['heading'] = $line[3]; // heading
780
-	    	    $data['latitude'] = $line[1]; // lat
781
-	    	    $data['longitude'] = $line[2]; // long
782
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
783
-	    	    $data['squawk'] = $line[6]; // squawk
784
-	    	    $data['aircraft_icao'] = $line[8];
785
-	    	    $data['registration'] = $line[9];
786
-		    $data['departure_airport_iata'] = $line[11];
787
-		    $data['arrival_airport_iata'] = $line[12];
788
-	    	    $data['emergency'] = ''; // emergency
789
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790
-	    	    $data['format_source'] = 'fr24json';
791
-    		    $data['id_source'] = $id_source;
792
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
793
-		    $SI->add($data);
794
-		    unset($data);
774
+			$data = array();
775
+			$data['hex'] = $line[0];
776
+			$data['ident'] = $line[16]; //$line[13]
777
+				$data['altitude'] = $line[4]; // altitude
778
+				$data['speed'] = $line[5]; // speed
779
+				$data['heading'] = $line[3]; // heading
780
+				$data['latitude'] = $line[1]; // lat
781
+				$data['longitude'] = $line[2]; // long
782
+				$data['verticalrate'] = $line[15]; // verticale rate
783
+				$data['squawk'] = $line[6]; // squawk
784
+				$data['aircraft_icao'] = $line[8];
785
+				$data['registration'] = $line[9];
786
+			$data['departure_airport_iata'] = $line[11];
787
+			$data['arrival_airport_iata'] = $line[12];
788
+				$data['emergency'] = ''; // emergency
789
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
790
+				$data['format_source'] = 'fr24json';
791
+				$data['id_source'] = $id_source;
792
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
793
+			$SI->add($data);
794
+			unset($data);
795
+		}
795 796
 		}
796
-	    }
797
-    	    //$last_exec['fr24json'] = time();
798
-    	    $last_exec[$id]['last'] = time();
799
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
800
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
801
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
802
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
803
-	    //echo $buffer;
804
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
805
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
806
-	    $all_data = json_decode($buffer,true);
807
-	    if (json_last_error() != JSON_ERROR_NONE) {
797
+			//$last_exec['fr24json'] = time();
798
+			$last_exec[$id]['last'] = time();
799
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
800
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
801
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
802
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
803
+		//echo $buffer;
804
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
805
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
806
+		$all_data = json_decode($buffer,true);
807
+		if (json_last_error() != JSON_ERROR_NONE) {
808 808
 		die(json_last_error_msg());
809
-	    }
810
-	    if (isset($all_data['mrkrs'])) {
809
+		}
810
+		if (isset($all_data['mrkrs'])) {
811 811
 		$reset = 0;
812 812
 		foreach ($all_data['mrkrs'] as $key => $line) {
813
-		    if (isset($line['inf'])) {
813
+			if (isset($line['inf'])) {
814 814
 			$data = array();
815 815
 			$data['hex'] = $line['inf']['ia'];
816 816
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
817
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
820
-	    		$data['latitude'] = $line['pt'][0]; // lat
821
-	    		$data['longitude'] = $line['pt'][1]; // long
822
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
824
-	    		//$data['aircraft_icao'] = $line[8];
825
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
817
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
818
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
819
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
820
+				$data['latitude'] = $line['pt'][0]; // lat
821
+				$data['longitude'] = $line['pt'][1]; // long
822
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
823
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
824
+				//$data['aircraft_icao'] = $line[8];
825
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
826 826
 			//$data['departure_airport_iata'] = $line[11];
827 827
 			//$data['arrival_airport_iata'] = $line[12];
828
-	    		//$data['emergency'] = ''; // emergency
828
+				//$data['emergency'] = ''; // emergency
829 829
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
830
-	    		$data['format_source'] = 'radarvirtueljson';
831
-    			$data['id_source'] = $id_source;
830
+				$data['format_source'] = 'radarvirtueljson';
831
+				$data['id_source'] = $id_source;
832 832
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
833 833
 			$SI->add($data);
834 834
 			unset($data);
835
-		    }
835
+			}
836 836
 		}
837
-	    }
838
-    	    //$last_exec['radarvirtueljson'] = time();
839
-    	    $last_exec[$id]['last'] = time();
840
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
841
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
842
-	    //$buffer = $Common->getData($hosts[$id]);
843
-	    $buffer = $Common->getData($value['host'].'?'.time());
844
-	    $all_data = json_decode(utf8_encode($buffer),true);
837
+		}
838
+			//$last_exec['radarvirtueljson'] = time();
839
+			$last_exec[$id]['last'] = time();
840
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
841
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
842
+		//$buffer = $Common->getData($hosts[$id]);
843
+		$buffer = $Common->getData($value['host'].'?'.time());
844
+		$all_data = json_decode(utf8_encode($buffer),true);
845 845
 	    
846
-	    if (isset($all_data['pireps'])) {
846
+		if (isset($all_data['pireps'])) {
847 847
 		$reset = 0;
848
-	        foreach ($all_data['pireps'] as $line) {
849
-		    $data = array();
850
-		    $data['id'] = $line['id'];
851
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852
-		    $data['ident'] = $line['callsign']; // ident
853
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
859
-		    $data['latitude'] = $line['lat']; // lat
860
-		    $data['longitude'] = $line['lon']; // long
861
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
862
-		    //$data['squawk'] = $line['squawk']; // squawk
863
-		    //$data['emergency'] = ''; // emergency
864
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
867
-		    //$data['arrival_airport_time'] = $line['arrtime'];
868
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
871
-		    else $data['info'] = '';
872
-		    $data['format_source'] = 'pireps';
873
-    		    $data['id_source'] = $id_source;
874
-		    $data['datetime'] = date('Y-m-d H:i:s');
875
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
876
-		    if ($line['icon'] == 'plane') {
848
+			foreach ($all_data['pireps'] as $line) {
849
+			$data = array();
850
+			$data['id'] = $line['id'];
851
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
852
+			$data['ident'] = $line['callsign']; // ident
853
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
854
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
855
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
856
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
857
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
858
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
859
+			$data['latitude'] = $line['lat']; // lat
860
+			$data['longitude'] = $line['lon']; // long
861
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
862
+			//$data['squawk'] = $line['squawk']; // squawk
863
+			//$data['emergency'] = ''; // emergency
864
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
865
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
866
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
867
+			//$data['arrival_airport_time'] = $line['arrtime'];
868
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
869
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
870
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
871
+			else $data['info'] = '';
872
+			$data['format_source'] = 'pireps';
873
+				$data['id_source'] = $id_source;
874
+			$data['datetime'] = date('Y-m-d H:i:s');
875
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
876
+			if ($line['icon'] == 'plane') {
877 877
 			$SI->add($data);
878
-		    //    print_r($data);
879
-    		    } elseif ($line['icon'] == 'ct') {
878
+			//    print_r($data);
879
+				} elseif ($line['icon'] == 'ct') {
880 880
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
881 881
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
882 882
 			$typec = substr($data['ident'],-3);
@@ -891,190 +891,190 @@  discard block
 block discarded – undo
891 891
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
892 892
 			else $data['type'] = 'Observer';
893 893
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
894
-		    }
895
-		    unset($data);
894
+			}
895
+			unset($data);
896 896
 		}
897
-	    }
898
-    	    //$last_exec['pirepsjson'] = time();
899
-    	    $last_exec[$id]['last'] = time();
900
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902
-	    //$buffer = $Common->getData($hosts[$id]);
903
-	    if ($globalDebug) echo 'Get Data...'."\n";
904
-	    $buffer = $Common->getData($value['host']);
905
-	    $all_data = json_decode($buffer,true);
906
-	    if ($buffer != '' && is_array($all_data)) {
897
+		}
898
+			//$last_exec['pirepsjson'] = time();
899
+			$last_exec[$id]['last'] = time();
900
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
901
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
902
+		//$buffer = $Common->getData($hosts[$id]);
903
+		if ($globalDebug) echo 'Get Data...'."\n";
904
+		$buffer = $Common->getData($value['host']);
905
+		$all_data = json_decode($buffer,true);
906
+		if ($buffer != '' && is_array($all_data)) {
907 907
 		$reset = 0;
908 908
 		foreach ($all_data as $line) {
909
-	    	    $data = array();
910
-	    	    //$data['id'] = $line['id']; // id not usable
911
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
912
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
915
-	    	    $data['ident'] = $line['flightnum']; // ident
916
-	    	    $data['altitude'] = $line['alt']; // altitude
917
-	    	    $data['speed'] = $line['gs']; // speed
918
-	    	    $data['heading'] = $line['heading']; // heading
919
-	    	    $data['latitude'] = $line['lat']; // lat
920
-	    	    $data['longitude'] = $line['lng']; // long
921
-	    	    $data['verticalrate'] = ''; // verticale rate
922
-	    	    $data['squawk'] = ''; // squawk
923
-	    	    $data['emergency'] = ''; // emergency
924
-	    	    //$data['datetime'] = $line['lastupdate'];
925
-	    	    $data['last_update'] = $line['lastupdate'];
926
-		    $data['datetime'] = date('Y-m-d H:i:s');
927
-	    	    $data['departure_airport_icao'] = $line['depicao'];
928
-	    	    $data['departure_airport_time'] = $line['deptime'];
929
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
930
-    		    $data['arrival_airport_time'] = $line['arrtime'];
931
-    		    $data['registration'] = $line['aircraft'];
932
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
933
-		    if (isset($line['aircraftname'])) {
909
+				$data = array();
910
+				//$data['id'] = $line['id']; // id not usable
911
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
912
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
913
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
914
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
915
+				$data['ident'] = $line['flightnum']; // ident
916
+				$data['altitude'] = $line['alt']; // altitude
917
+				$data['speed'] = $line['gs']; // speed
918
+				$data['heading'] = $line['heading']; // heading
919
+				$data['latitude'] = $line['lat']; // lat
920
+				$data['longitude'] = $line['lng']; // long
921
+				$data['verticalrate'] = ''; // verticale rate
922
+				$data['squawk'] = ''; // squawk
923
+				$data['emergency'] = ''; // emergency
924
+				//$data['datetime'] = $line['lastupdate'];
925
+				$data['last_update'] = $line['lastupdate'];
926
+			$data['datetime'] = date('Y-m-d H:i:s');
927
+				$data['departure_airport_icao'] = $line['depicao'];
928
+				$data['departure_airport_time'] = $line['deptime'];
929
+				$data['arrival_airport_icao'] = $line['arricao'];
930
+				$data['arrival_airport_time'] = $line['arrtime'];
931
+				$data['registration'] = $line['aircraft'];
932
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
933
+			if (isset($line['aircraftname'])) {
934 934
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
935 935
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
936
-	    		$aircraft_data = explode('-',$line['aircraftname']);
937
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
-	    		else {
940
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
941
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
-	    		    else $data['aircraft_icao'] = $line['aircraftname'];
943
-	    		}
944
-	    	    }
945
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
946
-    		    $data['id_source'] = $id_source;
947
-	    	    $data['format_source'] = 'phpvmacars';
948
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
949
-		    $SI->add($data);
950
-		    unset($data);
936
+				$aircraft_data = explode('-',$line['aircraftname']);
937
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0];
938
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1];
939
+				else {
940
+					$aircraft_data = explode(' ',$line['aircraftname']);
941
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1];
942
+					else $data['aircraft_icao'] = $line['aircraftname'];
943
+				}
944
+				}
945
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
946
+				$data['id_source'] = $id_source;
947
+				$data['format_source'] = 'phpvmacars';
948
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
949
+			$SI->add($data);
950
+			unset($data);
951 951
 		}
952 952
 		if ($globalDebug) echo 'No more data...'."\n";
953 953
 		unset($buffer);
954 954
 		unset($all_data);
955
-	    }
956
-    	    //$last_exec['phpvmacars'] = time();
957
-    	    $last_exec[$id]['last'] = time();
958
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
-	    //$buffer = $Common->getData($hosts[$id]);
960
-	    if ($globalDebug) echo 'Get Data...'."\n";
961
-	    $buffer = $Common->getData($value['host']);
962
-	    $all_data = json_decode($buffer,true);
963
-	    if ($buffer != '' && is_array($all_data)) {
955
+		}
956
+			//$last_exec['phpvmacars'] = time();
957
+			$last_exec[$id]['last'] = time();
958
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
959
+		//$buffer = $Common->getData($hosts[$id]);
960
+		if ($globalDebug) echo 'Get Data...'."\n";
961
+		$buffer = $Common->getData($value['host']);
962
+		$all_data = json_decode($buffer,true);
963
+		if ($buffer != '' && is_array($all_data)) {
964 964
 		$reset = 0;
965 965
 		foreach ($all_data as $line) {
966
-	    	    $data = array();
967
-	    	    //$data['id'] = $line['id']; // id not usable
968
-	    	    $data['id'] = trim($line['flight_id']);
969
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
970
-	    	    $data['pilot_name'] = $line['pilot_name'];
971
-	    	    $data['pilot_id'] = $line['pilot_id'];
972
-	    	    $data['ident'] = trim($line['callsign']); // ident
973
-	    	    $data['altitude'] = $line['altitude']; // altitude
974
-	    	    $data['speed'] = $line['gs']; // speed
975
-	    	    $data['heading'] = $line['heading']; // heading
976
-	    	    $data['latitude'] = $line['latitude']; // lat
977
-	    	    $data['longitude'] = $line['longitude']; // long
978
-	    	    $data['verticalrate'] = ''; // verticale rate
979
-	    	    $data['squawk'] = ''; // squawk
980
-	    	    $data['emergency'] = ''; // emergency
981
-	    	    //$data['datetime'] = $line['lastupdate'];
982
-	    	    $data['last_update'] = $line['last_update'];
983
-		    $data['datetime'] = date('Y-m-d H:i:s');
984
-	    	    $data['departure_airport_icao'] = $line['departure'];
985
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
986
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
987
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
988
-    		    //$data['registration'] = $line['aircraft'];
989
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
990
-	    	    $data['aircraft_icao'] = $line['plane_type'];
991
-    		    $data['id_source'] = $id_source;
992
-	    	    $data['format_source'] = 'vam';
993
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
-		    $SI->add($data);
995
-		    unset($data);
966
+				$data = array();
967
+				//$data['id'] = $line['id']; // id not usable
968
+				$data['id'] = trim($line['flight_id']);
969
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
970
+				$data['pilot_name'] = $line['pilot_name'];
971
+				$data['pilot_id'] = $line['pilot_id'];
972
+				$data['ident'] = trim($line['callsign']); // ident
973
+				$data['altitude'] = $line['altitude']; // altitude
974
+				$data['speed'] = $line['gs']; // speed
975
+				$data['heading'] = $line['heading']; // heading
976
+				$data['latitude'] = $line['latitude']; // lat
977
+				$data['longitude'] = $line['longitude']; // long
978
+				$data['verticalrate'] = ''; // verticale rate
979
+				$data['squawk'] = ''; // squawk
980
+				$data['emergency'] = ''; // emergency
981
+				//$data['datetime'] = $line['lastupdate'];
982
+				$data['last_update'] = $line['last_update'];
983
+			$data['datetime'] = date('Y-m-d H:i:s');
984
+				$data['departure_airport_icao'] = $line['departure'];
985
+				//$data['departure_airport_time'] = $line['departure_time'];
986
+				$data['arrival_airport_icao'] = $line['arrival'];
987
+				//$data['arrival_airport_time'] = $line['arrival_time'];
988
+				//$data['registration'] = $line['aircraft'];
989
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
990
+				$data['aircraft_icao'] = $line['plane_type'];
991
+				$data['id_source'] = $id_source;
992
+				$data['format_source'] = 'vam';
993
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
994
+			$SI->add($data);
995
+			unset($data);
996 996
 		}
997 997
 		if ($globalDebug) echo 'No more data...'."\n";
998 998
 		unset($buffer);
999 999
 		unset($all_data);
1000
-	    }
1001
-    	    //$last_exec['phpvmacars'] = time();
1002
-    	    $last_exec[$id]['last'] = time();
1000
+		}
1001
+			//$last_exec['phpvmacars'] = time();
1002
+			$last_exec[$id]['last'] = time();
1003 1003
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1004 1004
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1005
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1006
-    	    //$last_exec[$id]['last'] = time();
1005
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1006
+			//$last_exec[$id]['last'] = time();
1007 1007
 
1008
-	    //$read = array( $sockets[$id] );
1009
-	    $read = $sockets;
1010
-	    $write = NULL;
1011
-	    $e = NULL;
1012
-	    $n = socket_select($read, $write, $e, $timeout);
1013
-	    if ($e != NULL) var_dump($e);
1014
-	    if ($n > 0) {
1008
+		//$read = array( $sockets[$id] );
1009
+		$read = $sockets;
1010
+		$write = NULL;
1011
+		$e = NULL;
1012
+		$n = socket_select($read, $write, $e, $timeout);
1013
+		if ($e != NULL) var_dump($e);
1014
+		if ($n > 0) {
1015 1015
 		$reset = 0;
1016 1016
 		foreach ($read as $nb => $r) {
1017
-		    //$value = $formats[$nb];
1018
-		    $format = $globalSources[$nb]['format'];
1019
-        	    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') {
1020
-        		$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1021
-        	    } else {
1022
-	    	        $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1023
-	    	    }
1024
-        	    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1025
-        	    //echo $buffer."\n";
1026
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1027
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1028
-		    $error = false;
1029
-		    //$SI::del();
1030
-		    if ($format == 'vrstcp') {
1017
+			//$value = $formats[$nb];
1018
+			$format = $globalSources[$nb]['format'];
1019
+				if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3' || $format == 'vrstcp') {
1020
+				$buffer = socket_read($r, 6000,PHP_NORMAL_READ);
1021
+				} else {
1022
+					$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1023
+				}
1024
+				//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1025
+				//echo $buffer."\n";
1026
+			// lets play nice and handle signals such as ctrl-c/kill properly
1027
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1028
+			$error = false;
1029
+			//$SI::del();
1030
+			if ($format == 'vrstcp') {
1031 1031
 			$buffer = explode('},{',$buffer);
1032
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1033
-		    // SBS format is CSV format
1034
-		    if ($buffer != '') {
1032
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1033
+			// SBS format is CSV format
1034
+			if ($buffer != '') {
1035 1035
 			$tt[$format] = 0;
1036 1036
 			if ($format == 'acarssbs3') {
1037
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1038
-			    $ACARS->add(trim($buffer));
1039
-			    $ACARS->deleteLiveAcarsData();
1037
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1038
+				$ACARS->add(trim($buffer));
1039
+				$ACARS->deleteLiveAcarsData();
1040 1040
 			} elseif ($format == 'raw') {
1041
-			    // AVR format
1042
-			    $data = $SBS->parse($buffer);
1043
-			    if (is_array($data)) {
1041
+				// AVR format
1042
+				$data = $SBS->parse($buffer);
1043
+				if (is_array($data)) {
1044 1044
 				$data['datetime'] = date('Y-m-d H:i:s');
1045 1045
 				$data['format_source'] = 'raw';
1046 1046
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1047
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
-                                if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1049
-                            }
1050
-                        } elseif ($format == 'ais') {
1051
-			    $ais_data = $AIS->parse_line(trim($buffer));
1052
-			    $data = array();
1053
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1047
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1048
+								if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1049
+							}
1050
+						} elseif ($format == 'ais') {
1051
+				$ais_data = $AIS->parse_line(trim($buffer));
1052
+				$data = array();
1053
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1054
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1055
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1056
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1057
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1058
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1059
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1060
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1061
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1062
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1063
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1064
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1065 1065
 
1066
-			    if (isset($ais_data['timestamp'])) {
1066
+				if (isset($ais_data['timestamp'])) {
1067 1067
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1068
-			    } else {
1068
+				} else {
1069 1069
 				$data['datetime'] = date('Y-m-d H:i:s');
1070
-			    }
1071
-			    $data['format_source'] = 'aisnmea';
1072
-    			    $data['id_source'] = $id_source;
1073
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1074
-			    unset($data);
1075
-                        } elseif ($format == 'flightgearsp') {
1076
-                    	    //echo $buffer."\n";
1077
-                    	    if (strlen($buffer) > 5) {
1070
+				}
1071
+				$data['format_source'] = 'aisnmea';
1072
+					$data['id_source'] = $id_source;
1073
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1074
+				unset($data);
1075
+						} elseif ($format == 'flightgearsp') {
1076
+							//echo $buffer."\n";
1077
+							if (strlen($buffer) > 5) {
1078 1078
 				$line = explode(',',$buffer);
1079 1079
 				$data = array();
1080 1080
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1090,37 +1090,37 @@  discard block
 block discarded – undo
1090 1090
 				$data['format_source'] = 'flightgearsp';
1091 1091
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1092 1092
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1093
-			    }
1094
-                        } elseif ($format == 'acars') {
1095
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1096
-			    $ACARS->add(trim($buffer));
1097
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098
-			    $ACARS->deleteLiveAcarsData();
1093
+				}
1094
+						} elseif ($format == 'acars') {
1095
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1096
+				$ACARS->add(trim($buffer));
1097
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1098
+				$ACARS->deleteLiveAcarsData();
1099 1099
 			} elseif ($format == 'flightgearmp') {
1100
-			    if (substr($buffer,0,1) != '#') {
1100
+				if (substr($buffer,0,1) != '#') {
1101 1101
 				$data = array();
1102 1102
 				//echo $buffer."\n";
1103 1103
 				$line = explode(' ',$buffer);
1104 1104
 				if (count($line) == 11) {
1105
-				    $userserver = explode('@',$line[0]);
1106
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1107
-				    $data['ident'] = $userserver[0];
1108
-				    $data['registration'] = $userserver[0];
1109
-				    $data['latitude'] = $line[4];
1110
-				    $data['longitude'] = $line[5];
1111
-				    $data['altitude'] = $line[6];
1112
-				    $data['datetime'] = date('Y-m-d H:i:s');
1113
-				    $aircraft_type = $line[10];
1114
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1115
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1105
+					$userserver = explode('@',$line[0]);
1106
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1107
+					$data['ident'] = $userserver[0];
1108
+					$data['registration'] = $userserver[0];
1109
+					$data['latitude'] = $line[4];
1110
+					$data['longitude'] = $line[5];
1111
+					$data['altitude'] = $line[6];
1112
+					$data['datetime'] = date('Y-m-d H:i:s');
1113
+					$aircraft_type = $line[10];
1114
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1115
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1116
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1117
+				}
1117 1118
 				}
1118
-			    }
1119 1119
 			} elseif ($format == 'beast') {
1120
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1121
-			    die;
1120
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1121
+				die;
1122 1122
 			} elseif ($format == 'vrstcp') {
1123
-			    foreach($buffer as $all_data) {
1123
+				foreach($buffer as $all_data) {
1124 1124
 				$line = json_decode('{'.$all_data.'}',true);
1125 1125
 				$data = array();
1126 1126
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1140,100 +1140,100 @@  discard block
 block discarded – undo
1140 1140
 				*/
1141 1141
 				$data['datetime'] = date('Y-m-d H:i:s');
1142 1142
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1143
-		    		$data['format_source'] = 'vrstcp';
1143
+					$data['format_source'] = 'vrstcp';
1144 1144
 				$data['id_source'] = $id_source;
1145 1145
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1146 1146
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1147 1147
 				unset($data);
1148
-			    }
1148
+				}
1149 1149
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1150
-			    $line = explode("\t", $buffer);
1151
-			    for($k = 0; $k < count($line); $k=$k+2) {
1150
+				$line = explode("\t", $buffer);
1151
+				for($k = 0; $k < count($line); $k=$k+2) {
1152 1152
 				$key = $line[$k];
1153
-			        $lined[$key] = $line[$k+1];
1154
-			    }
1155
-    			    if (count($lined) > 3) {
1156
-    				$data['hex'] = $lined['hexid'];
1157
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1159
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1166
-    				$data['id_source'] = $id_source;
1167
-    				$data['format_source'] = 'tsv';
1168
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
-    				unset($lined);
1172
-    				unset($data);
1173
-    			    } else $error = true;
1153
+					$lined[$key] = $line[$k+1];
1154
+				}
1155
+					if (count($lined) > 3) {
1156
+					$data['hex'] = $lined['hexid'];
1157
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1158
+					$data['datetime'] = date('Y-m-d H:i:s');;
1159
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1160
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1161
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1162
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1163
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1164
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1165
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1166
+					$data['id_source'] = $id_source;
1167
+					$data['format_source'] = 'tsv';
1168
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1169
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1170
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1171
+					unset($lined);
1172
+					unset($data);
1173
+					} else $error = true;
1174 1174
 			} elseif ($format == 'aprs' && $use_aprs) {
1175
-			    if ($aprs_connect == 0) {
1175
+				if ($aprs_connect == 0) {
1176 1176
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1177 1177
 				$aprs_connect = 1;
1178
-			    }
1178
+				}
1179 1179
 			    
1180
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1180
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1181 1181
 				$aprs_last_tx = time();
1182 1182
 				$data_aprs = "# Keep alive";
1183 1183
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1184
-			    }
1184
+				}
1185 1185
 			    
1186
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1187
-			    //echo 'APRS data : '.$buffer."\n";
1188
-			    $buffer = str_replace('APRS <- ','',$buffer);
1189
-			    $buffer = str_replace('APRS -> ','',$buffer);
1190
-			    //echo $buffer."\n";
1191
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1186
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1187
+				//echo 'APRS data : '.$buffer."\n";
1188
+				$buffer = str_replace('APRS <- ','',$buffer);
1189
+				$buffer = str_replace('APRS -> ','',$buffer);
1190
+				//echo $buffer."\n";
1191
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1192 1192
 				$line = $APRS->parse($buffer);
1193 1193
 				//print_r($line);
1194 1194
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1195 1195
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']))) {
1196
-				    $aprs_last_tx = time();
1197
-				    $data = array();
1198
-				    //print_r($line);
1199
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1200
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1202
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1203
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1204
-				    $data['latitude'] = $line['latitude'];
1205
-				    $data['longitude'] = $line['longitude'];
1206
-				    //$data['verticalrate'] = $line[16];
1207
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
-				    else $data['speed'] = 0;
1209
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1213
-				    //else $data['heading'] = 0;
1214
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
-				    if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1216
-    				    $data['id_source'] = $id_source;
1217
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
-				    else $data['format_source'] = 'aprs';
1219
-				    $data['source_name'] = $line['source'];
1220
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
-				    else $data['source_type'] = 'flarm';
1222
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1223
-				    $currentdate = date('Y-m-d H:i:s');
1224
-				    $aprsdate = strtotime($data['datetime']);
1225
-				    // Accept data if time <= system time + 20s
1226
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1196
+					$aprs_last_tx = time();
1197
+					$data = array();
1198
+					//print_r($line);
1199
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1200
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1201
+					else $data['datetime'] = date('Y-m-d H:i:s');
1202
+					//$data['datetime'] = date('Y-m-d H:i:s');
1203
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1204
+					$data['latitude'] = $line['latitude'];
1205
+					$data['longitude'] = $line['longitude'];
1206
+					//$data['verticalrate'] = $line[16];
1207
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1208
+					else $data['speed'] = 0;
1209
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1210
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1211
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1212
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1213
+					//else $data['heading'] = 0;
1214
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1215
+					if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true;
1216
+						$data['id_source'] = $id_source;
1217
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1218
+					else $data['format_source'] = 'aprs';
1219
+					$data['source_name'] = $line['source'];
1220
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1221
+					else $data['source_type'] = 'flarm';
1222
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1223
+					$currentdate = date('Y-m-d H:i:s');
1224
+					$aprsdate = strtotime($data['datetime']);
1225
+					// Accept data if time <= system time + 20s
1226
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1227 1227
 					$send = $SI->add($data);
1228
-				    } elseif (isset($line['stealth'])) {
1228
+					} elseif (isset($line['stealth'])) {
1229 1229
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1230 1230
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1231
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1231
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1232
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1233 1233
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1234 1234
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1235
-				    }
1236
-				    unset($data);
1235
+					}
1236
+					unset($data);
1237 1237
 				} 
1238 1238
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1239 1239
 					echo '!! Weather Station not yet supported'."\n";
@@ -1243,12 +1243,12 @@  discard block
 block discarded – undo
1243 1243
 				}
1244 1244
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1245 1245
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1246
-			    }
1246
+				}
1247 1247
 			} else {
1248
-			    $line = explode(',', $buffer);
1249
-    			    if (count($line) > 20) {
1250
-    			    	$data['hex'] = $line[4];
1251
-    				/*
1248
+				$line = explode(',', $buffer);
1249
+					if (count($line) > 20) {
1250
+						$data['hex'] = $line[4];
1251
+					/*
1252 1252
     				$data['datetime'] = $line[6].' '.$line[7];
1253 1253
     					date_default_timezone_set($globalTimezone);
1254 1254
     					$datetime = new DateTime($data['datetime']);
@@ -1256,29 +1256,29 @@  discard block
 block discarded – undo
1256 1256
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1257 1257
     					date_default_timezone_set('UTC');
1258 1258
     				*/
1259
-    				// Force datetime to current UTC datetime
1260
-    				date_default_timezone_set('UTC');
1261
-    				$data['datetime'] = date('Y-m-d H:i:s');
1262
-    				$data['ident'] = trim($line[10]);
1263
-    				$data['latitude'] = $line[14];
1264
-    				$data['longitude'] = $line[15];
1265
-    				$data['verticalrate'] = $line[16];
1266
-    				$data['emergency'] = $line[20];
1267
-    				$data['speed'] = $line[12];
1268
-    				$data['squawk'] = $line[17];
1269
-    				$data['altitude'] = $line[11];
1270
-    				$data['heading'] = $line[13];
1271
-    				$data['ground'] = $line[21];
1272
-    				$data['emergency'] = $line[19];
1273
-    				$data['format_source'] = 'sbs';
1259
+					// Force datetime to current UTC datetime
1260
+					date_default_timezone_set('UTC');
1261
+					$data['datetime'] = date('Y-m-d H:i:s');
1262
+					$data['ident'] = trim($line[10]);
1263
+					$data['latitude'] = $line[14];
1264
+					$data['longitude'] = $line[15];
1265
+					$data['verticalrate'] = $line[16];
1266
+					$data['emergency'] = $line[20];
1267
+					$data['speed'] = $line[12];
1268
+					$data['squawk'] = $line[17];
1269
+					$data['altitude'] = $line[11];
1270
+					$data['heading'] = $line[13];
1271
+					$data['ground'] = $line[21];
1272
+					$data['emergency'] = $line[19];
1273
+					$data['format_source'] = 'sbs';
1274 1274
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1275
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
-    				$data['id_source'] = $id_source;
1277
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
-    				else $error = true;
1279
-    				unset($data);
1280
-    			    } else $error = true;
1281
-			    if ($error) {
1275
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1276
+					$data['id_source'] = $id_source;
1277
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1278
+					else $error = true;
1279
+					unset($data);
1280
+					} else $error = true;
1281
+				if ($error) {
1282 1282
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1283 1283
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1284 1284
 				} else {
@@ -1294,13 +1294,13 @@  discard block
 block discarded – undo
1294 1294
 					connect_all($sourceer);
1295 1295
 					$sourceer = array();
1296 1296
 				}
1297
-			    }
1297
+				}
1298 1298
 			}
1299 1299
 			// Sleep for xxx microseconds
1300 1300
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1301
-		    } else {
1301
+			} else {
1302 1302
 			if ($format == 'flightgearmp') {
1303
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1303
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1304 1304
 				//@socket_close($r);
1305 1305
 				sleep($globalMinFetch);
1306 1306
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1309,9 +1309,9 @@  discard block
 block discarded – undo
1309 1309
 				break;
1310 1310
 				
1311 1311
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1312
-			    if (isset($tt[$format])) $tt[$format]++;
1313
-			    else $tt[$format] = 0;
1314
-			    if ($tt[$format] > 30) {
1312
+				if (isset($tt[$format])) $tt[$format]++;
1313
+				else $tt[$format] = 0;
1314
+				if ($tt[$format] > 30) {
1315 1315
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1316 1316
 				//@socket_close($r);
1317 1317
 				sleep(2);
@@ -1322,23 +1322,23 @@  discard block
 block discarded – undo
1322 1322
 				//connect_all($globalSources);
1323 1323
 				$tt[$format]=0;
1324 1324
 				break;
1325
-			    }
1325
+				}
1326
+			}
1326 1327
 			}
1327
-		    }
1328 1328
 		}
1329
-	    } else {
1329
+		} else {
1330 1330
 		$error = socket_strerror(socket_last_error());
1331 1331
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1332 1332
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1333 1333
 			if (isset($globalDebug)) echo "Restarting...\n";
1334 1334
 			// Restart the script if possible
1335 1335
 			if (is_array($sockets)) {
1336
-			    if ($globalDebug) echo "Shutdown all sockets...";
1336
+				if ($globalDebug) echo "Shutdown all sockets...";
1337 1337
 			    
1338
-			    foreach ($sockets as $sock) {
1338
+				foreach ($sockets as $sock) {
1339 1339
 				@socket_shutdown($sock,2);
1340 1340
 				@socket_close($sock);
1341
-			    }
1341
+				}
1342 1342
 			    
1343 1343
 			}
1344 1344
 			if ($globalDebug) echo "Restart all connections...";
@@ -1349,13 +1349,13 @@  discard block
 block discarded – undo
1349 1349
 			if ($reset > 40) exit('Too many attempts...');
1350 1350
 			connect_all($globalSources);
1351 1351
 		}
1352
-	    }
1352
+		}
1353 1353
 	}
1354 1354
 	if ($globalDaemon === false) {
1355
-	    if ($globalDebug) echo 'Check all...'."\n";
1356
-	    $SI->checkAll();
1355
+		if ($globalDebug) echo 'Check all...'."\n";
1356
+		$SI->checkAll();
1357
+	}
1357 1358
 	}
1358
-    }
1359 1359
 }
1360 1360
 
1361 1361
 ?>
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@  discard block
 block discarded – undo
8 8
 require_once(dirname(__FILE__).'/class.Stats.php');
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 if (isset($globalServerAPRS) && $globalServerAPRS) {
11
-    require_once(dirname(__FILE__).'/class.APRS.php');
11
+	require_once(dirname(__FILE__).'/class.APRS.php');
12 12
 }
13 13
 
14 14
 class SpotterImport {
15
-    private $all_flights = array();
16
-    private $last_delete_hourly = 0;
17
-    private $last_delete = 0;
18
-    private $stats = array();
19
-    private $tmd = 0;
20
-    private $source_location = array();
21
-    public $db = null;
22
-    public $nb = 0;
23
-
24
-    public function __construct($dbc = null) {
15
+	private $all_flights = array();
16
+	private $last_delete_hourly = 0;
17
+	private $last_delete = 0;
18
+	private $stats = array();
19
+	private $tmd = 0;
20
+	private $source_location = array();
21
+	public $db = null;
22
+	public $nb = 0;
23
+
24
+	public function __construct($dbc = null) {
25 25
 	global $globalBeta, $globalServerAPRS, $APRSSpotter;
26 26
 	$Connection = new Connection($dbc);
27 27
 	$this->db = $Connection->db();
@@ -32,23 +32,23 @@  discard block
 block discarded – undo
32 32
 	$currentdate = date('Y-m-d');
33 33
 	$sourcestat = $Stats->getStatsSource($currentdate);
34 34
 	if (!empty($sourcestat)) {
35
-	    foreach($sourcestat as $srcst) {
36
-	    	$type = $srcst['stats_type'];
35
+		foreach($sourcestat as $srcst) {
36
+			$type = $srcst['stats_type'];
37 37
 		if ($type == 'polar' || $type == 'hist') {
38
-		    $source = $srcst['source_name'];
39
-		    $data = $srcst['source_data'];
40
-		    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
-	        }
42
-	    }
38
+			$source = $srcst['source_name'];
39
+			$data = $srcst['source_data'];
40
+			$this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			}
42
+		}
43 43
 	}
44 44
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
45 45
 		$APRSSpotter = new APRSSpotter();
46 46
 		//$APRSSpotter->connect();
47 47
 	}
48 48
 
49
-    }
49
+	}
50 50
 
51
-    public function get_Schedule($id,$ident) {
51
+	public function get_Schedule($id,$ident) {
52 52
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
53 53
 	// Get schedule here, so it's done only one time
54 54
 	
@@ -68,42 +68,42 @@  discard block
 block discarded – undo
68 68
 	$operator = $Spotter->getOperator($ident);
69 69
 	$scheduleexist = false;
70 70
 	if ($Schedule->checkSchedule($operator) == 0) {
71
-	    $operator = $Translation->checkTranslation($ident);
72
-	    if ($Schedule->checkSchedule($operator) == 0) {
71
+		$operator = $Translation->checkTranslation($ident);
72
+		if ($Schedule->checkSchedule($operator) == 0) {
73 73
 		$schedule = $Schedule->fetchSchedule($operator);
74 74
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
75
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
76
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
77
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
-		    // Should also check if route schedule = route from DB
79
-		    if ($schedule['DepartureAirportIATA'] != '') {
75
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
76
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
77
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+			// Should also check if route schedule = route from DB
79
+			if ($schedule['DepartureAirportIATA'] != '') {
80 80
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
81
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
82
-			    if (trim($airport_icao) != '') {
81
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
82
+				if (trim($airport_icao) != '') {
83 83
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
84 84
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
85
-			    }
85
+				}
86
+			}
86 87
 			}
87
-		    }
88
-		    if ($schedule['ArrivalAirportIATA'] != '') {
88
+			if ($schedule['ArrivalAirportIATA'] != '') {
89 89
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
90
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
91
-			    if (trim($airport_icao) != '') {
90
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
91
+				if (trim($airport_icao) != '') {
92 92
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
93 93
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
94
-			    }
94
+				}
95 95
 			}
96
-		    }
97
-		    $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']);
96
+			}
97
+			$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']);
98 98
 		}
99
-	    } else $scheduleexist = true;
99
+		} else $scheduleexist = true;
100 100
 	} else $scheduleexist = true;
101 101
 	// close connection, at least one way will work ?
102
-       if ($scheduleexist) {
102
+	   if ($scheduleexist) {
103 103
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
104
-    		$sch = $Schedule->getSchedule($operator);
104
+			$sch = $Schedule->getSchedule($operator);
105 105
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
106
-       }
106
+	   }
107 107
 	$Spotter->db = null;
108 108
 	$Schedule->db = null;
109 109
 	$Translation->db = null;
@@ -118,96 +118,96 @@  discard block
 block discarded – undo
118 118
 	}
119 119
 	  */
120 120
 	}
121
-    }
121
+	}
122 122
 
123
-    public function checkAll() {
123
+	public function checkAll() {
124 124
 	global $globalDebug, $globalNoImport;
125 125
 	if ($globalDebug) echo "Update last seen flights data...\n";
126 126
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
127
-	    foreach ($this->all_flights as $key => $flight) {
127
+		foreach ($this->all_flights as $key => $flight) {
128 128
 		if (isset($this->all_flights[$key]['id'])) {
129
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
130
-    		    $Spotter = new Spotter($this->db);
131
-        	    $real_arrival = $this->arrival($key);
132
-        	    $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']);
133
-        	}
134
-	    }
129
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
130
+				$Spotter = new Spotter($this->db);
131
+				$real_arrival = $this->arrival($key);
132
+				$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']);
133
+			}
134
+		}
135
+	}
135 136
 	}
136
-    }
137 137
 
138
-    public function arrival($key) {
138
+	public function arrival($key) {
139 139
 	global $globalClosestMinDist, $globalDebug;
140 140
 	if ($globalDebug) echo 'Update arrival...'."\n";
141 141
 	$Spotter = new Spotter($this->db);
142
-        $airport_icao = '';
143
-        $airport_time = '';
144
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
142
+		$airport_icao = '';
143
+		$airport_time = '';
144
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
145 145
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
146
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
147
-    	    if (isset($closestAirports[0])) {
148
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
149
-        	    $airport_icao = $closestAirports[0]['icao'];
150
-        	    $airport_time = $this->all_flights[$key]['datetime'];
151
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
152
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
153
-        	    foreach ($closestAirports as $airport) {
154
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
155
-        		    $airport_icao = $airport['icao'];
156
-        		    $airport_time = $this->all_flights[$key]['datetime'];
157
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
158
-        		    break;
159
-        		}
160
-        	    }
161
-        	} 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))) {
162
-        		$airport_icao = $closestAirports[0]['icao'];
163
-        		$airport_time = $this->all_flights[$key]['datetime'];
164
-        	} else {
165
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
166
-        	}
167
-    	    } else {
168
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
169
-    	    }
170
-
171
-        } else {
172
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
173
-        }
174
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
175
-    }
176
-
177
-
178
-
179
-    public function del() {
146
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
147
+			if (isset($closestAirports[0])) {
148
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
149
+				$airport_icao = $closestAirports[0]['icao'];
150
+				$airport_time = $this->all_flights[$key]['datetime'];
151
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
152
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
153
+				foreach ($closestAirports as $airport) {
154
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
155
+					$airport_icao = $airport['icao'];
156
+					$airport_time = $this->all_flights[$key]['datetime'];
157
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
158
+					break;
159
+				}
160
+				}
161
+			} 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))) {
162
+				$airport_icao = $closestAirports[0]['icao'];
163
+				$airport_time = $this->all_flights[$key]['datetime'];
164
+			} else {
165
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
166
+			}
167
+			} else {
168
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
169
+			}
170
+
171
+		} else {
172
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
173
+		}
174
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
175
+	}
176
+
177
+
178
+
179
+	public function del() {
180 180
 	global $globalDebug, $globalNoImport, $globalNoDB;
181 181
 	// Delete old infos
182 182
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
183 183
 	foreach ($this->all_flights as $key => $flight) {
184
-    	    if (isset($flight['lastupdate'])) {
185
-        	if ($flight['lastupdate'] < (time()-3000)) {
186
-            	    if (isset($this->all_flights[$key]['id'])) {
187
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
184
+			if (isset($flight['lastupdate'])) {
185
+			if ($flight['lastupdate'] < (time()-3000)) {
186
+					if (isset($this->all_flights[$key]['id'])) {
187
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
188 188
 			/*
189 189
 			$SpotterLive = new SpotterLive();
190 190
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
191 191
 			$SpotterLive->db = null;
192 192
 			*/
193 193
 			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
194
-            		    $real_arrival = $this->arrival($key);
195
-            		    $Spotter = new Spotter($this->db);
196
-            	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
194
+						$real_arrival = $this->arrival($key);
195
+						$Spotter = new Spotter($this->db);
196
+							if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
197 197
 				$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']);
198 198
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
199
-			    }
199
+				}
200 200
 			// Put in archive
201 201
 //				$Spotter->db = null;
202 202
 			}
203
-            	    }
204
-            	    unset($this->all_flights[$key]);
205
-    	        }
206
-	    }
207
-        }
208
-    }
203
+					}
204
+					unset($this->all_flights[$key]);
205
+				}
206
+		}
207
+		}
208
+	}
209 209
 
210
-    public function add($line) {
210
+	public function add($line) {
211 211
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB;
212 212
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
213 213
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 	
233 233
 	// SBS format is CSV format
234 234
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
235
-	    //print_r($line);
236
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
235
+		//print_r($line);
236
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
237 237
 
238 238
 		// Increment message number
239 239
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
240
-		    $current_date = date('Y-m-d');
241
-		    $source = $line['source_name'];
242
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
243
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
244
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
245
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
246
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
240
+			$current_date = date('Y-m-d');
241
+			$source = $line['source_name'];
242
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
243
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
244
+				$this->stats[$current_date][$source]['msg']['date'] = time();
245
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
246
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
247 247
 		}
248 248
 		
249 249
 		/*
@@ -259,49 +259,49 @@  discard block
 block discarded – undo
259 259
 		//$this->db = $dbc;
260 260
 
261 261
 		//$hex = trim($line['hex']);
262
-	        if (!isset($line['id'])) $id = trim($line['hex']);
263
-	        else $id = trim($line['id']);
262
+			if (!isset($line['id'])) $id = trim($line['hex']);
263
+			else $id = trim($line['id']);
264 264
 		
265 265
 		if (!isset($this->all_flights[$id])) {
266
-		    $this->all_flights[$id] = array();
267
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
268
-		    $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' => true,'source_type' => ''));
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270
-		    if (!isset($line['id'])) {
266
+			$this->all_flights[$id] = array();
267
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
268
+			$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' => true,'source_type' => ''));
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
270
+			if (!isset($line['id'])) {
271 271
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
272 272
 //			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')));
273 273
 //			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')));
274 274
 			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' => $id.'-'.date('YmdHi')));
275
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
277
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
275
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
276
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
277
+			if ($globalAllFlights !== FALSE) $dataFound = true;
278 278
 		}
279 279
 		if (isset($line['source_type']) && $line['source_type'] != '') {
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
280
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
281 281
 		}
282 282
 		
283 283
 		//print_r($this->all_flights);
284 284
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
285
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
286
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
285
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
286
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
287 287
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
288
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
289
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
288
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
289
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
290 290
 			$timeelapsed = microtime(true);
291 291
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
292
-			    $Spotter = new Spotter($this->db);
293
-			    if (isset($this->all_flights[$id]['source_type'])) {
292
+				$Spotter = new Spotter($this->db);
293
+				if (isset($this->all_flights[$id]['source_type'])) {
294 294
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
295
-			    } else {
295
+				} else {
296 296
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
297
-			    }
298
-			    $Spotter->db = null;
299
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
297
+				}
298
+				$Spotter->db = null;
299
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
301 301
 			}
302
-		    }
303
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
304
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
302
+			}
303
+			if ($globalAllFlights !== FALSE) $dataFound = true;
304
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
305 305
 		}
306 306
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
307 307
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 		}
328 328
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
329 329
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
330
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
330
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
331 331
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
332
-		    } else {
332
+			} else {
333 333
 				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";
334 334
 				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";
335 335
 				/*
@@ -338,43 +338,43 @@  discard block
 block discarded – undo
338 338
 				print_r($line);
339 339
 				*/
340 340
 				return '';
341
-		    }
341
+			}
342 342
 		} else {
343 343
 			date_default_timezone_set('UTC');
344 344
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
345 345
 		}
346 346
 
347 347
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
348
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
348
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
349 349
 		}
350 350
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
351
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
351
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
352 352
 		}
353 353
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
354
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
354
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
355 355
 		}
356 356
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
357
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
357
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
358 358
 		}
359 359
  
360 360
 		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'])) {
361
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
362
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
361
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
362
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
363 363
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
364
-			    $timeelapsed = microtime(true);
365
-            		    $Spotter = new Spotter($this->db);
366
-            		    $fromsource = NULL;
367
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
368
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
369
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
370
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
371
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
372
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
373
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
374
-			    $Spotter->db = null;
375
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
-			}
377
-		    }
364
+				$timeelapsed = microtime(true);
365
+						$Spotter = new Spotter($this->db);
366
+						$fromsource = NULL;
367
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
368
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
369
+				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
370
+				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
371
+				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
372
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
373
+				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
374
+				$Spotter->db = null;
375
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+			}
377
+			}
378 378
 
379 379
 /*
380 380
 		    if (!isset($line['id'])) {
@@ -384,104 +384,104 @@  discard block
 block discarded – undo
384 384
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
385 385
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
386 386
   */
387
-		    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']));
387
+			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']));
388 388
 
389
-		    //$putinarchive = true;
390
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
389
+			//$putinarchive = true;
390
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
391 391
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
392
-		    }
393
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
392
+			}
393
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
394 394
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
395
-		    }
396
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
397
-		    		$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' => ''));
398
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
395
+			}
396
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
397
+					$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' => ''));
398
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
399 399
 			$timeelapsed = microtime(true);
400 400
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
401 401
 				$Spotter = new Spotter($this->db);
402 402
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
403 403
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
404
-		    		$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' => ''));
404
+					$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' => ''));
405 405
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
406
-                        }
407
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
406
+						}
407
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
408 408
 			$timeelapsed = microtime(true);
409 409
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
410
-			    $Spotter = new Spotter($this->db);
411
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
412
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
410
+				$Spotter = new Spotter($this->db);
411
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
412
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
413 413
 				$Translation = new Translation($this->db);
414 414
 				$ident = $Translation->checkTranslation(trim($line['ident']));
415 415
 				$route = $Spotter->getRouteInfo($ident);
416 416
 				$Translation->db = null;
417
-			    }
418
-			    $Spotter->db = null;
419
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
420
-                    	}
417
+				}
418
+				$Spotter->db = null;
419
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
420
+						}
421 421
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
422
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
423
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
422
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
423
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
424 424
 				//    $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']));
425
-		    		$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']));
426
-		    	    }
425
+					$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']));
426
+					}
427 427
 			}
428 428
 			if (!isset($globalFork)) $globalFork = TRUE;
429 429
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
430 430
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
431 431
 			}
432
-		    }
432
+			}
433 433
 		}
434 434
 
435 435
 		if (isset($line['speed']) && $line['speed'] != '') {
436 436
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
437
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
438
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
439
-		    //$dataFound = true;
437
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
438
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
439
+			//$dataFound = true;
440 440
 		} 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'])) {
441
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
442
-		    if ($distance > 1000 && $distance < 10000) {
443
-		    // use datetime
441
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
442
+			if ($distance > 1000 && $distance < 10000) {
443
+			// use datetime
444 444
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
445 445
 			$speed = $speed*3.6;
446 446
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
447 447
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
448
-		    }
448
+			}
449 449
 		}
450 450
 
451 451
 
452 452
 
453
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
454
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
455
-	    	    else unset($timediff);
456
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && 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')))) {
453
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
454
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
455
+				else unset($timediff);
456
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && 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')))) {
457 457
 			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'])) {
458
-			    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'])) {
458
+				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'])) {
459 459
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
460 460
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
461 461
 				$this->all_flights[$id]['putinarchive'] = true;
462 462
 				$this->tmd = 0;
463 463
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
464
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
465
-				    $timeelapsed = microtime(true);
466
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
464
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
465
+					$timeelapsed = microtime(true);
466
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
467 467
 					$Spotter = new Spotter($this->db);
468 468
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
469 469
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
470 470
 					$Spotter->db = null;
471 471
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
472 472
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
473
-				    }
473
+					}
474
+				}
474 475
 				}
475
-			    }
476 476
 			}
477 477
 
478 478
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
479
-			    //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) {
479
+				//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) {
480 480
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
481 481
 				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') {
482
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
483
-				    $dataFound = true;
484
-				    $this->all_flights[$id]['time_last_coord'] = time();
482
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
483
+					$dataFound = true;
484
+					$this->all_flights[$id]['time_last_coord'] = time();
485 485
 				}
486 486
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
487 487
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -492,20 +492,20 @@  discard block
 block discarded – undo
492 492
 				    //$putinarchive = true;
493 493
 				}
494 494
 				*/
495
-			    /*
495
+				/*
496 496
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
497 497
 				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";
498 498
 			    }
499 499
 			    */
500 500
 			}
501 501
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
502
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
503
-			    //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) {
502
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
503
+				//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) {
504 504
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
505 505
 				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') {
506
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
507
-				    $dataFound = true;
508
-				    $this->all_flights[$id]['time_last_coord'] = time();
506
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
507
+					$dataFound = true;
508
+					$this->all_flights[$id]['time_last_coord'] = time();
509 509
 				}
510 510
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
511 511
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -523,95 +523,95 @@  discard block
 block discarded – undo
523 523
 			    */
524 524
 			}
525 525
 
526
-		    } else if ($globalDebug && $timediff > 20) {
526
+			} else if ($globalDebug && $timediff > 20) {
527 527
 			$this->tmd = $this->tmd + 1;
528 528
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
529 529
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
530 530
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
531 531
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
532
-		    }
532
+			}
533 533
 		}
534 534
 		if (isset($line['last_update']) && $line['last_update'] != '') {
535
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
536
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
535
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
536
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
537 537
 		}
538 538
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
539
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
540
-		    //$dataFound = true;
539
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
540
+			//$dataFound = true;
541 541
 		}
542 542
 		if (isset($line['format_source']) && $line['format_source'] != '') {
543
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
543
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
544 544
 		}
545 545
 		if (isset($line['source_name']) && $line['source_name'] != '') {
546
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
546
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
547 547
 		}
548 548
 		if (isset($line['emergency']) && $line['emergency'] != '') {
549
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
550
-		    //$dataFound = true;
549
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
550
+			//$dataFound = true;
551 551
 		}
552 552
 		if (isset($line['ground']) && $line['ground'] != '') {
553
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
553
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
554 554
 			// Here we force archive of flight because after ground it's a new one (or should be)
555 555
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
556 556
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
557 557
 			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')));
558
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
558
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
559 559
 			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']));
560
-		    }
561
-		    if ($line['ground'] != 1) $line['ground'] = 0;
562
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
563
-		    //$dataFound = true;
560
+			}
561
+			if ($line['ground'] != 1) $line['ground'] = 0;
562
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
563
+			//$dataFound = true;
564 564
 		}
565 565
 		if (isset($line['squawk']) && $line['squawk'] != '') {
566
-		    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'])) {
567
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
568
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
569
-			    $highlight = '';
570
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
571
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
572
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
573
-			    if ($highlight != '') {
566
+			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'])) {
567
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
568
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
569
+				$highlight = '';
570
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
571
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
572
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
573
+				if ($highlight != '') {
574 574
 				$timeelapsed = microtime(true);
575 575
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
576
-				    $Spotter = new Spotter($this->db);
577
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
578
-				    $Spotter->db = null;
579
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
576
+					$Spotter = new Spotter($this->db);
577
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
578
+					$Spotter->db = null;
579
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
580 580
 				}
581 581
 				//$putinarchive = true;
582 582
 				//$highlight = '';
583
-			    }
583
+				}
584 584
 			    
585
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
586
-		    //$dataFound = true;
585
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
586
+			//$dataFound = true;
587 587
 		}
588 588
 
589 589
 		if (isset($line['altitude']) && $line['altitude'] != '') {
590
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
590
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
591 591
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
592 592
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
593 593
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
594 594
 			//$dataFound = true;
595
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
595
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
596 596
   		}
597 597
 
598 598
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
599
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
599
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
600 600
 		}
601 601
 		
602 602
 		if (isset($line['heading']) && $line['heading'] != '') {
603
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
604
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
605
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
606
-		    //$dataFound = true;
603
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
604
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
605
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
606
+			//$dataFound = true;
607 607
   		} 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']) {
608
-  		    $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']);
609
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
610
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
611
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
608
+  			$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']);
609
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
610
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
611
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
612 612
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
613
-  		    // If not enough messages and ACARS set heading to 0
614
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
613
+  			// If not enough messages and ACARS set heading to 0
614
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
615 615
   		}
616 616
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
617 617
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -622,125 +622,125 @@  discard block
 block discarded – undo
622 622
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
623 623
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
624 624
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
625
-		    $this->all_flights[$id]['lastupdate'] = time();
626
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
627
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
628
-			    //print_r($this->all_flights);
629
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
630
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
631
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
625
+			$this->all_flights[$id]['lastupdate'] = time();
626
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
627
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
628
+				//print_r($this->all_flights);
629
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
630
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
631
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
632 632
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
633
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
634
-				    $timeelapsed = microtime(true);
635
-				    $SpotterLive = new SpotterLive($this->db);
636
-				    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')) {
633
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
634
+					$timeelapsed = microtime(true);
635
+					$SpotterLive = new SpotterLive($this->db);
636
+					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')) {
637 637
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
638 638
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
639
-				    } elseif (isset($line['id'])) {
639
+					} elseif (isset($line['id'])) {
640 640
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
641 641
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
642
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
642
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
643 643
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
644 644
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
645
-				    } else $recent_ident = '';
646
-				    $SpotterLive->db=null;
647
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
648
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
645
+					} else $recent_ident = '';
646
+					$SpotterLive->db=null;
647
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
648
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
649 649
 				} else $recent_ident = '';
650
-			    } else {
650
+				} else {
651 651
 				$recent_ident = '';
652 652
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
653
-			    }
654
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
655
-			    if($recent_ident == "")
656
-			    {
653
+				}
654
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
655
+				if($recent_ident == "")
656
+				{
657 657
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
658 658
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
659 659
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
660 660
 				//adds the spotter data for the archive
661 661
 				$ignoreImport = false;
662 662
 				foreach($globalAirportIgnore as $airportIgnore) {
663
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
663
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
664 664
 					$ignoreImport = true;
665
-				    }
665
+					}
666 666
 				}
667 667
 				if (count($globalAirportAccept) > 0) {
668
-				    $ignoreImport = true;
669
-				    foreach($globalAirportIgnore as $airportIgnore) {
668
+					$ignoreImport = true;
669
+					foreach($globalAirportIgnore as $airportIgnore) {
670 670
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
671
-					    $ignoreImport = false;
671
+						$ignoreImport = false;
672
+					}
672 673
 					}
673
-				    }
674 674
 				}
675 675
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
676
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
676
+					foreach($globalAirlineIgnore as $airlineIgnore) {
677 677
 					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)) {
678
-					    $ignoreImport = true;
678
+						$ignoreImport = true;
679
+					}
679 680
 					}
680
-				    }
681 681
 				}
682 682
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
683
-				    $ignoreImport = true;
684
-				    foreach($globalAirlineAccept as $airlineAccept) {
683
+					$ignoreImport = true;
684
+					foreach($globalAirlineAccept as $airlineAccept) {
685 685
 					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)) {
686
-					    $ignoreImport = false;
686
+						$ignoreImport = false;
687
+					}
687 688
 					}
688
-				    }
689 689
 				}
690 690
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
691
-				    $ignoreImport = true;
692
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
691
+					$ignoreImport = true;
692
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
693 693
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
694
-					    $ignoreImport = false;
694
+						$ignoreImport = false;
695
+					}
695 696
 					}
696
-				    }
697 697
 				}
698 698
 				
699 699
 				if (!$ignoreImport) {
700
-				    $highlight = '';
701
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
702
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
703
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
704
-				    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')));
705
-				    $timeelapsed = microtime(true);
706
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
700
+					$highlight = '';
701
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
702
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
703
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
704
+					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')));
705
+					$timeelapsed = microtime(true);
706
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
707 707
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
708
-					    $Spotter = new Spotter($this->db);
709
-					    $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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']);
710
-					    $Spotter->db = null;
711
-					    if ($globalDebug && isset($result)) echo $result."\n";
708
+						$Spotter = new Spotter($this->db);
709
+						$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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']);
710
+						$Spotter->db = null;
711
+						if ($globalDebug && isset($result)) echo $result."\n";
712
+					}
712 713
 					}
713
-				    }
714
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
715
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
714
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
715
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
716 716
 
717
-				    // Add source stat in DB
718
-				    $Stats = new Stats($this->db);
719
-				    if (!empty($this->stats)) {
717
+					// Add source stat in DB
718
+					$Stats = new Stats($this->db);
719
+					if (!empty($this->stats)) {
720 720
 					if ($globalDebug) echo 'Add source stats : ';
721
-				        foreach($this->stats as $date => $data) {
722
-					    foreach($data as $source => $sourced) {
723
-					        //print_r($sourced);
724
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
725
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
726
-				    		if (isset($sourced['msg'])) {
727
-				    		    if (time() - $sourced['msg']['date'] > 10) {
728
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
729
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
730
-			    			        unset($this->stats[$date][$source]['msg']);
731
-			    			    }
732
-			    			}
733
-			    		    }
734
-			    		    if ($date != date('Y-m-d')) {
735
-			    			unset($this->stats[$date]);
736
-			    		    }
737
-				    	}
738
-				    	if ($globalDebug) echo 'Done'."\n";
739
-
740
-				    }
741
-				    $Stats->db = null;
742
-				    }
743
-				    $this->del();
721
+						foreach($this->stats as $date => $data) {
722
+						foreach($data as $source => $sourced) {
723
+							//print_r($sourced);
724
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
725
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
726
+							if (isset($sourced['msg'])) {
727
+								if (time() - $sourced['msg']['date'] > 10) {
728
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
729
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
730
+									unset($this->stats[$date][$source]['msg']);
731
+								}
732
+							}
733
+							}
734
+							if ($date != date('Y-m-d')) {
735
+							unset($this->stats[$date]);
736
+							}
737
+						}
738
+						if ($globalDebug) echo 'Done'."\n";
739
+
740
+					}
741
+					$Stats->db = null;
742
+					}
743
+					$this->del();
744 744
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
745 745
 				//$ignoreImport = false;
746 746
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -758,41 +758,41 @@  discard block
 block discarded – undo
758 758
 			*/
759 759
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
760 760
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
761
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
762
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
763
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
761
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
762
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
763
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
764 764
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
765
-					    $SpotterLive = new SpotterLive($this->db);
766
-					    $SpotterLive->deleteLiveSpotterData();
767
-					    $SpotterLive->db=null;
765
+						$SpotterLive = new SpotterLive($this->db);
766
+						$SpotterLive->deleteLiveSpotterData();
767
+						$SpotterLive->db=null;
768
+					}
768 769
 					}
769
-				    }
770
-				    if ($globalDebug) echo " Done\n";
771
-				    $this->last_delete = time();
770
+					if ($globalDebug) echo " Done\n";
771
+					$this->last_delete = time();
772 772
 				}
773
-			    } else {
773
+				} else {
774 774
 				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')) {
775
-				    $this->all_flights[$id]['id'] = $recent_ident;
776
-				    $this->all_flights[$id]['addedSpotter'] = 1;
775
+					$this->all_flights[$id]['id'] = $recent_ident;
776
+					$this->all_flights[$id]['addedSpotter'] = 1;
777 777
 				}
778 778
 				if (isset($globalDaemon) && !$globalDaemon) {
779
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
779
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
780 780
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
781
-					    $Spotter = new Spotter($this->db);
782
-					    $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]['altitude_real'],$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']);
783
-					    $Spotter->db = null;
781
+						$Spotter = new Spotter($this->db);
782
+						$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]['altitude_real'],$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']);
783
+						$Spotter->db = null;
784
+					}
784 785
 					}
785
-				    }
786 786
 				}
787 787
 				
788
-			    }
788
+				}
789
+			}
789 790
 			}
790
-		    }
791
-		    //adds the spotter LIVE data
792
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
793
-		    //echo "\nAdd in Live !! \n";
794
-		    //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";
795
-		    if ($globalDebug) {
791
+			//adds the spotter LIVE data
792
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
793
+			//echo "\nAdd in Live !! \n";
794
+			//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";
795
+			if ($globalDebug) {
796 796
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
797 797
 				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";
798 798
 				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";
@@ -800,60 +800,60 @@  discard block
 block discarded – undo
800 800
 				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";
801 801
 				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";
802 802
 			}
803
-		    }
804
-		    $ignoreImport = false;
805
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
806
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
803
+			}
804
+			$ignoreImport = false;
805
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
806
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
807 807
 
808
-		    foreach($globalAirportIgnore as $airportIgnore) {
809
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
810
-			    $ignoreImport = true;
808
+			foreach($globalAirportIgnore as $airportIgnore) {
809
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
810
+				$ignoreImport = true;
811 811
 			}
812
-		    }
813
-		    if (count($globalAirportAccept) > 0) {
814
-		        $ignoreImport = true;
815
-		        foreach($globalAirportIgnore as $airportIgnore) {
816
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
+			}
813
+			if (count($globalAirportAccept) > 0) {
814
+				$ignoreImport = true;
815
+				foreach($globalAirportIgnore as $airportIgnore) {
816
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
817 817
 				$ignoreImport = false;
818
-			    }
818
+				}
819
+			}
819 820
 			}
820
-		    }
821
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
821
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
822 822
 			foreach($globalAirlineIgnore as $airlineIgnore) {
823
-			    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)) {
823
+				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)) {
824 824
 				$ignoreImport = true;
825
-			    }
825
+				}
826 826
 			}
827
-		    }
828
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
827
+			}
828
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
829 829
 			$ignoreImport = true;
830 830
 			foreach($globalAirlineAccept as $airlineAccept) {
831
-			    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)) {
831
+				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)) {
832 832
 				$ignoreImport = false;
833
-			    }
833
+				}
834
+			}
834 835
 			}
835
-		    }
836
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
836
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
837 837
 			$ignoreImport = true;
838 838
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
839
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
840
-			        $ignoreImport = false;
841
-			    }
839
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
840
+					$ignoreImport = false;
841
+				}
842
+			}
842 843
 			}
843
-		    }
844 844
 
845
-		    if (!$ignoreImport) {
845
+			if (!$ignoreImport) {
846 846
 			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'])) {
847 847
 				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')));
848 848
 				$timeelapsed = microtime(true);
849 849
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
850
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
850
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
851 851
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
852 852
 					$SpotterLive = new SpotterLive($this->db);
853 853
 					$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]['altitude_real'], $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']);
854 854
 					$SpotterLive->db = null;
855 855
 					if ($globalDebug) echo $result."\n";
856
-				    }
856
+					}
857 857
 				}
858 858
 				if (isset($globalServerAPRS) && $globalServerAPRS) {
859 859
 					$APRSSpotter->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]['altitude_real'], $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']);
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 				//if ($line['format_source'] != 'aprs') {
866 866
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
867 867
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
868
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
868
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
869 869
 					$source = $this->all_flights[$id]['source_name'];
870 870
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
871 871
 					if (!isset($this->source_location[$source])) {
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
 					if ($stats_heading == 16) $stats_heading = 0;
892 892
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
893 893
 						for ($i=0;$i<=15;$i++) {
894
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
894
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
895 895
 						}
896 896
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
897 897
 					} else {
@@ -904,17 +904,17 @@  discard block
 block discarded – undo
904 904
 					//var_dump($this->stats);
905 905
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
906 906
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
907
-						    end($this->stats[$current_date][$source]['hist']);
908
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
907
+							end($this->stats[$current_date][$source]['hist']);
908
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
909 909
 						} else $mini = 0;
910 910
 						for ($i=$mini;$i<=$distance;$i+=10) {
911
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
911
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
912 912
 						}
913 913
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
914 914
 					} else {
915 915
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
916 916
 					}
917
-				    }
917
+					}
918 918
 				}
919 919
 
920 920
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 			//$this->del();
925 925
 			
926 926
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
927
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
927
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
928 928
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
929 929
 				$SpotterLive = new SpotterLive($this->db);
930 930
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -932,19 +932,19 @@  discard block
 block discarded – undo
932 932
 				//SpotterLive->deleteLiveSpotterData();
933 933
 				if ($globalDebug) echo " Done\n";
934 934
 				$this->last_delete_hourly = time();
935
-			    } else {
935
+				} else {
936 936
 				$this->del();
937 937
 				$this->last_delete_hourly = time();
938
-			    }
938
+				}
939 939
 			}
940 940
 			
941
-		    }
942
-		    //$ignoreImport = false;
941
+			}
942
+			//$ignoreImport = false;
943 943
 		}
944 944
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
945 945
 		if ($send) return $this->all_flights[$id];
946
-	    }
946
+		}
947
+	}
947 948
 	}
948
-    }
949 949
 }
950 950
 ?>
Please login to merge, or discard this patch.