Completed
Push — master ( 150320...f1741a )
by Yannick
10:41
created
require/class.Spotter.php 3 patches
Indentation   +1454 added lines, -1454 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);
@@ -4374,11 +4374,11 @@  discard block
 block discarded – undo
4374 4374
 	
4375 4375
 	
4376 4376
 	/**
4377
-	* Gets all airlines that have flown over by airport
4378
-	*
4379
-	* @return Array the airline list
4380
-	*
4381
-	*/
4377
+	 * Gets all airlines that have flown over by airport
4378
+	 *
4379
+	 * @return Array the airline list
4380
+	 *
4381
+	 */
4382 4382
 	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4383 4383
 	{
4384 4384
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4409,11 +4409,11 @@  discard block
 block discarded – undo
4409 4409
 
4410 4410
 
4411 4411
 	/**
4412
-	* Gets all airline countries that have flown over by airport icao
4413
-	*
4414
-	* @return Array the airline country list
4415
-	*
4416
-	*/
4412
+	 * Gets all airline countries that have flown over by airport icao
4413
+	 *
4414
+	 * @return Array the airline country list
4415
+	 *
4416
+	 */
4417 4417
 	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4418 4418
 	{
4419 4419
 		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
@@ -4443,11 +4443,11 @@  discard block
 block discarded – undo
4443 4443
 
4444 4444
 
4445 4445
 	/**
4446
-	* Gets all airlines that have flown over by aircraft manufacturer
4447
-	*
4448
-	* @return Array the airline list
4449
-	*
4450
-	*/
4446
+	 * Gets all airlines that have flown over by aircraft manufacturer
4447
+	 *
4448
+	 * @return Array the airline list
4449
+	 *
4450
+	 */
4451 4451
 	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4452 4452
 	{
4453 4453
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4478,11 +4478,11 @@  discard block
 block discarded – undo
4478 4478
 
4479 4479
 
4480 4480
 	/**
4481
-	* Gets all airline countries that have flown over by aircraft manufacturer
4482
-	*
4483
-	* @return Array the airline country list
4484
-	*
4485
-	*/
4481
+	 * Gets all airline countries that have flown over by aircraft manufacturer
4482
+	 *
4483
+	 * @return Array the airline country list
4484
+	 *
4485
+	 */
4486 4486
 	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4487 4487
 	{
4488 4488
 		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
@@ -4511,11 +4511,11 @@  discard block
 block discarded – undo
4511 4511
 
4512 4512
 
4513 4513
 	/**
4514
-	* Gets all airlines that have flown over by date
4515
-	*
4516
-	* @return Array the airline list
4517
-	*
4518
-	*/
4514
+	 * Gets all airlines that have flown over by date
4515
+	 *
4516
+	 * @return Array the airline list
4517
+	 *
4518
+	 */
4519 4519
 	public function countAllAirlinesByDate($date,$filters = array())
4520 4520
 	{
4521 4521
 		global $globalTimezone, $globalDBdriver;
@@ -4559,11 +4559,11 @@  discard block
 block discarded – undo
4559 4559
 	
4560 4560
 	
4561 4561
 	/**
4562
-	* Gets all airline countries that have flown over by date
4563
-	*
4564
-	* @return Array the airline country list
4565
-	*
4566
-	*/
4562
+	 * Gets all airline countries that have flown over by date
4563
+	 *
4564
+	 * @return Array the airline country list
4565
+	 *
4566
+	 */
4567 4567
 	public function countAllAirlineCountriesByDate($date,$filters = array())
4568 4568
 	{
4569 4569
 		global $globalTimezone, $globalDBdriver;
@@ -4606,11 +4606,11 @@  discard block
 block discarded – undo
4606 4606
 
4607 4607
 
4608 4608
 	/**
4609
-	* Gets all airlines that have flown over by ident/callsign
4610
-	*
4611
-	* @return Array the airline list
4612
-	*
4613
-	*/
4609
+	 * Gets all airlines that have flown over by ident/callsign
4610
+	 *
4611
+	 * @return Array the airline list
4612
+	 *
4613
+	 */
4614 4614
 	public function countAllAirlinesByIdent($ident,$filters = array())
4615 4615
 	{
4616 4616
 		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
@@ -4627,11 +4627,11 @@  discard block
 block discarded – undo
4627 4627
 	}
4628 4628
 
4629 4629
 	/**
4630
-	* Gets all airlines by owner
4631
-	*
4632
-	* @return Array the airline list
4633
-	*
4634
-	*/
4630
+	 * Gets all airlines by owner
4631
+	 *
4632
+	 * @return Array the airline list
4633
+	 *
4634
+	 */
4635 4635
 	public function countAllAirlinesByOwner($owner,$filters = array())
4636 4636
 	{
4637 4637
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4648,11 +4648,11 @@  discard block
 block discarded – undo
4648 4648
 	}
4649 4649
 
4650 4650
 	/**
4651
-	* Gets flight duration by owner
4652
-	*
4653
-	* @return String Duration of all flights
4654
-	*
4655
-	*/
4651
+	 * Gets flight duration by owner
4652
+	 *
4653
+	 * @return String Duration of all flights
4654
+	 *
4655
+	 */
4656 4656
 	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4657 4657
 	{
4658 4658
 		global $globalDBdriver;
@@ -4699,11 +4699,11 @@  discard block
 block discarded – undo
4699 4699
 	}
4700 4700
 
4701 4701
 	/**
4702
-	* Count flights by owner
4703
-	*
4704
-	* @return String Duration of all flights
4705
-	*
4706
-	*/
4702
+	 * Count flights by owner
4703
+	 *
4704
+	 * @return String Duration of all flights
4705
+	 *
4706
+	 */
4707 4707
 	public function countFlightsByOwner($owner,$filters = array())
4708 4708
 	{
4709 4709
 		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
@@ -4719,11 +4719,11 @@  discard block
 block discarded – undo
4719 4719
 	}
4720 4720
 
4721 4721
 	/**
4722
-	* Count flights by pilot
4723
-	*
4724
-	* @return String Duration of all flights
4725
-	*
4726
-	*/
4722
+	 * Count flights by pilot
4723
+	 *
4724
+	 * @return String Duration of all flights
4725
+	 *
4726
+	 */
4727 4727
 	public function countFlightsByPilot($pilot,$filters = array())
4728 4728
 	{
4729 4729
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4739,11 +4739,11 @@  discard block
 block discarded – undo
4739 4739
 	}
4740 4740
 
4741 4741
 	/**
4742
-	* Gets flight duration by pilot
4743
-	*
4744
-	* @return String Duration of all flights
4745
-	*
4746
-	*/
4742
+	 * Gets flight duration by pilot
4743
+	 *
4744
+	 * @return String Duration of all flights
4745
+	 *
4746
+	 */
4747 4747
 	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4748 4748
 	{
4749 4749
 		global $globalDBdriver;
@@ -4789,11 +4789,11 @@  discard block
 block discarded – undo
4789 4789
 	}
4790 4790
 
4791 4791
 	/**
4792
-	* Gets all airlines used by pilot
4793
-	*
4794
-	* @return Array the airline list
4795
-	*
4796
-	*/
4792
+	 * Gets all airlines used by pilot
4793
+	 *
4794
+	 * @return Array the airline list
4795
+	 *
4796
+	 */
4797 4797
 	public function countAllAirlinesByPilot($pilot,$filters = array())
4798 4798
 	{
4799 4799
 		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
@@ -4810,11 +4810,11 @@  discard block
 block discarded – undo
4810 4810
 	}
4811 4811
 
4812 4812
 	/**
4813
-	* Gets all airlines that have flown over by route
4814
-	*
4815
-	* @return Array the airline list
4816
-	*
4817
-	*/
4813
+	 * Gets all airlines that have flown over by route
4814
+	 *
4815
+	 * @return Array the airline list
4816
+	 *
4817
+	 */
4818 4818
 	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4819 4819
 	{
4820 4820
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4846,11 +4846,11 @@  discard block
 block discarded – undo
4846 4846
 	}
4847 4847
 
4848 4848
 	/**
4849
-	* Gets all airline countries that have flown over by route
4850
-	*
4851
-	* @return Array the airline country list
4852
-	*
4853
-	*/
4849
+	 * Gets all airline countries that have flown over by route
4850
+	 *
4851
+	 * @return Array the airline country list
4852
+	 *
4853
+	 */
4854 4854
 	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4855 4855
 	{
4856 4856
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4882,11 +4882,11 @@  discard block
 block discarded – undo
4882 4882
 
4883 4883
 
4884 4884
 	/**
4885
-	* Gets all airlines that have flown over by country
4886
-	*
4887
-	* @return Array the airline list
4888
-	*
4889
-	*/
4885
+	 * Gets all airlines that have flown over by country
4886
+	 *
4887
+	 * @return Array the airline list
4888
+	 *
4889
+	 */
4890 4890
 	public function countAllAirlinesByCountry($country,$filters = array())
4891 4891
 	{
4892 4892
 		$country = filter_var($country,FILTER_SANITIZE_STRING);
@@ -4916,11 +4916,11 @@  discard block
 block discarded – undo
4916 4916
 
4917 4917
 
4918 4918
 	/**
4919
-	* Gets all airline countries that have flown over by country
4920
-	*
4921
-	* @return Array the airline country list
4922
-	*
4923
-	*/
4919
+	 * Gets all airline countries that have flown over by country
4920
+	 *
4921
+	 * @return Array the airline country list
4922
+	 *
4923
+	 */
4924 4924
 	public function countAllAirlineCountriesByCountry($country,$filters = array())
4925 4925
 	{
4926 4926
 		$filter_query = $this->getFilter($filters,true,true);
@@ -4949,11 +4949,11 @@  discard block
 block discarded – undo
4949 4949
 
4950 4950
 
4951 4951
 	/**
4952
-	* Gets all airlines countries
4953
-	*
4954
-	* @return Array the airline country list
4955
-	*
4956
-	*/
4952
+	 * Gets all airlines countries
4953
+	 *
4954
+	 * @return Array the airline country list
4955
+	 *
4956
+	 */
4957 4957
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4958 4958
 	{
4959 4959
 		global $globalDBdriver;
@@ -5009,11 +5009,11 @@  discard block
 block discarded – undo
5009 5009
 	}
5010 5010
 
5011 5011
 	/**
5012
-	* Gets all number of flight over countries
5013
-	*
5014
-	* @return Array the airline country list
5015
-	*
5016
-	*/
5012
+	 * Gets all number of flight over countries
5013
+	 *
5014
+	 * @return Array the airline country list
5015
+	 *
5016
+	 */
5017 5017
 	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5018 5018
 	{
5019 5019
 		global $globalDBdriver;
@@ -5035,15 +5035,15 @@  discard block
 block discarded – undo
5035 5035
 		$SpotterLive = new SpotterLive();
5036 5036
 		$filter_query = $SpotterLive->getFilter($filters,true,true);
5037 5037
 		$filter_query .= ' over_country IS NOT NULL';
5038
-                if ($olderthanmonths > 0) {
5038
+				if ($olderthanmonths > 0) {
5039 5039
 			if ($globalDBdriver == 'mysql') {
5040 5040
 				$filter_query .= ' AND spotter_live.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
5041 5041
 			} else {
5042 5042
 				$filter_query .= " AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
5043 5043
 			}
5044 5044
 		}
5045
-                if ($sincedate != '') {
5046
-            		if ($globalDBdriver == 'mysql') {
5045
+				if ($sincedate != '') {
5046
+					if ($globalDBdriver == 'mysql') {
5047 5047
 				$filter_query .= " AND spotter_live.date > '".$sincedate."' ";
5048 5048
 			} else {
5049 5049
 				$filter_query .= " AND spotter_live.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -5073,11 +5073,11 @@  discard block
 block discarded – undo
5073 5073
 	
5074 5074
 	
5075 5075
 	/**
5076
-	* Gets all aircraft types that have flown over
5077
-	*
5078
-	* @return Array the aircraft list
5079
-	*
5080
-	*/
5076
+	 * Gets all aircraft types that have flown over
5077
+	 *
5078
+	 * @return Array the aircraft list
5079
+	 *
5080
+	 */
5081 5081
 	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5082 5082
 	{
5083 5083
 		global $globalDBdriver;
@@ -5147,11 +5147,11 @@  discard block
 block discarded – undo
5147 5147
 	}
5148 5148
 
5149 5149
 	/**
5150
-	* Gets all aircraft types that have flown over by airline
5151
-	*
5152
-	* @return Array the aircraft list
5153
-	*
5154
-	*/
5150
+	 * Gets all aircraft types that have flown over by airline
5151
+	 *
5152
+	 * @return Array the aircraft list
5153
+	 *
5154
+	 */
5155 5155
 	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5156 5156
 	{
5157 5157
 		global $globalDBdriver;
@@ -5222,11 +5222,11 @@  discard block
 block discarded – undo
5222 5222
 	}
5223 5223
 
5224 5224
 	/**
5225
-	* Gets all aircraft types that have flown over by months
5226
-	*
5227
-	* @return Array the aircraft list
5228
-	*
5229
-	*/
5225
+	 * Gets all aircraft types that have flown over by months
5226
+	 *
5227
+	 * @return Array the aircraft list
5228
+	 *
5229
+	 */
5230 5230
 	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5231 5231
 	{
5232 5232
 		global $globalDBdriver;
@@ -5270,11 +5270,11 @@  discard block
 block discarded – undo
5270 5270
 
5271 5271
 
5272 5272
 	/**
5273
-	* Gets all aircraft registration that have flown over by aircaft icao
5274
-	*
5275
-	* @return Array the aircraft list
5276
-	*
5277
-	*/
5273
+	 * Gets all aircraft registration that have flown over by aircaft icao
5274
+	 *
5275
+	 * @return Array the aircraft list
5276
+	 *
5277
+	 */
5278 5278
 	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5279 5279
 	{
5280 5280
 		$Image = new Image($this->db);
@@ -5313,11 +5313,11 @@  discard block
 block discarded – undo
5313 5313
 
5314 5314
 
5315 5315
 	/**
5316
-	* Gets all aircraft types that have flown over by airline icao
5317
-	*
5318
-	* @return Array the aircraft list
5319
-	*
5320
-	*/
5316
+	 * Gets all aircraft types that have flown over by airline icao
5317
+	 *
5318
+	 * @return Array the aircraft list
5319
+	 *
5320
+	 */
5321 5321
 	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5322 5322
 	{
5323 5323
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5346,11 +5346,11 @@  discard block
 block discarded – undo
5346 5346
 
5347 5347
 
5348 5348
 	/**
5349
-	* Gets all aircraft registration that have flown over by airline icao
5350
-	*
5351
-	* @return Array the aircraft list
5352
-	*
5353
-	*/
5349
+	 * Gets all aircraft registration that have flown over by airline icao
5350
+	 *
5351
+	 * @return Array the aircraft list
5352
+	 *
5353
+	 */
5354 5354
 	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5355 5355
 	{
5356 5356
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5388,11 +5388,11 @@  discard block
 block discarded – undo
5388 5388
 
5389 5389
 
5390 5390
 	/**
5391
-	* Gets all aircraft manufacturer that have flown over by airline icao
5392
-	*
5393
-	* @return Array the aircraft list
5394
-	*
5395
-	*/
5391
+	 * Gets all aircraft manufacturer that have flown over by airline icao
5392
+	 *
5393
+	 * @return Array the aircraft list
5394
+	 *
5395
+	 */
5396 5396
 	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5397 5397
 	{
5398 5398
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5420,11 +5420,11 @@  discard block
 block discarded – undo
5420 5420
 
5421 5421
 
5422 5422
 	/**
5423
-	* Gets all aircraft types that have flown over by airline icao
5424
-	*
5425
-	* @return Array the aircraft list
5426
-	*
5427
-	*/
5423
+	 * Gets all aircraft types that have flown over by airline icao
5424
+	 *
5425
+	 * @return Array the aircraft list
5426
+	 *
5427
+	 */
5428 5428
 	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5429 5429
 	{
5430 5430
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5453,11 +5453,11 @@  discard block
 block discarded – undo
5453 5453
 
5454 5454
 
5455 5455
 	/**
5456
-	* Gets all aircraft registration that have flown over by airport icao
5457
-	*
5458
-	* @return Array the aircraft list
5459
-	*
5460
-	*/
5456
+	 * Gets all aircraft registration that have flown over by airport icao
5457
+	 *
5458
+	 * @return Array the aircraft list
5459
+	 *
5460
+	 */
5461 5461
 	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5462 5462
 	{
5463 5463
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5494,11 +5494,11 @@  discard block
 block discarded – undo
5494 5494
 	
5495 5495
 	
5496 5496
 	/**
5497
-	* Gets all aircraft manufacturer that have flown over by airport icao
5498
-	*
5499
-	* @return Array the aircraft list
5500
-	*
5501
-	*/
5497
+	 * Gets all aircraft manufacturer that have flown over by airport icao
5498
+	 *
5499
+	 * @return Array the aircraft list
5500
+	 *
5501
+	 */
5502 5502
 	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5503 5503
 	{
5504 5504
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5524,11 +5524,11 @@  discard block
 block discarded – undo
5524 5524
 	}
5525 5525
 
5526 5526
 	/**
5527
-	* Gets all aircraft types that have flown over by aircraft manufacturer
5528
-	*
5529
-	* @return Array the aircraft list
5530
-	*
5531
-	*/
5527
+	 * Gets all aircraft types that have flown over by aircraft manufacturer
5528
+	 *
5529
+	 * @return Array the aircraft list
5530
+	 *
5531
+	 */
5532 5532
 	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5533 5533
 	{
5534 5534
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5555,11 +5555,11 @@  discard block
 block discarded – undo
5555 5555
 
5556 5556
 
5557 5557
 	/**
5558
-	* Gets all aircraft registration that have flown over by aircaft manufacturer
5559
-	*
5560
-	* @return Array the aircraft list
5561
-	*
5562
-	*/
5558
+	 * Gets all aircraft registration that have flown over by aircaft manufacturer
5559
+	 *
5560
+	 * @return Array the aircraft list
5561
+	 *
5562
+	 */
5563 5563
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5564 5564
 	{
5565 5565
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5595,11 +5595,11 @@  discard block
 block discarded – undo
5595 5595
 	}
5596 5596
 
5597 5597
 	/**
5598
-	* Gets all aircraft types that have flown over by date
5599
-	*
5600
-	* @return Array the aircraft list
5601
-	*
5602
-	*/
5598
+	 * Gets all aircraft types that have flown over by date
5599
+	 *
5600
+	 * @return Array the aircraft list
5601
+	 *
5602
+	 */
5603 5603
 	public function countAllAircraftTypesByDate($date,$filters = array())
5604 5604
 	{
5605 5605
 		global $globalTimezone, $globalDBdriver;
@@ -5641,11 +5641,11 @@  discard block
 block discarded – undo
5641 5641
 
5642 5642
 
5643 5643
 	/**
5644
-	* Gets all aircraft registration that have flown over by date
5645
-	*
5646
-	* @return Array the aircraft list
5647
-	*
5648
-	*/
5644
+	 * Gets all aircraft registration that have flown over by date
5645
+	 *
5646
+	 * @return Array the aircraft list
5647
+	 *
5648
+	 */
5649 5649
 	public function countAllAircraftRegistrationByDate($date,$filters = array())
5650 5650
 	{
5651 5651
 		global $globalTimezone, $globalDBdriver;
@@ -5696,11 +5696,11 @@  discard block
 block discarded – undo
5696 5696
 
5697 5697
 
5698 5698
 	/**
5699
-	* Gets all aircraft manufacturer that have flown over by date
5700
-	*
5701
-	* @return Array the aircraft manufacturer list
5702
-	*
5703
-	*/
5699
+	 * Gets all aircraft manufacturer that have flown over by date
5700
+	 *
5701
+	 * @return Array the aircraft manufacturer list
5702
+	 *
5703
+	 */
5704 5704
 	public function countAllAircraftManufacturerByDate($date,$filters = array())
5705 5705
 	{
5706 5706
 		global $globalTimezone, $globalDBdriver;
@@ -5742,11 +5742,11 @@  discard block
 block discarded – undo
5742 5742
 
5743 5743
 
5744 5744
 	/**
5745
-	* Gets all aircraft types that have flown over by ident/callsign
5746
-	*
5747
-	* @return Array the aircraft list
5748
-	*
5749
-	*/
5745
+	 * Gets all aircraft types that have flown over by ident/callsign
5746
+	 *
5747
+	 * @return Array the aircraft list
5748
+	 *
5749
+	 */
5750 5750
 	public function countAllAircraftTypesByIdent($ident,$filters = array())
5751 5751
 	{
5752 5752
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5774,11 +5774,11 @@  discard block
 block discarded – undo
5774 5774
 	}
5775 5775
 
5776 5776
 	/**
5777
-	* Gets all aircraft types that have flown over by pilot
5778
-	*
5779
-	* @return Array the aircraft list
5780
-	*
5781
-	*/
5777
+	 * Gets all aircraft types that have flown over by pilot
5778
+	 *
5779
+	 * @return Array the aircraft list
5780
+	 *
5781
+	 */
5782 5782
 	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5783 5783
 	{
5784 5784
 		global $globalDBdriver;
@@ -5824,11 +5824,11 @@  discard block
 block discarded – undo
5824 5824
 	}
5825 5825
 
5826 5826
 	/**
5827
-	* Gets all aircraft types that have flown over by owner
5828
-	*
5829
-	* @return Array the aircraft list
5830
-	*
5831
-	*/
5827
+	 * Gets all aircraft types that have flown over by owner
5828
+	 *
5829
+	 * @return Array the aircraft list
5830
+	 *
5831
+	 */
5832 5832
 	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5833 5833
 	{
5834 5834
 		global $globalDBdriver;
@@ -5873,11 +5873,11 @@  discard block
 block discarded – undo
5873 5873
 	}
5874 5874
 
5875 5875
 	/**
5876
-	* Gets all aircraft registration that have flown over by ident/callsign
5877
-	*
5878
-	* @return Array the aircraft list
5879
-	*
5880
-	*/
5876
+	 * Gets all aircraft registration that have flown over by ident/callsign
5877
+	 *
5878
+	 * @return Array the aircraft list
5879
+	 *
5880
+	 */
5881 5881
 	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5882 5882
 	{
5883 5883
 		$filter_query = $this->getFilter($filters,true,true);
@@ -5916,11 +5916,11 @@  discard block
 block discarded – undo
5916 5916
 	}
5917 5917
 
5918 5918
 	/**
5919
-	* Gets all aircraft registration that have flown over by owner
5920
-	*
5921
-	* @return Array the aircraft list
5922
-	*
5923
-	*/
5919
+	 * Gets all aircraft registration that have flown over by owner
5920
+	 *
5921
+	 * @return Array the aircraft list
5922
+	 *
5923
+	 */
5924 5924
 	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5925 5925
 	{
5926 5926
 		global $globalDBdriver;
@@ -5991,11 +5991,11 @@  discard block
 block discarded – undo
5991 5991
 	}
5992 5992
 
5993 5993
 	/**
5994
-	* Gets all aircraft registration that have flown over by pilot
5995
-	*
5996
-	* @return Array the aircraft list
5997
-	*
5998
-	*/
5994
+	 * Gets all aircraft registration that have flown over by pilot
5995
+	 *
5996
+	 * @return Array the aircraft list
5997
+	 *
5998
+	 */
5999 5999
 	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6000 6000
 	{
6001 6001
 		global $globalDBdriver;
@@ -6067,11 +6067,11 @@  discard block
 block discarded – undo
6067 6067
 
6068 6068
 
6069 6069
 	/**
6070
-	* Gets all aircraft manufacturer that have flown over by ident/callsign
6071
-	*
6072
-	* @return Array the aircraft manufacturer list
6073
-	*
6074
-	*/
6070
+	 * Gets all aircraft manufacturer that have flown over by ident/callsign
6071
+	 *
6072
+	 * @return Array the aircraft manufacturer list
6073
+	 *
6074
+	 */
6075 6075
 	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6076 6076
 	{
6077 6077
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6096,11 +6096,11 @@  discard block
 block discarded – undo
6096 6096
 	}
6097 6097
 
6098 6098
 	/**
6099
-	* Gets all aircraft manufacturer that have flown over by owner
6100
-	*
6101
-	* @return Array the aircraft manufacturer list
6102
-	*
6103
-	*/
6099
+	 * Gets all aircraft manufacturer that have flown over by owner
6100
+	 *
6101
+	 * @return Array the aircraft manufacturer list
6102
+	 *
6103
+	 */
6104 6104
 	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6105 6105
 	{
6106 6106
 		global $globalDBdriver;
@@ -6148,11 +6148,11 @@  discard block
 block discarded – undo
6148 6148
 	}
6149 6149
 
6150 6150
 	/**
6151
-	* Gets all aircraft manufacturer that have flown over by pilot
6152
-	*
6153
-	* @return Array the aircraft manufacturer list
6154
-	*
6155
-	*/
6151
+	 * Gets all aircraft manufacturer that have flown over by pilot
6152
+	 *
6153
+	 * @return Array the aircraft manufacturer list
6154
+	 *
6155
+	 */
6156 6156
 	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6157 6157
 	{
6158 6158
 		global $globalDBdriver;
@@ -6201,11 +6201,11 @@  discard block
 block discarded – undo
6201 6201
 
6202 6202
 
6203 6203
 	/**
6204
-	* Gets all aircraft types that have flown over by route
6205
-	*
6206
-	* @return Array the aircraft list
6207
-	*
6208
-	*/
6204
+	 * Gets all aircraft types that have flown over by route
6205
+	 *
6206
+	 * @return Array the aircraft list
6207
+	 *
6208
+	 */
6209 6209
 	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6210 6210
 	{
6211 6211
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6234,11 +6234,11 @@  discard block
 block discarded – undo
6234 6234
 	}
6235 6235
 
6236 6236
 	/**
6237
-	* Gets all aircraft registration that have flown over by route
6238
-	*
6239
-	* @return Array the aircraft list
6240
-	*
6241
-	*/
6237
+	 * Gets all aircraft registration that have flown over by route
6238
+	 *
6239
+	 * @return Array the aircraft list
6240
+	 *
6241
+	 */
6242 6242
 	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6243 6243
 	{
6244 6244
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6280,11 +6280,11 @@  discard block
 block discarded – undo
6280 6280
 	
6281 6281
 	
6282 6282
 	/**
6283
-	* Gets all aircraft manufacturer that have flown over by route
6284
-	*
6285
-	* @return Array the aircraft manufacturer list
6286
-	*
6287
-	*/
6283
+	 * Gets all aircraft manufacturer that have flown over by route
6284
+	 *
6285
+	 * @return Array the aircraft manufacturer list
6286
+	 *
6287
+	 */
6288 6288
 	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6289 6289
 	{
6290 6290
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6318,11 +6318,11 @@  discard block
 block discarded – undo
6318 6318
 	
6319 6319
 	
6320 6320
 	/**
6321
-	* Gets all aircraft types that have flown over by country
6322
-	*
6323
-	* @return Array the aircraft list
6324
-	*
6325
-	*/
6321
+	 * Gets all aircraft types that have flown over by country
6322
+	 *
6323
+	 * @return Array the aircraft list
6324
+	 *
6325
+	 */
6326 6326
 	public function countAllAircraftTypesByCountry($country,$filters = array())
6327 6327
 	{
6328 6328
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6353,11 +6353,11 @@  discard block
 block discarded – undo
6353 6353
 
6354 6354
 
6355 6355
 	/**
6356
-	* Gets all aircraft registration that have flown over by country
6357
-	*
6358
-	* @return Array the aircraft list
6359
-	*
6360
-	*/
6356
+	 * Gets all aircraft registration that have flown over by country
6357
+	 *
6358
+	 * @return Array the aircraft list
6359
+	 *
6360
+	 */
6361 6361
 	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6362 6362
 	{
6363 6363
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6397,11 +6397,11 @@  discard block
 block discarded – undo
6397 6397
 	
6398 6398
 	
6399 6399
 	/**
6400
-	* Gets all aircraft manufacturer that have flown over by country
6401
-	*
6402
-	* @return Array the aircraft manufacturer list
6403
-	*
6404
-	*/
6400
+	 * Gets all aircraft manufacturer that have flown over by country
6401
+	 *
6402
+	 * @return Array the aircraft manufacturer list
6403
+	 *
6404
+	 */
6405 6405
 	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6406 6406
 	{
6407 6407
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6432,18 +6432,18 @@  discard block
 block discarded – undo
6432 6432
 	
6433 6433
 	
6434 6434
 	/**
6435
-	* Gets all aircraft manufacturers that have flown over
6436
-	*
6437
-	* @return Array the aircraft list
6438
-	*
6439
-	*/
6435
+	 * Gets all aircraft manufacturers that have flown over
6436
+	 *
6437
+	 * @return Array the aircraft list
6438
+	 *
6439
+	 */
6440 6440
 	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6441 6441
 	{
6442 6442
 		global $globalDBdriver;
6443 6443
 		$filter_query = $this->getFilter($filters,true,true);
6444 6444
 		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6445 6445
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6446
-                $query_values = array();
6446
+				$query_values = array();
6447 6447
 		if ($year != '') {
6448 6448
 			if ($globalDBdriver == 'mysql') {
6449 6449
 				$query .= " AND YEAR(spotter_output.date) = :year";
@@ -6496,11 +6496,11 @@  discard block
 block discarded – undo
6496 6496
 	
6497 6497
 	
6498 6498
 	/**
6499
-	* Gets all aircraft registrations that have flown over
6500
-	*
6501
-	* @return Array the aircraft list
6502
-	*
6503
-	*/
6499
+	 * Gets all aircraft registrations that have flown over
6500
+	 *
6501
+	 * @return Array the aircraft list
6502
+	 *
6503
+	 */
6504 6504
 	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6505 6505
 	{
6506 6506
 		global $globalDBdriver;
@@ -6508,15 +6508,15 @@  discard block
 block discarded – undo
6508 6508
 		$filter_query = $this->getFilter($filters,true,true);
6509 6509
 		$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    
6510 6510
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6511
-                if ($olderthanmonths > 0) {
6512
-            		if ($globalDBdriver == 'mysql') {
6511
+				if ($olderthanmonths > 0) {
6512
+					if ($globalDBdriver == 'mysql') {
6513 6513
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6514 6514
 			} else {
6515 6515
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6516 6516
 			}
6517 6517
 		}
6518
-                if ($sincedate != '') {
6519
-            		if ($globalDBdriver == 'mysql') {
6518
+				if ($sincedate != '') {
6519
+					if ($globalDBdriver == 'mysql') {
6520 6520
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6521 6521
 			} else {
6522 6522
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6581,11 +6581,11 @@  discard block
 block discarded – undo
6581 6581
 
6582 6582
 
6583 6583
 	/**
6584
-	* Gets all aircraft registrations that have flown over
6585
-	*
6586
-	* @return Array the aircraft list
6587
-	*
6588
-	*/
6584
+	 * Gets all aircraft registrations that have flown over
6585
+	 *
6586
+	 * @return Array the aircraft list
6587
+	 *
6588
+	 */
6589 6589
 	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6590 6590
 	{
6591 6591
 		global $globalDBdriver;
@@ -6593,15 +6593,15 @@  discard block
 block discarded – undo
6593 6593
 		$Image = new Image($this->db);
6594 6594
 		$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    
6595 6595
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6596
-                if ($olderthanmonths > 0) {
6597
-            		if ($globalDBdriver == 'mysql') {
6596
+				if ($olderthanmonths > 0) {
6597
+					if ($globalDBdriver == 'mysql') {
6598 6598
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6599 6599
 			} else {
6600 6600
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6601 6601
 			}
6602 6602
 		}
6603
-                if ($sincedate != '') {
6604
-            		if ($globalDBdriver == 'mysql') {
6603
+				if ($sincedate != '') {
6604
+					if ($globalDBdriver == 'mysql') {
6605 6605
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6606 6606
 			} else {
6607 6607
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6610,7 +6610,7 @@  discard block
 block discarded – undo
6610 6610
 
6611 6611
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6612 6612
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6613
-                $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";
6613
+				$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";
6614 6614
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6615 6615
 		
6616 6616
 		$sth = $this->db->prepare($query);
@@ -6642,26 +6642,26 @@  discard block
 block discarded – undo
6642 6642
 	
6643 6643
 	
6644 6644
 	/**
6645
-	* Gets all departure airports of the airplanes that have flown over
6646
-	*
6647
-	* @return Array the airport list
6648
-	*
6649
-	*/
6645
+	 * Gets all departure airports of the airplanes that have flown over
6646
+	 *
6647
+	 * @return Array the airport list
6648
+	 *
6649
+	 */
6650 6650
 	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6651 6651
 	{
6652 6652
 		global $globalDBdriver;
6653 6653
 		$filter_query = $this->getFilter($filters,true,true);
6654 6654
 		$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, airport.latitude, airport.longitude
6655 6655
 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.departure_airport_icao AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6656
-                if ($olderthanmonths > 0) {
6657
-            		if ($globalDBdriver == 'mysql') {
6656
+				if ($olderthanmonths > 0) {
6657
+					if ($globalDBdriver == 'mysql') {
6658 6658
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6659 6659
 			} else {
6660 6660
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6661 6661
 			}
6662
-                }
6663
-                if ($sincedate != '') {
6664
-            		if ($globalDBdriver == 'mysql') {
6662
+				}
6663
+				if ($sincedate != '') {
6664
+					if ($globalDBdriver == 'mysql') {
6665 6665
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6666 6666
 			} else {
6667 6667
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6695,7 +6695,7 @@  discard block
 block discarded – undo
6695 6695
 				$query_values = array_merge($query_values,array(':day' => $day));
6696 6696
 			}
6697 6697
 		}
6698
-                $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude
6698
+				$query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude
6699 6699
 				ORDER BY airport_departure_icao_count DESC";
6700 6700
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6701 6701
 
@@ -6719,35 +6719,35 @@  discard block
 block discarded – undo
6719 6719
 	}
6720 6720
 
6721 6721
 	/**
6722
-	* Gets all departure airports of the airplanes that have flown over
6723
-	*
6724
-	* @return Array the airport list
6725
-	*
6726
-	*/
6722
+	 * Gets all departure airports of the airplanes that have flown over
6723
+	 *
6724
+	 * @return Array the airport list
6725
+	 *
6726
+	 */
6727 6727
 	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6728 6728
 	{
6729 6729
 		global $globalDBdriver;
6730 6730
 		$filter_query = $this->getFilter($filters,true,true);
6731 6731
 		$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 
6732 6732
 			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 <> '' ";
6733
-                if ($olderthanmonths > 0) {
6734
-            		if ($globalDBdriver == 'mysql') {
6733
+				if ($olderthanmonths > 0) {
6734
+					if ($globalDBdriver == 'mysql') {
6735 6735
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6736 6736
 			} else {
6737 6737
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6738 6738
 			}
6739
-                }
6740
-                if ($sincedate != '') {
6741
-            		if ($globalDBdriver == 'mysql') {
6739
+				}
6740
+				if ($sincedate != '') {
6741
+					if ($globalDBdriver == 'mysql') {
6742 6742
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6743 6743
 			} else {
6744 6744
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
6745 6745
 			}
6746 6746
 		}
6747 6747
 
6748
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6749
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6750
-                $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
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6749
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6750
+				$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
6751 6751
 				ORDER BY airport_departure_icao_count DESC";
6752 6752
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6753 6753
       
@@ -6772,26 +6772,26 @@  discard block
 block discarded – undo
6772 6772
 	}
6773 6773
 
6774 6774
 	/**
6775
-	* Gets all detected departure airports of the airplanes that have flown over
6776
-	*
6777
-	* @return Array the airport list
6778
-	*
6779
-	*/
6775
+	 * Gets all detected departure airports of the airplanes that have flown over
6776
+	 *
6777
+	 * @return Array the airport list
6778
+	 *
6779
+	 */
6780 6780
 	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6781 6781
 	{
6782 6782
 		global $globalDBdriver;
6783 6783
 		$filter_query = $this->getFilter($filters,true,true);
6784 6784
 		$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, airport.latitude as departure_airport_latitude, airport.longitude as departure_airport.longitude
6785 6785
 				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";
6786
-                if ($olderthanmonths > 0) {
6787
-            		if ($globalDBdriver == 'mysql') {
6786
+				if ($olderthanmonths > 0) {
6787
+					if ($globalDBdriver == 'mysql') {
6788 6788
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
6789 6789
 			} else {
6790 6790
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
6791 6791
 			}
6792
-                }
6793
-                if ($sincedate != '') {
6794
-            		if ($globalDBdriver == 'mysql') {
6792
+				}
6793
+				if ($sincedate != '') {
6794
+					if ($globalDBdriver == 'mysql') {
6795 6795
 				$query .= " AND spotter_output.date > '".$sincedate."'";
6796 6796
 			} else {
6797 6797
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -6825,10 +6825,10 @@  discard block
 block discarded – undo
6825 6825
 				$query_values = array_merge($query_values,array(':day' => $day));
6826 6826
 			}
6827 6827
 		}
6828
-                $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
6828
+				$query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
6829 6829
 				ORDER BY airport_departure_icao_count DESC";
6830 6830
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6831
-    		//echo $query;
6831
+			//echo $query;
6832 6832
 		$sth = $this->db->prepare($query);
6833 6833
 		$sth->execute($query_values);
6834 6834
       
@@ -6851,35 +6851,35 @@  discard block
 block discarded – undo
6851 6851
 	}
6852 6852
 	
6853 6853
 	/**
6854
-	* Gets all detected departure airports of the airplanes that have flown over
6855
-	*
6856
-	* @return Array the airport list
6857
-	*
6858
-	*/
6854
+	 * Gets all detected departure airports of the airplanes that have flown over
6855
+	 *
6856
+	 * @return Array the airport list
6857
+	 *
6858
+	 */
6859 6859
 	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6860 6860
 	{
6861 6861
 		global $globalDBdriver;
6862 6862
 		$filter_query = $this->getFilter($filters,true,true);
6863 6863
 		$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
6864 6864
 				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 ";
6865
-                if ($olderthanmonths > 0) {
6866
-            		if ($globalDBdriver == 'mysql') {
6865
+				if ($olderthanmonths > 0) {
6866
+					if ($globalDBdriver == 'mysql') {
6867 6867
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
6868 6868
 			} else {
6869 6869
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
6870 6870
 			}
6871
-                }
6872
-                if ($sincedate != '') {
6873
-            		if ($globalDBdriver == 'mysql') {
6871
+				}
6872
+				if ($sincedate != '') {
6873
+					if ($globalDBdriver == 'mysql') {
6874 6874
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
6875 6875
 			} else {
6876 6876
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
6877 6877
 			}
6878 6878
 		}
6879 6879
 
6880
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6881
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6882
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6880
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6881
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6882
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6883 6883
 				ORDER BY airport_departure_icao_count DESC";
6884 6884
 		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6885 6885
       
@@ -6904,11 +6904,11 @@  discard block
 block discarded – undo
6904 6904
 	}	
6905 6905
 	
6906 6906
 	/**
6907
-	* Gets all departure airports of the airplanes that have flown over based on an airline icao
6908
-	*
6909
-	* @return Array the airport list
6910
-	*
6911
-	*/
6907
+	 * Gets all departure airports of the airplanes that have flown over based on an airline icao
6908
+	 *
6909
+	 * @return Array the airport list
6910
+	 *
6911
+	 */
6912 6912
 	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6913 6913
 	{
6914 6914
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6942,11 +6942,11 @@  discard block
 block discarded – undo
6942 6942
 	
6943 6943
 	
6944 6944
 	/**
6945
-	* Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6946
-	*
6947
-	* @return Array the airport list
6948
-	*
6949
-	*/
6945
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airline icao
6946
+	 *
6947
+	 * @return Array the airport list
6948
+	 *
6949
+	 */
6950 6950
 	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6951 6951
 	{
6952 6952
 		$filter_query = $this->getFilter($filters,true,true);
@@ -6975,11 +6975,11 @@  discard block
 block discarded – undo
6975 6975
 	
6976 6976
 	
6977 6977
 	/**
6978
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6979
-	*
6980
-	* @return Array the airport list
6981
-	*
6982
-	*/
6978
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft icao
6979
+	 *
6980
+	 * @return Array the airport list
6981
+	 *
6982
+	 */
6983 6983
 	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6984 6984
 	{
6985 6985
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7012,11 +7012,11 @@  discard block
 block discarded – undo
7012 7012
 	
7013 7013
 	
7014 7014
 	/**
7015
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7016
-	*
7017
-	* @return Array the airport list
7018
-	*
7019
-	*/
7015
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7016
+	 *
7017
+	 * @return Array the airport list
7018
+	 *
7019
+	 */
7020 7020
 	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7021 7021
 	{
7022 7022
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7046,11 +7046,11 @@  discard block
 block discarded – undo
7046 7046
 	
7047 7047
 	
7048 7048
 	/**
7049
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7050
-	*
7051
-	* @return Array the airport list
7052
-	*
7053
-	*/
7049
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft registration
7050
+	 *
7051
+	 * @return Array the airport list
7052
+	 *
7053
+	 */
7054 7054
 	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7055 7055
 	{
7056 7056
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7083,11 +7083,11 @@  discard block
 block discarded – undo
7083 7083
 	
7084 7084
 	
7085 7085
 	/**
7086
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7087
-	*
7088
-	* @return Array the airport list
7089
-	*
7090
-	*/
7086
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft registration
7087
+	 *
7088
+	 * @return Array the airport list
7089
+	 *
7090
+	 */
7091 7091
 	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7092 7092
 	{
7093 7093
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7117,11 +7117,11 @@  discard block
 block discarded – undo
7117 7117
 	
7118 7118
 	
7119 7119
 	/**
7120
-	* Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7121
-	*
7122
-	* @return Array the airport list
7123
-	*
7124
-	*/
7120
+	 * Gets all departure airports of the airplanes that have flown over based on an arrivl airport icao
7121
+	 *
7122
+	 * @return Array the airport list
7123
+	 *
7124
+	 */
7125 7125
 	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7126 7126
 	{
7127 7127
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7154,11 +7154,11 @@  discard block
 block discarded – undo
7154 7154
 	
7155 7155
 	
7156 7156
 	/**
7157
-	* Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7158
-	*
7159
-	* @return Array the airport list
7160
-	*
7161
-	*/
7157
+	 * Gets all departure airports by country of the airplanes that have flown over based on an airport icao
7158
+	 *
7159
+	 * @return Array the airport list
7160
+	 *
7161
+	 */
7162 7162
 	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7163 7163
 	{
7164 7164
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7189,11 +7189,11 @@  discard block
 block discarded – undo
7189 7189
 	
7190 7190
 	
7191 7191
 	/**
7192
-	* Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7193
-	*
7194
-	* @return Array the airport list
7195
-	*
7196
-	*/
7192
+	 * Gets all departure airports of the airplanes that have flown over based on an aircraft manufacturer
7193
+	 *
7194
+	 * @return Array the airport list
7195
+	 *
7196
+	 */
7197 7197
 	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7198 7198
 	{
7199 7199
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7226,11 +7226,11 @@  discard block
 block discarded – undo
7226 7226
 	
7227 7227
 	
7228 7228
 	/**
7229
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7230
-	*
7231
-	* @return Array the airport list
7232
-	*
7233
-	*/
7229
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft manufacturer
7230
+	 *
7231
+	 * @return Array the airport list
7232
+	 *
7233
+	 */
7234 7234
 	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7235 7235
 	{
7236 7236
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7260,11 +7260,11 @@  discard block
 block discarded – undo
7260 7260
 	
7261 7261
 	
7262 7262
 	/**
7263
-	* Gets all departure airports of the airplanes that have flown over based on a date
7264
-	*
7265
-	* @return Array the airport list
7266
-	*
7267
-	*/
7263
+	 * Gets all departure airports of the airplanes that have flown over based on a date
7264
+	 *
7265
+	 * @return Array the airport list
7266
+	 *
7267
+	 */
7268 7268
 	public function countAllDepartureAirportsByDate($date,$filters = array())
7269 7269
 	{
7270 7270
 		global $globalTimezone, $globalDBdriver;
@@ -7310,11 +7310,11 @@  discard block
 block discarded – undo
7310 7310
 	
7311 7311
 	
7312 7312
 	/**
7313
-	* Gets all departure airports by country of the airplanes that have flown over based on a date
7314
-	*
7315
-	* @return Array the airport list
7316
-	*
7317
-	*/
7313
+	 * Gets all departure airports by country of the airplanes that have flown over based on a date
7314
+	 *
7315
+	 * @return Array the airport list
7316
+	 *
7317
+	 */
7318 7318
 	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7319 7319
 	{
7320 7320
 		global $globalTimezone, $globalDBdriver;
@@ -7357,11 +7357,11 @@  discard block
 block discarded – undo
7357 7357
 	
7358 7358
 	
7359 7359
 	/**
7360
-	* Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7361
-	*
7362
-	* @return Array the airport list
7363
-	*
7364
-	*/
7360
+	 * Gets all departure airports of the airplanes that have flown over based on a ident/callsign
7361
+	 *
7362
+	 * @return Array the airport list
7363
+	 *
7364
+	 */
7365 7365
 	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7366 7366
 	{
7367 7367
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7393,11 +7393,11 @@  discard block
 block discarded – undo
7393 7393
 	}
7394 7394
 	
7395 7395
 	/**
7396
-	* Gets all departure airports of the airplanes that have flown over based on a owner
7397
-	*
7398
-	* @return Array the airport list
7399
-	*
7400
-	*/
7396
+	 * Gets all departure airports of the airplanes that have flown over based on a owner
7397
+	 *
7398
+	 * @return Array the airport list
7399
+	 *
7400
+	 */
7401 7401
 	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7402 7402
 	{
7403 7403
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7429,11 +7429,11 @@  discard block
 block discarded – undo
7429 7429
 	}
7430 7430
 	
7431 7431
 	/**
7432
-	* Gets all departure airports of the airplanes that have flown over based on a pilot
7433
-	*
7434
-	* @return Array the airport list
7435
-	*
7436
-	*/
7432
+	 * Gets all departure airports of the airplanes that have flown over based on a pilot
7433
+	 *
7434
+	 * @return Array the airport list
7435
+	 *
7436
+	 */
7437 7437
 	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7438 7438
 	{
7439 7439
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7466,11 +7466,11 @@  discard block
 block discarded – undo
7466 7466
 	
7467 7467
 	
7468 7468
 	/**
7469
-	* Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7470
-	*
7471
-	* @return Array the airport list
7472
-	*
7473
-	*/
7469
+	 * Gets all departure airports by country of the airplanes that have flown over based on a callsign/ident
7470
+	 *
7471
+	 * @return Array the airport list
7472
+	 *
7473
+	 */
7474 7474
 	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7475 7475
 	{
7476 7476
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7499,11 +7499,11 @@  discard block
 block discarded – undo
7499 7499
 	}
7500 7500
 	
7501 7501
 	/**
7502
-	* Gets all departure airports by country of the airplanes that have flown over based on owner
7503
-	*
7504
-	* @return Array the airport list
7505
-	*
7506
-	*/
7502
+	 * Gets all departure airports by country of the airplanes that have flown over based on owner
7503
+	 *
7504
+	 * @return Array the airport list
7505
+	 *
7506
+	 */
7507 7507
 	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7508 7508
 	{
7509 7509
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7519,11 +7519,11 @@  discard block
 block discarded – undo
7519 7519
 	}
7520 7520
 	
7521 7521
 	/**
7522
-	* Gets all departure airports by country of the airplanes that have flown over based on pilot
7523
-	*
7524
-	* @return Array the airport list
7525
-	*
7526
-	*/
7522
+	 * Gets all departure airports by country of the airplanes that have flown over based on pilot
7523
+	 *
7524
+	 * @return Array the airport list
7525
+	 *
7526
+	 */
7527 7527
 	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7528 7528
 	{
7529 7529
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7541,11 +7541,11 @@  discard block
 block discarded – undo
7541 7541
 	
7542 7542
 	
7543 7543
 	/**
7544
-	* Gets all departure airports of the airplanes that have flown over based on a country
7545
-	*
7546
-	* @return Array the airport list
7547
-	*
7548
-	*/
7544
+	 * Gets all departure airports of the airplanes that have flown over based on a country
7545
+	 *
7546
+	 * @return Array the airport list
7547
+	 *
7548
+	 */
7549 7549
 	public function countAllDepartureAirportsByCountry($country,$filters = array())
7550 7550
 	{
7551 7551
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7579,11 +7579,11 @@  discard block
 block discarded – undo
7579 7579
 
7580 7580
 
7581 7581
 	/**
7582
-	* Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7583
-	*
7584
-	* @return Array the airport list
7585
-	*
7586
-	*/
7582
+	 * Gets all departure airports by country of the airplanes that have flown over based on an aircraft icao
7583
+	 *
7584
+	 * @return Array the airport list
7585
+	 *
7586
+	 */
7587 7587
 	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7588 7588
 	{
7589 7589
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7613,31 +7613,31 @@  discard block
 block discarded – undo
7613 7613
 	
7614 7614
 
7615 7615
 	/**
7616
-	* Gets all arrival airports of the airplanes that have flown over
7617
-	*
7618
-	* @param Boolean $limit Limit result to 10 or not
7619
-	* @param Integer $olderthanmonths Only show result older than x months
7620
-	* @param String $sincedate Only show result since x date
7621
-	* @param Boolean $icaoaskey Show result by ICAO
7622
-	* @param Array $filters Filter used here
7623
-	* @return Array the airport list
7624
-	*
7625
-	*/
7616
+	 * Gets all arrival airports of the airplanes that have flown over
7617
+	 *
7618
+	 * @param Boolean $limit Limit result to 10 or not
7619
+	 * @param Integer $olderthanmonths Only show result older than x months
7620
+	 * @param String $sincedate Only show result since x date
7621
+	 * @param Boolean $icaoaskey Show result by ICAO
7622
+	 * @param Array $filters Filter used here
7623
+	 * @return Array the airport list
7624
+	 *
7625
+	 */
7626 7626
 	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7627 7627
 	{
7628 7628
 		global $globalDBdriver;
7629 7629
 		$filter_query = $this->getFilter($filters,true,true);
7630 7630
 		$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, airport.latitude as arrival_airport_latitude, airport.longitude as arrival_airport_longitude 
7631 7631
 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.arrival_airport_icao AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7632
-                if ($olderthanmonths > 0) {
7633
-            		if ($globalDBdriver == 'mysql') {
7632
+				if ($olderthanmonths > 0) {
7633
+					if ($globalDBdriver == 'mysql') {
7634 7634
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7635 7635
 			} else {
7636 7636
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7637 7637
 			}
7638 7638
 		}
7639
-                if ($sincedate != '') {
7640
-            		if ($globalDBdriver == 'mysql') {
7639
+				if ($sincedate != '') {
7640
+					if ($globalDBdriver == 'mysql') {
7641 7641
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7642 7642
 			} else {
7643 7643
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7671,7 +7671,7 @@  discard block
 block discarded – undo
7671 7671
 				$query_values = array_merge($query_values,array(':day' => $day));
7672 7672
 			}
7673 7673
 		}
7674
-                $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude
7674
+				$query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude
7675 7675
 					ORDER BY airport_arrival_icao_count DESC";
7676 7676
 		if ($limit) $query .= " LIMIT 10";
7677 7677
       
@@ -7702,35 +7702,35 @@  discard block
 block discarded – undo
7702 7702
 	}
7703 7703
 
7704 7704
 	/**
7705
-	* Gets all arrival airports of the airplanes that have flown over
7706
-	*
7707
-	* @return Array the airport list
7708
-	*
7709
-	*/
7705
+	 * Gets all arrival airports of the airplanes that have flown over
7706
+	 *
7707
+	 * @return Array the airport list
7708
+	 *
7709
+	 */
7710 7710
 	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7711 7711
 	{
7712 7712
 		global $globalDBdriver;
7713 7713
 		$filter_query = $this->getFilter($filters,true,true);
7714 7714
 		$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, country.iso3 AS arrival_airport_country_iso3 
7715 7715
 			FROM countries,spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7716
-                if ($olderthanmonths > 0) {
7717
-            		if ($globalDBdriver == 'mysql') {
7716
+				if ($olderthanmonths > 0) {
7717
+					if ($globalDBdriver == 'mysql') {
7718 7718
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7719 7719
 			} else {
7720 7720
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7721 7721
 			}
7722 7722
 		}
7723
-                if ($sincedate != '') {
7724
-            		if ($globalDBdriver == 'mysql') {
7723
+				if ($sincedate != '') {
7724
+					if ($globalDBdriver == 'mysql') {
7725 7725
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7726 7726
 			} else {
7727 7727
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7728 7728
 			}
7729 7729
 		}
7730 7730
 
7731
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7732
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7733
-                $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, countries.iso3
7731
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7732
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7733
+				$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, countries.iso3
7734 7734
 					ORDER BY airport_arrival_icao_count DESC";
7735 7735
 		if ($limit) $query .= " LIMIT 10";
7736 7736
       
@@ -7762,26 +7762,26 @@  discard block
 block discarded – undo
7762 7762
 
7763 7763
 
7764 7764
 	/**
7765
-	* Gets all detected arrival airports of the airplanes that have flown over
7766
-	*
7767
-	* @return Array the airport list
7768
-	*
7769
-	*/
7765
+	 * Gets all detected arrival airports of the airplanes that have flown over
7766
+	 *
7767
+	 * @return Array the airport list
7768
+	 *
7769
+	 */
7770 7770
 	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7771 7771
 	{
7772 7772
 		global $globalDBdriver;
7773 7773
 		$filter_query = $this->getFilter($filters,true,true);
7774 7774
 		$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, airport.latitude AS arrival_airport_latitude, airport.longitude AS arrival_airport_longitude 
7775 7775
 			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";
7776
-                if ($olderthanmonths > 0) {
7777
-            		if ($globalDBdriver == 'mysql') {
7776
+				if ($olderthanmonths > 0) {
7777
+					if ($globalDBdriver == 'mysql') {
7778 7778
 				$query .= ' AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH)';
7779 7779
 			} else {
7780 7780
 				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
7781 7781
 			}
7782 7782
 		}
7783
-                if ($sincedate != '') {
7784
-            		if ($globalDBdriver == 'mysql') {
7783
+				if ($sincedate != '') {
7784
+					if ($globalDBdriver == 'mysql') {
7785 7785
 				$query .= " AND spotter_output.date > '".$sincedate."'";
7786 7786
 			} else {
7787 7787
 				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
@@ -7843,35 +7843,35 @@  discard block
 block discarded – undo
7843 7843
 	}
7844 7844
 	
7845 7845
 	/**
7846
-	* Gets all detected arrival airports of the airplanes that have flown over
7847
-	*
7848
-	* @return Array the airport list
7849
-	*
7850
-	*/
7846
+	 * Gets all detected arrival airports of the airplanes that have flown over
7847
+	 *
7848
+	 * @return Array the airport list
7849
+	 *
7850
+	 */
7851 7851
 	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7852 7852
 	{
7853 7853
 		global $globalDBdriver;
7854 7854
 		$filter_query = $this->getFilter($filters,true,true);
7855 7855
 		$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 
7856 7856
 			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 ";
7857
-                if ($olderthanmonths > 0) {
7858
-            		if ($globalDBdriver == 'mysql') {
7857
+				if ($olderthanmonths > 0) {
7858
+					if ($globalDBdriver == 'mysql') {
7859 7859
 				$query .= 'AND spotter_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$olderthanmonths.' MONTH) ';
7860 7860
 			} else {
7861 7861
 				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
7862 7862
 			}
7863 7863
 		}
7864
-                if ($sincedate != '') {
7865
-            		if ($globalDBdriver == 'mysql') {
7864
+				if ($sincedate != '') {
7865
+					if ($globalDBdriver == 'mysql') {
7866 7866
 				$query .= "AND spotter_output.date > '".$sincedate."' ";
7867 7867
 			} else {
7868 7868
 				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
7869 7869
 			}
7870 7870
 		}
7871 7871
 
7872
-            	//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7873
-                //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7874
-                $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7872
+				//if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
7873
+				//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7874
+				$query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7875 7875
 					ORDER BY airport_arrival_icao_count DESC";
7876 7876
 		if ($limit) $query .= " LIMIT 10";
7877 7877
       
@@ -7901,11 +7901,11 @@  discard block
 block discarded – undo
7901 7901
 	}	
7902 7902
 	
7903 7903
 	/**
7904
-	* Gets all arrival airports of the airplanes that have flown over based on an airline icao
7905
-	*
7906
-	* @return Array the airport list
7907
-	*
7908
-	*/
7904
+	 * Gets all arrival airports of the airplanes that have flown over based on an airline icao
7905
+	 *
7906
+	 * @return Array the airport list
7907
+	 *
7908
+	 */
7909 7909
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7910 7910
 	{
7911 7911
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7937,11 +7937,11 @@  discard block
 block discarded – undo
7937 7937
 	
7938 7938
 	
7939 7939
 	/**
7940
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7941
-	*
7942
-	* @return Array the airport list
7943
-	*
7944
-	*/
7940
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airline icao
7941
+	 *
7942
+	 * @return Array the airport list
7943
+	 *
7944
+	 */
7945 7945
 	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7946 7946
 	{
7947 7947
 		$filter_query = $this->getFilter($filters,true,true);
@@ -7971,11 +7971,11 @@  discard block
 block discarded – undo
7971 7971
 	
7972 7972
 	
7973 7973
 	/**
7974
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7975
-	*
7976
-	* @return Array the airport list
7977
-	*
7978
-	*/
7974
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft icao
7975
+	 *
7976
+	 * @return Array the airport list
7977
+	 *
7978
+	 */
7979 7979
 	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7980 7980
 	{
7981 7981
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8009,11 +8009,11 @@  discard block
 block discarded – undo
8009 8009
 	
8010 8010
 	
8011 8011
 	/**
8012
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8013
-	*
8014
-	* @return Array the airport list
8015
-	*
8016
-	*/
8012
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft icao
8013
+	 *
8014
+	 * @return Array the airport list
8015
+	 *
8016
+	 */
8017 8017
 	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8018 8018
 	{
8019 8019
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8043,11 +8043,11 @@  discard block
 block discarded – undo
8043 8043
 	
8044 8044
 	
8045 8045
 	/**
8046
-	* Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8047
-	*
8048
-	* @return Array the airport list
8049
-	*
8050
-	*/
8046
+	 * Gets all arrival airports of the airplanes that have flown over based on an aircraft registration
8047
+	 *
8048
+	 * @return Array the airport list
8049
+	 *
8050
+	 */
8051 8051
 	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8052 8052
 	{
8053 8053
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8081,11 +8081,11 @@  discard block
 block discarded – undo
8081 8081
 	
8082 8082
 	
8083 8083
 	/**
8084
-	* Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8085
-	*
8086
-	* @return Array the airport list
8087
-	*
8088
-	*/
8084
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an aircraft registration
8085
+	 *
8086
+	 * @return Array the airport list
8087
+	 *
8088
+	 */
8089 8089
 	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8090 8090
 	{
8091 8091
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8116,11 +8116,11 @@  discard block
 block discarded – undo
8116 8116
 	
8117 8117
 	
8118 8118
 	/**
8119
-	* Gets all arrival airports of the airplanes that have flown over based on an departure airport
8120
-	*
8121
-	* @return Array the airport list
8122
-	*
8123
-	*/
8119
+	 * Gets all arrival airports of the airplanes that have flown over based on an departure airport
8120
+	 *
8121
+	 * @return Array the airport list
8122
+	 *
8123
+	 */
8124 8124
 	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8125 8125
 	{
8126 8126
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8153,11 +8153,11 @@  discard block
 block discarded – undo
8153 8153
 	
8154 8154
 	
8155 8155
 	/**
8156
-	* Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8157
-	*
8158
-	* @return Array the airport list
8159
-	*
8160
-	*/
8156
+	 * Gets all arrival airports by country of the airplanes that have flown over based on an airport icao
8157
+	 *
8158
+	 * @return Array the airport list
8159
+	 *
8160
+	 */
8161 8161
 	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8162 8162
 	{
8163 8163
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8187,11 +8187,11 @@  discard block
 block discarded – undo
8187 8187
 	
8188 8188
 	
8189 8189
 	/**
8190
-	* Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8191
-	*
8192
-	* @return Array the airport list
8193
-	*
8194
-	*/
8190
+	 * Gets all arrival airports of the airplanes that have flown over based on a aircraft manufacturer
8191
+	 *
8192
+	 * @return Array the airport list
8193
+	 *
8194
+	 */
8195 8195
 	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8196 8196
 	{
8197 8197
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8225,11 +8225,11 @@  discard block
 block discarded – undo
8225 8225
 	
8226 8226
 	
8227 8227
 	/**
8228
-	* Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8229
-	*
8230
-	* @return Array the airport list
8231
-	*
8232
-	*/
8228
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a aircraft manufacturer
8229
+	 *
8230
+	 * @return Array the airport list
8231
+	 *
8232
+	 */
8233 8233
 	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8234 8234
 	{
8235 8235
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8260,11 +8260,11 @@  discard block
 block discarded – undo
8260 8260
 	
8261 8261
 	
8262 8262
 	/**
8263
-	* Gets all arrival airports of the airplanes that have flown over based on a date
8264
-	*
8265
-	* @return Array the airport list
8266
-	*
8267
-	*/
8263
+	 * Gets all arrival airports of the airplanes that have flown over based on a date
8264
+	 *
8265
+	 * @return Array the airport list
8266
+	 *
8267
+	 */
8268 8268
 	public function countAllArrivalAirportsByDate($date,$filters = array())
8269 8269
 	{
8270 8270
 		global $globalTimezone, $globalDBdriver;
@@ -8310,11 +8310,11 @@  discard block
 block discarded – undo
8310 8310
 	
8311 8311
 	
8312 8312
 	/**
8313
-	* Gets all arrival airports by country of the airplanes that have flown over based on a date
8314
-	*
8315
-	* @return Array the airport list
8316
-	*
8317
-	*/
8313
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a date
8314
+	 *
8315
+	 * @return Array the airport list
8316
+	 *
8317
+	 */
8318 8318
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8319 8319
 	{
8320 8320
 		global $globalTimezone, $globalDBdriver;
@@ -8357,11 +8357,11 @@  discard block
 block discarded – undo
8357 8357
 	
8358 8358
 	
8359 8359
 	/**
8360
-	* Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8361
-	*
8362
-	* @return Array the airport list
8363
-	*
8364
-	*/
8360
+	 * Gets all arrival airports of the airplanes that have flown over based on a ident/callsign
8361
+	 *
8362
+	 * @return Array the airport list
8363
+	 *
8364
+	 */
8365 8365
 	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8366 8366
 	{
8367 8367
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8393,11 +8393,11 @@  discard block
 block discarded – undo
8393 8393
 	}
8394 8394
 	
8395 8395
 	/**
8396
-	* Gets all arrival airports of the airplanes that have flown over based on a owner
8397
-	*
8398
-	* @return Array the airport list
8399
-	*
8400
-	*/
8396
+	 * Gets all arrival airports of the airplanes that have flown over based on a owner
8397
+	 *
8398
+	 * @return Array the airport list
8399
+	 *
8400
+	 */
8401 8401
 	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8402 8402
 	{
8403 8403
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8428,11 +8428,11 @@  discard block
 block discarded – undo
8428 8428
 	}
8429 8429
 
8430 8430
 	/**
8431
-	* Gets all arrival airports of the airplanes that have flown over based on a pilot
8432
-	*
8433
-	* @return Array the airport list
8434
-	*
8435
-	*/
8431
+	 * Gets all arrival airports of the airplanes that have flown over based on a pilot
8432
+	 *
8433
+	 * @return Array the airport list
8434
+	 *
8435
+	 */
8436 8436
 	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8437 8437
 	{
8438 8438
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8463,11 +8463,11 @@  discard block
 block discarded – undo
8463 8463
 	}
8464 8464
 	
8465 8465
 	/**
8466
-	* Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8467
-	*
8468
-	* @return Array the airport list
8469
-	*
8470
-	*/
8466
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a callsign/ident
8467
+	 *
8468
+	 * @return Array the airport list
8469
+	 *
8470
+	 */
8471 8471
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8472 8472
 	{
8473 8473
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8496,11 +8496,11 @@  discard block
 block discarded – undo
8496 8496
 	}
8497 8497
 	
8498 8498
 	/**
8499
-	* Gets all arrival airports by country of the airplanes that have flown over based on a owner
8500
-	*
8501
-	* @return Array the airport list
8502
-	*
8503
-	*/
8499
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a owner
8500
+	 *
8501
+	 * @return Array the airport list
8502
+	 *
8503
+	 */
8504 8504
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8505 8505
 	{
8506 8506
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8516,11 +8516,11 @@  discard block
 block discarded – undo
8516 8516
 	}
8517 8517
 	
8518 8518
 	/**
8519
-	* Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8520
-	*
8521
-	* @return Array the airport list
8522
-	*
8523
-	*/
8519
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a pilot
8520
+	 *
8521
+	 * @return Array the airport list
8522
+	 *
8523
+	 */
8524 8524
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8525 8525
 	{
8526 8526
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8538,11 +8538,11 @@  discard block
 block discarded – undo
8538 8538
 	
8539 8539
 	
8540 8540
 	/**
8541
-	* Gets all arrival airports of the airplanes that have flown over based on a country
8542
-	*
8543
-	* @return Array the airport list
8544
-	*
8545
-	*/
8541
+	 * Gets all arrival airports of the airplanes that have flown over based on a country
8542
+	 *
8543
+	 * @return Array the airport list
8544
+	 *
8545
+	 */
8546 8546
 	public function countAllArrivalAirportsByCountry($country,$filters = array())
8547 8547
 	{
8548 8548
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8575,11 +8575,11 @@  discard block
 block discarded – undo
8575 8575
 	
8576 8576
 	
8577 8577
 	/**
8578
-	* Gets all arrival airports by country of the airplanes that have flown over based on a country
8579
-	*
8580
-	* @return Array the airport list
8581
-	*
8582
-	*/
8578
+	 * Gets all arrival airports by country of the airplanes that have flown over based on a country
8579
+	 *
8580
+	 * @return Array the airport list
8581
+	 *
8582
+	 */
8583 8583
 	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8584 8584
 	{
8585 8585
 		global $globalDBdriver;
@@ -8611,11 +8611,11 @@  discard block
 block discarded – undo
8611 8611
 
8612 8612
 
8613 8613
 	/**
8614
-	* Counts all airport departure countries
8615
-	*
8616
-	* @return Array the airport departure list
8617
-	*
8618
-	*/
8614
+	 * Counts all airport departure countries
8615
+	 *
8616
+	 * @return Array the airport departure list
8617
+	 *
8618
+	 */
8619 8619
 	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8620 8620
 	{
8621 8621
 		global $globalDBdriver;
@@ -8674,11 +8674,11 @@  discard block
 block discarded – undo
8674 8674
 	
8675 8675
 	
8676 8676
 	/**
8677
-	* Counts all airport arrival countries
8678
-	*
8679
-	* @return Array the airport arrival list
8680
-	*
8681
-	*/
8677
+	 * Counts all airport arrival countries
8678
+	 *
8679
+	 * @return Array the airport arrival list
8680
+	 *
8681
+	 */
8682 8682
 	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8683 8683
 	{
8684 8684
 		global $globalDBdriver;
@@ -8741,11 +8741,11 @@  discard block
 block discarded – undo
8741 8741
 
8742 8742
 
8743 8743
 	/**
8744
-	* Gets all route combinations
8745
-	*
8746
-	* @return Array the route list
8747
-	*
8748
-	*/
8744
+	 * Gets all route combinations
8745
+	 *
8746
+	 * @return Array the route list
8747
+	 *
8748
+	 */
8749 8749
 	public function countAllRoutes($filters = array())
8750 8750
 	{
8751 8751
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8784,11 +8784,11 @@  discard block
 block discarded – undo
8784 8784
 	
8785 8785
 	
8786 8786
 	/**
8787
-	* Gets all route combinations based on an aircraft
8788
-	*
8789
-	* @return Array the route list
8790
-	*
8791
-	*/
8787
+	 * Gets all route combinations based on an aircraft
8788
+	 *
8789
+	 * @return Array the route list
8790
+	 *
8791
+	 */
8792 8792
 	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8793 8793
 	{
8794 8794
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8824,11 +8824,11 @@  discard block
 block discarded – undo
8824 8824
 	
8825 8825
 	
8826 8826
 	/**
8827
-	* Gets all route combinations based on an aircraft registration
8828
-	*
8829
-	* @return Array the route list
8830
-	*
8831
-	*/
8827
+	 * Gets all route combinations based on an aircraft registration
8828
+	 *
8829
+	 * @return Array the route list
8830
+	 *
8831
+	 */
8832 8832
 	public function countAllRoutesByRegistration($registration, $filters = array())
8833 8833
 	{
8834 8834
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8866,11 +8866,11 @@  discard block
 block discarded – undo
8866 8866
 	
8867 8867
 	
8868 8868
 	/**
8869
-	* Gets all route combinations based on an airline
8870
-	*
8871
-	* @return Array the route list
8872
-	*
8873
-	*/
8869
+	 * Gets all route combinations based on an airline
8870
+	 *
8871
+	 * @return Array the route list
8872
+	 *
8873
+	 */
8874 8874
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8875 8875
 	{
8876 8876
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8908,11 +8908,11 @@  discard block
 block discarded – undo
8908 8908
 	
8909 8909
 	
8910 8910
 	/**
8911
-	* Gets all route combinations based on an airport
8912
-	*
8913
-	* @return Array the route list
8914
-	*
8915
-	*/
8911
+	 * Gets all route combinations based on an airport
8912
+	 *
8913
+	 * @return Array the route list
8914
+	 *
8915
+	 */
8916 8916
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8917 8917
 	{
8918 8918
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8949,11 +8949,11 @@  discard block
 block discarded – undo
8949 8949
 	
8950 8950
 	
8951 8951
 	/**
8952
-	* Gets all route combinations based on an country
8953
-	*
8954
-	* @return Array the route list
8955
-	*
8956
-	*/
8952
+	 * Gets all route combinations based on an country
8953
+	 *
8954
+	 * @return Array the route list
8955
+	 *
8956
+	 */
8957 8957
 	public function countAllRoutesByCountry($country, $filters = array())
8958 8958
 	{
8959 8959
 		$filter_query = $this->getFilter($filters,true,true);
@@ -8989,11 +8989,11 @@  discard block
 block discarded – undo
8989 8989
 
8990 8990
 
8991 8991
 	/**
8992
-	* Gets all route combinations based on an date
8993
-	*
8994
-	* @return Array the route list
8995
-	*
8996
-	*/
8992
+	 * Gets all route combinations based on an date
8993
+	 *
8994
+	 * @return Array the route list
8995
+	 *
8996
+	 */
8997 8997
 	public function countAllRoutesByDate($date, $filters = array())
8998 8998
 	{
8999 8999
 		global $globalTimezone, $globalDBdriver;
@@ -9043,11 +9043,11 @@  discard block
 block discarded – undo
9043 9043
 	
9044 9044
 	
9045 9045
 	/**
9046
-	* Gets all route combinations based on an ident/callsign
9047
-	*
9048
-	* @return Array the route list
9049
-	*
9050
-	*/
9046
+	 * Gets all route combinations based on an ident/callsign
9047
+	 *
9048
+	 * @return Array the route list
9049
+	 *
9050
+	 */
9051 9051
 	public function countAllRoutesByIdent($ident, $filters = array())
9052 9052
 	{
9053 9053
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9083,11 +9083,11 @@  discard block
 block discarded – undo
9083 9083
 	}
9084 9084
 	
9085 9085
 	/**
9086
-	* Gets all route combinations based on an owner
9087
-	*
9088
-	* @return Array the route list
9089
-	*
9090
-	*/
9086
+	 * Gets all route combinations based on an owner
9087
+	 *
9088
+	 * @return Array the route list
9089
+	 *
9090
+	 */
9091 9091
 	public function countAllRoutesByOwner($owner,$filters = array())
9092 9092
 	{
9093 9093
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9123,11 +9123,11 @@  discard block
 block discarded – undo
9123 9123
 	}
9124 9124
 	
9125 9125
 	/**
9126
-	* Gets all route combinations based on a pilot
9127
-	*
9128
-	* @return Array the route list
9129
-	*
9130
-	*/
9126
+	 * Gets all route combinations based on a pilot
9127
+	 *
9128
+	 * @return Array the route list
9129
+	 *
9130
+	 */
9131 9131
 	public function countAllRoutesByPilot($pilot,$filters = array())
9132 9132
 	{
9133 9133
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9164,11 +9164,11 @@  discard block
 block discarded – undo
9164 9164
 	
9165 9165
 	
9166 9166
 	/**
9167
-	* Gets all route combinations based on an manufacturer
9168
-	*
9169
-	* @return Array the route list
9170
-	*
9171
-	*/
9167
+	 * Gets all route combinations based on an manufacturer
9168
+	 *
9169
+	 * @return Array the route list
9170
+	 *
9171
+	 */
9172 9172
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9173 9173
 	{
9174 9174
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9206,11 +9206,11 @@  discard block
 block discarded – undo
9206 9206
 	
9207 9207
 	
9208 9208
 	/**
9209
-	* Gets all route combinations with waypoints
9210
-	*
9211
-	* @return Array the route list
9212
-	*
9213
-	*/
9209
+	 * Gets all route combinations with waypoints
9210
+	 *
9211
+	 * @return Array the route list
9212
+	 *
9213
+	 */
9214 9214
 	public function countAllRoutesWithWaypoints($filters = array())
9215 9215
 	{
9216 9216
 		$filter_query = $this->getFilter($filters,true,true);
@@ -9247,11 +9247,11 @@  discard block
 block discarded – undo
9247 9247
 	}
9248 9248
 	
9249 9249
 	/**
9250
-	* Gets all callsigns that have flown over
9251
-	*
9252
-	* @return Array the callsign list
9253
-	*
9254
-	*/
9250
+	 * Gets all callsigns that have flown over
9251
+	 *
9252
+	 * @return Array the callsign list
9253
+	 *
9254
+	 */
9255 9255
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9256 9256
 	{
9257 9257
 		global $globalDBdriver;
@@ -9317,11 +9317,11 @@  discard block
 block discarded – undo
9317 9317
 	}
9318 9318
 
9319 9319
 	/**
9320
-	* Gets all callsigns that have flown over
9321
-	*
9322
-	* @return Array the callsign list
9323
-	*
9324
-	*/
9320
+	 * Gets all callsigns that have flown over
9321
+	 *
9322
+	 * @return Array the callsign list
9323
+	 *
9324
+	 */
9325 9325
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9326 9326
 	{
9327 9327
 		global $globalDBdriver;
@@ -9362,11 +9362,11 @@  discard block
 block discarded – undo
9362 9362
 
9363 9363
 
9364 9364
 	/**
9365
-	* Counts all dates
9366
-	*
9367
-	* @return Array the date list
9368
-	*
9369
-	*/
9365
+	 * Counts all dates
9366
+	 *
9367
+	 * @return Array the date list
9368
+	 *
9369
+	 */
9370 9370
 	public function countAllDates($filters = array())
9371 9371
 	{
9372 9372
 		global $globalTimezone, $globalDBdriver;
@@ -9411,11 +9411,11 @@  discard block
 block discarded – undo
9411 9411
 	}
9412 9412
 	
9413 9413
 	/**
9414
-	* Counts all dates
9415
-	*
9416
-	* @return Array the date list
9417
-	*
9418
-	*/
9414
+	 * Counts all dates
9415
+	 *
9416
+	 * @return Array the date list
9417
+	 *
9418
+	 */
9419 9419
 	public function countAllDatesByAirlines($filters = array())
9420 9420
 	{
9421 9421
 		global $globalTimezone, $globalDBdriver;
@@ -9460,11 +9460,11 @@  discard block
 block discarded – undo
9460 9460
 	}	
9461 9461
 	
9462 9462
 	/**
9463
-	* Counts all dates during the last 7 days
9464
-	*
9465
-	* @return Array the date list
9466
-	*
9467
-	*/
9463
+	 * Counts all dates during the last 7 days
9464
+	 *
9465
+	 * @return Array the date list
9466
+	 *
9467
+	 */
9468 9468
 	public function countAllDatesLast7Days($filters = array())
9469 9469
 	{
9470 9470
 		global $globalTimezone, $globalDBdriver;
@@ -9486,7 +9486,7 @@  discard block
 block discarded – undo
9486 9486
 			$query .= " GROUP BY date_name 
9487 9487
 								ORDER BY date_name ASC";
9488 9488
 			$query_data = array(':offset' => $offset);
9489
-    		}
9489
+			}
9490 9490
 		
9491 9491
 		$sth = $this->db->prepare($query);
9492 9492
 		$sth->execute($query_data);
@@ -9506,11 +9506,11 @@  discard block
 block discarded – undo
9506 9506
 	}
9507 9507
 
9508 9508
 	/**
9509
-	* Counts all dates during the last month
9510
-	*
9511
-	* @return Array the date list
9512
-	*
9513
-	*/
9509
+	 * Counts all dates during the last month
9510
+	 *
9511
+	 * @return Array the date list
9512
+	 *
9513
+	 */
9514 9514
 	public function countAllDatesLastMonth($filters = array())
9515 9515
 	{
9516 9516
 		global $globalTimezone, $globalDBdriver;
@@ -9532,7 +9532,7 @@  discard block
 block discarded – undo
9532 9532
 			$query .= " GROUP BY date_name 
9533 9533
 								ORDER BY date_name ASC";
9534 9534
 			$query_data = array(':offset' => $offset);
9535
-    		}
9535
+			}
9536 9536
 		
9537 9537
 		$sth = $this->db->prepare($query);
9538 9538
 		$sth->execute($query_data);
@@ -9553,11 +9553,11 @@  discard block
 block discarded – undo
9553 9553
 
9554 9554
 
9555 9555
 	/**
9556
-	* Counts all dates during the last month
9557
-	*
9558
-	* @return Array the date list
9559
-	*
9560
-	*/
9556
+	 * Counts all dates during the last month
9557
+	 *
9558
+	 * @return Array the date list
9559
+	 *
9560
+	 */
9561 9561
 	public function countAllDatesLastMonthByAirlines($filters = array())
9562 9562
 	{
9563 9563
 		global $globalTimezone, $globalDBdriver;
@@ -9580,7 +9580,7 @@  discard block
 block discarded – undo
9580 9580
 								GROUP BY spotter_output.airline_icao, date_name 
9581 9581
 								ORDER BY date_name ASC";
9582 9582
 			$query_data = array(':offset' => $offset);
9583
-    		}
9583
+			}
9584 9584
 		
9585 9585
 		$sth = $this->db->prepare($query);
9586 9586
 		$sth->execute($query_data);
@@ -9602,11 +9602,11 @@  discard block
 block discarded – undo
9602 9602
 	
9603 9603
 
9604 9604
 	/**
9605
-	* Counts all month
9606
-	*
9607
-	* @return Array the month list
9608
-	*
9609
-	*/
9605
+	 * Counts all month
9606
+	 *
9607
+	 * @return Array the month list
9608
+	 *
9609
+	 */
9610 9610
 	public function countAllMonths($filters = array())
9611 9611
 	{
9612 9612
 		global $globalTimezone, $globalDBdriver;
@@ -9648,11 +9648,11 @@  discard block
 block discarded – undo
9648 9648
 	}
9649 9649
 
9650 9650
 	/**
9651
-	* Counts all month
9652
-	*
9653
-	* @return Array the month list
9654
-	*
9655
-	*/
9651
+	 * Counts all month
9652
+	 *
9653
+	 * @return Array the month list
9654
+	 *
9655
+	 */
9656 9656
 	public function countAllMonthsByAirlines($filters = array())
9657 9657
 	{
9658 9658
 		global $globalTimezone, $globalDBdriver;
@@ -9697,11 +9697,11 @@  discard block
 block discarded – undo
9697 9697
 	}
9698 9698
 
9699 9699
 	/**
9700
-	* Counts all military month
9701
-	*
9702
-	* @return Array the month list
9703
-	*
9704
-	*/
9700
+	 * Counts all military month
9701
+	 *
9702
+	 * @return Array the month list
9703
+	 *
9704
+	 */
9705 9705
 	public function countAllMilitaryMonths($filters = array())
9706 9706
 	{
9707 9707
 		global $globalTimezone, $globalDBdriver;
@@ -9742,11 +9742,11 @@  discard block
 block discarded – undo
9742 9742
 	}
9743 9743
 	
9744 9744
 	/**
9745
-	* Counts all month owners
9746
-	*
9747
-	* @return Array the month list
9748
-	*
9749
-	*/
9745
+	 * Counts all month owners
9746
+	 *
9747
+	 * @return Array the month list
9748
+	 *
9749
+	 */
9750 9750
 	public function countAllMonthsOwners($filters = array())
9751 9751
 	{
9752 9752
 		global $globalTimezone, $globalDBdriver;
@@ -9788,11 +9788,11 @@  discard block
 block discarded – undo
9788 9788
 	}
9789 9789
 	
9790 9790
 	/**
9791
-	* Counts all month owners
9792
-	*
9793
-	* @return Array the month list
9794
-	*
9795
-	*/
9791
+	 * Counts all month owners
9792
+	 *
9793
+	 * @return Array the month list
9794
+	 *
9795
+	 */
9796 9796
 	public function countAllMonthsOwnersByAirlines($filters = array())
9797 9797
 	{
9798 9798
 		global $globalTimezone, $globalDBdriver;
@@ -9835,11 +9835,11 @@  discard block
 block discarded – undo
9835 9835
 	}
9836 9836
 
9837 9837
 	/**
9838
-	* Counts all month pilot
9839
-	*
9840
-	* @return Array the month list
9841
-	*
9842
-	*/
9838
+	 * Counts all month pilot
9839
+	 *
9840
+	 * @return Array the month list
9841
+	 *
9842
+	 */
9843 9843
 	public function countAllMonthsPilots($filters = array())
9844 9844
 	{
9845 9845
 		global $globalTimezone, $globalDBdriver;
@@ -9881,11 +9881,11 @@  discard block
 block discarded – undo
9881 9881
 	}
9882 9882
 	
9883 9883
 	/**
9884
-	* Counts all month pilot
9885
-	*
9886
-	* @return Array the month list
9887
-	*
9888
-	*/
9884
+	 * Counts all month pilot
9885
+	 *
9886
+	 * @return Array the month list
9887
+	 *
9888
+	 */
9889 9889
 	public function countAllMonthsPilotsByAirlines($filters = array())
9890 9890
 	{
9891 9891
 		global $globalTimezone, $globalDBdriver;
@@ -9928,11 +9928,11 @@  discard block
 block discarded – undo
9928 9928
 	}
9929 9929
 
9930 9930
 	/**
9931
-	* Counts all month airline
9932
-	*
9933
-	* @return Array the month list
9934
-	*
9935
-	*/
9931
+	 * Counts all month airline
9932
+	 *
9933
+	 * @return Array the month list
9934
+	 *
9935
+	 */
9936 9936
 	public function countAllMonthsAirlines($filters = array())
9937 9937
 	{
9938 9938
 		global $globalTimezone, $globalDBdriver;
@@ -9974,11 +9974,11 @@  discard block
 block discarded – undo
9974 9974
 	}
9975 9975
 	
9976 9976
 	/**
9977
-	* Counts all month aircraft
9978
-	*
9979
-	* @return Array the month list
9980
-	*
9981
-	*/
9977
+	 * Counts all month aircraft
9978
+	 *
9979
+	 * @return Array the month list
9980
+	 *
9981
+	 */
9982 9982
 	public function countAllMonthsAircrafts($filters = array())
9983 9983
 	{
9984 9984
 		global $globalTimezone, $globalDBdriver;
@@ -10021,11 +10021,11 @@  discard block
 block discarded – undo
10021 10021
 	
10022 10022
 
10023 10023
 	/**
10024
-	* Counts all month aircraft
10025
-	*
10026
-	* @return Array the month list
10027
-	*
10028
-	*/
10024
+	 * Counts all month aircraft
10025
+	 *
10026
+	 * @return Array the month list
10027
+	 *
10028
+	 */
10029 10029
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10030 10030
 	{
10031 10031
 		global $globalTimezone, $globalDBdriver;
@@ -10068,11 +10068,11 @@  discard block
 block discarded – undo
10068 10068
 	}
10069 10069
 
10070 10070
 	/**
10071
-	* Counts all month real arrival
10072
-	*
10073
-	* @return Array the month list
10074
-	*
10075
-	*/
10071
+	 * Counts all month real arrival
10072
+	 *
10073
+	 * @return Array the month list
10074
+	 *
10075
+	 */
10076 10076
 	public function countAllMonthsRealArrivals($filters = array())
10077 10077
 	{
10078 10078
 		global $globalTimezone, $globalDBdriver;
@@ -10115,11 +10115,11 @@  discard block
 block discarded – undo
10115 10115
 	
10116 10116
 
10117 10117
 	/**
10118
-	* Counts all month real arrival
10119
-	*
10120
-	* @return Array the month list
10121
-	*
10122
-	*/
10118
+	 * Counts all month real arrival
10119
+	 *
10120
+	 * @return Array the month list
10121
+	 *
10122
+	 */
10123 10123
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10124 10124
 	{
10125 10125
 		global $globalTimezone, $globalDBdriver;
@@ -10163,11 +10163,11 @@  discard block
 block discarded – undo
10163 10163
 	
10164 10164
 
10165 10165
 	/**
10166
-	* Counts all dates during the last year
10167
-	*
10168
-	* @return Array the date list
10169
-	*
10170
-	*/
10166
+	 * Counts all dates during the last year
10167
+	 *
10168
+	 * @return Array the date list
10169
+	 *
10170
+	 */
10171 10171
 	public function countAllMonthsLastYear($filters)
10172 10172
 	{
10173 10173
 		global $globalTimezone, $globalDBdriver;
@@ -10189,7 +10189,7 @@  discard block
 block discarded – undo
10189 10189
 			$query .= " GROUP BY year_name, month_name
10190 10190
 								ORDER BY year_name, month_name ASC";
10191 10191
 			$query_data = array(':offset' => $offset);
10192
-    		}
10192
+			}
10193 10193
 		
10194 10194
 		$sth = $this->db->prepare($query);
10195 10195
 		$sth->execute($query_data);
@@ -10212,11 +10212,11 @@  discard block
 block discarded – undo
10212 10212
 	
10213 10213
 	
10214 10214
 	/**
10215
-	* Counts all hours
10216
-	*
10217
-	* @return Array the hour list
10218
-	*
10219
-	*/
10215
+	 * Counts all hours
10216
+	 *
10217
+	 * @return Array the hour list
10218
+	 *
10219
+	 */
10220 10220
 	public function countAllHours($orderby,$filters = array())
10221 10221
 	{
10222 10222
 		global $globalTimezone, $globalDBdriver;
@@ -10277,11 +10277,11 @@  discard block
 block discarded – undo
10277 10277
 	}
10278 10278
 	
10279 10279
 	/**
10280
-	* Counts all hours
10281
-	*
10282
-	* @return Array the hour list
10283
-	*
10284
-	*/
10280
+	 * Counts all hours
10281
+	 *
10282
+	 * @return Array the hour list
10283
+	 *
10284
+	 */
10285 10285
 	public function countAllHoursByAirlines($orderby, $filters = array())
10286 10286
 	{
10287 10287
 		global $globalTimezone, $globalDBdriver;
@@ -10344,11 +10344,11 @@  discard block
 block discarded – undo
10344 10344
 
10345 10345
 
10346 10346
 	/**
10347
-	* Counts all hours by airline
10348
-	*
10349
-	* @return Array the hour list
10350
-	*
10351
-	*/
10347
+	 * Counts all hours by airline
10348
+	 *
10349
+	 * @return Array the hour list
10350
+	 *
10351
+	 */
10352 10352
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10353 10353
 	{
10354 10354
 		global $globalTimezone, $globalDBdriver;
@@ -10394,11 +10394,11 @@  discard block
 block discarded – undo
10394 10394
 	
10395 10395
 	
10396 10396
 	/**
10397
-	* Counts all hours by aircraft
10398
-	*
10399
-	* @return Array the hour list
10400
-	*
10401
-	*/
10397
+	 * Counts all hours by aircraft
10398
+	 *
10399
+	 * @return Array the hour list
10400
+	 *
10401
+	 */
10402 10402
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10403 10403
 	{
10404 10404
 		global $globalTimezone, $globalDBdriver;
@@ -10441,11 +10441,11 @@  discard block
 block discarded – undo
10441 10441
 	
10442 10442
 	
10443 10443
 	/**
10444
-	* Counts all hours by aircraft registration
10445
-	*
10446
-	* @return Array the hour list
10447
-	*
10448
-	*/
10444
+	 * Counts all hours by aircraft registration
10445
+	 *
10446
+	 * @return Array the hour list
10447
+	 *
10448
+	 */
10449 10449
 	public function countAllHoursByRegistration($registration, $filters = array())
10450 10450
 	{
10451 10451
 		global $globalTimezone, $globalDBdriver;
@@ -10488,11 +10488,11 @@  discard block
 block discarded – undo
10488 10488
 	
10489 10489
 	
10490 10490
 	/**
10491
-	* Counts all hours by airport
10492
-	*
10493
-	* @return Array the hour list
10494
-	*
10495
-	*/
10491
+	 * Counts all hours by airport
10492
+	 *
10493
+	 * @return Array the hour list
10494
+	 *
10495
+	 */
10496 10496
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10497 10497
 	{
10498 10498
 		global $globalTimezone, $globalDBdriver;
@@ -10536,11 +10536,11 @@  discard block
 block discarded – undo
10536 10536
 	
10537 10537
 	
10538 10538
 	/**
10539
-	* Counts all hours by manufacturer
10540
-	*
10541
-	* @return Array the hour list
10542
-	*
10543
-	*/
10539
+	 * Counts all hours by manufacturer
10540
+	 *
10541
+	 * @return Array the hour list
10542
+	 *
10543
+	 */
10544 10544
 	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10545 10545
 	{
10546 10546
 		global $globalTimezone, $globalDBdriver;
@@ -10584,11 +10584,11 @@  discard block
 block discarded – undo
10584 10584
 	
10585 10585
 	
10586 10586
 	/**
10587
-	* Counts all hours by date
10588
-	*
10589
-	* @return Array the hour list
10590
-	*
10591
-	*/
10587
+	 * Counts all hours by date
10588
+	 *
10589
+	 * @return Array the hour list
10590
+	 *
10591
+	 */
10592 10592
 	public function countAllHoursByDate($date, $filters = array())
10593 10593
 	{
10594 10594
 		global $globalTimezone, $globalDBdriver;
@@ -10632,11 +10632,11 @@  discard block
 block discarded – undo
10632 10632
 	
10633 10633
 	
10634 10634
 	/**
10635
-	* Counts all hours by a ident/callsign
10636
-	*
10637
-	* @return Array the hour list
10638
-	*
10639
-	*/
10635
+	 * Counts all hours by a ident/callsign
10636
+	 *
10637
+	 * @return Array the hour list
10638
+	 *
10639
+	 */
10640 10640
 	public function countAllHoursByIdent($ident, $filters = array())
10641 10641
 	{
10642 10642
 		global $globalTimezone, $globalDBdriver;
@@ -10679,11 +10679,11 @@  discard block
 block discarded – undo
10679 10679
 	}
10680 10680
 	
10681 10681
 	/**
10682
-	* Counts all hours by a owner
10683
-	*
10684
-	* @return Array the hour list
10685
-	*
10686
-	*/
10682
+	 * Counts all hours by a owner
10683
+	 *
10684
+	 * @return Array the hour list
10685
+	 *
10686
+	 */
10687 10687
 	public function countAllHoursByOwner($owner, $filters = array())
10688 10688
 	{
10689 10689
 		global $globalTimezone, $globalDBdriver;
@@ -10726,11 +10726,11 @@  discard block
 block discarded – undo
10726 10726
 	}
10727 10727
 	
10728 10728
 	/**
10729
-	* Counts all hours by a pilot
10730
-	*
10731
-	* @return Array the hour list
10732
-	*
10733
-	*/
10729
+	 * Counts all hours by a pilot
10730
+	 *
10731
+	 * @return Array the hour list
10732
+	 *
10733
+	 */
10734 10734
 	public function countAllHoursByPilot($pilot, $filters = array())
10735 10735
 	{
10736 10736
 		global $globalTimezone, $globalDBdriver;
@@ -10775,11 +10775,11 @@  discard block
 block discarded – undo
10775 10775
 	
10776 10776
 	
10777 10777
 	/**
10778
-	* Counts all hours by route
10779
-	*
10780
-	* @return Array the hour list
10781
-	*
10782
-	*/
10778
+	 * Counts all hours by route
10779
+	 *
10780
+	 * @return Array the hour list
10781
+	 *
10782
+	 */
10783 10783
 	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10784 10784
 	{
10785 10785
 		global $globalTimezone, $globalDBdriver;
@@ -10823,11 +10823,11 @@  discard block
 block discarded – undo
10823 10823
 	
10824 10824
 	
10825 10825
 	/**
10826
-	* Counts all hours by country
10827
-	*
10828
-	* @return Array the hour list
10829
-	*
10830
-	*/
10826
+	 * Counts all hours by country
10827
+	 *
10828
+	 * @return Array the hour list
10829
+	 *
10830
+	 */
10831 10831
 	public function countAllHoursByCountry($country, $filters = array())
10832 10832
 	{
10833 10833
 		global $globalTimezone, $globalDBdriver;
@@ -10872,11 +10872,11 @@  discard block
 block discarded – undo
10872 10872
 
10873 10873
 
10874 10874
 	/**
10875
-	* Counts all aircraft that have flown over
10876
-	*
10877
-	* @return Integer the number of aircrafts
10878
-	*
10879
-	*/
10875
+	 * Counts all aircraft that have flown over
10876
+	 *
10877
+	 * @return Integer the number of aircrafts
10878
+	 *
10879
+	 */
10880 10880
 	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10881 10881
 	{
10882 10882
 		global $globalDBdriver;
@@ -10909,11 +10909,11 @@  discard block
 block discarded – undo
10909 10909
 	}
10910 10910
 
10911 10911
 	/**
10912
-	* Counts all flight that really arrival
10913
-	*
10914
-	* @return Integer the number of aircrafts
10915
-	*
10916
-	*/
10912
+	 * Counts all flight that really arrival
10913
+	 *
10914
+	 * @return Integer the number of aircrafts
10915
+	 *
10916
+	 */
10917 10917
 	public function countOverallArrival($filters = array(),$year = '',$month = '')
10918 10918
 	{
10919 10919
 		global $globalDBdriver;
@@ -10946,11 +10946,11 @@  discard block
 block discarded – undo
10946 10946
 	}
10947 10947
 
10948 10948
 	/**
10949
-	* Counts all pilots that have flown over
10950
-	*
10951
-	* @return Integer the number of pilots
10952
-	*
10953
-	*/
10949
+	 * Counts all pilots that have flown over
10950
+	 *
10951
+	 * @return Integer the number of pilots
10952
+	 *
10953
+	 */
10954 10954
 	public function countOverallPilots($filters = array(),$year = '',$month = '')
10955 10955
 	{
10956 10956
 		global $globalDBdriver;
@@ -10982,11 +10982,11 @@  discard block
 block discarded – undo
10982 10982
 	}
10983 10983
 
10984 10984
 	/**
10985
-	* Counts all owners that have flown over
10986
-	*
10987
-	* @return Integer the number of owners
10988
-	*
10989
-	*/
10985
+	 * Counts all owners that have flown over
10986
+	 *
10987
+	 * @return Integer the number of owners
10988
+	 *
10989
+	 */
10990 10990
 	public function countOverallOwners($filters = array(),$year = '',$month = '')
10991 10991
 	{
10992 10992
 		global $globalDBdriver;
@@ -11019,11 +11019,11 @@  discard block
 block discarded – undo
11019 11019
 	
11020 11020
 	
11021 11021
 	/**
11022
-	* Counts all flights that have flown over
11023
-	*
11024
-	* @return Integer the number of flights
11025
-	*
11026
-	*/
11022
+	 * Counts all flights that have flown over
11023
+	 *
11024
+	 * @return Integer the number of flights
11025
+	 *
11026
+	 */
11027 11027
 	public function countOverallFlights($filters = array(),$year = '',$month = '')
11028 11028
 	{
11029 11029
 		global $globalDBdriver;
@@ -11057,11 +11057,11 @@  discard block
 block discarded – undo
11057 11057
 	}
11058 11058
 	
11059 11059
 	/**
11060
-	* Counts all military flights that have flown over
11061
-	*
11062
-	* @return Integer the number of flights
11063
-	*
11064
-	*/
11060
+	 * Counts all military flights that have flown over
11061
+	 *
11062
+	 * @return Integer the number of flights
11063
+	 *
11064
+	 */
11065 11065
 	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11066 11066
 	{
11067 11067
 		global $globalDBdriver;
@@ -11096,11 +11096,11 @@  discard block
 block discarded – undo
11096 11096
 	
11097 11097
 	
11098 11098
 	/**
11099
-	* Counts all airlines that have flown over
11100
-	*
11101
-	* @return Integer the number of airlines
11102
-	*
11103
-	*/
11099
+	 * Counts all airlines that have flown over
11100
+	 *
11101
+	 * @return Integer the number of airlines
11102
+	 *
11103
+	 */
11104 11104
 	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11105 11105
 	{
11106 11106
 		global $globalDBdriver;
@@ -11127,8 +11127,8 @@  discard block
 block discarded – undo
11127 11127
 				$query_values = array_merge($query_values,array(':month' => $month));
11128 11128
 			}
11129 11129
 		}
11130
-                if ($query == '') $queryi .= $this->getFilter($filters);
11131
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11130
+				if ($query == '') $queryi .= $this->getFilter($filters);
11131
+				else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11132 11132
 
11133 11133
 
11134 11134
 		$sth = $this->db->prepare($queryi);
@@ -11138,11 +11138,11 @@  discard block
 block discarded – undo
11138 11138
 
11139 11139
   
11140 11140
 	/**
11141
-	* Counts all hours of today
11142
-	*
11143
-	* @return Array the hour list
11144
-	*
11145
-	*/
11141
+	 * Counts all hours of today
11142
+	 *
11143
+	 * @return Array the hour list
11144
+	 *
11145
+	 */
11146 11146
 	public function countAllHoursFromToday($filters = array())
11147 11147
 	{
11148 11148
 		global $globalTimezone, $globalDBdriver;
@@ -11182,11 +11182,11 @@  discard block
 block discarded – undo
11182 11182
 	}
11183 11183
     
11184 11184
 	/**
11185
-	* Gets all the spotter information based on calculated upcoming flights
11186
-	*
11187
-	* @return Array the spotter information
11188
-	*
11189
-	*/
11185
+	 * Gets all the spotter information based on calculated upcoming flights
11186
+	 *
11187
+	 * @return Array the spotter information
11188
+	 *
11189
+	 */
11190 11190
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11191 11191
 	{
11192 11192
 		global $global_query, $globalDBdriver, $globalTimezone;
@@ -11261,12 +11261,12 @@  discard block
 block discarded – undo
11261 11261
 	}
11262 11262
     
11263 11263
     
11264
-     /**
11265
-	* Gets the Barrie Spotter ID based on the FlightAware ID
11266
-	*
11267
-	* @return Integer the Barrie Spotter ID
11264
+	 /**
11265
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
11266
+	  *
11267
+	  * @return Integer the Barrie Spotter ID
11268 11268
 q	*
11269
-	*/
11269
+	  */
11270 11270
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11271 11271
 	{
11272 11272
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -11287,13 +11287,13 @@  discard block
 block discarded – undo
11287 11287
   
11288 11288
  
11289 11289
 	/**
11290
-	* Parses a date string
11291
-	*
11292
-	* @param String $dateString the date string
11293
-	* @param String $timezone the timezone of a user
11294
-	* @return Array the time information
11295
-	*
11296
-	*/
11290
+	 * Parses a date string
11291
+	 *
11292
+	 * @param String $dateString the date string
11293
+	 * @param String $timezone the timezone of a user
11294
+	 * @return Array the time information
11295
+	 *
11296
+	 */
11297 11297
 	public function parseDateString($dateString, $timezone = '')
11298 11298
 	{
11299 11299
 		$time_array = array();
@@ -11329,12 +11329,12 @@  discard block
 block discarded – undo
11329 11329
 	
11330 11330
 	
11331 11331
 	/**
11332
-	* Parses the direction degrees to working
11333
-	*
11334
-	* @param Float $direction the direction in degrees
11335
-	* @return Array the direction information
11336
-	*
11337
-	*/
11332
+	 * Parses the direction degrees to working
11333
+	 *
11334
+	 * @param Float $direction the direction in degrees
11335
+	 * @return Array the direction information
11336
+	 *
11337
+	 */
11338 11338
 	public function parseDirection($direction = 0)
11339 11339
 	{
11340 11340
 		if ($direction == '') $direction = 0;
@@ -11413,12 +11413,12 @@  discard block
 block discarded – undo
11413 11413
 	
11414 11414
 	
11415 11415
 	/**
11416
-	* Gets the aircraft registration
11417
-	*
11418
-	* @param String $flightaware_id the flight aware id
11419
-	* @return String the aircraft registration
11420
-	*
11421
-	*/
11416
+	 * Gets the aircraft registration
11417
+	 *
11418
+	 * @param String $flightaware_id the flight aware id
11419
+	 * @return String the aircraft registration
11420
+	 *
11421
+	 */
11422 11422
 	
11423 11423
 	public function getAircraftRegistration($flightaware_id)
11424 11424
 	{
@@ -11447,12 +11447,12 @@  discard block
 block discarded – undo
11447 11447
 
11448 11448
 
11449 11449
 	/**
11450
-	* Gets the aircraft registration from ModeS
11451
-	*
11452
-	* @param String $aircraft_modes the flight ModeS in hex
11453
-	* @return String the aircraft registration
11454
-	*
11455
-	*/
11450
+	 * Gets the aircraft registration from ModeS
11451
+	 *
11452
+	 * @param String $aircraft_modes the flight ModeS in hex
11453
+	 * @return String the aircraft registration
11454
+	 *
11455
+	 */
11456 11456
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11457 11457
 	{
11458 11458
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11468,8 +11468,8 @@  discard block
 block discarded – undo
11468 11468
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11469 11469
 		$sth->closeCursor();
11470 11470
 		if (count($row) > 0) {
11471
-		    //return $row['Registration'];
11472
-		    return $row['registration'];
11471
+			//return $row['Registration'];
11472
+			return $row['registration'];
11473 11473
 		} elseif ($source_type == 'flarm') {
11474 11474
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11475 11475
 		} else return '';
@@ -11477,12 +11477,12 @@  discard block
 block discarded – undo
11477 11477
 	}
11478 11478
 
11479 11479
 	/**
11480
-	* Gets the aircraft type from ModeS
11481
-	*
11482
-	* @param String $aircraft_modes the flight ModeS in hex
11483
-	* @return String the aircraft type
11484
-	*
11485
-	*/
11480
+	 * Gets the aircraft type from ModeS
11481
+	 *
11482
+	 * @param String $aircraft_modes the flight ModeS in hex
11483
+	 * @return String the aircraft type
11484
+	 *
11485
+	 */
11486 11486
 	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11487 11487
 	{
11488 11488
 		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
@@ -11508,12 +11508,12 @@  discard block
 block discarded – undo
11508 11508
 	}
11509 11509
 
11510 11510
 	/**
11511
-	* Gets Country from latitude/longitude
11512
-	*
11513
-	* @param Float $latitude latitute of the flight
11514
-	* @param Float $longitude longitute of the flight
11515
-	* @return String the countrie
11516
-	*/
11511
+	 * Gets Country from latitude/longitude
11512
+	 *
11513
+	 * @param Float $latitude latitute of the flight
11514
+	 * @param Float $longitude longitute of the flight
11515
+	 * @return String the countrie
11516
+	 */
11517 11517
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11518 11518
 	{
11519 11519
 		global $globalDBdriver, $globalDebug;
@@ -11550,11 +11550,11 @@  discard block
 block discarded – undo
11550 11550
 	}
11551 11551
 
11552 11552
 	/**
11553
-	* Gets Country from iso2
11554
-	*
11555
-	* @param String $iso2 ISO2 country code
11556
-	* @return String the countrie
11557
-	*/
11553
+	 * Gets Country from iso2
11554
+	 *
11555
+	 * @param String $iso2 ISO2 country code
11556
+	 * @return String the countrie
11557
+	 */
11558 11558
 	public function getCountryFromISO2($iso2)
11559 11559
 	{
11560 11560
 		global $globalDBdriver, $globalDebug;
@@ -11582,12 +11582,12 @@  discard block
 block discarded – undo
11582 11582
 	}
11583 11583
 
11584 11584
 	/**
11585
-	* converts the registration code using the country prefix
11586
-	*
11587
-	* @param String $registration the aircraft registration
11588
-	* @return String the aircraft registration
11589
-	*
11590
-	*/
11585
+	 * converts the registration code using the country prefix
11586
+	 *
11587
+	 * @param String $registration the aircraft registration
11588
+	 * @return String the aircraft registration
11589
+	 *
11590
+	 */
11591 11591
 	public function convertAircraftRegistration($registration)
11592 11592
 	{
11593 11593
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11639,12 +11639,12 @@  discard block
 block discarded – undo
11639 11639
 	}
11640 11640
 
11641 11641
 	/**
11642
-	* Country from the registration code
11643
-	*
11644
-	* @param String $registration the aircraft registration
11645
-	* @return String the country
11646
-	*
11647
-	*/
11642
+	 * Country from the registration code
11643
+	 *
11644
+	 * @param String $registration the aircraft registration
11645
+	 * @return String the country
11646
+	 *
11647
+	 */
11648 11648
 	public function countryFromAircraftRegistration($registration)
11649 11649
 	{
11650 11650
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11663,8 +11663,8 @@  discard block
 block discarded – undo
11663 11663
 				$country = $row['country'];
11664 11664
 			}
11665 11665
 		} else {
11666
-    			$registration_1 = substr($registration, 0, 1);
11667
-		        $registration_2 = substr($registration, 0, 2);
11666
+				$registration_1 = substr($registration, 0, 1);
11667
+				$registration_2 = substr($registration, 0, 2);
11668 11668
 
11669 11669
 			$country = '';
11670 11670
 			//first get the prefix based on two characters
@@ -11700,12 +11700,12 @@  discard block
 block discarded – undo
11700 11700
 	}
11701 11701
 
11702 11702
 	/**
11703
-	* Registration prefix from the registration code
11704
-	*
11705
-	* @param String $registration the aircraft registration
11706
-	* @return String the registration prefix
11707
-	*
11708
-	*/
11703
+	 * Registration prefix from the registration code
11704
+	 *
11705
+	 * @param String $registration the aircraft registration
11706
+	 * @return String the registration prefix
11707
+	 *
11708
+	 */
11709 11709
 	public function registrationPrefixFromAircraftRegistration($registration)
11710 11710
 	{
11711 11711
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11724,8 +11724,8 @@  discard block
 block discarded – undo
11724 11724
 				//$country = $row['country'];
11725 11725
 			}
11726 11726
 		} else {
11727
-    			$registration_1 = substr($registration, 0, 1);
11728
-		        $registration_2 = substr($registration, 0, 2);
11727
+				$registration_1 = substr($registration, 0, 1);
11728
+				$registration_2 = substr($registration, 0, 2);
11729 11729
 
11730 11730
 			//first get the prefix based on two characters
11731 11731
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
@@ -11761,12 +11761,12 @@  discard block
 block discarded – undo
11761 11761
 
11762 11762
 
11763 11763
 	/**
11764
-	* Country from the registration code
11765
-	*
11766
-	* @param String $registration the aircraft registration
11767
-	* @return String the country
11768
-	*
11769
-	*/
11764
+	 * Country from the registration code
11765
+	 *
11766
+	 * @param String $registration the aircraft registration
11767
+	 * @return String the country
11768
+	 *
11769
+	 */
11770 11770
 	public function countryFromAircraftRegistrationCode($registration)
11771 11771
 	{
11772 11772
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
@@ -11783,11 +11783,11 @@  discard block
 block discarded – undo
11783 11783
 	}
11784 11784
 	
11785 11785
 	/**
11786
-	* Set a new highlight value for a flight
11787
-	*
11788
-	* @param String $flightaware_id flightaware_id from spotter_output table
11789
-	* @param String $highlight New highlight value
11790
-	*/
11786
+	 * Set a new highlight value for a flight
11787
+	 *
11788
+	 * @param String $flightaware_id flightaware_id from spotter_output table
11789
+	 * @param String $highlight New highlight value
11790
+	 */
11791 11791
 	public function setHighlightFlight($flightaware_id,$highlight) {
11792 11792
 		
11793 11793
 		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
@@ -11796,12 +11796,12 @@  discard block
 block discarded – undo
11796 11796
 	}
11797 11797
 
11798 11798
 	/**
11799
-	* Set a new highlight value for a flight by Registration
11800
-	*
11801
-	* @param String $registration Registration of the aircraft
11802
-	* @param String $date Date of spotted aircraft
11803
-	* @param String $highlight New highlight value
11804
-	*/
11799
+	 * Set a new highlight value for a flight by Registration
11800
+	 *
11801
+	 * @param String $registration Registration of the aircraft
11802
+	 * @param String $date Date of spotted aircraft
11803
+	 * @param String $highlight New highlight value
11804
+	 */
11805 11805
 	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11806 11806
 		if ($date == '') {
11807 11807
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
@@ -11815,12 +11815,12 @@  discard block
 block discarded – undo
11815 11815
 	}
11816 11816
 	
11817 11817
 	/**
11818
-	* Gets the short url from bit.ly
11819
-	*
11820
-	* @param String $url the full url
11821
-	* @return String the bit.ly url
11822
-	*
11823
-	*/
11818
+	 * Gets the short url from bit.ly
11819
+	 *
11820
+	 * @param String $url the full url
11821
+	 * @return String the bit.ly url
11822
+	 *
11823
+	 */
11824 11824
 	public function getBitlyURL($url)
11825 11825
 	{
11826 11826
 		global $globalBitlyAccessToken;
@@ -12109,11 +12109,11 @@  discard block
 block discarded – undo
12109 12109
 			$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 
12110 12110
 	                      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)) 
12111 12111
 	                      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;";
12112
-                } else {
12112
+				} else {
12113 12113
 			$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 
12114 12114
 	                      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)) 
12115 12115
 	                      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;";
12116
-    		}
12116
+			}
12117 12117
 		$sth = $this->db->prepare($query);
12118 12118
 		$sth->execute();
12119 12119
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
Spacing   +1353 added lines, -1353 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 require_once(dirname(__FILE__).'/class.Image.php');
5 5
 $global_query = "SELECT spotter_output.* FROM spotter_output";
6 6
 
7
-class Spotter{
7
+class Spotter {
8 8
 	public $aircraft_correct_icaotype = array('CL64' => 'CL60',
9 9
 					'F9LX' => 'F900',
10 10
 					'K35T' => 'K35R',
@@ -59,62 +59,62 @@  discard block
 block discarded – undo
59 59
 	* @param Array $filter the filter
60 60
 	* @return Array the SQL part
61 61
 	*/
62
-	public function getFilter($filter = array(),$where = false,$and = false) {
62
+	public function getFilter($filter = array(), $where = false, $and = false) {
63 63
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
64 64
 		$filters = array();
65 65
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
66 66
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
67 67
 				$filters = $globalStatsFilters[$globalFilterName];
68 68
 			} else {
69
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
69
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter[0]['source'])) {
73
-			$filters = array_merge($filters,$filter);
73
+			$filters = array_merge($filters, $filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
76 76
 		$filter_query_join = '';
77 77
 		$filter_query_where = '';
78
-		foreach($filters as $flt) {
78
+		foreach ($filters as $flt) {
79 79
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
80 80
 				if ($flt['airlines'][0] != '') {
81 81
 					if (isset($flt['source'])) {
82
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
82
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
83 83
 					} else {
84
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
84
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id";
85 85
 					}
86 86
 				}
87 87
 			}
88 88
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
89 89
 				if (isset($flt['source'])) {
90
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
90
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
91 91
 				} else {
92
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
92
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id";
93 93
 				}
94 94
 			}
95 95
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
96 96
 				if (isset($flt['source'])) {
97
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
97
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
98 98
 				} else {
99
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
99
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id";
100 100
 				}
101 101
 			}
102 102
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
103 103
 				if (isset($flt['source'])) {
104
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
104
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
105 105
 				} else {
106
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
106
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_output.flightaware_id";
107 107
 				}
108 108
 			}
109 109
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
110 110
 				if (isset($flt['source'])) {
111
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
111
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id";
112 112
 				}
113 113
 			}
114 114
 		}
115 115
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
116 116
 			if ($filter['airlines'][0] != '') {
117
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
117
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id";
118 118
 			}
119 119
 		}
120 120
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
@@ -124,16 +124,16 @@  discard block
 block discarded – undo
124 124
 			$filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao ";
125 125
 		}
126 126
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
127
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
127
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id";
128 128
 			}
129 129
 		if (isset($filter['source']) && !empty($filter['source'])) {
130
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
130
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
131 131
 		}
132 132
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
133 133
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
134 134
 		}
135 135
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
136
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
136
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
137 137
 		}
138 138
 		if (isset($filter['year']) && $filter['year'] != '') {
139 139
 			if ($globalDBdriver == 'mysql') {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160 160
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161 161
 		if ($filter_query_where != '') {
162
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
162
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
163 163
 		}
164 164
 		$filter_query = $filter_query_join.$filter_query_where;
165 165
 		return $filter_query;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	* @return Array the spotter information
175 175
 	*
176 176
 	*/
177
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
177
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
178 178
 	{
179 179
 		global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM;
180 180
 		$Image = new Image($this->db);
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 			$sth = $this->db->prepare($query.$limitQuery);
205 205
 			$sth->execute($params);
206 206
 		} catch (PDOException $e) {
207
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
207
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
208 208
 			exit();
209 209
 		}
210 210
 		
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		$spotter_array = array();
215 215
 		
216 216
 
217
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
217
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
218 218
 		{
219 219
 			$num_rows++;
220 220
 			$temp_array = array();
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
259 259
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 260
 				$temp_array['route_stop'] = $row['route_stop'];
261
-				$allroute = explode(' ',$row['route_stop']);
261
+				$allroute = explode(' ', $row['route_stop']);
262 262
 				foreach ($allroute as $route) {
263 263
 					$route_airport_array = $this->getAllAirportInfo($route);
264 264
 					if (isset($route_airport_array[0]['name'])) {
@@ -311,17 +311,17 @@  discard block
 block discarded – undo
311 311
 				{
312 312
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
313 313
 				} else {
314
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
314
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
315 315
 				}
316 316
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
317
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
318
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
317
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
318
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
319 319
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
320 320
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
321 321
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
322 322
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
323
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
324
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
323
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
324
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
325 325
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
326 326
 					}
327 327
 				}
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 358
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 359
 					if (is_numeric(substr($row['ident'], 2, 1))) {
360
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource);
360
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource);
361 361
 					} elseif (is_numeric(substr($row['ident'], 3, 1))) {
362
-						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
362
+						$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
363 363
 					} else {
364 364
 						$airline_array = $this->getAllAirlineInfo('NA');
365 365
 					}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 				}
397 397
 			}
398 398
 			if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') {
399
-				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3));
399
+				$acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3));
400 400
 				//$acars_array = ACARS->getLiveAcarsData('BA40YL');
401 401
 				if (count($acars_array) > 0) {
402 402
 					$temp_array['acars'] = $acars_array;
@@ -413,11 +413,11 @@  discard block
 block discarded – undo
413 413
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 414
 			}
415 415
 
416
-			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
416
+			if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 417
 			{
418 418
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
419
+					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']);
420
+					else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']);
421 421
 				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
422 422
 				if (count($image_array) > 0) {
423 423
 					$temp_array['image'] = $image_array[0]['image'];
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
442 442
 			}
443 443
 			
444
-			if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
444
+			if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) {
445 445
 				if ($schedules === true) {
446 446
 					$schedule_array = $Schedule->getSchedule($temp_array['ident']);
447 447
 					//print_r($schedule_array);
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
 			if (isset($row['squawk'])) {
524 524
 				$temp_array['squawk'] = $row['squawk'];
525 525
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
526
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']);
527
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
528 528
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529
-					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
529
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']);
530
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
531
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry);
532 532
 			}
533 533
     			
534 534
 			$temp_array['query_number_rows'] = $num_rows;
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	* @return Array the spotter information
548 548
 	*
549 549
 	*/
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())
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;
553 553
 		require_once(dirname(__FILE__).'/class.Translation.php');
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
 		$query_values = array();
559 559
 		$additional_query = '';
560
-		$filter_query = $this->getFilter($filters,true,true);
560
+		$filter_query = $this->getFilter($filters, true, true);
561 561
 		if ($q != "")
562 562
 		{
563 563
 			if (!is_string($q))
@@ -565,8 +565,8 @@  discard block
 block discarded – undo
565 565
 				return false;
566 566
 			} else {
567 567
 				$q_array = explode(" ", $q);
568
-				foreach ($q_array as $q_item){
569
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
568
+				foreach ($q_array as $q_item) {
569
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
570 570
 					$additional_query .= " AND (";
571 571
 					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
572 572
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -598,37 +598,37 @@  discard block
 block discarded – undo
598 598
 
599 599
 		if ($registration != "")
600 600
 		{
601
-			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
601
+			$registration = filter_var($registration, FILTER_SANITIZE_STRING);
602 602
 			if (!is_string($registration))
603 603
 			{
604 604
 				return false;
605 605
 			} else {
606 606
 				$additional_query .= " AND spotter_output.registration = :registration";
607
-				$query_values = array_merge($query_values,array(':registration' => $registration));
607
+				$query_values = array_merge($query_values, array(':registration' => $registration));
608 608
 			}
609 609
 		}
610 610
 
611 611
 		if ($aircraft_icao != "")
612 612
 		{
613
-			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
613
+			$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
614 614
 			if (!is_string($aircraft_icao))
615 615
 			{
616 616
 				return false;
617 617
 			} else {
618 618
 				$additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao";
619
-				$query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao));
619
+				$query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao));
620 620
 			}
621 621
 		}
622 622
 
623 623
 		if ($aircraft_manufacturer != "")
624 624
 		{
625
-			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
625
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
626 626
 			if (!is_string($aircraft_manufacturer))
627 627
 			{
628 628
 				return false;
629 629
 			} else {
630 630
 				$additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer";
631
-				$query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer));
631
+				$query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer));
632 632
 			}
633 633
 		}
634 634
 
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
 
645 645
 		if ($airline_icao != "")
646 646
 		{
647
-			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+			$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
648 648
 			if (!is_string($airline_icao))
649 649
 			{
650 650
 				return false;
651 651
 			} else {
652 652
 				$additional_query .= " AND spotter_output.airline_icao = :airline_icao";
653
-				$query_values = array_merge($query_values,array(':airline_icao' => $airline_icao));
653
+				$query_values = array_merge($query_values, array(':airline_icao' => $airline_icao));
654 654
 			}
655 655
 		}
656 656
 
657 657
 		if ($airline_country != "")
658 658
 		{
659
-			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+			$airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
660 660
 			if (!is_string($airline_country))
661 661
 			{
662 662
 				return false;
663 663
 			} else {
664 664
 				$additional_query .= " AND spotter_output.airline_country = :airline_country";
665
-				$query_values = array_merge($query_values,array(':airline_country' => $airline_country));
665
+				$query_values = array_merge($query_values, array(':airline_country' => $airline_country));
666 666
 			}
667 667
 		}
668 668
 
@@ -689,31 +689,31 @@  discard block
 block discarded – undo
689 689
 
690 690
 		if ($airport != "")
691 691
 		{
692
-			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+			$airport = filter_var($airport, FILTER_SANITIZE_STRING);
693 693
 			if (!is_string($airport))
694 694
 			{
695 695
 				return false;
696 696
 			} else {
697 697
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)";
698
-				$query_values = array_merge($query_values,array(':airport' => $airport));
698
+				$query_values = array_merge($query_values, array(':airport' => $airport));
699 699
 			}
700 700
 		}
701 701
 
702 702
 		if ($airport_country != "")
703 703
 		{
704
-			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
704
+			$airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
705 705
 			if (!is_string($airport_country))
706 706
 			{
707 707
 				return false;
708 708
 			} else {
709 709
 				$additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)";
710
-				$query_values = array_merge($query_values,array(':airport_country' => $airport_country));
710
+				$query_values = array_merge($query_values, array(':airport_country' => $airport_country));
711 711
 			}
712 712
 		}
713 713
     
714 714
 		if ($callsign != "")
715 715
 		{
716
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
716
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
717 717
 			if (!is_string($callsign))
718 718
 			{
719 719
 				return false;
@@ -721,79 +721,79 @@  discard block
 block discarded – undo
721 721
 				$translate = $Translation->ident2icao($callsign);
722 722
 				if ($translate != $callsign) {
723 723
 					$additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)";
724
-					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
724
+					$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
725 725
 				} else {
726 726
 					$additional_query .= " AND spotter_output.ident = :callsign";
727
-					$query_values = array_merge($query_values,array(':callsign' => $callsign));
727
+					$query_values = array_merge($query_values, array(':callsign' => $callsign));
728 728
 				}
729 729
 			}
730 730
 		}
731 731
 
732 732
 		if ($owner != "")
733 733
 		{
734
-			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
734
+			$owner = filter_var($owner, FILTER_SANITIZE_STRING);
735 735
 			if (!is_string($owner))
736 736
 			{
737 737
 				return false;
738 738
 			} else {
739 739
 				$additional_query .= " AND spotter_output.owner_name = :owner";
740
-				$query_values = array_merge($query_values,array(':owner' => $owner));
740
+				$query_values = array_merge($query_values, array(':owner' => $owner));
741 741
 			}
742 742
 		}
743 743
 
744 744
 		if ($pilot_name != "")
745 745
 		{
746
-			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
746
+			$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
747 747
 			if (!is_string($pilot_name))
748 748
 			{
749 749
 				return false;
750 750
 			} else {
751 751
 				$additional_query .= " AND spotter_output.pilot_name = :pilot_name";
752
-				$query_values = array_merge($query_values,array(':pilot_name' => $pilot_name));
752
+				$query_values = array_merge($query_values, array(':pilot_name' => $pilot_name));
753 753
 			}
754 754
 		}
755 755
 
756 756
 		if ($pilot_id != "")
757 757
 		{
758
-			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
758
+			$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
759 759
 			if (!is_string($pilot_id))
760 760
 			{
761 761
 				return false;
762 762
 			} else {
763 763
 				$additional_query .= " AND spotter_output.pilot_id = :pilot_id";
764
-				$query_values = array_merge($query_values,array(':pilot_id' => $pilot_id));
764
+				$query_values = array_merge($query_values, array(':pilot_id' => $pilot_id));
765 765
 			}
766 766
 		}
767 767
 
768 768
 		if ($departure_airport_route != "")
769 769
 		{
770
-			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
770
+			$departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
771 771
 			if (!is_string($departure_airport_route))
772 772
 			{
773 773
 				return false;
774 774
 			} else {
775 775
 				$additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route";
776
-				$query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route));
776
+				$query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route));
777 777
 			}
778 778
 		}
779 779
 
780 780
 		if ($arrival_airport_route != "")
781 781
 		{
782
-			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
782
+			$arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
783 783
 			if (!is_string($arrival_airport_route))
784 784
 			{
785 785
 				return false;
786 786
 			} else {
787 787
 				$additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route";
788
-				$query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route));
788
+				$query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route));
789 789
 			}
790 790
 		}
791 791
 
792 792
 		if ($altitude != "")
793 793
 		{
794 794
 			$altitude_array = explode(",", $altitude);
795
-			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
796
-			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
795
+			$altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
796
+			$altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
797 797
 
798 798
 			if ($altitude_array[1] != "")
799 799
 			{                
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 		if ($date_posted != "")
810 810
 		{
811 811
 			$date_array = explode(",", $date_posted);
812
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
813
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
812
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
813
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
814 814
 
815 815
 			if ($globalTimezone != '') {
816 816
 				date_default_timezone_set($globalTimezone);
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
 		{
842 842
 			$limit_array = explode(",", $limit);
843 843
 			
844
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
845
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
844
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
845
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
846 846
 			
847 847
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
848 848
 			{
@@ -871,23 +871,23 @@  discard block
 block discarded – undo
871 871
 
872 872
 
873 873
 		if ($origLat != "" && $origLon != "" && $dist != "") {
874
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
874
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
875 875
 
876 876
 			if ($globalDBdriver == 'mysql') {
877
-				$query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
877
+				$query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance 
878 878
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
879 879
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
880 880
 			} else {
881
-				$query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
881
+				$query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
882 882
 						FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
883 883
 						AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
884 884
 			}
885 885
 		} else {		
886
-			$query  = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
886
+			$query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' 
887 887
 					".$additional_query."
888 888
 					".$orderby_query;
889 889
 		}
890
-		$spotter_array = $this->getDataFromDB($query, $query_values,$limit_query);
890
+		$spotter_array = $this->getDataFromDB($query, $query_values, $limit_query);
891 891
 		return $spotter_array;
892 892
 	}
893 893
 	
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 		{
911 911
 			$limit_array = explode(",", $limit);
912 912
 			
913
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
914
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
913
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
914
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
915 915
 			
916 916
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
917 917
 			{
@@ -928,9 +928,9 @@  discard block
 block discarded – undo
928 928
 			$orderby_query = " ORDER BY spotter_output.date DESC";
929 929
 		}
930 930
 
931
-		$query  = $global_query.$filter_query." ".$orderby_query;
931
+		$query = $global_query.$filter_query." ".$orderby_query;
932 932
 
933
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
933
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
934 934
 
935 935
 		return $spotter_array;
936 936
 	}
@@ -976,34 +976,34 @@  discard block
 block discarded – undo
976 976
 			{
977 977
 				return false;
978 978
 			} else {
979
-				if ($interval == "30m"){
979
+				if ($interval == "30m") {
980 980
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date ';
981
-				} else if ($interval == "1h"){
981
+				} else if ($interval == "1h") {
982 982
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date ';
983
-				} else if ($interval == "3h"){
983
+				} else if ($interval == "3h") {
984 984
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date ';
985
-				} else if ($interval == "6h"){
985
+				} else if ($interval == "6h") {
986 986
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date ';
987
-				} else if ($interval == "12h"){
987
+				} else if ($interval == "12h") {
988 988
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date ';
989
-				} else if ($interval == "24h"){
989
+				} else if ($interval == "24h") {
990 990
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date ';
991
-				} else if ($interval == "7d"){
991
+				} else if ($interval == "7d") {
992 992
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date ';
993
-				} else if ($interval == "30d"){
993
+				} else if ($interval == "30d") {
994 994
 					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date ';
995 995
 				} 
996 996
 			}
997 997
 		}
998 998
 
999
-		$query  = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
999
+		$query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output 
1000 1000
                    WHERE spotter_output.latitude <> '' 
1001 1001
 				   AND spotter_output.longitude <> '' 
1002 1002
                    ".$additional_query."
1003 1003
                    HAVING distance < :radius  
1004 1004
 				   ORDER BY distance";
1005 1005
 
1006
-		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query);
1006
+		$spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query);
1007 1007
 
1008 1008
 		return $spotter_array;
1009 1009
 	}
@@ -1015,21 +1015,21 @@  discard block
 block discarded – undo
1015 1015
 	* @return Array the spotter information
1016 1016
 	*
1017 1017
 	*/
1018
-	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array())
1018
+	public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array())
1019 1019
 	{
1020 1020
 		global $global_query;
1021 1021
 		
1022 1022
 		date_default_timezone_set('UTC');
1023 1023
 
1024
-		$filter_query = $this->getFilter($filter,true,true);
1024
+		$filter_query = $this->getFilter($filter, true, true);
1025 1025
 
1026 1026
 		$limit_query = '';
1027 1027
 		if ($limit != "")
1028 1028
 		{
1029 1029
 			$limit_array = explode(",", $limit);
1030 1030
 			
1031
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1032
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1031
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1032
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1033 1033
 			
1034 1034
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1035 1035
 			{
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1047 1047
 		}
1048 1048
 
1049
-		$query  = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1049
+		$query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1050 1050
 
1051 1051
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1052 1052
 
@@ -1065,15 +1065,15 @@  discard block
 block discarded – undo
1065 1065
 		global $global_query;
1066 1066
 		
1067 1067
 		date_default_timezone_set('UTC');
1068
-		$filter_query = $this->getFilter($filter,true,true);
1068
+		$filter_query = $this->getFilter($filter, true, true);
1069 1069
 
1070 1070
 		$limit_query = '';
1071 1071
 		if ($limit != "")
1072 1072
 		{
1073 1073
 			$limit_array = explode(",", $limit);
1074 1074
 			
1075
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1076
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1075
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1076
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1077 1077
 			
1078 1078
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1079 1079
 			{
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1091 1091
 		}
1092 1092
 
1093
-		$query  = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1093
+		$query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1094 1094
 
1095 1095
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1096 1096
 
@@ -1104,20 +1104,20 @@  discard block
 block discarded – undo
1104 1104
 	* @return Array the spotter information
1105 1105
 	*
1106 1106
 	*/
1107
-	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array())
1107
+	public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array())
1108 1108
 	{
1109 1109
 		global $global_query;
1110 1110
 		
1111 1111
 		date_default_timezone_set('UTC');
1112
-		$filter_query = $this->getFilter($filter,true,true);
1112
+		$filter_query = $this->getFilter($filter, true, true);
1113 1113
 		
1114 1114
 		$limit_query = '';
1115 1115
 		if ($limit != "")
1116 1116
 		{
1117 1117
 			$limit_array = explode(",", $limit);
1118 1118
 			
1119
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1120
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1119
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1120
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1121 1121
 			
1122 1122
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1123 1123
 			{
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1135 1135
 		}
1136 1136
 
1137
-		$query  = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1137
+		$query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1138 1138
 
1139 1139
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1140 1140
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 		
1155 1155
 		date_default_timezone_set('UTC');
1156 1156
 		
1157
-		$filter_query = $this->getFilter($filter,true,true);
1157
+		$filter_query = $this->getFilter($filter, true, true);
1158 1158
 		
1159 1159
 		$limit_query = '';
1160 1160
 		
@@ -1162,8 +1162,8 @@  discard block
 block discarded – undo
1162 1162
 		{
1163 1163
 			$limit_array = explode(",", $limit);
1164 1164
 			
1165
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1166
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1165
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1166
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1167 1167
 			
1168 1168
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1169 1169
 			{
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1181 1181
 		}
1182 1182
 
1183
-		$query  = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1183
+		$query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1184 1184
 
1185 1185
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1186 1186
 
@@ -1199,14 +1199,14 @@  discard block
 block discarded – undo
1199 1199
 		global $global_query;
1200 1200
 		
1201 1201
 		date_default_timezone_set('UTC');
1202
-		$filter_query = $this->getFilter($filter,true,true);
1202
+		$filter_query = $this->getFilter($filter, true, true);
1203 1203
 		$limit_query = '';
1204 1204
 		if ($limit != "")
1205 1205
 		{
1206 1206
 			$limit_array = explode(",", $limit);
1207 1207
 			
1208
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1209
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1208
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1209
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1210 1210
 			
1211 1211
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1212 1212
 			{
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 			$orderby_query = " ORDER BY spotter_output.date DESC ";
1224 1224
 		}
1225 1225
 
1226
-		$query  = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1226
+		$query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query;
1227 1227
 
1228 1228
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1229 1229
 
@@ -1247,9 +1247,9 @@  discard block
 block discarded – undo
1247 1247
 		$query_values = array(':id' => $id);
1248 1248
 
1249 1249
 		//$query  = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." ";
1250
-		$query  = $global_query." WHERE ".$additional_query." ";
1250
+		$query = $global_query." WHERE ".$additional_query." ";
1251 1251
 
1252
-		$spotter_array = $this->getDataFromDB($query,$query_values);
1252
+		$spotter_array = $this->getDataFromDB($query, $query_values);
1253 1253
 
1254 1254
 		return $spotter_array;
1255 1255
 	}
@@ -1272,7 +1272,7 @@  discard block
 block discarded – undo
1272 1272
 		$query_values = array();
1273 1273
 		$limit_query = '';
1274 1274
 		$additional_query = '';
1275
-		$filter_query = $this->getFilter($filter,true,true);
1275
+		$filter_query = $this->getFilter($filter, true, true);
1276 1276
 		if ($ident != "")
1277 1277
 		{
1278 1278
 			if (!is_string($ident))
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		{
1289 1289
 			$limit_array = explode(",", $limit);
1290 1290
 			
1291
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1292
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1291
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1292
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1293 1293
 			
1294 1294
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1295 1295
 			{
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 		$query_values = array();
1329 1329
 		$limit_query = '';
1330 1330
 		$additional_query = '';
1331
-		$filter_query = $this->getFilter($filter,true,true);
1331
+		$filter_query = $this->getFilter($filter, true, true);
1332 1332
 		if ($owner != "")
1333 1333
 		{
1334 1334
 			if (!is_string($owner))
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 		{
1345 1345
 			$limit_array = explode(",", $limit);
1346 1346
 			
1347
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1348
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1347
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1348
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1349 1349
 			
1350 1350
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1351 1351
 			{
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		$query_values = array();
1386 1386
 		$limit_query = '';
1387 1387
 		$additional_query = '';
1388
-		$filter_query = $this->getFilter($filter,true,true);
1388
+		$filter_query = $this->getFilter($filter, true, true);
1389 1389
 		if ($pilot != "")
1390 1390
 		{
1391 1391
 			$additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
@@ -1396,8 +1396,8 @@  discard block
 block discarded – undo
1396 1396
 		{
1397 1397
 			$limit_array = explode(",", $limit);
1398 1398
 			
1399
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1400
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1399
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1400
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1401 1401
 			
1402 1402
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1403 1403
 			{
@@ -1438,7 +1438,7 @@  discard block
 block discarded – undo
1438 1438
 		$query_values = array();
1439 1439
 		$limit_query = '';
1440 1440
 		$additional_query = '';
1441
-		$filter_query = $this->getFilter($filter,true,true);
1441
+		$filter_query = $this->getFilter($filter, true, true);
1442 1442
 		
1443 1443
 		if ($aircraft_type != "")
1444 1444
 		{
@@ -1455,8 +1455,8 @@  discard block
 block discarded – undo
1455 1455
 		{
1456 1456
 			$limit_array = explode(",", $limit);
1457 1457
 			
1458
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1459
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1458
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1459
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1460 1460
 			
1461 1461
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1462 1462
 			{
@@ -1512,8 +1512,8 @@  discard block
 block discarded – undo
1512 1512
 		{
1513 1513
 			$limit_array = explode(",", $limit);
1514 1514
 			
1515
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1516
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1515
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1516
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1517 1517
 			
1518 1518
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1519 1519
 			{
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		} else {
1530 1530
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1531 1531
 		}
1532
-		$filter_query = $this->getFilter($filter,true,true);
1532
+		$filter_query = $this->getFilter($filter, true, true);
1533 1533
 
1534 1534
 		//$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query;
1535 1535
 		$query = $global_query.$filter_query." ".$additional_query." ".$orderby_query;
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 	* @return Array the spotter information
1549 1549
 	*
1550 1550
 	*/
1551
-	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array())
1551
+	public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array())
1552 1552
 	{
1553 1553
 		global $global_query;
1554 1554
 		
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 		$query_values = array();
1558 1558
 		$limit_query = '';
1559 1559
 		$additional_query = '';
1560
-		$filter_query = $this->getFilter($filters,true,true);
1560
+		$filter_query = $this->getFilter($filters, true, true);
1561 1561
 		
1562 1562
 		if ($airline != "")
1563 1563
 		{
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 		{
1575 1575
 			$limit_array = explode(",", $limit);
1576 1576
 			
1577
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1578
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1577
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1578
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1579 1579
 			
1580 1580
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1581 1581
 			{
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 	* @return Array the spotter information
1606 1606
 	*
1607 1607
 	*/
1608
-	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1608
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1609 1609
 	{
1610 1610
 		global $global_query;
1611 1611
 		
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 		$query_values = array();
1614 1614
 		$limit_query = '';
1615 1615
 		$additional_query = '';
1616
-		$filter_query = $this->getFilter($filters,true,true);
1616
+		$filter_query = $this->getFilter($filters, true, true);
1617 1617
 		
1618 1618
 		if ($airport != "")
1619 1619
 		{
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 		{
1631 1631
 			$limit_array = explode(",", $limit);
1632 1632
 			
1633
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1634
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1633
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1634
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1635 1635
 			
1636 1636
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1637 1637
 			{
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
 	* @return Array the spotter information
1664 1664
 	*
1665 1665
 	*/
1666
-	public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array())
1666
+	public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array())
1667 1667
 	{
1668 1668
 		global $global_query, $globalTimezone, $globalDBdriver;
1669 1669
 		
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 		$limit_query = '';
1672 1672
 		$additional_query = '';
1673 1673
 
1674
-		$filter_query = $this->getFilter($filter,true,true);
1674
+		$filter_query = $this->getFilter($filter, true, true);
1675 1675
 		
1676 1676
 		if ($date != "")
1677 1677
 		{
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 		{
1701 1701
 			$limit_array = explode(",", $limit);
1702 1702
 			
1703
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1704
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1703
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1704
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1705 1705
 			
1706 1706
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1707 1707
 			{
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	* @return Array the spotter information
1732 1732
 	*
1733 1733
 	*/
1734
-	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array())
1734
+	public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array())
1735 1735
 	{
1736 1736
 		global $global_query;
1737 1737
 		
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 		$query_values = array();
1741 1741
 		$limit_query = '';
1742 1742
 		$additional_query = '';
1743
-		$filter_query = $this->getFilter($filters,true,true);
1743
+		$filter_query = $this->getFilter($filters, true, true);
1744 1744
 		if ($country != "")
1745 1745
 		{
1746 1746
 			if (!is_string($country))
@@ -1757,8 +1757,8 @@  discard block
 block discarded – undo
1757 1757
 		{
1758 1758
 			$limit_array = explode(",", $limit);
1759 1759
 			
1760
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1761
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1760
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1761
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1762 1762
 			
1763 1763
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1764 1764
 			{
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
 		$query_values = array();
1799 1799
 		$additional_query = '';
1800 1800
 		$limit_query = '';
1801
-		$filter_query = $this->getFilter($filters,true,true);
1801
+		$filter_query = $this->getFilter($filters, true, true);
1802 1802
 		
1803 1803
 		if ($aircraft_manufacturer != "")
1804 1804
 		{
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 		{
1816 1816
 			$limit_array = explode(",", $limit);
1817 1817
 			
1818
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1819
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1818
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1819
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1820 1820
 			
1821 1821
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1822 1822
 			{
@@ -1858,14 +1858,14 @@  discard block
 block discarded – undo
1858 1858
 		$query_values = array();
1859 1859
 		$additional_query = '';
1860 1860
 		$limit_query = '';
1861
-		$filter_query = $this->getFilter($filters,true,true);
1861
+		$filter_query = $this->getFilter($filters, true, true);
1862 1862
 		if ($departure_airport_icao != "")
1863 1863
 		{
1864 1864
 			if (!is_string($departure_airport_icao))
1865 1865
 			{
1866 1866
 				return false;
1867 1867
 			} else {
1868
-				$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1868
+				$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1869 1869
 				$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)";
1870 1870
 				//$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao";
1871 1871
 				$query_values = array(':departure_airport_icao' => $departure_airport_icao);
@@ -1878,10 +1878,10 @@  discard block
 block discarded – undo
1878 1878
 			{
1879 1879
 				return false;
1880 1880
 			} else {
1881
-				$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1881
+				$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1882 1882
 				$additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)";
1883 1883
 				//$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)";
1884
-				$query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao));
1884
+				$query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao));
1885 1885
 			}
1886 1886
 		}
1887 1887
 		
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 		{
1890 1890
 			$limit_array = explode(",", $limit);
1891 1891
 			
1892
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1893
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1892
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1893
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1894 1894
 			
1895 1895
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1896 1896
 			{
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
 		global $global_query;
1930 1930
 		
1931 1931
 		date_default_timezone_set('UTC');
1932
-		$filter_query = $this->getFilter($filter,true,true);
1932
+		$filter_query = $this->getFilter($filter, true, true);
1933 1933
 		$limit_query = '';
1934 1934
 		
1935 1935
 		if ($limit != "")
1936 1936
 		{
1937 1937
 			$limit_array = explode(",", $limit);
1938 1938
 			
1939
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1940
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1939
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1940
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1941 1941
 			
1942 1942
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1943 1943
 			{
@@ -1954,7 +1954,7 @@  discard block
 block discarded – undo
1954 1954
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1955 1955
 		}
1956 1956
 
1957
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1957
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query;
1958 1958
 
1959 1959
 		$spotter_array = $this->getDataFromDB($query, array(), $limit_query);
1960 1960
 
@@ -1967,19 +1967,19 @@  discard block
 block discarded – undo
1967 1967
 	* @return String the highlight text
1968 1968
 	*
1969 1969
 	*/
1970
-	public function getHighlightByRegistration($registration,$filter = array())
1970
+	public function getHighlightByRegistration($registration, $filter = array())
1971 1971
 	{
1972 1972
 		global $global_query;
1973 1973
 		
1974 1974
 		date_default_timezone_set('UTC');
1975
-		$filter_query = $this->getFilter($filter,true,true);
1976
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
1975
+		$filter_query = $this->getFilter($filter, true, true);
1976
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
1977 1977
 		
1978
-		$query  = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1978
+		$query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration";
1979 1979
 		$sth = $this->db->prepare($query);
1980 1980
 		$sth->execute(array(':registration' => $registration));
1981 1981
 
1982
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1982
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1983 1983
 		{
1984 1984
 			$highlight = $row['highlight'];
1985 1985
 		}
@@ -1995,14 +1995,14 @@  discard block
 block discarded – undo
1995 1995
 	* @return String usage
1996 1996
 	*
1997 1997
 	*/
1998
-	public function getSquawkUsage($squawk = '',$country = 'FR')
1998
+	public function getSquawkUsage($squawk = '', $country = 'FR')
1999 1999
 	{
2000 2000
 		
2001
-		$squawk = filter_var($squawk,FILTER_SANITIZE_STRING);
2002
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
2001
+		$squawk = filter_var($squawk, FILTER_SANITIZE_STRING);
2002
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
2003 2003
 
2004 2004
 		$query  = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1";
2005
-		$query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country);
2005
+		$query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country);
2006 2006
 		
2007 2007
 		$sth = $this->db->prepare($query);
2008 2008
 		$sth->execute($query_values);
@@ -2024,9 +2024,9 @@  discard block
 block discarded – undo
2024 2024
 	public function getAirportIcao($airport_iata = '')
2025 2025
 	{
2026 2026
 		
2027
-		$airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING);
2027
+		$airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING);
2028 2028
 
2029
-		$query  = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2029
+		$query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1";
2030 2030
 		$query_values = array(':airport' => $airport_iata);
2031 2031
 		
2032 2032
 		$sth = $this->db->prepare($query);
@@ -2048,12 +2048,12 @@  discard block
 block discarded – undo
2048 2048
 	* @return Float distance to the airport
2049 2049
 	*
2050 2050
 	*/
2051
-	public function getAirportDistance($airport_icao,$latitude,$longitude)
2051
+	public function getAirportDistance($airport_icao, $latitude, $longitude)
2052 2052
 	{
2053 2053
 		
2054
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
2054
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
2055 2055
 
2056
-		$query  = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2056
+		$query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1";
2057 2057
 		$query_values = array(':airport' => $airport_icao);
2058 2058
 		$sth = $this->db->prepare($query);
2059 2059
 		$sth->execute($query_values);
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 			$airport_latitude = $row['latitude'];
2064 2064
 			$airport_longitude = $row['longitude'];
2065 2065
 			$Common = new Common();
2066
-			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2066
+			return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude);
2067 2067
 		} else return '';
2068 2068
 	}
2069 2069
 	
@@ -2077,11 +2077,11 @@  discard block
 block discarded – undo
2077 2077
 	public function getAllAirportInfo($airport = '')
2078 2078
 	{
2079 2079
 		
2080
-		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
2080
+		$airport = filter_var($airport, FILTER_SANITIZE_STRING);
2081 2081
 
2082 2082
 		$query_values = array();
2083 2083
 		if ($airport == 'NA') {
2084
-			return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => ''));
2084
+			return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => ''));
2085 2085
 		} elseif ($airport == '') {
2086 2086
 			$query  = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport";
2087 2087
 		} else {
@@ -2129,14 +2129,14 @@  discard block
 block discarded – undo
2129 2129
 	{
2130 2130
 		$lst_countries = '';
2131 2131
 		foreach ($countries as $country) {
2132
-			$country = filter_var($country,FILTER_SANITIZE_STRING);
2132
+			$country = filter_var($country, FILTER_SANITIZE_STRING);
2133 2133
 			if ($lst_countries == '') {
2134 2134
 				$lst_countries = "'".$country."'";
2135 2135
 			} else {
2136 2136
 				$lst_countries .= ",'".$country."'";
2137 2137
 			}
2138 2138
 		}
2139
-		$query  = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2139
+		$query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")";
2140 2140
 		
2141 2141
 		$sth = $this->db->prepare($query);
2142 2142
 		$sth->execute();
@@ -2144,7 +2144,7 @@  discard block
 block discarded – undo
2144 2144
 		$airport_array = array();
2145 2145
 		$temp_array = array();
2146 2146
 		
2147
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2147
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2148 2148
 		{
2149 2149
 			$temp_array['name'] = $row['name'];
2150 2150
 			$temp_array['city'] = $row['city'];
@@ -2172,10 +2172,10 @@  discard block
 block discarded – undo
2172 2172
 	{
2173 2173
 		global $globalDBdriver;
2174 2174
 		if (is_array($coord)) {
2175
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2176
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2175
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2176
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2177
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2178
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2179 2179
 		} else return array();
2180 2180
 		if ($globalDBdriver == 'mysql') {
2181 2181
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
     
2188 2188
 		$airport_array = array();
2189 2189
 		
2190
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2190
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2191 2191
 		{
2192 2192
 			$temp_array = $row;
2193 2193
 
@@ -2207,13 +2207,13 @@  discard block
 block discarded – undo
2207 2207
 	public function getAllWaypointsInfobyCoord($coord)
2208 2208
 	{
2209 2209
 		if (is_array($coord)) {
2210
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2211
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2210
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2211
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2212
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2213
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
2214 2214
 		} else return array();
2215 2215
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216
-		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2216
+		$query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2217 2217
 		//$query  = "SELECT waypoints.* FROM waypoints";
2218 2218
 		//$query  = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end";
2219 2219
 		//$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
     
2226 2226
 		$waypoints_array = array();
2227 2227
 		
2228
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2228
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2229 2229
 		{
2230 2230
 			$temp_array = $row;
2231 2231
 
@@ -2247,10 +2247,10 @@  discard block
 block discarded – undo
2247 2247
 	{
2248 2248
 		global $globalUseRealAirlines;
2249 2249
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2250
-		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2250
+		$airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING));
2251 2251
 		if ($airline_icao == 'NA') {
2252 2252
 			$airline_array = array();
2253
-			$airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2253
+			$airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>'');
2254 2254
 			return $airline_array;
2255 2255
 		} else {
2256 2256
 			if (strlen($airline_icao) == 2) {
@@ -2271,7 +2271,7 @@  discard block
 block discarded – undo
2271 2271
 			if ($fromsource === NULL) {
2272 2272
 				$sth->execute(array(':airline_icao' => $airline_icao));
2273 2273
 			} else {
2274
-				$sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource));
2274
+				$sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource));
2275 2275
 			}
2276 2276
                         /*
2277 2277
 			$airline_array = array();
@@ -2316,13 +2316,13 @@  discard block
 block discarded – undo
2316 2316
 	{
2317 2317
 		global $globalUseRealAirlines;
2318 2318
 		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2319
-		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320
-		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2319
+		$airline_name = strtolower(filter_var($airline_name, FILTER_SANITIZE_STRING));
2320
+		$query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2321
 		$sth = $this->db->prepare($query);
2322 2322
 		if ($fromsource === NULL) {
2323 2323
 			$sth->execute(array(':airline_name' => $airline_name));
2324 2324
 		} else {
2325
-			$sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource));
2325
+			$sth->execute(array(':airline_name' => $airline_name, ':fromsource' => $fromsource));
2326 2326
 		}
2327 2327
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2328 2328
 		if (empty($result) && $fromsource !== NULL) {
@@ -2347,12 +2347,12 @@  discard block
 block discarded – undo
2347 2347
 	*/
2348 2348
 	public function getAllAircraftInfo($aircraft_type)
2349 2349
 	{
2350
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2350
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2351 2351
 
2352 2352
 		if ($aircraft_type == 'NA') {
2353
-			return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2353
+			return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL));
2354 2354
 		}
2355
-		$query  = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2355
+		$query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type";
2356 2356
 		
2357 2357
 		$sth = $this->db->prepare($query);
2358 2358
 		$sth->execute(array(':aircraft_type' => $aircraft_type));
@@ -2384,7 +2384,7 @@  discard block
 block discarded – undo
2384 2384
 	*/
2385 2385
 	public function getAircraftIcao($aircraft_type)
2386 2386
 	{
2387
-		$aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING);
2387
+		$aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING);
2388 2388
 		$all_aircraft = array('737-300' => 'B733',
2389 2389
 				'777-200' => 'B772',
2390 2390
 				'777-200ER' => 'B772',
@@ -2396,10 +2396,10 @@  discard block
 block discarded – undo
2396 2396
 				'A380' => 'A388');
2397 2397
 		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2398 2398
 
2399
-		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2399
+		$query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2400
 		$aircraft_type = strtoupper($aircraft_type);
2401 2401
 		$sth = $this->db->prepare($query);
2402
-		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2402
+		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,));
2403 2403
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404 2404
 		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405 2405
 		else return '';
@@ -2412,10 +2412,10 @@  discard block
 block discarded – undo
2412 2412
 	* @return String aircraft type
2413 2413
 	*
2414 2414
 	*/
2415
-	public function getAllAircraftType($aircraft_modes,$source_type = '')
2415
+	public function getAllAircraftType($aircraft_modes, $source_type = '')
2416 2416
 	{
2417
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
2418
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
2417
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
2418
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
2419 2419
 
2420 2420
 		if ($source_type == '' || $source_type == 'modes') {
2421 2421
 			$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
@@ -2446,9 +2446,9 @@  discard block
 block discarded – undo
2446 2446
 	*/
2447 2447
 	public function getAllAircraftTypeByRegistration($registration)
2448 2448
 	{
2449
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2449
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2450 2450
 
2451
-		$query  = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2451
+		$query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1";
2452 2452
 		
2453 2453
 		$sth = $this->db->prepare($query);
2454 2454
 		$sth->execute(array(':registration' => $registration));
@@ -2469,9 +2469,9 @@  discard block
 block discarded – undo
2469 2469
 	*/
2470 2470
 	public function getAllIDByRegistration($registration)
2471 2471
 	{
2472
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2472
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2473 2473
 
2474
-		$query  = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2474
+		$query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration";
2475 2475
 		
2476 2476
 		$sth = $this->db->prepare($query);
2477 2477
 		$sth->execute(array(':registration' => $registration));
@@ -2479,7 +2479,7 @@  discard block
 block discarded – undo
2479 2479
 		$idarray = array();
2480 2480
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
2481 2481
 			$date = $row['date'];
2482
-			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']);
2482
+			$idarray[$date] = array('flightaware_id' => $row['flightaware_id'], 'spotter_id' => $row['spotter_id']);
2483 2483
 		}
2484 2484
 		return $idarray;
2485 2485
 	}
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	*/
2494 2494
 	public function getOperator($operator)
2495 2495
 	{
2496
-		$operator = filter_var($operator,FILTER_SANITIZE_STRING);
2497
-		$query  = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2496
+		$operator = filter_var($operator, FILTER_SANITIZE_STRING);
2497
+		$query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1";
2498 2498
 		
2499 2499
 		$sth = $this->db->prepare($query);
2500 2500
 		$sth->execute(array(':operator' => $operator));
@@ -2515,9 +2515,9 @@  discard block
 block discarded – undo
2515 2515
 	*/
2516 2516
 	public function getRouteInfo($callsign)
2517 2517
 	{
2518
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2518
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
2519 2519
                 if ($callsign == '') return array();
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";
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);
2523 2523
 		$sth->execute(array(':callsign' => $callsign));
@@ -2538,9 +2538,9 @@  discard block
 block discarded – undo
2538 2538
 	*/
2539 2539
 	public function getAircraftInfoByRegistration($registration)
2540 2540
 	{
2541
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2541
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2542 2542
 
2543
-		$query  = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2543
+		$query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration";
2544 2544
 		
2545 2545
 		$sth = $this->db->prepare($query);
2546 2546
 		$sth->execute(array(':registration' => $registration));
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 		$aircraft_array = array();
2549 2549
 		$temp_array = array();
2550 2550
 		
2551
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2551
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2552 2552
 		{
2553 2553
 			$temp_array['airline_icao'] = $row['airline_icao'];
2554 2554
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -2570,7 +2570,7 @@  discard block
 block discarded – undo
2570 2570
 	*/
2571 2571
 	public function getAircraftOwnerByRegistration($registration)
2572 2572
 	{
2573
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
2573
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
2574 2574
 		$Connection = new Connection($this->db);
2575 2575
 		if ($Connection->tableExists('aircraft_owner')) {
2576 2576
 			$query  = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1";
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
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 ";
2595
-		$query  = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2595
+		$query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0";
2596 2596
 		
2597 2597
 		$sth = $this->db->prepare($query);
2598 2598
 		$sth->execute();
@@ -2639,7 +2639,7 @@  discard block
 block discarded – undo
2639 2639
 		$manufacturer_array = array();
2640 2640
 		$temp_array = array();
2641 2641
 		
2642
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2642
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2643 2643
 		{
2644 2644
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
2645 2645
 
@@ -2676,7 +2676,7 @@  discard block
 block discarded – undo
2676 2676
 		$aircraft_array = array();
2677 2677
 		$temp_array = array();
2678 2678
 		
2679
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2679
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2680 2680
 		{
2681 2681
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
2682 2682
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
@@ -2697,8 +2697,8 @@  discard block
 block discarded – undo
2697 2697
 	*/
2698 2698
 	public function getAllAircraftRegistrations($filters = array())
2699 2699
 	{
2700
-		$filter_query = $this->getFilter($filters,true,true);
2701
-		$query  = "SELECT DISTINCT spotter_output.registration 
2700
+		$filter_query = $this->getFilter($filters, true, true);
2701
+		$query = "SELECT DISTINCT spotter_output.registration 
2702 2702
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' 
2703 2703
 				ORDER BY spotter_output.registration ASC";
2704 2704
 
@@ -2708,7 +2708,7 @@  discard block
 block discarded – undo
2708 2708
 		$aircraft_array = array();
2709 2709
 		$temp_array = array();
2710 2710
 		
2711
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2711
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2712 2712
 		{
2713 2713
 			$temp_array['registration'] = $row['registration'];
2714 2714
 
@@ -2725,11 +2725,11 @@  discard block
 block discarded – undo
2725 2725
 	* @return Array list of source name
2726 2726
 	*
2727 2727
 	*/
2728
-	public function getAllSourceName($type = '',$filters = array())
2728
+	public function getAllSourceName($type = '', $filters = array())
2729 2729
 	{
2730
-		$filter_query = $this->getFilter($filters,true,true);
2730
+		$filter_query = $this->getFilter($filters, true, true);
2731 2731
 		$query_values = array();
2732
-		$query  = "SELECT DISTINCT spotter_output.source_name 
2732
+		$query = "SELECT DISTINCT spotter_output.source_name 
2733 2733
 				FROM spotter_output".$filter_query." spotter_output.source_name <> ''";
2734 2734
 		if ($type != '') {
2735 2735
 			$query_values = array(':type' => $type);
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
 		$source_array = array();
2745 2745
 		$temp_array = array();
2746 2746
 		
2747
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2747
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2748 2748
 		{
2749 2749
 			$temp_array['source_name'] = $row['source_name'];
2750 2750
 			$source_array[] = $temp_array;
@@ -2760,11 +2760,11 @@  discard block
 block discarded – undo
2760 2760
 	* @return Array list of airline names
2761 2761
 	*
2762 2762
 	*/
2763
-	public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array())
2763
+	public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array())
2764 2764
 	{
2765
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2766
-		$filter_query = $this->getFilter($filters,true,true);
2767
-		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
2765
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2766
+		$filter_query = $this->getFilter($filters, true, true);
2767
+		$airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
2768 2768
 		if ($airline_type == '' || $airline_type == 'all') {
2769 2769
 			/*
2770 2770
 			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
@@ -2783,7 +2783,7 @@  discard block
 block discarded – undo
2783 2783
 				$query_data = array(':forsource' => $forsource);
2784 2784
 			}
2785 2785
 		} else {
2786
-			$query  = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2786
+			$query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type
2787 2787
 					FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
2788 2788
 					AND spotter_output.airline_type = :airline_type 
2789 2789
 					ORDER BY spotter_output.airline_icao ASC";
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
 		$airline_array = array();
2797 2797
 		$temp_array = array();
2798 2798
 		
2799
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2799
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2800 2800
 		{
2801 2801
 			$temp_array['airline_icao'] = $row['airline_icao'];
2802 2802
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -2813,10 +2813,10 @@  discard block
 block discarded – undo
2813 2813
 	* @return Array list of alliance names
2814 2814
 	*
2815 2815
 	*/
2816
-	public function getAllAllianceNames($forsource = NULL,$filters = array())
2816
+	public function getAllAllianceNames($forsource = NULL, $filters = array())
2817 2817
 	{
2818
-		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819
-		$filter_query = $this->getFilter($filters,true,true);
2818
+		global $globalAirlinesSource, $globalVATSIM, $globalIVAO;
2819
+		$filter_query = $this->getFilter($filters, true, true);
2820 2820
 		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821 2821
 		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822 2822
 		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
@@ -2844,8 +2844,8 @@  discard block
 block discarded – undo
2844 2844
 	*/
2845 2845
 	public function getAllAirlineCountries($filters = array())
2846 2846
 	{
2847
-		$filter_query = $this->getFilter($filters,true,true);
2848
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2847
+		$filter_query = $this->getFilter($filters, true, true);
2848
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
2849 2849
 				FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
2850 2850
 				ORDER BY spotter_output.airline_country ASC";
2851 2851
 		
@@ -2856,7 +2856,7 @@  discard block
 block discarded – undo
2856 2856
 		$airline_array = array();
2857 2857
 		$temp_array = array();
2858 2858
 		
2859
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2859
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2860 2860
 		{
2861 2861
 			$temp_array['airline_country'] = $row['airline_country'];
2862 2862
 
@@ -2876,9 +2876,9 @@  discard block
 block discarded – undo
2876 2876
 	*/
2877 2877
 	public function getAllAirportNames($filters = array())
2878 2878
 	{
2879
-		$filter_query = $this->getFilter($filters,true,true);
2879
+		$filter_query = $this->getFilter($filters, true, true);
2880 2880
 		$airport_array = array();
2881
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2881
+		$query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country
2882 2882
 				FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' 
2883 2883
 				ORDER BY spotter_output.departure_airport_city ASC";
2884 2884
 		
@@ -2887,7 +2887,7 @@  discard block
 block discarded – undo
2887 2887
 		$sth->execute();
2888 2888
 
2889 2889
 		$temp_array = array();
2890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2891 2891
 		{
2892 2892
 			$temp_array['airport_icao'] = $row['airport_icao'];
2893 2893
 			$temp_array['airport_name'] = $row['airport_name'];
@@ -2897,14 +2897,14 @@  discard block
 block discarded – undo
2897 2897
 			$airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array;
2898 2898
 		}
2899 2899
 
2900
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2900
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country
2901 2901
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' 
2902 2902
 								ORDER BY spotter_output.arrival_airport_city ASC";
2903 2903
 					
2904 2904
 		$sth = $this->db->prepare($query);
2905 2905
 		$sth->execute();
2906 2906
 
2907
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2907
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2908 2908
 			{
2909 2909
 		//	if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao'])
2910 2910
 		//	{
@@ -2928,8 +2928,8 @@  discard block
 block discarded – undo
2928 2928
 	*/
2929 2929
 	public function getAllOwnerNames($filters = array())
2930 2930
 	{
2931
-		$filter_query = $this->getFilter($filters,true,true);
2932
-		$query  = "SELECT DISTINCT spotter_output.owner_name
2931
+		$filter_query = $this->getFilter($filters, true, true);
2932
+		$query = "SELECT DISTINCT spotter_output.owner_name
2933 2933
 				FROM spotter_output".$filter_query." spotter_output.owner_name <> '' 
2934 2934
 				ORDER BY spotter_output.owner_name ASC";
2935 2935
 		
@@ -2946,8 +2946,8 @@  discard block
 block discarded – undo
2946 2946
 	*/
2947 2947
 	public function getAllPilotNames($filters = array())
2948 2948
 	{
2949
-		$filter_query = $this->getFilter($filters,true,true);
2950
-		$query  = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2949
+		$filter_query = $this->getFilter($filters, true, true);
2950
+		$query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id
2951 2951
 				FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' 
2952 2952
 				ORDER BY spotter_output.pilot_name ASC";
2953 2953
 		
@@ -2980,21 +2980,21 @@  discard block
 block discarded – undo
2980 2980
    
2981 2981
 		$temp_array = array();
2982 2982
 		
2983
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2983
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2984 2984
 		{
2985 2985
 			$temp_array['airport_country'] = $row['airport_country'];
2986 2986
 
2987 2987
 			$airport_array[$row['airport_country']] = $temp_array;
2988 2988
 		}
2989
-		$filter_query = $this->getFilter($filters,true,true);
2990
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2989
+		$filter_query = $this->getFilter($filters, true, true);
2990
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
2991 2991
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
2992 2992
 								ORDER BY spotter_output.arrival_airport_country ASC";
2993 2993
 					
2994 2994
 		$sth = $this->db->prepare($query);
2995 2995
 		$sth->execute();
2996 2996
 		
2997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
2997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
2998 2998
 		{
2999 2999
 			if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country'])
3000 3000
 			{
@@ -3017,9 +3017,9 @@  discard block
 block discarded – undo
3017 3017
 	*/
3018 3018
 	public function getAllCountries($filters = array())
3019 3019
 	{
3020
-		$Connection= new Connection($this->db);
3020
+		$Connection = new Connection($this->db);
3021 3021
 		if ($Connection->tableExists('countries')) {
3022
-			$query  = "SELECT countries.name AS airport_country
3022
+			$query = "SELECT countries.name AS airport_country
3023 3023
 				FROM countries
3024 3024
 				ORDER BY countries.name ASC";
3025 3025
 			$sth = $this->db->prepare($query);
@@ -3028,14 +3028,14 @@  discard block
 block discarded – undo
3028 3028
 			$temp_array = array();
3029 3029
 			$country_array = array();
3030 3030
 		
3031
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3031
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3032 3032
 			{
3033 3033
 				$temp_array['country'] = $row['airport_country'];
3034 3034
 				$country_array[$row['airport_country']] = $temp_array;
3035 3035
 			}
3036 3036
 		} else {
3037
-			$filter_query = $this->getFilter($filters,true,true);
3038
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3037
+			$filter_query = $this->getFilter($filters, true, true);
3038
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country
3039 3039
 								FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' 
3040 3040
 								ORDER BY spotter_output.departure_airport_country ASC";
3041 3041
 
@@ -3044,20 +3044,20 @@  discard block
 block discarded – undo
3044 3044
    
3045 3045
 			$temp_array = array();
3046 3046
 			$country_array = array();
3047
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
3047
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3048 3048
 			{
3049 3049
 				$temp_array['country'] = $row['airport_country'];
3050 3050
 				$country_array[$row['airport_country']] = $temp_array;
3051 3051
 			}
3052 3052
 
3053
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3053
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country
3054 3054
 								FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' 
3055 3055
 								ORDER BY spotter_output.arrival_airport_country ASC";
3056 3056
 					
3057 3057
 		$sth = $this->db->prepare($query);
3058 3058
 		$sth->execute();
3059 3059
 		
3060
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3060
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3061 3061
 		{
3062 3062
 			if ($country_array[$row['airport_country']]['country'] != $row['airport_country'])
3063 3063
 			{
@@ -3067,14 +3067,14 @@  discard block
 block discarded – undo
3067 3067
 			}
3068 3068
 		}
3069 3069
 		
3070
-		$query  = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3070
+		$query = "SELECT DISTINCT spotter_output.airline_country AS airline_country
3071 3071
 								FROM spotter_output".$filter_query." spotter_output.airline_country <> '' 
3072 3072
 								ORDER BY spotter_output.airline_country ASC";
3073 3073
 					
3074 3074
 		$sth = $this->db->prepare($query);
3075 3075
 		$sth->execute();
3076 3076
 		
3077
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3077
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3078 3078
 		{
3079 3079
 			if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country'])
3080 3080
 			{
@@ -3098,8 +3098,8 @@  discard block
 block discarded – undo
3098 3098
 	*/
3099 3099
 	public function getAllIdents($filters = array())
3100 3100
 	{
3101
-		$filter_query = $this->getFilter($filters,true,true);
3102
-		$query  = "SELECT DISTINCT spotter_output.ident
3101
+		$filter_query = $this->getFilter($filters, true, true);
3102
+		$query = "SELECT DISTINCT spotter_output.ident
3103 3103
 								FROM spotter_output".$filter_query." spotter_output.ident <> '' 
3104 3104
 								ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0";
3105 3105
 
@@ -3109,7 +3109,7 @@  discard block
 block discarded – undo
3109 3109
 		$ident_array = array();
3110 3110
 		$temp_array = array();
3111 3111
 		
3112
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3112
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3113 3113
 		{
3114 3114
 			$temp_array['ident'] = $row['ident'];
3115 3115
 			$ident_array[] = $temp_array;
@@ -3123,9 +3123,9 @@  discard block
 block discarded – undo
3123 3123
 	* @return Array number, icao, name and city of airports
3124 3124
 	*/
3125 3125
 
3126
-	public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) {
3126
+	public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) {
3127 3127
 		global $globalTimezone, $globalDBdriver;
3128
-		$filter_query = $this->getFilter($filters,true,true);
3128
+		$filter_query = $this->getFilter($filters, true, true);
3129 3129
 		if ($globalTimezone != '') {
3130 3130
 			date_default_timezone_set($globalTimezone);
3131 3131
 			$datetime = new DateTime();
@@ -3190,7 +3190,7 @@  discard block
 block discarded – undo
3190 3190
 
3191 3191
 	public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) {
3192 3192
 		global $globalTimezone, $globalDBdriver;
3193
-		$filter_query = $this->getFilter($filters,true,true);
3193
+		$filter_query = $this->getFilter($filters, true, true);
3194 3194
 		if ($globalTimezone != '') {
3195 3195
 			date_default_timezone_set($globalTimezone);
3196 3196
 			$datetime = new DateTime();
@@ -3274,7 +3274,7 @@  discard block
 block discarded – undo
3274 3274
 
3275 3275
 	public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) {
3276 3276
 		global $globalTimezone, $globalDBdriver;
3277
-		$filter_query = $this->getFilter($filters,true,true);
3277
+		$filter_query = $this->getFilter($filters, true, true);
3278 3278
 		if ($globalTimezone != '') {
3279 3279
 			date_default_timezone_set($globalTimezone);
3280 3280
 			$datetime = new DateTime();
@@ -3307,9 +3307,9 @@  discard block
 block discarded – undo
3307 3307
 	* @return Array number, icao, name and city of airports
3308 3308
 	*/
3309 3309
 
3310
-	public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) {
3310
+	public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) {
3311 3311
 		global $globalTimezone, $globalDBdriver;
3312
-		$filter_query = $this->getFilter($filters,true,true);
3312
+		$filter_query = $this->getFilter($filters, true, true);
3313 3313
 		if ($globalTimezone != '') {
3314 3314
 			date_default_timezone_set($globalTimezone);
3315 3315
 			$datetime = new DateTime();
@@ -3441,12 +3441,12 @@  discard block
 block discarded – undo
3441 3441
 		} else $offset = '+00:00';
3442 3442
 
3443 3443
 		if ($globalDBdriver == 'mysql') {
3444
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3444
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
3445 3445
 								FROM spotter_output
3446 3446
 								WHERE spotter_output.date <> '' 
3447 3447
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
3448 3448
 		} else {
3449
-			$query  = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3449
+			$query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
3450 3450
 								FROM spotter_output
3451 3451
 								WHERE spotter_output.date <> '' 
3452 3452
 								ORDER BY spotter_output.date ASC LIMIT 0,200";
@@ -3458,7 +3458,7 @@  discard block
 block discarded – undo
3458 3458
 		$date_array = array();
3459 3459
 		$temp_array = array();
3460 3460
 		
3461
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3461
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3462 3462
 		{
3463 3463
 			$temp_array['date'] = $row['date'];
3464 3464
 
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
 	*/
3479 3479
 	public function getAllRoutes()
3480 3480
 	{
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 
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 
3482 3482
 				FROM spotter_output
3483 3483
 				WHERE spotter_output.ident <> '' 
3484 3484
 				GROUP BY route
@@ -3489,7 +3489,7 @@  discard block
 block discarded – undo
3489 3489
 
3490 3490
 		$routes_array = array();
3491 3491
 		$temp_array = array();
3492
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3492
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3493 3493
 		{
3494 3494
 			$temp_array['route'] = $row['route'];
3495 3495
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -3508,21 +3508,21 @@  discard block
 block discarded – undo
3508 3508
 	* @return String success or false
3509 3509
 	*
3510 3510
 	*/	
3511
-	public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL)
3511
+	public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL)
3512 3512
 	{
3513 3513
 		if (!is_numeric(substr($ident, 0, 3)))
3514 3514
 		{
3515 3515
 			if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3516
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3516
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3517 3517
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3518
-				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3518
+				$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3519 3519
 			} else {
3520 3520
 				$airline_array = $this->getAllAirlineInfo("NA");
3521 3521
 			}
3522 3522
 			if (count($airline_array) == 0) {
3523 3523
 				$airline_array = $this->getAllAirlineInfo("NA");
3524 3524
 			}
3525
-			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3525
+			if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3526 3526
 				$airline_array = $this->getAllAirlineInfo("NA");
3527 3527
 			}
3528 3528
 		} else {
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
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);
@@ -3556,11 +3556,11 @@  discard block
 block discarded – undo
3556 3556
 	* @return String success or false
3557 3557
 	*
3558 3558
 	*/	
3559
-	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
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);
@@ -3600,7 +3600,7 @@  discard block
 block discarded – undo
3600 3600
 	* @param String $verticalrate vertival rate of flight
3601 3601
 	* @return String success or false
3602 3602
 	*/
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 = '')
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;
3606 3606
 		
@@ -3623,14 +3623,14 @@  discard block
 block discarded – undo
3623 3623
 			} else {
3624 3624
 				if ($ModeS != '') {
3625 3625
 					$timeelapsed = microtime(true);
3626
-					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3626
+					$registration = $this->getAircraftRegistrationBymodeS($ModeS, $source_type);
3627
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3628 3628
 				} else {
3629
-					$myhex = explode('-',$flightaware_id);
3629
+					$myhex = explode('-', $flightaware_id);
3630 3630
 					if (count($myhex) > 0) {
3631 3631
 						$timeelapsed = microtime(true);
3632
-						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3632
+						$registration = $this->getAircraftRegistrationBymodeS($myhex[0], $source_type);
3633
+						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3634 3634
 					}
3635 3635
 				}
3636 3636
 			}
@@ -3652,24 +3652,24 @@  discard block
 block discarded – undo
3652 3652
 				{
3653 3653
 					$timeelapsed = microtime(true);
3654 3654
 					if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) {
3655
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource);
3655
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource);
3656 3656
 					} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
3657
-						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource);
3657
+						$airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource);
3658 3658
 					} else {
3659 3659
 						$airline_array = $this->getAllAirlineInfo("NA");
3660 3660
 					}
3661 3661
 					if (count($airline_array) == 0) {
3662 3662
 						$airline_array = $this->getAllAirlineInfo("NA");
3663 3663
 					}
3664
-					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3664
+					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") {
3665 3665
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3666
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3667
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3668 3668
 
3669 3669
 				} else {
3670 3670
 					$timeelapsed = microtime(true);
3671 3671
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3672
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3673 3673
 				}
3674 3674
 			}
3675 3675
 		} else $airline_array = array();
@@ -3686,27 +3686,27 @@  discard block
 block discarded – undo
3686 3686
 				{
3687 3687
 					$timeelapsed = microtime(true);
3688 3688
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3689
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3690 3690
 				} else {
3691 3691
 					$timeelapsed = microtime(true);
3692 3692
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3693
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3694 3694
 				}
3695 3695
 			}
3696 3696
 		} else {
3697 3697
 			if ($ModeS != '') {
3698 3698
 				$timeelapsed = microtime(true);
3699
-				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3699
+				$aircraft_icao = $this->getAllAircraftType($ModeS, $source_type);
3700
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3701 3701
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3702
 				{
3703 3703
 					$timeelapsed = microtime(true);
3704 3704
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3705
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3706 3706
 				} else {
3707 3707
 					$timeelapsed = microtime(true);
3708 3708
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3709
+					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3710 3710
 				}
3711 3711
 			}
3712 3712
 		}
@@ -3722,7 +3722,7 @@  discard block
 block discarded – undo
3722 3722
 			} else {
3723 3723
 				$timeelapsed = microtime(true);
3724 3724
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3725
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3726 3726
 			}
3727 3727
 		}
3728 3728
 		
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
 			} else {
3738 3738
 				$timeelapsed = microtime(true);
3739 3739
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3740
+				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3741 3741
 			}
3742 3742
 		}
3743 3743
 
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 		}
3791 3791
 
3792 3792
     
3793
-		if ($date == "" || strtotime($date) < time()-20*60)
3793
+		if ($date == "" || strtotime($date) < time() - 20*60)
3794 3794
 		{
3795 3795
 			$date = date("Y-m-d H:i:s", time());
3796 3796
 		}
@@ -3800,7 +3800,7 @@  discard block
 block discarded – undo
3800 3800
 		{
3801 3801
 			$timeelapsed = microtime(true);
3802 3802
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3803
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3804 3804
 			if (!isset($image_array[0]['registration']))
3805 3805
 			{
3806 3806
 				//echo "Add image !!!! \n";
@@ -3808,7 +3808,7 @@  discard block
 block discarded – undo
3808 3808
 			}
3809 3809
 			$timeelapsed = microtime(true);
3810 3810
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3811
+			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
3812 3812
 			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
3813 3813
 		}
3814 3814
     
@@ -3816,33 +3816,33 @@  discard block
 block discarded – undo
3816 3816
 		{
3817 3817
             		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818 3818
             		else $airline_icao = '';
3819
-			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3819
+			$image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao);
3820 3820
 			if (!isset($image_array[0]['registration']))
3821 3821
 			{
3822 3822
 				//echo "Add image !!!! \n";
3823
-				$Image->addSpotterImage('',$aircraft_icao,$airline_icao);
3823
+				$Image->addSpotterImage('', $aircraft_icao, $airline_icao);
3824 3824
 			}
3825 3825
 		}
3826 3826
     
3827
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
3828
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
3829
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
3830
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
3831
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
3832
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
3833
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3834
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3835
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
3836
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3837
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
3838
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
3839
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
3840
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
3841
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
3842
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
3843
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
3844
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
3845
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
3827
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
3828
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
3829
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
3830
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
3831
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
3832
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
3833
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3834
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3835
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
3836
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3837
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
3838
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
3839
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
3840
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
3841
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
3842
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
3843
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
3844
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
3845
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
3846 3846
 	
3847 3847
 		if (count($airline_array) == 0) 
3848 3848
 		{
@@ -3870,7 +3870,7 @@  discard block
 block discarded – undo
3870 3870
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
3871 3871
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
3872 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) 
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 3876
                 $airline_name = $airline_array[0]['name'];
@@ -3880,7 +3880,7 @@  discard block
 block discarded – undo
3880 3880
 		if ($airline_type == '') {
3881 3881
 			$timeelapsed = microtime(true);
3882 3882
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
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 3886
                 $aircraft_type = $aircraft_array[0]['type'];
@@ -3892,7 +3892,7 @@  discard block
 block discarded – undo
3892 3892
                 $arrival_airport_name = $arrival_airport_array[0]['name'];
3893 3893
                 $arrival_airport_city = $arrival_airport_array[0]['city'];
3894 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);
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
 		        
@@ -3918,13 +3918,13 @@  discard block
 block discarded – undo
3918 3918
 	{
3919 3919
 		global $globalDBdriver, $globalTimezone;
3920 3920
 		if ($globalDBdriver == 'mysql') {
3921
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3921
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3922 3922
 								WHERE spotter_output.ident = :ident 
3923 3923
 								AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
3924 3924
 								AND spotter_output.date < UTC_TIMESTAMP()";
3925 3925
 			$query_data = array(':ident' => $ident);
3926 3926
 		} else {
3927
-			$query  = "SELECT spotter_output.ident FROM spotter_output 
3927
+			$query = "SELECT spotter_output.ident FROM spotter_output 
3928 3928
 								WHERE spotter_output.ident = :ident 
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'";
@@ -3933,8 +3933,8 @@  discard block
 block discarded – undo
3933 3933
 		
3934 3934
 		$sth = $this->db->prepare($query);
3935 3935
 		$sth->execute($query_data);
3936
-    		$ident_result='';
3937
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
3936
+    		$ident_result = '';
3937
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
3938 3938
 		{
3939 3939
 			$ident_result = $row['ident'];
3940 3940
 		}
@@ -3960,8 +3960,8 @@  discard block
 block discarded – undo
3960 3960
 				return false;
3961 3961
 			} else {
3962 3962
 				$q_array = explode(" ", $q);
3963
-				foreach ($q_array as $q_item){
3964
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
3963
+				foreach ($q_array as $q_item) {
3964
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
3965 3965
 					$additional_query .= " AND (";
3966 3966
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
3967 3967
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
@@ -3976,11 +3976,11 @@  discard block
 block discarded – undo
3976 3976
 			}
3977 3977
 		}
3978 3978
 		if ($globalDBdriver == 'mysql') {
3979
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3979
+			$query = "SELECT spotter_output.* FROM spotter_output 
3980 3980
 				WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
3981 3981
 				AND spotter_output.date < UTC_TIMESTAMP()";
3982 3982
 		} else {
3983
-			$query  = "SELECT spotter_output.* FROM spotter_output 
3983
+			$query = "SELECT spotter_output.* FROM spotter_output 
3984 3984
 				WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
3985 3985
 				AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
3986 3986
 		}
@@ -3997,11 +3997,11 @@  discard block
 block discarded – undo
3997 3997
 	* @return Array the airline list
3998 3998
 	*
3999 3999
 	*/
4000
-	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '')
4000
+	public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4001 4001
 	{
4002 4002
 		global $globalDBdriver;
4003
-		$filter_query = $this->getFilter($filters,true,true);
4004
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4003
+		$filter_query = $this->getFilter($filters, true, true);
4004
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4005 4005
 		 			FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'";
4006 4006
 		if ($olderthanmonths > 0) {
4007 4007
 			if ($globalDBdriver == 'mysql') {
@@ -4021,28 +4021,28 @@  discard block
 block discarded – undo
4021 4021
 		if ($year != '') {
4022 4022
 			if ($globalDBdriver == 'mysql') {
4023 4023
 				$query .= " AND YEAR(spotter_output.date) = :year";
4024
-				$query_values = array_merge($query_values,array(':year' => $year));
4024
+				$query_values = array_merge($query_values, array(':year' => $year));
4025 4025
 			} else {
4026 4026
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4027
-				$query_values = array_merge($query_values,array(':year' => $year));
4027
+				$query_values = array_merge($query_values, array(':year' => $year));
4028 4028
 			}
4029 4029
 		}
4030 4030
 		if ($month != '') {
4031 4031
 			if ($globalDBdriver == 'mysql') {
4032 4032
 				$query .= " AND MONTH(spotter_output.date) = :month";
4033
-				$query_values = array_merge($query_values,array(':month' => $month));
4033
+				$query_values = array_merge($query_values, array(':month' => $month));
4034 4034
 			} else {
4035 4035
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4036
-				$query_values = array_merge($query_values,array(':month' => $month));
4036
+				$query_values = array_merge($query_values, array(':month' => $month));
4037 4037
 			}
4038 4038
 		}
4039 4039
 		if ($day != '') {
4040 4040
 			if ($globalDBdriver == 'mysql') {
4041 4041
 				$query .= " AND DAY(spotter_output.date) = :day";
4042
-				$query_values = array_merge($query_values,array(':day' => $day));
4042
+				$query_values = array_merge($query_values, array(':day' => $day));
4043 4043
 			} else {
4044 4044
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4045
-				$query_values = array_merge($query_values,array(':day' => $day));
4045
+				$query_values = array_merge($query_values, array(':day' => $day));
4046 4046
 			}
4047 4047
 		}
4048 4048
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
@@ -4052,7 +4052,7 @@  discard block
 block discarded – undo
4052 4052
 		$sth->execute($query_values);
4053 4053
 		$airline_array = array();
4054 4054
 		$temp_array = array();
4055
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4055
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4056 4056
 		{
4057 4057
 			$temp_array['airline_name'] = $row['airline_name'];
4058 4058
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4069,11 +4069,11 @@  discard block
 block discarded – undo
4069 4069
 	* @return Array the pilots list
4070 4070
 	*
4071 4071
 	*/
4072
-	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '')
4072
+	public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4073 4073
 	{
4074 4074
 		global $globalDBdriver;
4075
-		$filter_query = $this->getFilter($filters,true,true);
4076
-		$query  = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source
4075
+		$filter_query = $this->getFilter($filters, true, true);
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 4078
                 if ($olderthanmonths > 0) {
4079 4079
             		if ($globalDBdriver == 'mysql') {
@@ -4093,28 +4093,28 @@  discard block
 block discarded – undo
4093 4093
 		if ($year != '') {
4094 4094
 			if ($globalDBdriver == 'mysql') {
4095 4095
 				$query .= " AND YEAR(spotter_output.date) = :year";
4096
-				$query_values = array_merge($query_values,array(':year' => $year));
4096
+				$query_values = array_merge($query_values, array(':year' => $year));
4097 4097
 			} else {
4098 4098
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4099
-				$query_values = array_merge($query_values,array(':year' => $year));
4099
+				$query_values = array_merge($query_values, array(':year' => $year));
4100 4100
 			}
4101 4101
 		}
4102 4102
 		if ($month != '') {
4103 4103
 			if ($globalDBdriver == 'mysql') {
4104 4104
 				$query .= " AND MONTH(spotter_output.date) = :month";
4105
-				$query_values = array_merge($query_values,array(':month' => $month));
4105
+				$query_values = array_merge($query_values, array(':month' => $month));
4106 4106
 			} else {
4107 4107
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4108
-				$query_values = array_merge($query_values,array(':month' => $month));
4108
+				$query_values = array_merge($query_values, array(':month' => $month));
4109 4109
 			}
4110 4110
 		}
4111 4111
 		if ($day != '') {
4112 4112
 			if ($globalDBdriver == 'mysql') {
4113 4113
 				$query .= " AND DAY(spotter_output.date) = :day";
4114
-				$query_values = array_merge($query_values,array(':day' => $day));
4114
+				$query_values = array_merge($query_values, array(':day' => $day));
4115 4115
 			} else {
4116 4116
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4117
-				$query_values = array_merge($query_values,array(':day' => $day));
4117
+				$query_values = array_merge($query_values, array(':day' => $day));
4118 4118
 			}
4119 4119
 		}
4120 4120
 		
@@ -4126,7 +4126,7 @@  discard block
 block discarded – undo
4126 4126
 		$sth->execute($query_values);
4127 4127
 		$airline_array = array();
4128 4128
 		$temp_array = array();
4129
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4129
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4130 4130
 		{
4131 4131
 			$temp_array['pilot_name'] = $row['pilot_name'];
4132 4132
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4146,7 +4146,7 @@  discard block
 block discarded – undo
4146 4146
 	public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
4147 4147
 	{
4148 4148
 		global $globalDBdriver;
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
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 4151
                 if ($olderthanmonths > 0) {
4152 4152
             		if ($globalDBdriver == 'mysql') {
@@ -4172,7 +4172,7 @@  discard block
 block discarded – undo
4172 4172
 		$airline_array = array();
4173 4173
 		$temp_array = array();
4174 4174
         
4175
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4175
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4176 4176
 		{
4177 4177
 			$temp_array['pilot_name'] = $row['pilot_name'];
4178 4178
 			$temp_array['pilot_id'] = $row['pilot_id'];
@@ -4190,11 +4190,11 @@  discard block
 block discarded – undo
4190 4190
 	* @return Array the pilots list
4191 4191
 	*
4192 4192
 	*/
4193
-	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
4193
+	public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
4194 4194
 	{
4195 4195
 		global $globalDBdriver;
4196
-		$filter_query = $this->getFilter($filters,true,true);
4197
-		$query  = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4196
+		$filter_query = $this->getFilter($filters, true, true);
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 4199
                 if ($olderthanmonths > 0) {
4200 4200
             		if ($globalDBdriver == 'mysql') {
@@ -4214,28 +4214,28 @@  discard block
 block discarded – undo
4214 4214
 		if ($year != '') {
4215 4215
 			if ($globalDBdriver == 'mysql') {
4216 4216
 				$query .= " AND YEAR(spotter_output.date) = :year";
4217
-				$query_values = array_merge($query_values,array(':year' => $year));
4217
+				$query_values = array_merge($query_values, array(':year' => $year));
4218 4218
 			} else {
4219 4219
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4220
-				$query_values = array_merge($query_values,array(':year' => $year));
4220
+				$query_values = array_merge($query_values, array(':year' => $year));
4221 4221
 			}
4222 4222
 		}
4223 4223
 		if ($month != '') {
4224 4224
 			if ($globalDBdriver == 'mysql') {
4225 4225
 				$query .= " AND MONTH(spotter_output.date) = :month";
4226
-				$query_values = array_merge($query_values,array(':month' => $month));
4226
+				$query_values = array_merge($query_values, array(':month' => $month));
4227 4227
 			} else {
4228 4228
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4229
-				$query_values = array_merge($query_values,array(':month' => $month));
4229
+				$query_values = array_merge($query_values, array(':month' => $month));
4230 4230
 			}
4231 4231
 		}
4232 4232
 		if ($day != '') {
4233 4233
 			if ($globalDBdriver == 'mysql') {
4234 4234
 				$query .= " AND DAY(spotter_output.date) = :day";
4235
-				$query_values = array_merge($query_values,array(':day' => $day));
4235
+				$query_values = array_merge($query_values, array(':day' => $day));
4236 4236
 			} else {
4237 4237
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4238
-				$query_values = array_merge($query_values,array(':day' => $day));
4238
+				$query_values = array_merge($query_values, array(':day' => $day));
4239 4239
 			}
4240 4240
 		}
4241 4241
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
@@ -4245,7 +4245,7 @@  discard block
 block discarded – undo
4245 4245
 		$sth->execute($query_values);
4246 4246
 		$airline_array = array();
4247 4247
 		$temp_array = array();
4248
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4248
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4249 4249
 		{
4250 4250
 			$temp_array['owner_name'] = $row['owner_name'];
4251 4251
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4260,11 +4260,11 @@  discard block
 block discarded – undo
4260 4260
 	* @return Array the pilots list
4261 4261
 	*
4262 4262
 	*/
4263
-	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
4263
+	public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
4264 4264
 	{
4265 4265
 		global $globalDBdriver;
4266
-		$filter_query = $this->getFilter($filters,true,true);
4267
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count
4266
+		$filter_query = $this->getFilter($filters, true, true);
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 4269
                 if ($olderthanmonths > 0) {
4270 4270
             		if ($globalDBdriver == 'mysql') {
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 		$airline_array = array();
4291 4291
 		$temp_array = array();
4292 4292
         
4293
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4293
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4294 4294
 		{
4295 4295
 			$temp_array['owner_name'] = $row['owner_name'];
4296 4296
 			$temp_array['owner_count'] = $row['owner_count'];
@@ -4306,11 +4306,11 @@  discard block
 block discarded – undo
4306 4306
 	* @return Array the airline list
4307 4307
 	*
4308 4308
 	*/
4309
-	public function countAllAirlinesByAircraft($aircraft_icao,$filters = array())
4309
+	public function countAllAirlinesByAircraft($aircraft_icao, $filters = array())
4310 4310
 	{
4311
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4312
-		$filter_query = $this->getFilter($filters,true,true);
4313
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4311
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4312
+		$filter_query = $this->getFilter($filters, true, true);
4313
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4314 4314
 		 	    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
4315 4315
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4316 4316
 			    ORDER BY airline_count DESC";
@@ -4322,7 +4322,7 @@  discard block
 block discarded – undo
4322 4322
 		$airline_array = array();
4323 4323
 		$temp_array = array();
4324 4324
         
4325
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4325
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4326 4326
 		{
4327 4327
 			$temp_array['airline_name'] = $row['airline_name'];
4328 4328
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4342,11 +4342,11 @@  discard block
 block discarded – undo
4342 4342
 	* @return Array the airline country list
4343 4343
 	*
4344 4344
 	*/
4345
-	public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array())
4345
+	public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array())
4346 4346
 	{
4347
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
4348
-		$filter_query = $this->getFilter($filters,true,true);
4349
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 
4347
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
4348
+		$filter_query = $this->getFilter($filters, true, true);
4349
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3 
4350 4350
 			FROM spotter_output, countries ".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
4351 4351
 			GROUP BY spotter_output.airline_country, countries.iso3
4352 4352
 			ORDER BY airline_country_count DESC
@@ -4359,7 +4359,7 @@  discard block
 block discarded – undo
4359 4359
 		$airline_country_array = array();
4360 4360
 		$temp_array = array();
4361 4361
         
4362
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4362
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4363 4363
 		{
4364 4364
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4365 4365
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4379,11 +4379,11 @@  discard block
 block discarded – undo
4379 4379
 	* @return Array the airline list
4380 4380
 	*
4381 4381
 	*/
4382
-	public function countAllAirlinesByAirport($airport_icao,$filters = array())
4382
+	public function countAllAirlinesByAirport($airport_icao, $filters = array())
4383 4383
 	{
4384
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4385
-		$filter_query = $this->getFilter($filters,true,true);
4386
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4384
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4385
+		$filter_query = $this->getFilter($filters, true, true);
4386
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4387 4387
 		    FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) 
4388 4388
                     GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country
4389 4389
 		    ORDER BY airline_count DESC";
@@ -4395,7 +4395,7 @@  discard block
 block discarded – undo
4395 4395
 		$airline_array = array();
4396 4396
 		$temp_array = array();
4397 4397
         
4398
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4398
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4399 4399
 		{
4400 4400
 			$temp_array['airline_name'] = $row['airline_name'];
4401 4401
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4414,11 +4414,11 @@  discard block
 block discarded – undo
4414 4414
 	* @return Array the airline country list
4415 4415
 	*
4416 4416
 	*/
4417
-	public function countAllAirlineCountriesByAirport($airport_icao,$filters = array())
4417
+	public function countAllAirlineCountriesByAirport($airport_icao, $filters = array())
4418 4418
 	{
4419
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
4420
-		$filter_query = $this->getFilter($filters,true,true);
4421
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4419
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
4420
+		$filter_query = $this->getFilter($filters, true, true);
4421
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4422 4422
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao )
4423 4423
 					GROUP BY spotter_output.airline_country
4424 4424
 					ORDER BY airline_country_count DESC
@@ -4431,7 +4431,7 @@  discard block
 block discarded – undo
4431 4431
 		$airline_country_array = array();
4432 4432
 		$temp_array = array();
4433 4433
         
4434
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4434
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4435 4435
 		{
4436 4436
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4437 4437
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4448,11 +4448,11 @@  discard block
 block discarded – undo
4448 4448
 	* @return Array the airline list
4449 4449
 	*
4450 4450
 	*/
4451
-	public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array())
4451
+	public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array())
4452 4452
 	{
4453
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4454
-		$filter_query = $this->getFilter($filters,true,true);
4455
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4453
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4454
+		$filter_query = $this->getFilter($filters, true, true);
4455
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4456 4456
 		 			FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4457 4457
 					GROUP BY spotter_output.airline_name
4458 4458
 					ORDER BY airline_count DESC";
@@ -4463,7 +4463,7 @@  discard block
 block discarded – undo
4463 4463
 		$airline_array = array();
4464 4464
 		$temp_array = array();
4465 4465
         
4466
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4466
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4467 4467
 		{
4468 4468
 			$temp_array['airline_name'] = $row['airline_name'];
4469 4469
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4483,11 +4483,11 @@  discard block
 block discarded – undo
4483 4483
 	* @return Array the airline country list
4484 4484
 	*
4485 4485
 	*/
4486
-	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array())
4486
+	public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array())
4487 4487
 	{
4488
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
4489
-		$filter_query = $this->getFilter($filters,true,true);
4490
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4488
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
4489
+		$filter_query = $this->getFilter($filters, true, true);
4490
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4491 4491
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
4492 4492
 					GROUP BY spotter_output.airline_country
4493 4493
 					ORDER BY airline_country_count DESC
@@ -4500,7 +4500,7 @@  discard block
 block discarded – undo
4500 4500
 		$airline_country_array = array();
4501 4501
 		$temp_array = array();
4502 4502
         
4503
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4503
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4504 4504
 		{
4505 4505
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4506 4506
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4516,11 +4516,11 @@  discard block
 block discarded – undo
4516 4516
 	* @return Array the airline list
4517 4517
 	*
4518 4518
 	*/
4519
-	public function countAllAirlinesByDate($date,$filters = array())
4519
+	public function countAllAirlinesByDate($date, $filters = array())
4520 4520
 	{
4521 4521
 		global $globalTimezone, $globalDBdriver;
4522
-		$filter_query = $this->getFilter($filters,true,true);
4523
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4522
+		$filter_query = $this->getFilter($filters, true, true);
4523
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4524 4524
 		if ($globalTimezone != '') {
4525 4525
 			date_default_timezone_set($globalTimezone);
4526 4526
 			$datetime = new DateTime($date);
@@ -4528,12 +4528,12 @@  discard block
 block discarded – undo
4528 4528
 		} else $offset = '+00:00';
4529 4529
 
4530 4530
 		if ($globalDBdriver == 'mysql') {
4531
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4531
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4532 4532
 		 			FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4533 4533
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country 
4534 4534
 					ORDER BY airline_count DESC";
4535 4535
 		} else {
4536
-			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4536
+			$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4537 4537
 		 			FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4538 4538
 					GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country
4539 4539
 					ORDER BY airline_count DESC";
@@ -4544,7 +4544,7 @@  discard block
 block discarded – undo
4544 4544
 
4545 4545
 		$airline_array = array();
4546 4546
 		$temp_array = array();
4547
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4547
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4548 4548
 		{
4549 4549
 			$temp_array['airline_name'] = $row['airline_name'];
4550 4550
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4564,11 +4564,11 @@  discard block
 block discarded – undo
4564 4564
 	* @return Array the airline country list
4565 4565
 	*
4566 4566
 	*/
4567
-	public function countAllAirlineCountriesByDate($date,$filters = array())
4567
+	public function countAllAirlineCountriesByDate($date, $filters = array())
4568 4568
 	{
4569 4569
 		global $globalTimezone, $globalDBdriver;
4570
-		$filter_query = $this->getFilter($filters,true,true);
4571
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
4570
+		$filter_query = $this->getFilter($filters, true, true);
4571
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
4572 4572
 		if ($globalTimezone != '') {
4573 4573
 			date_default_timezone_set($globalTimezone);
4574 4574
 			$datetime = new DateTime($date);
@@ -4576,13 +4576,13 @@  discard block
 block discarded – undo
4576 4576
 		} else $offset = '+00:00';
4577 4577
 		
4578 4578
 		if ($globalDBdriver == 'mysql') {
4579
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4579
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4580 4580
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
4581 4581
 					GROUP BY spotter_output.airline_country
4582 4582
 					ORDER BY airline_country_count DESC
4583 4583
 					LIMIT 10 OFFSET 0";
4584 4584
 		} else {
4585
-			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4585
+			$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4586 4586
 		 			FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
4587 4587
 					GROUP BY spotter_output.airline_country
4588 4588
 					ORDER BY airline_country_count DESC
@@ -4594,7 +4594,7 @@  discard block
 block discarded – undo
4594 4594
  
4595 4595
 		$airline_country_array = array();
4596 4596
 		$temp_array = array();
4597
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4597
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4598 4598
 		{
4599 4599
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4600 4600
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4611,11 +4611,11 @@  discard block
 block discarded – undo
4611 4611
 	* @return Array the airline list
4612 4612
 	*
4613 4613
 	*/
4614
-	public function countAllAirlinesByIdent($ident,$filters = array())
4614
+	public function countAllAirlinesByIdent($ident, $filters = array())
4615 4615
 	{
4616
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
4617
-		$filter_query = $this->getFilter($filters,true,true);
4618
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4616
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
4617
+		$filter_query = $this->getFilter($filters, true, true);
4618
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4619 4619
 		 		FROM spotter_output".$filter_query." spotter_output.ident = :ident  
4620 4620
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4621 4621
 				ORDER BY airline_count DESC";
@@ -4632,11 +4632,11 @@  discard block
 block discarded – undo
4632 4632
 	* @return Array the airline list
4633 4633
 	*
4634 4634
 	*/
4635
-	public function countAllAirlinesByOwner($owner,$filters = array())
4635
+	public function countAllAirlinesByOwner($owner, $filters = array())
4636 4636
 	{
4637
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4638
-		$filter_query = $this->getFilter($filters,true,true);
4639
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4637
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4638
+		$filter_query = $this->getFilter($filters, true, true);
4639
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4640 4640
 		 		FROM spotter_output".$filter_query." spotter_output.owner_name = :owner  
4641 4641
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4642 4642
 				ORDER BY airline_count DESC";
@@ -4653,47 +4653,47 @@  discard block
 block discarded – undo
4653 4653
 	* @return String Duration of all flights
4654 4654
 	*
4655 4655
 	*/
4656
-	public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
4656
+	public function getFlightDurationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
4657 4657
 	{
4658 4658
 		global $globalDBdriver;
4659
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4660
-		$filter_query = $this->getFilter($filters,true,true);
4661
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4659
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4660
+		$filter_query = $this->getFilter($filters, true, true);
4661
+		$query = "SELECT SUM(last_seen - date) AS duration 
4662 4662
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
4663 4663
 				AND last_seen > date";
4664 4664
 		$query_values = array();
4665 4665
 		if ($year != '') {
4666 4666
 			if ($globalDBdriver == 'mysql') {
4667 4667
 				$query .= " AND YEAR(spotter_output.date) = :year";
4668
-				$query_values = array_merge($query_values,array(':year' => $year));
4668
+				$query_values = array_merge($query_values, array(':year' => $year));
4669 4669
 			} else {
4670 4670
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4671
-				$query_values = array_merge($query_values,array(':year' => $year));
4671
+				$query_values = array_merge($query_values, array(':year' => $year));
4672 4672
 			}
4673 4673
 		}
4674 4674
 		if ($month != '') {
4675 4675
 			if ($globalDBdriver == 'mysql') {
4676 4676
 				$query .= " AND MONTH(spotter_output.date) = :month";
4677
-				$query_values = array_merge($query_values,array(':month' => $month));
4677
+				$query_values = array_merge($query_values, array(':month' => $month));
4678 4678
 			} else {
4679 4679
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4680
-				$query_values = array_merge($query_values,array(':month' => $month));
4680
+				$query_values = array_merge($query_values, array(':month' => $month));
4681 4681
 			}
4682 4682
 		}
4683 4683
 		if ($day != '') {
4684 4684
 			if ($globalDBdriver == 'mysql') {
4685 4685
 				$query .= " AND DAY(spotter_output.date) = :day";
4686
-				$query_values = array_merge($query_values,array(':day' => $day));
4686
+				$query_values = array_merge($query_values, array(':day' => $day));
4687 4687
 			} else {
4688 4688
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4689
-				$query_values = array_merge($query_values,array(':day' => $day));
4689
+				$query_values = array_merge($query_values, array(':day' => $day));
4690 4690
 			}
4691 4691
 		}
4692
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4692
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4693 4693
 		$sth = $this->db->prepare($query);
4694 4694
 		$sth->execute($query_values);
4695 4695
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4696
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4696
+		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4697 4697
 		elseif ($result[0]['duration'] == '') return 0;
4698 4698
 		else return $result[0]['duration'];
4699 4699
 	}
@@ -4704,14 +4704,14 @@  discard block
 block discarded – undo
4704 4704
 	* @return String Duration of all flights
4705 4705
 	*
4706 4706
 	*/
4707
-	public function countFlightsByOwner($owner,$filters = array())
4707
+	public function countFlightsByOwner($owner, $filters = array())
4708 4708
 	{
4709
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
4710
-		$filter_query = $this->getFilter($filters,true,true);
4711
-		$query  = "SELECT COUNT(*) AS nb 
4709
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
4710
+		$filter_query = $this->getFilter($filters, true, true);
4711
+		$query = "SELECT COUNT(*) AS nb 
4712 4712
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
4713 4713
 		$query_values = array();
4714
-		$query_values = array_merge($query_values,array(':owner' => $owner));
4714
+		$query_values = array_merge($query_values, array(':owner' => $owner));
4715 4715
 		$sth = $this->db->prepare($query);
4716 4716
 		$sth->execute($query_values);
4717 4717
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4724,14 +4724,14 @@  discard block
 block discarded – undo
4724 4724
 	* @return String Duration of all flights
4725 4725
 	*
4726 4726
 	*/
4727
-	public function countFlightsByPilot($pilot,$filters = array())
4727
+	public function countFlightsByPilot($pilot, $filters = array())
4728 4728
 	{
4729
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4730
-		$filter_query = $this->getFilter($filters,true,true);
4731
-		$query  = "SELECT COUNT(*) AS nb 
4729
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4730
+		$filter_query = $this->getFilter($filters, true, true);
4731
+		$query = "SELECT COUNT(*) AS nb 
4732 4732
 				FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)";
4733 4733
 		$query_values = array();
4734
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4734
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4735 4735
 		$sth = $this->db->prepare($query);
4736 4736
 		$sth->execute($query_values);
4737 4737
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -4744,47 +4744,47 @@  discard block
 block discarded – undo
4744 4744
 	* @return String Duration of all flights
4745 4745
 	*
4746 4746
 	*/
4747
-	public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
4747
+	public function getFlightDurationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
4748 4748
 	{
4749 4749
 		global $globalDBdriver;
4750
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4751
-		$filter_query = $this->getFilter($filters,true,true);
4752
-		$query  = "SELECT SUM(last_seen - date) AS duration 
4750
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4751
+		$filter_query = $this->getFilter($filters, true, true);
4752
+		$query = "SELECT SUM(last_seen - date) AS duration 
4753 4753
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4754 4754
 		 		AND last_seen > date";
4755 4755
 		$query_values = array();
4756 4756
 		if ($year != '') {
4757 4757
 			if ($globalDBdriver == 'mysql') {
4758 4758
 				$query .= " AND YEAR(spotter_output.date) = :year";
4759
-				$query_values = array_merge($query_values,array(':year' => $year));
4759
+				$query_values = array_merge($query_values, array(':year' => $year));
4760 4760
 			} else {
4761 4761
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4762
-				$query_values = array_merge($query_values,array(':year' => $year));
4762
+				$query_values = array_merge($query_values, array(':year' => $year));
4763 4763
 			}
4764 4764
 		}
4765 4765
 		if ($month != '') {
4766 4766
 			if ($globalDBdriver == 'mysql') {
4767 4767
 				$query .= " AND MONTH(spotter_output.date) = :month";
4768
-				$query_values = array_merge($query_values,array(':month' => $month));
4768
+				$query_values = array_merge($query_values, array(':month' => $month));
4769 4769
 			} else {
4770 4770
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4771
-				$query_values = array_merge($query_values,array(':month' => $month));
4771
+				$query_values = array_merge($query_values, array(':month' => $month));
4772 4772
 			}
4773 4773
 		}
4774 4774
 		if ($day != '') {
4775 4775
 			if ($globalDBdriver == 'mysql') {
4776 4776
 				$query .= " AND DAY(spotter_output.date) = :day";
4777
-				$query_values = array_merge($query_values,array(':day' => $day));
4777
+				$query_values = array_merge($query_values, array(':day' => $day));
4778 4778
 			} else {
4779 4779
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4780
-				$query_values = array_merge($query_values,array(':day' => $day));
4780
+				$query_values = array_merge($query_values, array(':day' => $day));
4781 4781
 			}
4782 4782
 		}
4783
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
4783
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
4784 4784
 		$sth = $this->db->prepare($query);
4785 4785
 		$sth->execute($query_values);
4786 4786
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4787
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4787
+		if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']);
4788 4788
 		else return $result[0]['duration'];
4789 4789
 	}
4790 4790
 
@@ -4794,11 +4794,11 @@  discard block
 block discarded – undo
4794 4794
 	* @return Array the airline list
4795 4795
 	*
4796 4796
 	*/
4797
-	public function countAllAirlinesByPilot($pilot,$filters = array())
4797
+	public function countAllAirlinesByPilot($pilot, $filters = array())
4798 4798
 	{
4799
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
4800
-		$filter_query = $this->getFilter($filters,true,true);
4801
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4799
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
4800
+		$filter_query = $this->getFilter($filters, true, true);
4801
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4802 4802
 		 		FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
4803 4803
 				GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country
4804 4804
 				ORDER BY airline_count DESC";
@@ -4815,25 +4815,25 @@  discard block
 block discarded – undo
4815 4815
 	* @return Array the airline list
4816 4816
 	*
4817 4817
 	*/
4818
-	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
4818
+	public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4819 4819
 	{
4820
-		$filter_query = $this->getFilter($filters,true,true);
4821
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4822
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4820
+		$filter_query = $this->getFilter($filters, true, true);
4821
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4822
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4823 4823
 
4824
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4824
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4825 4825
 		 			FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4826 4826
 					GROUP BY spotter_output.airline_name
4827 4827
 					ORDER BY airline_count DESC";
4828 4828
       
4829 4829
 		
4830 4830
 		$sth = $this->db->prepare($query);
4831
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4831
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4832 4832
       
4833 4833
 		$airline_array = array();
4834 4834
 		$temp_array = array();
4835 4835
         
4836
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4836
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4837 4837
 		{
4838 4838
 			$temp_array['airline_name'] = $row['airline_name'];
4839 4839
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4851,13 +4851,13 @@  discard block
 block discarded – undo
4851 4851
 	* @return Array the airline country list
4852 4852
 	*
4853 4853
 	*/
4854
-	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array())
4854
+	public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
4855 4855
 	{
4856
-		$filter_query = $this->getFilter($filters,true,true);
4857
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
4858
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
4856
+		$filter_query = $this->getFilter($filters, true, true);
4857
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
4858
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
4859 4859
       
4860
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4860
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4861 4861
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
4862 4862
 				GROUP BY spotter_output.airline_country
4863 4863
 				ORDER BY airline_country_count DESC
@@ -4865,11 +4865,11 @@  discard block
 block discarded – undo
4865 4865
       
4866 4866
 		
4867 4867
 		$sth = $this->db->prepare($query);
4868
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
4868
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
4869 4869
       
4870 4870
 		$airline_country_array = array();
4871 4871
 		$temp_array = array();
4872
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4872
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4873 4873
 		{
4874 4874
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4875 4875
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4887,11 +4887,11 @@  discard block
 block discarded – undo
4887 4887
 	* @return Array the airline list
4888 4888
 	*
4889 4889
 	*/
4890
-	public function countAllAirlinesByCountry($country,$filters = array())
4890
+	public function countAllAirlinesByCountry($country, $filters = array())
4891 4891
 	{
4892
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4893
-		$filter_query = $this->getFilter($filters,true,true);
4894
-		$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4892
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4893
+		$filter_query = $this->getFilter($filters, true, true);
4894
+		$query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
4895 4895
 		 	    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
4896 4896
 			    GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country 
4897 4897
 			    ORDER BY airline_count DESC";
@@ -4902,7 +4902,7 @@  discard block
 block discarded – undo
4902 4902
 
4903 4903
 		$airline_array = array();
4904 4904
 		$temp_array = array();
4905
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4905
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4906 4906
 		{
4907 4907
 			$temp_array['airline_name'] = $row['airline_name'];
4908 4908
 			$temp_array['airline_icao'] = $row['airline_icao'];
@@ -4921,11 +4921,11 @@  discard block
 block discarded – undo
4921 4921
 	* @return Array the airline country list
4922 4922
 	*
4923 4923
 	*/
4924
-	public function countAllAirlineCountriesByCountry($country,$filters = array())
4924
+	public function countAllAirlineCountriesByCountry($country, $filters = array())
4925 4925
 	{
4926
-		$filter_query = $this->getFilter($filters,true,true);
4927
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
4928
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4926
+		$filter_query = $this->getFilter($filters, true, true);
4927
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
4928
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
4929 4929
 		 		FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
4930 4930
 				GROUP BY spotter_output.airline_country
4931 4931
 				ORDER BY airline_country_count DESC
@@ -4937,7 +4937,7 @@  discard block
 block discarded – undo
4937 4937
 
4938 4938
 		$airline_country_array = array();
4939 4939
 		$temp_array = array();
4940
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
4940
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
4941 4941
 		{
4942 4942
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
4943 4943
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -4957,35 +4957,35 @@  discard block
 block discarded – undo
4957 4957
 	public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
4958 4958
 	{
4959 4959
 		global $globalDBdriver;
4960
-		$filter_query = $this->getFilter($filters,true,true);
4961
-		$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3
4960
+		$filter_query = $this->getFilter($filters, true, true);
4961
+		$query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count, countries.iso3 AS airline_country_iso3
4962 4962
 		 			FROM countries, spotter_output".$filter_query." countries.name = spotter_output.airline_country AND spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'";
4963 4963
 		$query_values = array();
4964 4964
 		if ($year != '') {
4965 4965
 			if ($globalDBdriver == 'mysql') {
4966 4966
 				$query .= " AND YEAR(spotter_output.date) = :year";
4967
-				$query_values = array_merge($query_values,array(':year' => $year));
4967
+				$query_values = array_merge($query_values, array(':year' => $year));
4968 4968
 			} else {
4969 4969
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
4970
-				$query_values = array_merge($query_values,array(':year' => $year));
4970
+				$query_values = array_merge($query_values, array(':year' => $year));
4971 4971
 			}
4972 4972
 		}
4973 4973
 		if ($month != '') {
4974 4974
 			if ($globalDBdriver == 'mysql') {
4975 4975
 				$query .= " AND MONTH(spotter_output.date) = :month";
4976
-				$query_values = array_merge($query_values,array(':month' => $month));
4976
+				$query_values = array_merge($query_values, array(':month' => $month));
4977 4977
 			} else {
4978 4978
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
4979
-				$query_values = array_merge($query_values,array(':month' => $month));
4979
+				$query_values = array_merge($query_values, array(':month' => $month));
4980 4980
 			}
4981 4981
 		}
4982 4982
 		if ($day != '') {
4983 4983
 			if ($globalDBdriver == 'mysql') {
4984 4984
 				$query .= " AND DAY(spotter_output.date) = :day";
4985
-				$query_values = array_merge($query_values,array(':day' => $day));
4985
+				$query_values = array_merge($query_values, array(':day' => $day));
4986 4986
 			} else {
4987 4987
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
4988
-				$query_values = array_merge($query_values,array(':day' => $day));
4988
+				$query_values = array_merge($query_values, array(':day' => $day));
4989 4989
 			}
4990 4990
 		}
4991 4991
 		$query .= " GROUP BY spotter_output.airline_country, countries.iso3
@@ -4997,7 +4997,7 @@  discard block
 block discarded – undo
4997 4997
 
4998 4998
 		$airline_array = array();
4999 4999
 		$temp_array = array();
5000
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5000
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5001 5001
 		{
5002 5002
 			$temp_array['airline_country_count'] = $row['airline_country_count'];
5003 5003
 			$temp_array['airline_country'] = $row['airline_country'];
@@ -5014,11 +5014,11 @@  discard block
 block discarded – undo
5014 5014
 	* @return Array the airline country list
5015 5015
 	*
5016 5016
 	*/
5017
-	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5017
+	public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5018 5018
 	{
5019 5019
 		global $globalDBdriver;
5020 5020
 		//$filter_query = $this->getFilter($filters,true,true);
5021
-		$Connection= new Connection($this->db);
5021
+		$Connection = new Connection($this->db);
5022 5022
 		if (!$Connection->tableExists('countries')) return array();
5023 5023
 		/*
5024 5024
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -5033,7 +5033,7 @@  discard block
 block discarded – undo
5033 5033
 */
5034 5034
 		require_once('class.SpotterLive.php');
5035 5035
 		$SpotterLive = new SpotterLive();
5036
-		$filter_query = $SpotterLive->getFilter($filters,true,true);
5036
+		$filter_query = $SpotterLive->getFilter($filters, true, true);
5037 5037
 		$filter_query .= ' over_country IS NOT NULL';
5038 5038
                 if ($olderthanmonths > 0) {
5039 5039
 			if ($globalDBdriver == 'mysql') {
@@ -5060,7 +5060,7 @@  discard block
 block discarded – undo
5060 5060
 		$flight_array = array();
5061 5061
 		$temp_array = array();
5062 5062
         
5063
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5063
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5064 5064
 		{
5065 5065
 			$temp_array['flight_count'] = $row['nb'];
5066 5066
 			$temp_array['flight_country'] = $row['name'];
@@ -5078,11 +5078,11 @@  discard block
 block discarded – undo
5078 5078
 	* @return Array the aircraft list
5079 5079
 	*
5080 5080
 	*/
5081
-	public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
5081
+	public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5082 5082
 	{
5083 5083
 		global $globalDBdriver;
5084
-		$filter_query = $this->getFilter($filters,true,true);
5085
-		$query  = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5084
+		$filter_query = $this->getFilter($filters, true, true);
5085
+		$query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5086 5086
 		    FROM spotter_output ".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> ''";
5087 5087
 		if ($olderthanmonths > 0) {
5088 5088
 			if ($globalDBdriver == 'mysql') {
@@ -5102,28 +5102,28 @@  discard block
 block discarded – undo
5102 5102
 		if ($year != '') {
5103 5103
 			if ($globalDBdriver == 'mysql') {
5104 5104
 				$query .= " AND YEAR(spotter_output.date) = :year";
5105
-				$query_values = array_merge($query_values,array(':year' => $year));
5105
+				$query_values = array_merge($query_values, array(':year' => $year));
5106 5106
 			} else {
5107 5107
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5108
-				$query_values = array_merge($query_values,array(':year' => $year));
5108
+				$query_values = array_merge($query_values, array(':year' => $year));
5109 5109
 			}
5110 5110
 		}
5111 5111
 		if ($month != '') {
5112 5112
 			if ($globalDBdriver == 'mysql') {
5113 5113
 				$query .= " AND MONTH(spotter_output.date) = :month";
5114
-				$query_values = array_merge($query_values,array(':month' => $month));
5114
+				$query_values = array_merge($query_values, array(':month' => $month));
5115 5115
 			} else {
5116 5116
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5117
-				$query_values = array_merge($query_values,array(':month' => $month));
5117
+				$query_values = array_merge($query_values, array(':month' => $month));
5118 5118
 			}
5119 5119
 		}
5120 5120
 		if ($day != '') {
5121 5121
 			if ($globalDBdriver == 'mysql') {
5122 5122
 				$query .= " AND DAY(spotter_output.date) = :day";
5123
-				$query_values = array_merge($query_values,array(':day' => $day));
5123
+				$query_values = array_merge($query_values, array(':day' => $day));
5124 5124
 			} else {
5125 5125
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5126
-				$query_values = array_merge($query_values,array(':day' => $day));
5126
+				$query_values = array_merge($query_values, array(':day' => $day));
5127 5127
 			}
5128 5128
 		}
5129 5129
 
@@ -5135,7 +5135,7 @@  discard block
 block discarded – undo
5135 5135
 
5136 5136
 		$aircraft_array = array();
5137 5137
 		$temp_array = array();
5138
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5138
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5139 5139
 		{
5140 5140
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5141 5141
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5152,11 +5152,11 @@  discard block
 block discarded – undo
5152 5152
 	* @return Array the aircraft list
5153 5153
 	*
5154 5154
 	*/
5155
-	public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '')
5155
+	public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
5156 5156
 	{
5157 5157
 		global $globalDBdriver;
5158
-		$filter_query = $this->getFilter($filters,true,true);
5159
-		$query  = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5158
+		$filter_query = $this->getFilter($filters, true, true);
5159
+		$query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5160 5160
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA'";
5161 5161
 		if ($olderthanmonths > 0) {
5162 5162
 			if ($globalDBdriver == 'mysql') {
@@ -5176,28 +5176,28 @@  discard block
 block discarded – undo
5176 5176
 		if ($year != '') {
5177 5177
 			if ($globalDBdriver == 'mysql') {
5178 5178
 				$query .= " AND YEAR(spotter_output.date) = :year";
5179
-				$query_values = array_merge($query_values,array(':year' => $year));
5179
+				$query_values = array_merge($query_values, array(':year' => $year));
5180 5180
 			} else {
5181 5181
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5182
-				$query_values = array_merge($query_values,array(':year' => $year));
5182
+				$query_values = array_merge($query_values, array(':year' => $year));
5183 5183
 			}
5184 5184
 		}
5185 5185
 		if ($month != '') {
5186 5186
 			if ($globalDBdriver == 'mysql') {
5187 5187
 				$query .= " AND MONTH(spotter_output.date) = :month";
5188
-				$query_values = array_merge($query_values,array(':month' => $month));
5188
+				$query_values = array_merge($query_values, array(':month' => $month));
5189 5189
 			} else {
5190 5190
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5191
-				$query_values = array_merge($query_values,array(':month' => $month));
5191
+				$query_values = array_merge($query_values, array(':month' => $month));
5192 5192
 			}
5193 5193
 		}
5194 5194
 		if ($day != '') {
5195 5195
 			if ($globalDBdriver == 'mysql') {
5196 5196
 				$query .= " AND DAY(spotter_output.date) = :day";
5197
-				$query_values = array_merge($query_values,array(':day' => $day));
5197
+				$query_values = array_merge($query_values, array(':day' => $day));
5198 5198
 			} else {
5199 5199
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5200
-				$query_values = array_merge($query_values,array(':day' => $day));
5200
+				$query_values = array_merge($query_values, array(':day' => $day));
5201 5201
 			}
5202 5202
 		}
5203 5203
 
@@ -5209,7 +5209,7 @@  discard block
 block discarded – undo
5209 5209
 
5210 5210
 		$aircraft_array = array();
5211 5211
 		$temp_array = array();
5212
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5212
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5213 5213
 		{
5214 5214
 			$temp_array['airline_icao'] = $row['airline_icao'];
5215 5215
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5227,11 +5227,11 @@  discard block
 block discarded – undo
5227 5227
 	* @return Array the aircraft list
5228 5228
 	*
5229 5229
 	*/
5230
-	public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
5230
+	public function countAllAircraftTypesByMonths($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
5231 5231
 	{
5232 5232
 		global $globalDBdriver;
5233
-		$filter_query = $this->getFilter($filters,true,true);
5234
-		$query  = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5233
+		$filter_query = $this->getFilter($filters, true, true);
5234
+		$query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5235 5235
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_name  <> '' AND spotter_output.aircraft_icao  <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' ";
5236 5236
 		if ($olderthanmonths > 0) {
5237 5237
 			if ($globalDBdriver == 'mysql') {
@@ -5256,7 +5256,7 @@  discard block
 block discarded – undo
5256 5256
 
5257 5257
 		$aircraft_array = array();
5258 5258
 		$temp_array = array();
5259
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5259
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5260 5260
 		{
5261 5261
 			//$temp_array['airline_icao'] = $row['airline_icao'];
5262 5262
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
@@ -5275,13 +5275,13 @@  discard block
 block discarded – undo
5275 5275
 	* @return Array the aircraft list
5276 5276
 	*
5277 5277
 	*/
5278
-	public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array())
5278
+	public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array())
5279 5279
 	{
5280 5280
 		$Image = new Image($this->db);
5281
-		$filter_query = $this->getFilter($filters,true,true);
5282
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
5281
+		$filter_query = $this->getFilter($filters, true, true);
5282
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
5283 5283
 
5284
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5284
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5285 5285
 				FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao  
5286 5286
 				GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5287 5287
 				ORDER BY registration_count DESC";
@@ -5292,14 +5292,14 @@  discard block
 block discarded – undo
5292 5292
 		$aircraft_array = array();
5293 5293
 		$temp_array = array();
5294 5294
         
5295
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5295
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5296 5296
 		{
5297 5297
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5298 5298
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5299 5299
 			$temp_array['registration'] = $row['registration'];
5300 5300
 			$temp_array['airline_name'] = $row['airline_name'];
5301 5301
 			$temp_array['image_thumbnail'] = "";
5302
-			if($row['registration'] != "")
5302
+			if ($row['registration'] != "")
5303 5303
 			{
5304 5304
 				$image_array = $Image->getSpotterImage($row['registration']);
5305 5305
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5318,11 +5318,11 @@  discard block
 block discarded – undo
5318 5318
 	* @return Array the aircraft list
5319 5319
 	*
5320 5320
 	*/
5321
-	public function countAllAircraftTypesByAirline($airline_icao,$filters = array())
5321
+	public function countAllAircraftTypesByAirline($airline_icao, $filters = array())
5322 5322
 	{
5323
-		$filter_query = $this->getFilter($filters,true,true);
5324
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5325
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5323
+		$filter_query = $this->getFilter($filters, true, true);
5324
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5325
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5326 5326
 			    FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao 
5327 5327
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5328 5328
 			    ORDER BY aircraft_icao_count DESC";
@@ -5333,7 +5333,7 @@  discard block
 block discarded – undo
5333 5333
 		$aircraft_array = array();
5334 5334
 		$temp_array = array();
5335 5335
 
5336
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5336
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5337 5337
 		{
5338 5338
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5339 5339
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5351,13 +5351,13 @@  discard block
 block discarded – undo
5351 5351
 	* @return Array the aircraft list
5352 5352
 	*
5353 5353
 	*/
5354
-	public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array())
5354
+	public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array())
5355 5355
 	{
5356
-		$filter_query = $this->getFilter($filters,true,true);
5356
+		$filter_query = $this->getFilter($filters, true, true);
5357 5357
 		$Image = new Image($this->db);
5358
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5358
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5359 5359
 
5360
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5360
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5361 5361
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao 
5362 5362
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5363 5363
 			    ORDER BY registration_count DESC";
@@ -5367,14 +5367,14 @@  discard block
 block discarded – undo
5367 5367
 
5368 5368
 		$aircraft_array = array();
5369 5369
 		$temp_array = array();
5370
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5370
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5371 5371
 		{
5372 5372
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5373 5373
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5374 5374
 			$temp_array['registration'] = $row['registration'];
5375 5375
 			$temp_array['airline_name'] = $row['airline_name'];
5376 5376
 			$temp_array['image_thumbnail'] = "";
5377
-			if($row['registration'] != "")
5377
+			if ($row['registration'] != "")
5378 5378
 			{
5379 5379
 				$image_array = $Image->getSpotterImage($row['registration']);
5380 5380
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5393,11 +5393,11 @@  discard block
 block discarded – undo
5393 5393
 	* @return Array the aircraft list
5394 5394
 	*
5395 5395
 	*/
5396
-	public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array())
5396
+	public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array())
5397 5397
 	{
5398
-		$filter_query = $this->getFilter($filters,true,true);
5399
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
5400
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5398
+		$filter_query = $this->getFilter($filters, true, true);
5399
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
5400
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5401 5401
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao 
5402 5402
 				GROUP BY spotter_output.aircraft_manufacturer 
5403 5403
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5408,7 +5408,7 @@  discard block
 block discarded – undo
5408 5408
 		$aircraft_array = array();
5409 5409
 		$temp_array = array();
5410 5410
 
5411
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5411
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5412 5412
 		{
5413 5413
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5414 5414
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5425,12 +5425,12 @@  discard block
 block discarded – undo
5425 5425
 	* @return Array the aircraft list
5426 5426
 	*
5427 5427
 	*/
5428
-	public function countAllAircraftTypesByAirport($airport_icao,$filters = array())
5428
+	public function countAllAircraftTypesByAirport($airport_icao, $filters = array())
5429 5429
 	{
5430
-		$filter_query = $this->getFilter($filters,true,true);
5431
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5430
+		$filter_query = $this->getFilter($filters, true, true);
5431
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5432 5432
 
5433
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5433
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5434 5434
 				FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) 
5435 5435
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5436 5436
 				ORDER BY aircraft_icao_count DESC";
@@ -5440,7 +5440,7 @@  discard block
 block discarded – undo
5440 5440
 
5441 5441
 		$aircraft_array = array();
5442 5442
 		$temp_array = array();
5443
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5443
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5444 5444
 		{
5445 5445
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5446 5446
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5458,13 +5458,13 @@  discard block
 block discarded – undo
5458 5458
 	* @return Array the aircraft list
5459 5459
 	*
5460 5460
 	*/
5461
-	public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array())
5461
+	public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array())
5462 5462
 	{
5463
-		$filter_query = $this->getFilter($filters,true,true);
5463
+		$filter_query = $this->getFilter($filters, true, true);
5464 5464
 		$Image = new Image($this->db);
5465
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5465
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5466 5466
 
5467
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5467
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5468 5468
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)   
5469 5469
                     GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5470 5470
 		    ORDER BY registration_count DESC";
@@ -5474,14 +5474,14 @@  discard block
 block discarded – undo
5474 5474
 
5475 5475
 		$aircraft_array = array();
5476 5476
 		$temp_array = array();
5477
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5477
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5478 5478
 		{
5479 5479
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5480 5480
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5481 5481
 			$temp_array['registration'] = $row['registration'];
5482 5482
 			$temp_array['airline_name'] = $row['airline_name'];
5483 5483
 			$temp_array['image_thumbnail'] = "";
5484
-			if($row['registration'] != "")
5484
+			if ($row['registration'] != "")
5485 5485
 			{
5486 5486
 				$image_array = $Image->getSpotterImage($row['registration']);
5487 5487
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5499,11 +5499,11 @@  discard block
 block discarded – undo
5499 5499
 	* @return Array the aircraft list
5500 5500
 	*
5501 5501
 	*/
5502
-	public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array())
5502
+	public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array())
5503 5503
 	{
5504
-		$filter_query = $this->getFilter($filters,true,true);
5505
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
5506
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5504
+		$filter_query = $this->getFilter($filters, true, true);
5505
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
5506
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5507 5507
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)  
5508 5508
                     GROUP BY spotter_output.aircraft_manufacturer 
5509 5509
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -5514,7 +5514,7 @@  discard block
 block discarded – undo
5514 5514
 
5515 5515
 		$aircraft_array = array();
5516 5516
 		$temp_array = array();
5517
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5517
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5518 5518
 		{
5519 5519
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5520 5520
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5529,12 +5529,12 @@  discard block
 block discarded – undo
5529 5529
 	* @return Array the aircraft list
5530 5530
 	*
5531 5531
 	*/
5532
-	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array())
5532
+	public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array())
5533 5533
 	{
5534
-		$filter_query = $this->getFilter($filters,true,true);
5535
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5534
+		$filter_query = $this->getFilter($filters, true, true);
5535
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5536 5536
 
5537
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5537
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5538 5538
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
5539 5539
                     GROUP BY spotter_output.aircraft_name 
5540 5540
 					ORDER BY aircraft_icao_count DESC";
@@ -5543,7 +5543,7 @@  discard block
 block discarded – undo
5543 5543
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5544 5544
 		$aircraft_array = array();
5545 5545
 		$temp_array = array();
5546
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5546
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5547 5547
 		{
5548 5548
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5549 5549
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5562,11 +5562,11 @@  discard block
 block discarded – undo
5562 5562
 	*/
5563 5563
 	public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array())
5564 5564
 	{
5565
-		$filter_query = $this->getFilter($filters,true,true);
5565
+		$filter_query = $this->getFilter($filters, true, true);
5566 5566
 		$Image = new Image($this->db);
5567
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
5567
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
5568 5568
 
5569
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5569
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
5570 5570
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
5571 5571
                     GROUP BY spotter_output.registration 
5572 5572
 					ORDER BY registration_count DESC";
@@ -5576,14 +5576,14 @@  discard block
 block discarded – undo
5576 5576
 		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer));
5577 5577
 		$aircraft_array = array();
5578 5578
 		$temp_array = array();
5579
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5579
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5580 5580
 		{
5581 5581
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5582 5582
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5583 5583
 			$temp_array['registration'] = $row['registration'];
5584 5584
 			$temp_array['airline_name'] = $row['airline_name'];
5585 5585
 			$temp_array['image_thumbnail'] = "";
5586
-			if($row['registration'] != "")
5586
+			if ($row['registration'] != "")
5587 5587
 			{
5588 5588
 				$image_array = $Image->getSpotterImage($row['registration']);
5589 5589
 				$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5600,11 +5600,11 @@  discard block
 block discarded – undo
5600 5600
 	* @return Array the aircraft list
5601 5601
 	*
5602 5602
 	*/
5603
-	public function countAllAircraftTypesByDate($date,$filters = array())
5603
+	public function countAllAircraftTypesByDate($date, $filters = array())
5604 5604
 	{
5605 5605
 		global $globalTimezone, $globalDBdriver;
5606
-		$filter_query = $this->getFilter($filters,true,true);
5607
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5606
+		$filter_query = $this->getFilter($filters, true, true);
5607
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5608 5608
 		if ($globalTimezone != '') {
5609 5609
 			date_default_timezone_set($globalTimezone);
5610 5610
 			$datetime = new DateTime($date);
@@ -5612,12 +5612,12 @@  discard block
 block discarded – undo
5612 5612
 		} else $offset = '+00:00';
5613 5613
 
5614 5614
 		if ($globalDBdriver == 'mysql') {
5615
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5615
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5616 5616
 					FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
5617 5617
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5618 5618
 					ORDER BY aircraft_icao_count DESC";
5619 5619
 		} else {
5620
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5620
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5621 5621
 					FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
5622 5622
 					GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
5623 5623
 					ORDER BY aircraft_icao_count DESC";
@@ -5628,7 +5628,7 @@  discard block
 block discarded – undo
5628 5628
 
5629 5629
 		$aircraft_array = array();
5630 5630
 		$temp_array = array();
5631
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5631
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5632 5632
 		{
5633 5633
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5634 5634
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5646,12 +5646,12 @@  discard block
 block discarded – undo
5646 5646
 	* @return Array the aircraft list
5647 5647
 	*
5648 5648
 	*/
5649
-	public function countAllAircraftRegistrationByDate($date,$filters = array())
5649
+	public function countAllAircraftRegistrationByDate($date, $filters = array())
5650 5650
 	{
5651 5651
 		global $globalTimezone, $globalDBdriver;
5652
-		$filter_query = $this->getFilter($filters,true,true);
5652
+		$filter_query = $this->getFilter($filters, true, true);
5653 5653
 		$Image = new Image($this->db);
5654
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5654
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5655 5655
 		if ($globalTimezone != '') {
5656 5656
 			date_default_timezone_set($globalTimezone);
5657 5657
 			$datetime = new DateTime($date);
@@ -5659,12 +5659,12 @@  discard block
 block discarded – undo
5659 5659
 		} else $offset = '+00:00';
5660 5660
 
5661 5661
 		if ($globalDBdriver == 'mysql') {
5662
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5662
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
5663 5663
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5664 5664
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5665 5665
 					ORDER BY registration_count DESC";
5666 5666
 		} else {
5667
-			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
5667
+			$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name    
5668 5668
 					FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5669 5669
 					GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
5670 5670
 					ORDER BY registration_count DESC";
@@ -5675,14 +5675,14 @@  discard block
 block discarded – undo
5675 5675
 
5676 5676
 		$aircraft_array = array();
5677 5677
 		$temp_array = array();
5678
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5678
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5679 5679
 		{
5680 5680
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5681 5681
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5682 5682
 			$temp_array['registration'] = $row['registration'];
5683 5683
 			$temp_array['airline_name'] = $row['airline_name'];
5684 5684
 			$temp_array['image_thumbnail'] = "";
5685
-			if($row['registration'] != "")
5685
+			if ($row['registration'] != "")
5686 5686
 			{
5687 5687
 				$image_array = $Image->getSpotterImage($row['registration']);
5688 5688
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5701,11 +5701,11 @@  discard block
 block discarded – undo
5701 5701
 	* @return Array the aircraft manufacturer list
5702 5702
 	*
5703 5703
 	*/
5704
-	public function countAllAircraftManufacturerByDate($date,$filters = array())
5704
+	public function countAllAircraftManufacturerByDate($date, $filters = array())
5705 5705
 	{
5706 5706
 		global $globalTimezone, $globalDBdriver;
5707
-		$filter_query = $this->getFilter($filters,true,true);
5708
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
5707
+		$filter_query = $this->getFilter($filters, true, true);
5708
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
5709 5709
 		if ($globalTimezone != '') {
5710 5710
 			date_default_timezone_set($globalTimezone);
5711 5711
 			$datetime = new DateTime($date);
@@ -5713,12 +5713,12 @@  discard block
 block discarded – undo
5713 5713
 		} else $offset = '+00:00';
5714 5714
 
5715 5715
 		if ($globalDBdriver == 'mysql') {
5716
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5716
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5717 5717
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
5718 5718
 				GROUP BY spotter_output.aircraft_manufacturer 
5719 5719
 				ORDER BY aircraft_manufacturer_count DESC";
5720 5720
 		} else {
5721
-			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5721
+			$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
5722 5722
 				FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
5723 5723
 				GROUP BY spotter_output.aircraft_manufacturer 
5724 5724
 				ORDER BY aircraft_manufacturer_count DESC";
@@ -5730,7 +5730,7 @@  discard block
 block discarded – undo
5730 5730
 		$aircraft_array = array();
5731 5731
 		$temp_array = array();
5732 5732
 
5733
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5733
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5734 5734
 		{
5735 5735
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
5736 5736
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -5747,11 +5747,11 @@  discard block
 block discarded – undo
5747 5747
 	* @return Array the aircraft list
5748 5748
 	*
5749 5749
 	*/
5750
-	public function countAllAircraftTypesByIdent($ident,$filters = array())
5750
+	public function countAllAircraftTypesByIdent($ident, $filters = array())
5751 5751
 	{
5752
-		$filter_query = $this->getFilter($filters,true,true);
5753
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5754
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5752
+		$filter_query = $this->getFilter($filters, true, true);
5753
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5754
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5755 5755
 				FROM spotter_output".$filter_query." spotter_output.ident = :ident 
5756 5756
 				GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5757 5757
 				ORDER BY aircraft_icao_count DESC";
@@ -5762,7 +5762,7 @@  discard block
 block discarded – undo
5762 5762
 		$aircraft_array = array();
5763 5763
 		$temp_array = array();
5764 5764
 
5765
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5765
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5766 5766
 		{
5767 5767
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5768 5768
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5779,45 +5779,45 @@  discard block
 block discarded – undo
5779 5779
 	* @return Array the aircraft list
5780 5780
 	*
5781 5781
 	*/
5782
-	public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5782
+	public function countAllAircraftTypesByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
5783 5783
 	{
5784 5784
 		global $globalDBdriver;
5785
-		$filter_query = $this->getFilter($filters,true,true);
5786
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
5787
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5785
+		$filter_query = $this->getFilter($filters, true, true);
5786
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
5787
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
5788 5788
 				FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)";
5789 5789
 		$query_values = array();
5790 5790
 		if ($year != '') {
5791 5791
 			if ($globalDBdriver == 'mysql') {
5792 5792
 				$query .= " AND YEAR(spotter_output.date) = :year";
5793
-				$query_values = array_merge($query_values,array(':year' => $year));
5793
+				$query_values = array_merge($query_values, array(':year' => $year));
5794 5794
 			} else {
5795 5795
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5796
-				$query_values = array_merge($query_values,array(':year' => $year));
5796
+				$query_values = array_merge($query_values, array(':year' => $year));
5797 5797
 			}
5798 5798
 		}
5799 5799
 		if ($month != '') {
5800 5800
 			if ($globalDBdriver == 'mysql') {
5801 5801
 				$query .= " AND MONTH(spotter_output.date) = :month";
5802
-				$query_values = array_merge($query_values,array(':month' => $month));
5802
+				$query_values = array_merge($query_values, array(':month' => $month));
5803 5803
 			} else {
5804 5804
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5805
-				$query_values = array_merge($query_values,array(':month' => $month));
5805
+				$query_values = array_merge($query_values, array(':month' => $month));
5806 5806
 			}
5807 5807
 		}
5808 5808
 		if ($day != '') {
5809 5809
 			if ($globalDBdriver == 'mysql') {
5810 5810
 				$query .= " AND DAY(spotter_output.date) = :day";
5811
-				$query_values = array_merge($query_values,array(':day' => $day));
5811
+				$query_values = array_merge($query_values, array(':day' => $day));
5812 5812
 			} else {
5813 5813
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5814
-				$query_values = array_merge($query_values,array(':day' => $day));
5814
+				$query_values = array_merge($query_values, array(':day' => $day));
5815 5815
 			}
5816 5816
 		}
5817 5817
 
5818 5818
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao
5819 5819
 				ORDER BY aircraft_icao_count DESC";
5820
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
5820
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
5821 5821
 		$sth = $this->db->prepare($query);
5822 5822
 		$sth->execute($query_values);
5823 5823
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5829,44 +5829,44 @@  discard block
 block discarded – undo
5829 5829
 	* @return Array the aircraft list
5830 5830
 	*
5831 5831
 	*/
5832
-	public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5832
+	public function countAllAircraftTypesByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5833 5833
 	{
5834 5834
 		global $globalDBdriver;
5835
-		$filter_query = $this->getFilter($filters,true,true);
5836
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5837
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5835
+		$filter_query = $this->getFilter($filters, true, true);
5836
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5837
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer 
5838 5838
 				FROM spotter_output".$filter_query." spotter_output.owner_name = :owner";
5839 5839
 		$query_values = array();
5840 5840
 		if ($year != '') {
5841 5841
 			if ($globalDBdriver == 'mysql') {
5842 5842
 				$query .= " AND YEAR(spotter_output.date) = :year";
5843
-				$query_values = array_merge($query_values,array(':year' => $year));
5843
+				$query_values = array_merge($query_values, array(':year' => $year));
5844 5844
 			} else {
5845 5845
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5846
-				$query_values = array_merge($query_values,array(':year' => $year));
5846
+				$query_values = array_merge($query_values, array(':year' => $year));
5847 5847
 			}
5848 5848
 		}
5849 5849
 		if ($month != '') {
5850 5850
 			if ($globalDBdriver == 'mysql') {
5851 5851
 				$query .= " AND MONTH(spotter_output.date) = :month";
5852
-				$query_values = array_merge($query_values,array(':month' => $month));
5852
+				$query_values = array_merge($query_values, array(':month' => $month));
5853 5853
 			} else {
5854 5854
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5855
-				$query_values = array_merge($query_values,array(':month' => $month));
5855
+				$query_values = array_merge($query_values, array(':month' => $month));
5856 5856
 			}
5857 5857
 		}
5858 5858
 		if ($day != '') {
5859 5859
 			if ($globalDBdriver == 'mysql') {
5860 5860
 				$query .= " AND DAY(spotter_output.date) = :day";
5861
-				$query_values = array_merge($query_values,array(':day' => $day));
5861
+				$query_values = array_merge($query_values, array(':day' => $day));
5862 5862
 			} else {
5863 5863
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5864
-				$query_values = array_merge($query_values,array(':day' => $day));
5864
+				$query_values = array_merge($query_values, array(':day' => $day));
5865 5865
 			}
5866 5866
 		}
5867 5867
 		$query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao
5868 5868
 				ORDER BY aircraft_icao_count DESC";
5869
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5869
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5870 5870
 		$sth = $this->db->prepare($query);
5871 5871
 		$sth->execute($query_values);
5872 5872
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -5878,13 +5878,13 @@  discard block
 block discarded – undo
5878 5878
 	* @return Array the aircraft list
5879 5879
 	*
5880 5880
 	*/
5881
-	public function countAllAircraftRegistrationByIdent($ident,$filters = array())
5881
+	public function countAllAircraftRegistrationByIdent($ident, $filters = array())
5882 5882
 	{
5883
-		$filter_query = $this->getFilter($filters,true,true);
5883
+		$filter_query = $this->getFilter($filters, true, true);
5884 5884
 		$Image = new Image($this->db);
5885
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
5885
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
5886 5886
 
5887
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5887
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name  
5888 5888
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident   
5889 5889
                     GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name
5890 5890
 		    ORDER BY registration_count DESC";
@@ -5896,14 +5896,14 @@  discard block
 block discarded – undo
5896 5896
 		$aircraft_array = array();
5897 5897
 		$temp_array = array();
5898 5898
         
5899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5900 5900
 		{
5901 5901
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5902 5902
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
5903 5903
 			$temp_array['registration'] = $row['registration'];
5904 5904
 			$temp_array['airline_name'] = $row['airline_name'];
5905 5905
 			$temp_array['image_thumbnail'] = "";
5906
-			if($row['registration'] != "")
5906
+			if ($row['registration'] != "")
5907 5907
 			{
5908 5908
 				$image_array = $Image->getSpotterImage($row['registration']);
5909 5909
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5921,44 +5921,44 @@  discard block
 block discarded – undo
5921 5921
 	* @return Array the aircraft list
5922 5922
 	*
5923 5923
 	*/
5924
-	public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
5924
+	public function countAllAircraftRegistrationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
5925 5925
 	{
5926 5926
 		global $globalDBdriver;
5927
-		$filter_query = $this->getFilter($filters,true,true);
5927
+		$filter_query = $this->getFilter($filters, true, true);
5928 5928
 		$Image = new Image($this->db);
5929
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
5929
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
5930 5930
 
5931
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5931
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
5932 5932
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner";
5933 5933
 		$query_values = array();
5934 5934
 		if ($year != '') {
5935 5935
 			if ($globalDBdriver == 'mysql') {
5936 5936
 				$query .= " AND YEAR(spotter_output.date) = :year";
5937
-				$query_values = array_merge($query_values,array(':year' => $year));
5937
+				$query_values = array_merge($query_values, array(':year' => $year));
5938 5938
 			} else {
5939 5939
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
5940
-				$query_values = array_merge($query_values,array(':year' => $year));
5940
+				$query_values = array_merge($query_values, array(':year' => $year));
5941 5941
 			}
5942 5942
 		}
5943 5943
 		if ($month != '') {
5944 5944
 			if ($globalDBdriver == 'mysql') {
5945 5945
 				$query .= " AND MONTH(spotter_output.date) = :month";
5946
-				$query_values = array_merge($query_values,array(':month' => $month));
5946
+				$query_values = array_merge($query_values, array(':month' => $month));
5947 5947
 			} else {
5948 5948
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
5949
-				$query_values = array_merge($query_values,array(':month' => $month));
5949
+				$query_values = array_merge($query_values, array(':month' => $month));
5950 5950
 			}
5951 5951
 		}
5952 5952
 		if ($day != '') {
5953 5953
 			if ($globalDBdriver == 'mysql') {
5954 5954
 				$query .= " AND DAY(spotter_output.date) = :day";
5955
-				$query_values = array_merge($query_values,array(':day' => $day));
5955
+				$query_values = array_merge($query_values, array(':day' => $day));
5956 5956
 			} else {
5957 5957
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
5958
-				$query_values = array_merge($query_values,array(':day' => $day));
5958
+				$query_values = array_merge($query_values, array(':day' => $day));
5959 5959
 			}
5960 5960
 		}
5961
-		$query_values = array_merge($query_values,array(':owner' => $owner));
5961
+		$query_values = array_merge($query_values, array(':owner' => $owner));
5962 5962
 
5963 5963
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
5964 5964
 		    ORDER BY registration_count DESC";
@@ -5970,7 +5970,7 @@  discard block
 block discarded – undo
5970 5970
 		$aircraft_array = array();
5971 5971
 		$temp_array = array();
5972 5972
         
5973
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
5973
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
5974 5974
 		{
5975 5975
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
5976 5976
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -5978,7 +5978,7 @@  discard block
 block discarded – undo
5978 5978
 			$temp_array['registration'] = $row['registration'];
5979 5979
 			$temp_array['airline_name'] = $row['airline_name'];
5980 5980
 			$temp_array['image_thumbnail'] = "";
5981
-			if($row['registration'] != "")
5981
+			if ($row['registration'] != "")
5982 5982
 			{
5983 5983
 				$image_array = $Image->getSpotterImage($row['registration']);
5984 5984
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -5996,44 +5996,44 @@  discard block
 block discarded – undo
5996 5996
 	* @return Array the aircraft list
5997 5997
 	*
5998 5998
 	*/
5999
-	public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
5999
+	public function countAllAircraftRegistrationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
6000 6000
 	{
6001 6001
 		global $globalDBdriver;
6002
-		$filter_query = $this->getFilter($filters,true,true);
6002
+		$filter_query = $this->getFilter($filters, true, true);
6003 6003
 		$Image = new Image($this->db);
6004
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6004
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6005 6005
 
6006
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6006
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name  
6007 6007
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6008 6008
 		$query_values = array();
6009 6009
 		if ($year != '') {
6010 6010
 			if ($globalDBdriver == 'mysql') {
6011 6011
 				$query .= " AND YEAR(spotter_output.date) = :year";
6012
-				$query_values = array_merge($query_values,array(':year' => $year));
6012
+				$query_values = array_merge($query_values, array(':year' => $year));
6013 6013
 			} else {
6014 6014
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6015
-				$query_values = array_merge($query_values,array(':year' => $year));
6015
+				$query_values = array_merge($query_values, array(':year' => $year));
6016 6016
 			}
6017 6017
 		}
6018 6018
 		if ($month != '') {
6019 6019
 			if ($globalDBdriver == 'mysql') {
6020 6020
 				$query .= " AND MONTH(spotter_output.date) = :month";
6021
-				$query_values = array_merge($query_values,array(':month' => $month));
6021
+				$query_values = array_merge($query_values, array(':month' => $month));
6022 6022
 			} else {
6023 6023
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6024
-				$query_values = array_merge($query_values,array(':month' => $month));
6024
+				$query_values = array_merge($query_values, array(':month' => $month));
6025 6025
 			}
6026 6026
 		}
6027 6027
 		if ($day != '') {
6028 6028
 			if ($globalDBdriver == 'mysql') {
6029 6029
 				$query .= " AND DAY(spotter_output.date) = :day";
6030
-				$query_values = array_merge($query_values,array(':day' => $day));
6030
+				$query_values = array_merge($query_values, array(':day' => $day));
6031 6031
 			} else {
6032 6032
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6033
-				$query_values = array_merge($query_values,array(':day' => $day));
6033
+				$query_values = array_merge($query_values, array(':day' => $day));
6034 6034
 			}
6035 6035
 		}
6036
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6036
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6037 6037
 
6038 6038
 		$query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name
6039 6039
 		    ORDER BY registration_count DESC";
@@ -6045,7 +6045,7 @@  discard block
 block discarded – undo
6045 6045
 		$aircraft_array = array();
6046 6046
 		$temp_array = array();
6047 6047
         
6048
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6048
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6049 6049
 		{
6050 6050
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6051 6051
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6053,7 +6053,7 @@  discard block
 block discarded – undo
6053 6053
 			$temp_array['registration'] = $row['registration'];
6054 6054
 			$temp_array['airline_name'] = $row['airline_name'];
6055 6055
 			$temp_array['image_thumbnail'] = "";
6056
-			if($row['registration'] != "")
6056
+			if ($row['registration'] != "")
6057 6057
 			{
6058 6058
 				$image_array = $Image->getSpotterImage($row['registration']);
6059 6059
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6072,11 +6072,11 @@  discard block
 block discarded – undo
6072 6072
 	* @return Array the aircraft manufacturer list
6073 6073
 	*
6074 6074
 	*/
6075
-	public function countAllAircraftManufacturerByIdent($ident,$filters = array())
6075
+	public function countAllAircraftManufacturerByIdent($ident, $filters = array())
6076 6076
 	{
6077
-		$filter_query = $this->getFilter($filters,true,true);
6078
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
6079
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6077
+		$filter_query = $this->getFilter($filters, true, true);
6078
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
6079
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6080 6080
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident  
6081 6081
                     GROUP BY spotter_output.aircraft_manufacturer 
6082 6082
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6086,7 +6086,7 @@  discard block
 block discarded – undo
6086 6086
 		$sth->execute(array(':ident' => $ident));
6087 6087
 		$aircraft_array = array();
6088 6088
 		$temp_array = array();
6089
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6089
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6090 6090
 		{
6091 6091
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6092 6092
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6101,42 +6101,42 @@  discard block
 block discarded – undo
6101 6101
 	* @return Array the aircraft manufacturer list
6102 6102
 	*
6103 6103
 	*/
6104
-	public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '')
6104
+	public function countAllAircraftManufacturerByOwner($owner, $filters = array(), $year = '', $month = '', $day = '')
6105 6105
 	{
6106 6106
 		global $globalDBdriver;
6107
-		$filter_query = $this->getFilter($filters,true,true);
6108
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
6109
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6107
+		$filter_query = $this->getFilter($filters, true, true);
6108
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
6109
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6110 6110
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner";
6111 6111
 		$query_values = array();
6112 6112
 		if ($year != '') {
6113 6113
 			if ($globalDBdriver == 'mysql') {
6114 6114
 				$query .= " AND YEAR(spotter_output.date) = :year";
6115
-				$query_values = array_merge($query_values,array(':year' => $year));
6115
+				$query_values = array_merge($query_values, array(':year' => $year));
6116 6116
 			} else {
6117 6117
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6118
-				$query_values = array_merge($query_values,array(':year' => $year));
6118
+				$query_values = array_merge($query_values, array(':year' => $year));
6119 6119
 			}
6120 6120
 		}
6121 6121
 		if ($month != '') {
6122 6122
 			if ($globalDBdriver == 'mysql') {
6123 6123
 				$query .= " AND MONTH(spotter_output.date) = :month";
6124
-				$query_values = array_merge($query_values,array(':month' => $month));
6124
+				$query_values = array_merge($query_values, array(':month' => $month));
6125 6125
 			} else {
6126 6126
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6127
-				$query_values = array_merge($query_values,array(':month' => $month));
6127
+				$query_values = array_merge($query_values, array(':month' => $month));
6128 6128
 			}
6129 6129
 		}
6130 6130
 		if ($day != '') {
6131 6131
 			if ($globalDBdriver == 'mysql') {
6132 6132
 				$query .= " AND DAY(spotter_output.date) = :day";
6133
-				$query_values = array_merge($query_values,array(':day' => $day));
6133
+				$query_values = array_merge($query_values, array(':day' => $day));
6134 6134
 			} else {
6135 6135
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6136
-				$query_values = array_merge($query_values,array(':day' => $day));
6136
+				$query_values = array_merge($query_values, array(':day' => $day));
6137 6137
 			}
6138 6138
 		}
6139
-		$query_values = array_merge($query_values,array(':owner' => $owner));
6139
+		$query_values = array_merge($query_values, array(':owner' => $owner));
6140 6140
 
6141 6141
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6142 6142
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6153,42 +6153,42 @@  discard block
 block discarded – undo
6153 6153
 	* @return Array the aircraft manufacturer list
6154 6154
 	*
6155 6155
 	*/
6156
-	public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '')
6156
+	public function countAllAircraftManufacturerByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '')
6157 6157
 	{
6158 6158
 		global $globalDBdriver;
6159
-		$filter_query = $this->getFilter($filters,true,true);
6160
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
6161
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6159
+		$filter_query = $this->getFilter($filters, true, true);
6160
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
6161
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6162 6162
 		    FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)";
6163 6163
 		$query_values = array();
6164 6164
 		if ($year != '') {
6165 6165
 			if ($globalDBdriver == 'mysql') {
6166 6166
 				$query .= " AND YEAR(spotter_output.date) = :year";
6167
-				$query_values = array_merge($query_values,array(':year' => $year));
6167
+				$query_values = array_merge($query_values, array(':year' => $year));
6168 6168
 			} else {
6169 6169
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6170
-				$query_values = array_merge($query_values,array(':year' => $year));
6170
+				$query_values = array_merge($query_values, array(':year' => $year));
6171 6171
 			}
6172 6172
 		}
6173 6173
 		if ($month != '') {
6174 6174
 			if ($globalDBdriver == 'mysql') {
6175 6175
 				$query .= " AND MONTH(spotter_output.date) = :month";
6176
-				$query_values = array_merge($query_values,array(':month' => $month));
6176
+				$query_values = array_merge($query_values, array(':month' => $month));
6177 6177
 			} else {
6178 6178
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6179
-				$query_values = array_merge($query_values,array(':month' => $month));
6179
+				$query_values = array_merge($query_values, array(':month' => $month));
6180 6180
 			}
6181 6181
 		}
6182 6182
 		if ($day != '') {
6183 6183
 			if ($globalDBdriver == 'mysql') {
6184 6184
 				$query .= " AND DAY(spotter_output.date) = :day";
6185
-				$query_values = array_merge($query_values,array(':day' => $day));
6185
+				$query_values = array_merge($query_values, array(':day' => $day));
6186 6186
 			} else {
6187 6187
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6188
-				$query_values = array_merge($query_values,array(':day' => $day));
6188
+				$query_values = array_merge($query_values, array(':day' => $day));
6189 6189
 			}
6190 6190
 		}
6191
-		$query_values = array_merge($query_values,array(':pilot' => $pilot));
6191
+		$query_values = array_merge($query_values, array(':pilot' => $pilot));
6192 6192
 
6193 6193
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer 
6194 6194
 		    ORDER BY aircraft_manufacturer_count DESC";
@@ -6206,24 +6206,24 @@  discard block
 block discarded – undo
6206 6206
 	* @return Array the aircraft list
6207 6207
 	*
6208 6208
 	*/
6209
-	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6209
+	public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6210 6210
 	{
6211
-		$filter_query = $this->getFilter($filters,true,true);
6212
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6213
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6211
+		$filter_query = $this->getFilter($filters, true, true);
6212
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6213
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6214 6214
 		
6215 6215
 
6216
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6216
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6217 6217
                     FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
6218 6218
                     GROUP BY spotter_output.aircraft_name 
6219 6219
 					ORDER BY aircraft_icao_count DESC";
6220 6220
  
6221 6221
 		
6222 6222
 		$sth = $this->db->prepare($query);
6223
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6223
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6224 6224
 		$aircraft_array = array();
6225 6225
 		$temp_array = array();
6226
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6226
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6227 6227
 		{
6228 6228
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6229 6229
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6239,33 +6239,33 @@  discard block
 block discarded – undo
6239 6239
 	* @return Array the aircraft list
6240 6240
 	*
6241 6241
 	*/
6242
-	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6242
+	public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6243 6243
 	{
6244
-		$filter_query = $this->getFilter($filters,true,true);
6244
+		$filter_query = $this->getFilter($filters, true, true);
6245 6245
 		$Image = new Image($this->db);
6246
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6247
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6246
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6247
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6248 6248
 
6249
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
6249
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name   
6250 6250
                     FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)   
6251 6251
                     GROUP BY spotter_output.registration 
6252 6252
 					ORDER BY registration_count DESC";
6253 6253
 
6254 6254
 		
6255 6255
 		$sth = $this->db->prepare($query);
6256
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6256
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6257 6257
       
6258 6258
 		$aircraft_array = array();
6259 6259
 		$temp_array = array();
6260 6260
         
6261
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6261
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6262 6262
 		{
6263 6263
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6264 6264
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6265 6265
 			$temp_array['registration'] = $row['registration'];
6266 6266
 			$temp_array['airline_name'] = $row['airline_name'];
6267 6267
 			$temp_array['image_thumbnail'] = "";
6268
-			if($row['registration'] != "")
6268
+			if ($row['registration'] != "")
6269 6269
 			{
6270 6270
 				$image_array = $Image->getSpotterImage($row['registration']);
6271 6271
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6285,25 +6285,25 @@  discard block
 block discarded – undo
6285 6285
 	* @return Array the aircraft manufacturer list
6286 6286
 	*
6287 6287
 	*/
6288
-	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array())
6288
+	public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
6289 6289
 	{
6290
-		$filter_query = $this->getFilter($filters,true,true);
6291
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
6292
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
6290
+		$filter_query = $this->getFilter($filters, true, true);
6291
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
6292
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
6293 6293
 
6294
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6294
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6295 6295
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) 
6296 6296
                     GROUP BY spotter_output.aircraft_manufacturer 
6297 6297
 					ORDER BY aircraft_manufacturer_count DESC";
6298 6298
 
6299 6299
 		
6300 6300
 		$sth = $this->db->prepare($query);
6301
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao));
6301
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao));
6302 6302
       
6303 6303
 		$aircraft_array = array();
6304 6304
 		$temp_array = array();
6305 6305
         
6306
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6306
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6307 6307
 		{
6308 6308
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6309 6309
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6323,11 +6323,11 @@  discard block
 block discarded – undo
6323 6323
 	* @return Array the aircraft list
6324 6324
 	*
6325 6325
 	*/
6326
-	public function countAllAircraftTypesByCountry($country,$filters = array())
6326
+	public function countAllAircraftTypesByCountry($country, $filters = array())
6327 6327
 	{
6328
-		$filter_query = $this->getFilter($filters,true,true);
6329
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6330
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6328
+		$filter_query = $this->getFilter($filters, true, true);
6329
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6330
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
6331 6331
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
6332 6332
 			    GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao 
6333 6333
 			    ORDER BY aircraft_icao_count DESC";
@@ -6339,7 +6339,7 @@  discard block
 block discarded – undo
6339 6339
 		$aircraft_array = array();
6340 6340
 		$temp_array = array();
6341 6341
         
6342
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6342
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6343 6343
 		{
6344 6344
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6345 6345
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
@@ -6358,12 +6358,12 @@  discard block
 block discarded – undo
6358 6358
 	* @return Array the aircraft list
6359 6359
 	*
6360 6360
 	*/
6361
-	public function countAllAircraftRegistrationByCountry($country,$filters = array())
6361
+	public function countAllAircraftRegistrationByCountry($country, $filters = array())
6362 6362
 	{
6363
-		$filter_query = $this->getFilter($filters,true,true);
6363
+		$filter_query = $this->getFilter($filters, true, true);
6364 6364
 		$Image = new Image($this->db);
6365
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6366
-		$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
6365
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6366
+		$query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
6367 6367
 			    FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country)    
6368 6368
 			    GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name 
6369 6369
 			    ORDER BY registration_count DESC";
@@ -6375,14 +6375,14 @@  discard block
 block discarded – undo
6375 6375
 		$aircraft_array = array();
6376 6376
 		$temp_array = array();
6377 6377
         
6378
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6378
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6379 6379
 		{
6380 6380
 			$temp_array['aircraft_icao'] = $row['aircraft_icao'];
6381 6381
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6382 6382
 			$temp_array['registration'] = $row['registration'];
6383 6383
 			$temp_array['airline_name'] = $row['airline_name'];
6384 6384
 			$temp_array['image_thumbnail'] = "";
6385
-			if($row['registration'] != "")
6385
+			if ($row['registration'] != "")
6386 6386
 			{
6387 6387
 				$image_array = $Image->getSpotterImage($row['registration']);
6388 6388
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6402,11 +6402,11 @@  discard block
 block discarded – undo
6402 6402
 	* @return Array the aircraft manufacturer list
6403 6403
 	*
6404 6404
 	*/
6405
-	public function countAllAircraftManufacturerByCountry($country,$filters = array())
6405
+	public function countAllAircraftManufacturerByCountry($country, $filters = array())
6406 6406
 	{
6407
-		$filter_query = $this->getFilter($filters,true,true);
6408
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
6409
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6407
+		$filter_query = $this->getFilter($filters, true, true);
6408
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
6409
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6410 6410
                     FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) 
6411 6411
                     GROUP BY spotter_output.aircraft_manufacturer 
6412 6412
 					ORDER BY aircraft_manufacturer_count DESC";
@@ -6418,7 +6418,7 @@  discard block
 block discarded – undo
6418 6418
 		$aircraft_array = array();
6419 6419
 		$temp_array = array();
6420 6420
         
6421
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6421
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6422 6422
 		{
6423 6423
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6424 6424
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6437,38 +6437,38 @@  discard block
 block discarded – undo
6437 6437
 	* @return Array the aircraft list
6438 6438
 	*
6439 6439
 	*/
6440
-	public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '')
6440
+	public function countAllAircraftManufacturers($filters = array(), $year = '', $month = '', $day = '')
6441 6441
 	{
6442 6442
 		global $globalDBdriver;
6443
-		$filter_query = $this->getFilter($filters,true,true);
6444
-		$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6443
+		$filter_query = $this->getFilter($filters, true, true);
6444
+		$query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
6445 6445
                     FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'";
6446 6446
                 $query_values = array();
6447 6447
 		if ($year != '') {
6448 6448
 			if ($globalDBdriver == 'mysql') {
6449 6449
 				$query .= " AND YEAR(spotter_output.date) = :year";
6450
-				$query_values = array_merge($query_values,array(':year' => $year));
6450
+				$query_values = array_merge($query_values, array(':year' => $year));
6451 6451
 			} else {
6452 6452
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6453
-				$query_values = array_merge($query_values,array(':year' => $year));
6453
+				$query_values = array_merge($query_values, array(':year' => $year));
6454 6454
 			}
6455 6455
 		}
6456 6456
 		if ($month != '') {
6457 6457
 			if ($globalDBdriver == 'mysql') {
6458 6458
 				$query .= " AND MONTH(spotter_output.date) = :month";
6459
-				$query_values = array_merge($query_values,array(':month' => $month));
6459
+				$query_values = array_merge($query_values, array(':month' => $month));
6460 6460
 			} else {
6461 6461
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6462
-				$query_values = array_merge($query_values,array(':month' => $month));
6462
+				$query_values = array_merge($query_values, array(':month' => $month));
6463 6463
 			}
6464 6464
 		}
6465 6465
 		if ($day != '') {
6466 6466
 			if ($globalDBdriver == 'mysql') {
6467 6467
 				$query .= " AND DAY(spotter_output.date) = :day";
6468
-				$query_values = array_merge($query_values,array(':day' => $day));
6468
+				$query_values = array_merge($query_values, array(':day' => $day));
6469 6469
 			} else {
6470 6470
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6471
-				$query_values = array_merge($query_values,array(':day' => $day));
6471
+				$query_values = array_merge($query_values, array(':day' => $day));
6472 6472
 			}
6473 6473
 		}
6474 6474
 		$query .= " GROUP BY spotter_output.aircraft_manufacturer
@@ -6482,7 +6482,7 @@  discard block
 block discarded – undo
6482 6482
 		$manufacturer_array = array();
6483 6483
 		$temp_array = array();
6484 6484
         
6485
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6485
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6486 6486
 		{
6487 6487
 			$temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer'];
6488 6488
 			$temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count'];
@@ -6501,12 +6501,12 @@  discard block
 block discarded – undo
6501 6501
 	* @return Array the aircraft list
6502 6502
 	*
6503 6503
 	*/
6504
-	public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
6504
+	public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6505 6505
 	{
6506 6506
 		global $globalDBdriver;
6507 6507
 		$Image = new Image($this->db);
6508
-		$filter_query = $this->getFilter($filters,true,true);
6509
-		$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
+		$filter_query = $this->getFilter($filters, true, true);
6509
+		$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    
6510 6510
                     FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'";
6511 6511
                 if ($olderthanmonths > 0) {
6512 6512
             		if ($globalDBdriver == 'mysql') {
@@ -6526,28 +6526,28 @@  discard block
 block discarded – undo
6526 6526
 		if ($year != '') {
6527 6527
 			if ($globalDBdriver == 'mysql') {
6528 6528
 				$query .= " AND YEAR(spotter_output.date) = :year";
6529
-				$query_values = array_merge($query_values,array(':year' => $year));
6529
+				$query_values = array_merge($query_values, array(':year' => $year));
6530 6530
 			} else {
6531 6531
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6532
-				$query_values = array_merge($query_values,array(':year' => $year));
6532
+				$query_values = array_merge($query_values, array(':year' => $year));
6533 6533
 			}
6534 6534
 		}
6535 6535
 		if ($month != '') {
6536 6536
 			if ($globalDBdriver == 'mysql') {
6537 6537
 				$query .= " AND MONTH(spotter_output.date) = :month";
6538
-				$query_values = array_merge($query_values,array(':month' => $month));
6538
+				$query_values = array_merge($query_values, array(':month' => $month));
6539 6539
 			} else {
6540 6540
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6541
-				$query_values = array_merge($query_values,array(':month' => $month));
6541
+				$query_values = array_merge($query_values, array(':month' => $month));
6542 6542
 			}
6543 6543
 		}
6544 6544
 		if ($day != '') {
6545 6545
 			if ($globalDBdriver == 'mysql') {
6546 6546
 				$query .= " AND DAY(spotter_output.date) = :day";
6547
-				$query_values = array_merge($query_values,array(':day' => $day));
6547
+				$query_values = array_merge($query_values, array(':day' => $day));
6548 6548
 			} else {
6549 6549
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6550
-				$query_values = array_merge($query_values,array(':day' => $day));
6550
+				$query_values = array_merge($query_values, array(':day' => $day));
6551 6551
 			}
6552 6552
 		}
6553 6553
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
@@ -6559,7 +6559,7 @@  discard block
 block discarded – undo
6559 6559
 		$aircraft_array = array();
6560 6560
 		$temp_array = array();
6561 6561
         
6562
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6562
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6563 6563
 		{
6564 6564
 			$temp_array['registration'] = $row['registration'];
6565 6565
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6567,7 +6567,7 @@  discard block
 block discarded – undo
6567 6567
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6568 6568
 			$temp_array['airline_name'] = $row['airline_name'];
6569 6569
 			$temp_array['image_thumbnail'] = "";
6570
-			if($row['registration'] != "")
6570
+			if ($row['registration'] != "")
6571 6571
 			{
6572 6572
 				$image_array = $Image->getSpotterImage($row['registration']);
6573 6573
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6586,12 +6586,12 @@  discard block
 block discarded – undo
6586 6586
 	* @return Array the aircraft list
6587 6587
 	*
6588 6588
 	*/
6589
-	public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
6589
+	public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6590 6590
 	{
6591 6591
 		global $globalDBdriver;
6592
-		$filter_query = $this->getFilter($filters,true,true);
6592
+		$filter_query = $this->getFilter($filters, true, true);
6593 6593
 		$Image = new Image($this->db);
6594
-		$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    
6594
+		$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    
6595 6595
                     FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' ";
6596 6596
                 if ($olderthanmonths > 0) {
6597 6597
             		if ($globalDBdriver == 'mysql') {
@@ -6619,7 +6619,7 @@  discard block
 block discarded – undo
6619 6619
 		$aircraft_array = array();
6620 6620
 		$temp_array = array();
6621 6621
         
6622
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6622
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6623 6623
 		{
6624 6624
 			$temp_array['registration'] = $row['registration'];
6625 6625
 			$temp_array['aircraft_registration_count'] = $row['aircraft_registration_count'];
@@ -6628,7 +6628,7 @@  discard block
 block discarded – undo
6628 6628
 			$temp_array['aircraft_name'] = $row['aircraft_name'];
6629 6629
 			$temp_array['airline_name'] = $row['airline_name'];
6630 6630
 			$temp_array['image_thumbnail'] = "";
6631
-			if($row['registration'] != "")
6631
+			if ($row['registration'] != "")
6632 6632
 			{
6633 6633
 				$image_array = $Image->getSpotterImage($row['registration']);
6634 6634
 				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -6647,11 +6647,11 @@  discard block
 block discarded – undo
6647 6647
 	* @return Array the airport list
6648 6648
 	*
6649 6649
 	*/
6650
-	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6650
+	public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6651 6651
 	{
6652 6652
 		global $globalDBdriver;
6653
-		$filter_query = $this->getFilter($filters,true,true);
6654
-		$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, airport.latitude, airport.longitude
6653
+		$filter_query = $this->getFilter($filters, true, true);
6654
+		$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, airport.latitude, airport.longitude
6655 6655
 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.departure_airport_icao AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
6656 6656
                 if ($olderthanmonths > 0) {
6657 6657
             		if ($globalDBdriver == 'mysql') {
@@ -6671,28 +6671,28 @@  discard block
 block discarded – undo
6671 6671
 		if ($year != '') {
6672 6672
 			if ($globalDBdriver == 'mysql') {
6673 6673
 				$query .= " AND YEAR(spotter_output.date) = :year";
6674
-				$query_values = array_merge($query_values,array(':year' => $year));
6674
+				$query_values = array_merge($query_values, array(':year' => $year));
6675 6675
 			} else {
6676 6676
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6677
-				$query_values = array_merge($query_values,array(':year' => $year));
6677
+				$query_values = array_merge($query_values, array(':year' => $year));
6678 6678
 			}
6679 6679
 		}
6680 6680
 		if ($month != '') {
6681 6681
 			if ($globalDBdriver == 'mysql') {
6682 6682
 				$query .= " AND MONTH(spotter_output.date) = :month";
6683
-				$query_values = array_merge($query_values,array(':month' => $month));
6683
+				$query_values = array_merge($query_values, array(':month' => $month));
6684 6684
 			} else {
6685 6685
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6686
-				$query_values = array_merge($query_values,array(':month' => $month));
6686
+				$query_values = array_merge($query_values, array(':month' => $month));
6687 6687
 			}
6688 6688
 		}
6689 6689
 		if ($day != '') {
6690 6690
 			if ($globalDBdriver == 'mysql') {
6691 6691
 				$query .= " AND DAY(spotter_output.date) = :day";
6692
-				$query_values = array_merge($query_values,array(':day' => $day));
6692
+				$query_values = array_merge($query_values, array(':day' => $day));
6693 6693
 			} else {
6694 6694
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6695
-				$query_values = array_merge($query_values,array(':day' => $day));
6695
+				$query_values = array_merge($query_values, array(':day' => $day));
6696 6696
 			}
6697 6697
 		}
6698 6698
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude
@@ -6704,7 +6704,7 @@  discard block
 block discarded – undo
6704 6704
 
6705 6705
 		$airport_array = array();
6706 6706
 		$temp_array = array();
6707
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6707
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6708 6708
 		{
6709 6709
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6710 6710
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6724,11 +6724,11 @@  discard block
 block discarded – undo
6724 6724
 	* @return Array the airport list
6725 6725
 	*
6726 6726
 	*/
6727
-	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6727
+	public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6728 6728
 	{
6729 6729
 		global $globalDBdriver;
6730
-		$filter_query = $this->getFilter($filters,true,true);
6731
-		$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 
6730
+		$filter_query = $this->getFilter($filters, true, true);
6731
+		$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 
6732 6732
 			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 <> '' ";
6733 6733
                 if ($olderthanmonths > 0) {
6734 6734
             		if ($globalDBdriver == 'mysql') {
@@ -6757,7 +6757,7 @@  discard block
 block discarded – undo
6757 6757
 		$airport_array = array();
6758 6758
 		$temp_array = array();
6759 6759
         
6760
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6760
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6761 6761
 		{
6762 6762
 			$temp_array['airline_icao'] = $row['airline_icao'];
6763 6763
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6777,11 +6777,11 @@  discard block
 block discarded – undo
6777 6777
 	* @return Array the airport list
6778 6778
 	*
6779 6779
 	*/
6780
-	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
6780
+	public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
6781 6781
 	{
6782 6782
 		global $globalDBdriver;
6783
-		$filter_query = $this->getFilter($filters,true,true);
6784
-		$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, airport.latitude as departure_airport_latitude, airport.longitude as departure_airport.longitude
6783
+		$filter_query = $this->getFilter($filters, true, true);
6784
+		$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, airport.latitude as departure_airport_latitude, airport.longitude as departure_airport.longitude
6785 6785
 				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";
6786 6786
                 if ($olderthanmonths > 0) {
6787 6787
             		if ($globalDBdriver == 'mysql') {
@@ -6801,28 +6801,28 @@  discard block
 block discarded – undo
6801 6801
 		if ($year != '') {
6802 6802
 			if ($globalDBdriver == 'mysql') {
6803 6803
 				$query .= " AND YEAR(spotter_output.date) = :year";
6804
-				$query_values = array_merge($query_values,array(':year' => $year));
6804
+				$query_values = array_merge($query_values, array(':year' => $year));
6805 6805
 			} else {
6806 6806
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
6807
-				$query_values = array_merge($query_values,array(':year' => $year));
6807
+				$query_values = array_merge($query_values, array(':year' => $year));
6808 6808
 			}
6809 6809
 		}
6810 6810
 		if ($month != '') {
6811 6811
 			if ($globalDBdriver == 'mysql') {
6812 6812
 				$query .= " AND MONTH(spotter_output.date) = :month";
6813
-				$query_values = array_merge($query_values,array(':month' => $month));
6813
+				$query_values = array_merge($query_values, array(':month' => $month));
6814 6814
 			} else {
6815 6815
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
6816
-				$query_values = array_merge($query_values,array(':month' => $month));
6816
+				$query_values = array_merge($query_values, array(':month' => $month));
6817 6817
 			}
6818 6818
 		}
6819 6819
 		if ($day != '') {
6820 6820
 			if ($globalDBdriver == 'mysql') {
6821 6821
 				$query .= " AND DAY(spotter_output.date) = :day";
6822
-				$query_values = array_merge($query_values,array(':day' => $day));
6822
+				$query_values = array_merge($query_values, array(':day' => $day));
6823 6823
 			} else {
6824 6824
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
6825
-				$query_values = array_merge($query_values,array(':day' => $day));
6825
+				$query_values = array_merge($query_values, array(':day' => $day));
6826 6826
 			}
6827 6827
 		}
6828 6828
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
@@ -6835,7 +6835,7 @@  discard block
 block discarded – undo
6835 6835
 		$airport_array = array();
6836 6836
 		$temp_array = array();
6837 6837
         
6838
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6838
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6839 6839
 		{
6840 6840
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6841 6841
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6856,11 +6856,11 @@  discard block
 block discarded – undo
6856 6856
 	* @return Array the airport list
6857 6857
 	*
6858 6858
 	*/
6859
-	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array())
6859
+	public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
6860 6860
 	{
6861 6861
 		global $globalDBdriver;
6862
-		$filter_query = $this->getFilter($filters,true,true);
6863
-		$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
6862
+		$filter_query = $this->getFilter($filters, true, true);
6863
+		$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
6864 6864
 				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 ";
6865 6865
                 if ($olderthanmonths > 0) {
6866 6866
             		if ($globalDBdriver == 'mysql') {
@@ -6889,7 +6889,7 @@  discard block
 block discarded – undo
6889 6889
 		$airport_array = array();
6890 6890
 		$temp_array = array();
6891 6891
         
6892
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6892
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6893 6893
 		{
6894 6894
 			$temp_array['airline_icao'] = $row['airline_icao'];
6895 6895
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -6909,11 +6909,11 @@  discard block
 block discarded – undo
6909 6909
 	* @return Array the airport list
6910 6910
 	*
6911 6911
 	*/
6912
-	public function countAllDepartureAirportsByAirline($airline_icao,$filters = array())
6912
+	public function countAllDepartureAirportsByAirline($airline_icao, $filters = array())
6913 6913
 	{
6914
-		$filter_query = $this->getFilter($filters,true,true);
6915
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6916
-		$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 
6914
+		$filter_query = $this->getFilter($filters, true, true);
6915
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6916
+		$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 
6917 6917
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> '' 
6918 6918
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
6919 6919
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6925,7 +6925,7 @@  discard block
 block discarded – undo
6925 6925
 		$airport_array = array();
6926 6926
 		$temp_array = array();
6927 6927
         
6928
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6928
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6929 6929
 		{
6930 6930
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
6931 6931
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -6947,11 +6947,11 @@  discard block
 block discarded – undo
6947 6947
 	* @return Array the airport list
6948 6948
 	*
6949 6949
 	*/
6950
-	public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array())
6950
+	public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array())
6951 6951
 	{
6952
-		$filter_query = $this->getFilter($filters,true,true);
6953
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
6954
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 
6952
+		$filter_query = $this->getFilter($filters, true, true);
6953
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
6954
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 
6955 6955
 			FROM countries,spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
6956 6956
 			GROUP BY spotter_output.departure_airport_country, countries.iso3
6957 6957
 			ORDER BY airport_departure_country_count DESC";
@@ -6962,7 +6962,7 @@  discard block
 block discarded – undo
6962 6962
 		$airport_array = array();
6963 6963
 		$temp_array = array();
6964 6964
         
6965
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6965
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
6966 6966
 		{
6967 6967
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
6968 6968
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -6980,11 +6980,11 @@  discard block
 block discarded – undo
6980 6980
 	* @return Array the airport list
6981 6981
 	*
6982 6982
 	*/
6983
-	public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array())
6983
+	public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array())
6984 6984
 	{
6985
-		$filter_query = $this->getFilter($filters,true,true);
6986
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
6987
-		$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 
6985
+		$filter_query = $this->getFilter($filters, true, true);
6986
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
6987
+		$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 
6988 6988
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> '' 
6989 6989
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
6990 6990
 			    ORDER BY airport_departure_icao_count DESC";
@@ -6996,7 +6996,7 @@  discard block
 block discarded – undo
6996 6996
 		$airport_array = array();
6997 6997
 		$temp_array = array();
6998 6998
         
6999
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
6999
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7000 7000
 		{
7001 7001
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7002 7002
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7017,11 +7017,11 @@  discard block
 block discarded – undo
7017 7017
 	* @return Array the airport list
7018 7018
 	*
7019 7019
 	*/
7020
-	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array())
7020
+	public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array())
7021 7021
 	{
7022
-		$filter_query = $this->getFilter($filters,true,true);
7023
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7024
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 
7022
+		$filter_query = $this->getFilter($filters, true, true);
7023
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7024
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS departure_airport_country_iso3 
7025 7025
 			FROM countries, spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
7026 7026
 			GROUP BY spotter_output.departure_airport_country, countries.iso3
7027 7027
 			ORDER BY airport_departure_country_count DESC";
@@ -7033,7 +7033,7 @@  discard block
 block discarded – undo
7033 7033
 		$airport_array = array();
7034 7034
 		$temp_array = array();
7035 7035
         
7036
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7036
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7037 7037
 		{
7038 7038
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7039 7039
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7051,11 +7051,11 @@  discard block
 block discarded – undo
7051 7051
 	* @return Array the airport list
7052 7052
 	*
7053 7053
 	*/
7054
-	public function countAllDepartureAirportsByRegistration($registration,$filters = array())
7054
+	public function countAllDepartureAirportsByRegistration($registration, $filters = array())
7055 7055
 	{
7056
-		$filter_query = $this->getFilter($filters,true,true);
7057
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7058
-		$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 
7056
+		$filter_query = $this->getFilter($filters, true, true);
7057
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7058
+		$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 
7059 7059
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> '' 
7060 7060
                     GROUP BY spotter_output.departure_airport_icao
7061 7061
 					ORDER BY airport_departure_icao_count DESC";
@@ -7067,7 +7067,7 @@  discard block
 block discarded – undo
7067 7067
 		$airport_array = array();
7068 7068
 		$temp_array = array();
7069 7069
         
7070
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7070
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7071 7071
 		{
7072 7072
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7073 7073
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7088,11 +7088,11 @@  discard block
 block discarded – undo
7088 7088
 	* @return Array the airport list
7089 7089
 	*
7090 7090
 	*/
7091
-	public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array())
7091
+	public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array())
7092 7092
 	{
7093
-		$filter_query = $this->getFilter($filters,true,true);
7094
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
7095
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7093
+		$filter_query = $this->getFilter($filters, true, true);
7094
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
7095
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7096 7096
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration 
7097 7097
                     GROUP BY spotter_output.departure_airport_country
7098 7098
 					ORDER BY airport_departure_country_count DESC";
@@ -7104,7 +7104,7 @@  discard block
 block discarded – undo
7104 7104
 		$airport_array = array();
7105 7105
 		$temp_array = array();
7106 7106
         
7107
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7107
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7108 7108
 		{
7109 7109
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7110 7110
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7122,11 +7122,11 @@  discard block
 block discarded – undo
7122 7122
 	* @return Array the airport list
7123 7123
 	*
7124 7124
 	*/
7125
-	public function countAllDepartureAirportsByAirport($airport_icao,$filters = array())
7125
+	public function countAllDepartureAirportsByAirport($airport_icao, $filters = array())
7126 7126
 	{
7127
-		$filter_query = $this->getFilter($filters,true,true);
7128
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7129
-		$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 
7127
+		$filter_query = $this->getFilter($filters, true, true);
7128
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7129
+		$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 
7130 7130
 			    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao AND spotter_output.departure_airport_icao <> '' 
7131 7131
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7132 7132
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7138,7 +7138,7 @@  discard block
 block discarded – undo
7138 7138
 		$airport_array = array();
7139 7139
 		$temp_array = array();
7140 7140
         
7141
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7141
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7142 7142
 		{
7143 7143
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7144 7144
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7159,11 +7159,11 @@  discard block
 block discarded – undo
7159 7159
 	* @return Array the airport list
7160 7160
 	*
7161 7161
 	*/
7162
-	public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array())
7162
+	public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array())
7163 7163
 	{
7164
-		$filter_query = $this->getFilter($filters,true,true);
7165
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
7166
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7164
+		$filter_query = $this->getFilter($filters, true, true);
7165
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
7166
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7167 7167
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao 
7168 7168
                     GROUP BY spotter_output.departure_airport_country
7169 7169
 					ORDER BY airport_departure_country_count DESC";
@@ -7175,7 +7175,7 @@  discard block
 block discarded – undo
7175 7175
 		$airport_array = array();
7176 7176
 		$temp_array = array();
7177 7177
         
7178
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7178
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7179 7179
 		{
7180 7180
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7181 7181
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7194,11 +7194,11 @@  discard block
 block discarded – undo
7194 7194
 	* @return Array the airport list
7195 7195
 	*
7196 7196
 	*/
7197
-	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array())
7197
+	public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array())
7198 7198
 	{
7199
-		$filter_query = $this->getFilter($filters,true,true);
7200
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7201
-		$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 
7199
+		$filter_query = $this->getFilter($filters, true, true);
7200
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7201
+		$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 
7202 7202
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> '' 
7203 7203
                     GROUP BY spotter_output.departure_airport_icao
7204 7204
 					ORDER BY airport_departure_icao_count DESC";
@@ -7210,7 +7210,7 @@  discard block
 block discarded – undo
7210 7210
 		$airport_array = array();
7211 7211
 		$temp_array = array();
7212 7212
         
7213
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7213
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7214 7214
 		{
7215 7215
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7216 7216
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7231,11 +7231,11 @@  discard block
 block discarded – undo
7231 7231
 	* @return Array the airport list
7232 7232
 	*
7233 7233
 	*/
7234
-	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
7234
+	public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
7235 7235
 	{
7236
-		$filter_query = $this->getFilter($filters,true,true);
7237
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
7238
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7236
+		$filter_query = $this->getFilter($filters, true, true);
7237
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
7238
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7239 7239
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
7240 7240
                     GROUP BY spotter_output.departure_airport_country
7241 7241
 					ORDER BY airport_departure_country_count DESC";
@@ -7247,7 +7247,7 @@  discard block
 block discarded – undo
7247 7247
 		$airport_array = array();
7248 7248
 		$temp_array = array();
7249 7249
         
7250
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7250
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7251 7251
 		{
7252 7252
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7253 7253
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7265,11 +7265,11 @@  discard block
 block discarded – undo
7265 7265
 	* @return Array the airport list
7266 7266
 	*
7267 7267
 	*/
7268
-	public function countAllDepartureAirportsByDate($date,$filters = array())
7268
+	public function countAllDepartureAirportsByDate($date, $filters = array())
7269 7269
 	{
7270 7270
 		global $globalTimezone, $globalDBdriver;
7271
-		$filter_query = $this->getFilter($filters,true,true);
7272
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7271
+		$filter_query = $this->getFilter($filters, true, true);
7272
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7273 7273
 		if ($globalTimezone != '') {
7274 7274
 			date_default_timezone_set($globalTimezone);
7275 7275
 			$datetime = new DateTime($date);
@@ -7277,12 +7277,12 @@  discard block
 block discarded – undo
7277 7277
 		} else $offset = '+00:00';
7278 7278
 
7279 7279
 		if ($globalDBdriver == 'mysql') {
7280
-			$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 
7280
+			$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 
7281 7281
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
7282 7282
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7283 7283
 					ORDER BY airport_departure_icao_count DESC";
7284 7284
 		} else {
7285
-			$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 
7285
+			$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 
7286 7286
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date
7287 7287
 					GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7288 7288
 					ORDER BY airport_departure_icao_count DESC";
@@ -7294,7 +7294,7 @@  discard block
 block discarded – undo
7294 7294
 		$airport_array = array();
7295 7295
 		$temp_array = array();
7296 7296
         
7297
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7297
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7298 7298
 		{
7299 7299
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7300 7300
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7315,11 +7315,11 @@  discard block
 block discarded – undo
7315 7315
 	* @return Array the airport list
7316 7316
 	*
7317 7317
 	*/
7318
-	public function countAllDepartureAirportCountriesByDate($date,$filters = array())
7318
+	public function countAllDepartureAirportCountriesByDate($date, $filters = array())
7319 7319
 	{
7320 7320
 		global $globalTimezone, $globalDBdriver;
7321
-		$filter_query = $this->getFilter($filters,true,true);
7322
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
7321
+		$filter_query = $this->getFilter($filters, true, true);
7322
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
7323 7323
 		if ($globalTimezone != '') {
7324 7324
 			date_default_timezone_set($globalTimezone);
7325 7325
 			$datetime = new DateTime($date);
@@ -7327,12 +7327,12 @@  discard block
 block discarded – undo
7327 7327
 		} else $offset = '+00:00';
7328 7328
 
7329 7329
 		if ($globalDBdriver == 'mysql') {
7330
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7330
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7331 7331
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
7332 7332
 					GROUP BY spotter_output.departure_airport_country
7333 7333
 					ORDER BY airport_departure_country_count DESC";
7334 7334
 		} else {
7335
-			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7335
+			$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7336 7336
 					FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
7337 7337
 					GROUP BY spotter_output.departure_airport_country
7338 7338
 					ORDER BY airport_departure_country_count DESC";
@@ -7344,7 +7344,7 @@  discard block
 block discarded – undo
7344 7344
 		$airport_array = array();
7345 7345
 		$temp_array = array();
7346 7346
         
7347
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7347
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7348 7348
 		{
7349 7349
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7350 7350
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7362,11 +7362,11 @@  discard block
 block discarded – undo
7362 7362
 	* @return Array the airport list
7363 7363
 	*
7364 7364
 	*/
7365
-	public function countAllDepartureAirportsByIdent($ident,$filters = array())
7365
+	public function countAllDepartureAirportsByIdent($ident, $filters = array())
7366 7366
 	{
7367
-		$filter_query = $this->getFilter($filters,true,true);
7368
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7369
-		$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 
7367
+		$filter_query = $this->getFilter($filters, true, true);
7368
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7369
+		$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 
7370 7370
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident 
7371 7371
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7372 7372
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7378,7 +7378,7 @@  discard block
 block discarded – undo
7378 7378
 		$airport_array = array();
7379 7379
 		$temp_array = array();
7380 7380
         
7381
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7381
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7382 7382
 		{
7383 7383
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7384 7384
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7398,11 +7398,11 @@  discard block
 block discarded – undo
7398 7398
 	* @return Array the airport list
7399 7399
 	*
7400 7400
 	*/
7401
-	public function countAllDepartureAirportsByOwner($owner,$filters = array())
7401
+	public function countAllDepartureAirportsByOwner($owner, $filters = array())
7402 7402
 	{
7403
-		$filter_query = $this->getFilter($filters,true,true);
7404
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7405
-		$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 
7403
+		$filter_query = $this->getFilter($filters, true, true);
7404
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7405
+		$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 
7406 7406
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner 
7407 7407
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7408 7408
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7414,7 +7414,7 @@  discard block
 block discarded – undo
7414 7414
 		$airport_array = array();
7415 7415
 		$temp_array = array();
7416 7416
         
7417
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7417
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7418 7418
 		{
7419 7419
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7420 7420
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7434,11 +7434,11 @@  discard block
 block discarded – undo
7434 7434
 	* @return Array the airport list
7435 7435
 	*
7436 7436
 	*/
7437
-	public function countAllDepartureAirportsByPilot($pilot,$filters = array())
7437
+	public function countAllDepartureAirportsByPilot($pilot, $filters = array())
7438 7438
 	{
7439
-		$filter_query = $this->getFilter($filters,true,true);
7440
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7441
-		$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 
7439
+		$filter_query = $this->getFilter($filters, true, true);
7440
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7441
+		$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 
7442 7442
 		    FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7443 7443
                     GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
7444 7444
 		    ORDER BY airport_departure_icao_count DESC";
@@ -7449,7 +7449,7 @@  discard block
 block discarded – undo
7449 7449
 		$airport_array = array();
7450 7450
 		$temp_array = array();
7451 7451
         
7452
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7452
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7453 7453
 		{
7454 7454
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7455 7455
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7471,11 +7471,11 @@  discard block
 block discarded – undo
7471 7471
 	* @return Array the airport list
7472 7472
 	*
7473 7473
 	*/
7474
-	public function countAllDepartureAirportCountriesByIdent($ident,$filters = array())
7474
+	public function countAllDepartureAirportCountriesByIdent($ident, $filters = array())
7475 7475
 	{
7476
-		$filter_query = $this->getFilter($filters,true,true);
7477
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
7478
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7476
+		$filter_query = $this->getFilter($filters, true, true);
7477
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
7478
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7479 7479
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident 
7480 7480
                     GROUP BY spotter_output.departure_airport_country
7481 7481
 					ORDER BY airport_departure_country_count DESC";
@@ -7487,7 +7487,7 @@  discard block
 block discarded – undo
7487 7487
 		$airport_array = array();
7488 7488
 		$temp_array = array();
7489 7489
         
7490
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7490
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7491 7491
 		{
7492 7492
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7493 7493
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7504,11 +7504,11 @@  discard block
 block discarded – undo
7504 7504
 	* @return Array the airport list
7505 7505
 	*
7506 7506
 	*/
7507
-	public function countAllDepartureAirportCountriesByOwner($owner,$filters = array())
7507
+	public function countAllDepartureAirportCountriesByOwner($owner, $filters = array())
7508 7508
 	{
7509
-		$filter_query = $this->getFilter($filters,true,true);
7510
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
7511
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7509
+		$filter_query = $this->getFilter($filters, true, true);
7510
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
7511
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7512 7512
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner 
7513 7513
 			GROUP BY spotter_output.departure_airport_country
7514 7514
 			ORDER BY airport_departure_country_count DESC";
@@ -7524,11 +7524,11 @@  discard block
 block discarded – undo
7524 7524
 	* @return Array the airport list
7525 7525
 	*
7526 7526
 	*/
7527
-	public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array())
7527
+	public function countAllDepartureAirportCountriesByPilot($pilot, $filters = array())
7528 7528
 	{
7529
-		$filter_query = $this->getFilter($filters,true,true);
7530
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
7531
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7529
+		$filter_query = $this->getFilter($filters, true, true);
7530
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
7531
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7532 7532
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
7533 7533
 			GROUP BY spotter_output.departure_airport_country
7534 7534
 			ORDER BY airport_departure_country_count DESC";
@@ -7546,12 +7546,12 @@  discard block
 block discarded – undo
7546 7546
 	* @return Array the airport list
7547 7547
 	*
7548 7548
 	*/
7549
-	public function countAllDepartureAirportsByCountry($country,$filters = array())
7549
+	public function countAllDepartureAirportsByCountry($country, $filters = array())
7550 7550
 	{
7551
-		$filter_query = $this->getFilter($filters,true,true);
7552
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7551
+		$filter_query = $this->getFilter($filters, true, true);
7552
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7553 7553
 
7554
-		$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 
7554
+		$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 
7555 7555
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
7556 7556
 			    GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country 
7557 7557
 			    ORDER BY airport_departure_icao_count DESC";
@@ -7563,7 +7563,7 @@  discard block
 block discarded – undo
7563 7563
 		$airport_array = array();
7564 7564
 		$temp_array = array();
7565 7565
         
7566
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7566
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7567 7567
 		{
7568 7568
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
7569 7569
 			$temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count'];
@@ -7584,11 +7584,11 @@  discard block
 block discarded – undo
7584 7584
 	* @return Array the airport list
7585 7585
 	*
7586 7586
 	*/
7587
-	public function countAllDepartureAirportCountriesByCountry($country,$filters = array())
7587
+	public function countAllDepartureAirportCountriesByCountry($country, $filters = array())
7588 7588
 	{
7589
-		$filter_query = $this->getFilter($filters,true,true);
7590
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
7591
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7589
+		$filter_query = $this->getFilter($filters, true, true);
7590
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
7591
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
7592 7592
 			FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
7593 7593
                     GROUP BY spotter_output.departure_airport_country
7594 7594
 					ORDER BY airport_departure_country_count DESC";
@@ -7600,7 +7600,7 @@  discard block
 block discarded – undo
7600 7600
 		$airport_array = array();
7601 7601
 		$temp_array = array();
7602 7602
         
7603
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7603
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7604 7604
 		{
7605 7605
 			$temp_array['departure_airport_country'] = $row['departure_airport_country'];
7606 7606
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
@@ -7623,11 +7623,11 @@  discard block
 block discarded – undo
7623 7623
 	* @return Array the airport list
7624 7624
 	*
7625 7625
 	*/
7626
-	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7626
+	public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7627 7627
 	{
7628 7628
 		global $globalDBdriver;
7629
-		$filter_query = $this->getFilter($filters,true,true);
7630
-		$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, airport.latitude as arrival_airport_latitude, airport.longitude as arrival_airport_longitude 
7629
+		$filter_query = $this->getFilter($filters, true, true);
7630
+		$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, airport.latitude as arrival_airport_latitude, airport.longitude as arrival_airport_longitude 
7631 7631
 				FROM airport, spotter_output".$filter_query." airport.icao = spotter_output.arrival_airport_icao AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
7632 7632
                 if ($olderthanmonths > 0) {
7633 7633
             		if ($globalDBdriver == 'mysql') {
@@ -7647,28 +7647,28 @@  discard block
 block discarded – undo
7647 7647
 		if ($year != '') {
7648 7648
 			if ($globalDBdriver == 'mysql') {
7649 7649
 				$query .= " AND YEAR(spotter_output.date) = :year";
7650
-				$query_values = array_merge($query_values,array(':year' => $year));
7650
+				$query_values = array_merge($query_values, array(':year' => $year));
7651 7651
 			} else {
7652 7652
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7653
-				$query_values = array_merge($query_values,array(':year' => $year));
7653
+				$query_values = array_merge($query_values, array(':year' => $year));
7654 7654
 			}
7655 7655
 		}
7656 7656
 		if ($month != '') {
7657 7657
 			if ($globalDBdriver == 'mysql') {
7658 7658
 				$query .= " AND MONTH(spotter_output.date) = :month";
7659
-				$query_values = array_merge($query_values,array(':month' => $month));
7659
+				$query_values = array_merge($query_values, array(':month' => $month));
7660 7660
 			} else {
7661 7661
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7662
-				$query_values = array_merge($query_values,array(':month' => $month));
7662
+				$query_values = array_merge($query_values, array(':month' => $month));
7663 7663
 			}
7664 7664
 		}
7665 7665
 		if ($day != '') {
7666 7666
 			if ($globalDBdriver == 'mysql') {
7667 7667
 				$query .= " AND DAY(spotter_output.date) = :day";
7668
-				$query_values = array_merge($query_values,array(':day' => $day));
7668
+				$query_values = array_merge($query_values, array(':day' => $day));
7669 7669
 			} else {
7670 7670
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7671
-				$query_values = array_merge($query_values,array(':day' => $day));
7671
+				$query_values = array_merge($query_values, array(':day' => $day));
7672 7672
 			}
7673 7673
 		}
7674 7674
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude
@@ -7682,7 +7682,7 @@  discard block
 block discarded – undo
7682 7682
 		$airport_array = array();
7683 7683
 		$temp_array = array();
7684 7684
         
7685
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7685
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7686 7686
 		{
7687 7687
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7688 7688
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7707,11 +7707,11 @@  discard block
 block discarded – undo
7707 7707
 	* @return Array the airport list
7708 7708
 	*
7709 7709
 	*/
7710
-	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array())
7710
+	public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7711 7711
 	{
7712 7712
 		global $globalDBdriver;
7713
-		$filter_query = $this->getFilter($filters,true,true);
7714
-		$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, country.iso3 AS arrival_airport_country_iso3 
7713
+		$filter_query = $this->getFilter($filters, true, true);
7714
+		$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, country.iso3 AS arrival_airport_country_iso3 
7715 7715
 			FROM countries,spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' ";
7716 7716
                 if ($olderthanmonths > 0) {
7717 7717
             		if ($globalDBdriver == 'mysql') {
@@ -7741,7 +7741,7 @@  discard block
 block discarded – undo
7741 7741
 		$airport_array = array();
7742 7742
 		$temp_array = array();
7743 7743
         
7744
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7744
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7745 7745
 		{
7746 7746
 			$temp_array['airline_icao'] = $row['airline_icao'];
7747 7747
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
@@ -7767,11 +7767,11 @@  discard block
 block discarded – undo
7767 7767
 	* @return Array the airport list
7768 7768
 	*
7769 7769
 	*/
7770
-	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '')
7770
+	public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '')
7771 7771
 	{
7772 7772
 		global $globalDBdriver;
7773
-		$filter_query = $this->getFilter($filters,true,true);
7774
-		$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, airport.latitude AS arrival_airport_latitude, airport.longitude AS arrival_airport_longitude 
7773
+		$filter_query = $this->getFilter($filters, true, true);
7774
+		$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, airport.latitude AS arrival_airport_latitude, airport.longitude AS arrival_airport_longitude 
7775 7775
 			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";
7776 7776
                 if ($olderthanmonths > 0) {
7777 7777
             		if ($globalDBdriver == 'mysql') {
@@ -7791,28 +7791,28 @@  discard block
 block discarded – undo
7791 7791
 		if ($year != '') {
7792 7792
 			if ($globalDBdriver == 'mysql') {
7793 7793
 				$query .= " AND YEAR(spotter_output.date) = :year";
7794
-				$query_values = array_merge($query_values,array(':year' => $year));
7794
+				$query_values = array_merge($query_values, array(':year' => $year));
7795 7795
 			} else {
7796 7796
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
7797
-				$query_values = array_merge($query_values,array(':year' => $year));
7797
+				$query_values = array_merge($query_values, array(':year' => $year));
7798 7798
 			}
7799 7799
 		}
7800 7800
 		if ($month != '') {
7801 7801
 			if ($globalDBdriver == 'mysql') {
7802 7802
 				$query .= " AND MONTH(spotter_output.date) = :month";
7803
-				$query_values = array_merge($query_values,array(':month' => $month));
7803
+				$query_values = array_merge($query_values, array(':month' => $month));
7804 7804
 			} else {
7805 7805
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
7806
-				$query_values = array_merge($query_values,array(':month' => $month));
7806
+				$query_values = array_merge($query_values, array(':month' => $month));
7807 7807
 			}
7808 7808
 		}
7809 7809
 		if ($day != '') {
7810 7810
 			if ($globalDBdriver == 'mysql') {
7811 7811
 				$query .= " AND DAY(spotter_output.date) = :day";
7812
-				$query_values = array_merge($query_values,array(':day' => $day));
7812
+				$query_values = array_merge($query_values, array(':day' => $day));
7813 7813
 			} else {
7814 7814
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
7815
-				$query_values = array_merge($query_values,array(':day' => $day));
7815
+				$query_values = array_merge($query_values, array(':day' => $day));
7816 7816
 			}
7817 7817
 		}
7818 7818
 		$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
@@ -7825,7 +7825,7 @@  discard block
 block discarded – undo
7825 7825
       
7826 7826
 		$airport_array = array();
7827 7827
 		$temp_array = array();
7828
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7828
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7829 7829
 		{
7830 7830
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7831 7831
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7848,11 +7848,11 @@  discard block
 block discarded – undo
7848 7848
 	* @return Array the airport list
7849 7849
 	*
7850 7850
 	*/
7851
-	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array())
7851
+	public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array())
7852 7852
 	{
7853 7853
 		global $globalDBdriver;
7854
-		$filter_query = $this->getFilter($filters,true,true);
7855
-		$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 
7854
+		$filter_query = $this->getFilter($filters, true, true);
7855
+		$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 
7856 7856
 			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 ";
7857 7857
                 if ($olderthanmonths > 0) {
7858 7858
             		if ($globalDBdriver == 'mysql') {
@@ -7882,7 +7882,7 @@  discard block
 block discarded – undo
7882 7882
 		$airport_array = array();
7883 7883
 		$temp_array = array();
7884 7884
         
7885
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7885
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7886 7886
 		{
7887 7887
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7888 7888
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7908,9 +7908,9 @@  discard block
 block discarded – undo
7908 7908
 	*/
7909 7909
 	public function countAllArrivalAirportsByAirline($airline_icao, $filters = array())
7910 7910
 	{
7911
-		$filter_query = $this->getFilter($filters,true,true);
7912
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7913
-		$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 
7911
+		$filter_query = $this->getFilter($filters, true, true);
7912
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7913
+		$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 
7914 7914
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao 
7915 7915
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
7916 7916
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7921,7 +7921,7 @@  discard block
 block discarded – undo
7921 7921
 		$airport_array = array();
7922 7922
 		$temp_array = array();
7923 7923
         
7924
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7924
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7925 7925
 		{
7926 7926
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7927 7927
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -7942,12 +7942,12 @@  discard block
 block discarded – undo
7942 7942
 	* @return Array the airport list
7943 7943
 	*
7944 7944
 	*/
7945
-	public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array())
7945
+	public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array())
7946 7946
 	{
7947
-		$filter_query = $this->getFilter($filters,true,true);
7948
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
7947
+		$filter_query = $this->getFilter($filters, true, true);
7948
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
7949 7949
 		
7950
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS arrival_airport_country_iso3 
7950
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS arrival_airport_country_iso3 
7951 7951
 			FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao 
7952 7952
 			GROUP BY spotter_output.arrival_airport_country, countries.iso3
7953 7953
 			ORDER BY airport_arrival_country_count DESC";
@@ -7959,7 +7959,7 @@  discard block
 block discarded – undo
7959 7959
 		$airport_array = array();
7960 7960
 		$temp_array = array();
7961 7961
         
7962
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7962
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7963 7963
 		{
7964 7964
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
7965 7965
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -7976,11 +7976,11 @@  discard block
 block discarded – undo
7976 7976
 	* @return Array the airport list
7977 7977
 	*
7978 7978
 	*/
7979
-	public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array())
7979
+	public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array())
7980 7980
 	{
7981
-		$filter_query = $this->getFilter($filters,true,true);
7982
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
7983
-		$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 
7981
+		$filter_query = $this->getFilter($filters, true, true);
7982
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
7983
+		$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 
7984 7984
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
7985 7985
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
7986 7986
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -7992,7 +7992,7 @@  discard block
 block discarded – undo
7992 7992
 		$airport_array = array();
7993 7993
 		$temp_array = array();
7994 7994
         
7995
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
7995
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
7996 7996
 		{
7997 7997
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
7998 7998
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8014,11 +8014,11 @@  discard block
 block discarded – undo
8014 8014
 	* @return Array the airport list
8015 8015
 	*
8016 8016
 	*/
8017
-	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array())
8017
+	public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array())
8018 8018
 	{
8019
-		$filter_query = $this->getFilter($filters,true,true);
8020
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8021
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
8019
+		$filter_query = $this->getFilter($filters, true, true);
8020
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8021
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
8022 8022
 			    FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao
8023 8023
 			    GROUP BY spotter_output.arrival_airport_country, countries.iso3
8024 8024
 			    ORDER BY airport_arrival_country_count DESC";
@@ -8030,7 +8030,7 @@  discard block
 block discarded – undo
8030 8030
 		$airport_array = array();
8031 8031
 		$temp_array = array();
8032 8032
         
8033
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8033
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8034 8034
 		{
8035 8035
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8036 8036
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8048,12 +8048,12 @@  discard block
 block discarded – undo
8048 8048
 	* @return Array the airport list
8049 8049
 	*
8050 8050
 	*/
8051
-	public function countAllArrivalAirportsByRegistration($registration,$filters = array())
8051
+	public function countAllArrivalAirportsByRegistration($registration, $filters = array())
8052 8052
 	{
8053
-		$filter_query = $this->getFilter($filters,true,true);
8054
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8053
+		$filter_query = $this->getFilter($filters, true, true);
8054
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8055 8055
 
8056
-		$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 
8056
+		$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 
8057 8057
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.registration = :registration 
8058 8058
                     GROUP BY spotter_output.arrival_airport_icao
8059 8059
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8065,7 +8065,7 @@  discard block
 block discarded – undo
8065 8065
 		$airport_array = array();
8066 8066
 		$temp_array = array();
8067 8067
         
8068
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8068
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8069 8069
 		{
8070 8070
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8071 8071
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8086,11 +8086,11 @@  discard block
 block discarded – undo
8086 8086
 	* @return Array the airport list
8087 8087
 	*
8088 8088
 	*/
8089
-	public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array())
8089
+	public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array())
8090 8090
 	{
8091
-		$filter_query = $this->getFilter($filters,true,true);
8092
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
8093
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8091
+		$filter_query = $this->getFilter($filters, true, true);
8092
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8093
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8094 8094
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration 
8095 8095
                     GROUP BY spotter_output.arrival_airport_country
8096 8096
 					ORDER BY airport_arrival_country_count DESC";
@@ -8102,7 +8102,7 @@  discard block
 block discarded – undo
8102 8102
 		$airport_array = array();
8103 8103
 		$temp_array = array();
8104 8104
         
8105
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8105
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8106 8106
 		{
8107 8107
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8108 8108
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8121,11 +8121,11 @@  discard block
 block discarded – undo
8121 8121
 	* @return Array the airport list
8122 8122
 	*
8123 8123
 	*/
8124
-	public function countAllArrivalAirportsByAirport($airport_icao,$filters = array())
8124
+	public function countAllArrivalAirportsByAirport($airport_icao, $filters = array())
8125 8125
 	{
8126
-		$filter_query = $this->getFilter($filters,true,true);
8127
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8128
-		$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 
8126
+		$filter_query = $this->getFilter($filters, true, true);
8127
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8128
+		$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 
8129 8129
 			    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8130 8130
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8131 8131
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8137,7 +8137,7 @@  discard block
 block discarded – undo
8137 8137
 		$airport_array = array();
8138 8138
 		$temp_array = array();
8139 8139
         
8140
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8140
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8141 8141
 		{
8142 8142
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8143 8143
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8158,11 +8158,11 @@  discard block
 block discarded – undo
8158 8158
 	* @return Array the airport list
8159 8159
 	*
8160 8160
 	*/
8161
-	public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array())
8161
+	public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array())
8162 8162
 	{
8163
-		$filter_query = $this->getFilter($filters,true,true);
8164
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8165
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8163
+		$filter_query = $this->getFilter($filters, true, true);
8164
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8165
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8166 8166
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao 
8167 8167
                     GROUP BY spotter_output.arrival_airport_country
8168 8168
 					ORDER BY airport_arrival_country_count DESC";
@@ -8174,7 +8174,7 @@  discard block
 block discarded – undo
8174 8174
 		$airport_array = array();
8175 8175
 		$temp_array = array();
8176 8176
         
8177
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8177
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8178 8178
 		{
8179 8179
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8180 8180
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8192,11 +8192,11 @@  discard block
 block discarded – undo
8192 8192
 	* @return Array the airport list
8193 8193
 	*
8194 8194
 	*/
8195
-	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array())
8195
+	public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array())
8196 8196
 	{
8197
-		$filter_query = $this->getFilter($filters,true,true);
8198
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8199
-		$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 
8197
+		$filter_query = $this->getFilter($filters, true, true);
8198
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8199
+		$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 
8200 8200
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8201 8201
                     GROUP BY spotter_output.arrival_airport_icao
8202 8202
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8208,7 +8208,7 @@  discard block
 block discarded – undo
8208 8208
 		$airport_array = array();
8209 8209
 		$temp_array = array();
8210 8210
         
8211
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8211
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8212 8212
 		{
8213 8213
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8214 8214
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8230,11 +8230,11 @@  discard block
 block discarded – undo
8230 8230
 	* @return Array the airport list
8231 8231
 	*
8232 8232
 	*/
8233
-	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array())
8233
+	public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array())
8234 8234
 	{
8235
-		$filter_query = $this->getFilter($filters,true,true);
8236
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
8237
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8235
+		$filter_query = $this->getFilter($filters, true, true);
8236
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
8237
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8238 8238
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer 
8239 8239
                     GROUP BY spotter_output.arrival_airport_country
8240 8240
 					ORDER BY airport_arrival_country_count DESC";
@@ -8246,7 +8246,7 @@  discard block
 block discarded – undo
8246 8246
 		$airport_array = array();
8247 8247
 		$temp_array = array();
8248 8248
         
8249
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8249
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8250 8250
 		{
8251 8251
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8252 8252
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8265,11 +8265,11 @@  discard block
 block discarded – undo
8265 8265
 	* @return Array the airport list
8266 8266
 	*
8267 8267
 	*/
8268
-	public function countAllArrivalAirportsByDate($date,$filters = array())
8268
+	public function countAllArrivalAirportsByDate($date, $filters = array())
8269 8269
 	{
8270 8270
 		global $globalTimezone, $globalDBdriver;
8271
-		$filter_query = $this->getFilter($filters,true,true);
8272
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8271
+		$filter_query = $this->getFilter($filters, true, true);
8272
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8273 8273
 		if ($globalTimezone != '') {
8274 8274
 			date_default_timezone_set($globalTimezone);
8275 8275
 			$datetime = new DateTime($date);
@@ -8277,12 +8277,12 @@  discard block
 block discarded – undo
8277 8277
 		} else $offset = '+00:00';
8278 8278
 
8279 8279
 		if ($globalDBdriver == 'mysql') {
8280
-			$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 
8280
+			$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 
8281 8281
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
8282 8282
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8283 8283
 					ORDER BY airport_arrival_icao_count DESC";
8284 8284
 		} else {
8285
-			$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 
8285
+			$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 
8286 8286
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
8287 8287
 					GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8288 8288
 					ORDER BY airport_arrival_icao_count DESC";
@@ -8294,7 +8294,7 @@  discard block
 block discarded – undo
8294 8294
 		$airport_array = array();
8295 8295
 		$temp_array = array();
8296 8296
         
8297
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8297
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8298 8298
 		{
8299 8299
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8300 8300
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8318,8 +8318,8 @@  discard block
 block discarded – undo
8318 8318
 	public function countAllArrivalAirportCountriesByDate($date, $filters = array())
8319 8319
 	{
8320 8320
 		global $globalTimezone, $globalDBdriver;
8321
-		$filter_query = $this->getFilter($filters,true,true);
8322
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
8321
+		$filter_query = $this->getFilter($filters, true, true);
8322
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
8323 8323
 		if ($globalTimezone != '') {
8324 8324
 			date_default_timezone_set($globalTimezone);
8325 8325
 			$datetime = new DateTime($date);
@@ -8327,12 +8327,12 @@  discard block
 block discarded – undo
8327 8327
 		} else $offset = '+00:00';
8328 8328
 
8329 8329
 		if ($globalDBdriver == 'mysql') {
8330
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8330
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8331 8331
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date 
8332 8332
 					GROUP BY spotter_output.arrival_airport_country
8333 8333
 					ORDER BY airport_arrival_country_count DESC";
8334 8334
 		} else {
8335
-			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8335
+			$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8336 8336
 					FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date 
8337 8337
 					GROUP BY spotter_output.arrival_airport_country
8338 8338
 					ORDER BY airport_arrival_country_count DESC";
@@ -8344,7 +8344,7 @@  discard block
 block discarded – undo
8344 8344
 		$airport_array = array();
8345 8345
 		$temp_array = array();
8346 8346
         
8347
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8347
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8348 8348
 		{
8349 8349
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8350 8350
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8362,11 +8362,11 @@  discard block
 block discarded – undo
8362 8362
 	* @return Array the airport list
8363 8363
 	*
8364 8364
 	*/
8365
-	public function countAllArrivalAirportsByIdent($ident,$filters = array())
8365
+	public function countAllArrivalAirportsByIdent($ident, $filters = array())
8366 8366
 	{
8367
-		$filter_query = $this->getFilter($filters,true,true);
8368
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8369
-		$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 
8367
+		$filter_query = $this->getFilter($filters, true, true);
8368
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8369
+		$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 
8370 8370
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.ident = :ident  
8371 8371
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8372 8372
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8378,7 +8378,7 @@  discard block
 block discarded – undo
8378 8378
 		$airport_array = array();
8379 8379
 		$temp_array = array();
8380 8380
         
8381
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8381
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8382 8382
 		{
8383 8383
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8384 8384
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8398,11 +8398,11 @@  discard block
 block discarded – undo
8398 8398
 	* @return Array the airport list
8399 8399
 	*
8400 8400
 	*/
8401
-	public function countAllArrivalAirportsByOwner($owner,$filters = array())
8401
+	public function countAllArrivalAirportsByOwner($owner, $filters = array())
8402 8402
 	{
8403
-		$filter_query = $this->getFilter($filters,true,true);
8404
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8405
-		$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 
8403
+		$filter_query = $this->getFilter($filters, true, true);
8404
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8405
+		$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 
8406 8406
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.owner_name = :owner 
8407 8407
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8408 8408
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8413,7 +8413,7 @@  discard block
 block discarded – undo
8413 8413
 		$airport_array = array();
8414 8414
 		$temp_array = array();
8415 8415
         
8416
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8416
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8417 8417
 		{
8418 8418
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8419 8419
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8433,11 +8433,11 @@  discard block
 block discarded – undo
8433 8433
 	* @return Array the airport list
8434 8434
 	*
8435 8435
 	*/
8436
-	public function countAllArrivalAirportsByPilot($pilot,$filters = array())
8436
+	public function countAllArrivalAirportsByPilot($pilot, $filters = array())
8437 8437
 	{
8438
-		$filter_query = $this->getFilter($filters,true,true);
8439
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8440
-		$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 
8438
+		$filter_query = $this->getFilter($filters, true, true);
8439
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8440
+		$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 
8441 8441
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8442 8442
                     GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
8443 8443
 		    ORDER BY airport_arrival_icao_count DESC";
@@ -8448,7 +8448,7 @@  discard block
 block discarded – undo
8448 8448
 		$airport_array = array();
8449 8449
 		$temp_array = array();
8450 8450
         
8451
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8451
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8452 8452
 		{
8453 8453
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8454 8454
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8470,9 +8470,9 @@  discard block
 block discarded – undo
8470 8470
 	*/
8471 8471
 	public function countAllArrivalAirportCountriesByIdent($ident, $filters = array())
8472 8472
 	{
8473
-		$filter_query = $this->getFilter($filters,true,true);
8474
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
8475
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8473
+		$filter_query = $this->getFilter($filters, true, true);
8474
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
8475
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8476 8476
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident 
8477 8477
                     GROUP BY spotter_output.arrival_airport_country
8478 8478
 					ORDER BY airport_arrival_country_count DESC";
@@ -8484,7 +8484,7 @@  discard block
 block discarded – undo
8484 8484
 		$airport_array = array();
8485 8485
 		$temp_array = array();
8486 8486
         
8487
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8487
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8488 8488
 		{
8489 8489
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8490 8490
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8503,9 +8503,9 @@  discard block
 block discarded – undo
8503 8503
 	*/
8504 8504
 	public function countAllArrivalAirportCountriesByOwner($owner, $filters = array())
8505 8505
 	{
8506
-		$filter_query = $this->getFilter($filters,true,true);
8507
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
8508
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8506
+		$filter_query = $this->getFilter($filters, true, true);
8507
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
8508
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8509 8509
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner 
8510 8510
                     GROUP BY spotter_output.arrival_airport_country
8511 8511
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8523,9 +8523,9 @@  discard block
 block discarded – undo
8523 8523
 	*/
8524 8524
 	public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array())
8525 8525
 	{
8526
-		$filter_query = $this->getFilter($filters,true,true);
8527
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
8528
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8526
+		$filter_query = $this->getFilter($filters, true, true);
8527
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
8528
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8529 8529
 		    FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
8530 8530
                     GROUP BY spotter_output.arrival_airport_country
8531 8531
 		    ORDER BY airport_arrival_country_count DESC";
@@ -8543,11 +8543,11 @@  discard block
 block discarded – undo
8543 8543
 	* @return Array the airport list
8544 8544
 	*
8545 8545
 	*/
8546
-	public function countAllArrivalAirportsByCountry($country,$filters = array())
8546
+	public function countAllArrivalAirportsByCountry($country, $filters = array())
8547 8547
 	{
8548
-		$filter_query = $this->getFilter($filters,true,true);
8549
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8550
-		$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 
8548
+		$filter_query = $this->getFilter($filters, true, true);
8549
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8550
+		$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 
8551 8551
 			    FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country  
8552 8552
 			    GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8553 8553
 			    ORDER BY airport_arrival_icao_count DESC";
@@ -8559,7 +8559,7 @@  discard block
 block discarded – undo
8559 8559
 		$airport_array = array();
8560 8560
 		$temp_array = array();
8561 8561
         
8562
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8562
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8563 8563
 		{
8564 8564
 			$temp_array['airport_arrival_icao'] = $row['arrival_airport_icao'];
8565 8565
 			$temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count'];
@@ -8580,12 +8580,12 @@  discard block
 block discarded – undo
8580 8580
 	* @return Array the airport list
8581 8581
 	*
8582 8582
 	*/
8583
-	public function countAllArrivalAirportCountriesByCountry($country,$filters = array())
8583
+	public function countAllArrivalAirportCountriesByCountry($country, $filters = array())
8584 8584
 	{
8585 8585
 		global $globalDBdriver;
8586
-		$filter_query = $this->getFilter($filters,true,true);
8587
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8588
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8586
+		$filter_query = $this->getFilter($filters, true, true);
8587
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8588
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
8589 8589
 			FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
8590 8590
                     GROUP BY spotter_output.arrival_airport_country
8591 8591
 					ORDER BY airport_arrival_country_count DESC";
@@ -8597,7 +8597,7 @@  discard block
 block discarded – undo
8597 8597
 		$airport_array = array();
8598 8598
 		$temp_array = array();
8599 8599
         
8600
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8600
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8601 8601
 		{
8602 8602
 			$temp_array['arrival_airport_country'] = $row['arrival_airport_country'];
8603 8603
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
@@ -8616,38 +8616,38 @@  discard block
 block discarded – undo
8616 8616
 	* @return Array the airport departure list
8617 8617
 	*
8618 8618
 	*/
8619
-	public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '')
8619
+	public function countAllDepartureCountries($filters = array(), $year = '', $month = '', $day = '')
8620 8620
 	{
8621 8621
 		global $globalDBdriver;
8622
-		$filter_query = $this->getFilter($filters,true,true);
8623
-		$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 
8622
+		$filter_query = $this->getFilter($filters, true, true);
8623
+		$query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count, countries.iso3 AS airport_departure_country_iso3 
8624 8624
 				FROM countries,spotter_output".$filter_query." countries.name = spotter_output.departure_airport_country AND spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''";
8625 8625
 		$query_values = array();
8626 8626
 		if ($year != '') {
8627 8627
 			if ($globalDBdriver == 'mysql') {
8628 8628
 				$query .= " AND YEAR(spotter_output.date) = :year";
8629
-				$query_values = array_merge($query_values,array(':year' => $year));
8629
+				$query_values = array_merge($query_values, array(':year' => $year));
8630 8630
 			} else {
8631 8631
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8632
-				$query_values = array_merge($query_values,array(':year' => $year));
8632
+				$query_values = array_merge($query_values, array(':year' => $year));
8633 8633
 			}
8634 8634
 		}
8635 8635
 		if ($month != '') {
8636 8636
 			if ($globalDBdriver == 'mysql') {
8637 8637
 				$query .= " AND MONTH(spotter_output.date) = :month";
8638
-				$query_values = array_merge($query_values,array(':month' => $month));
8638
+				$query_values = array_merge($query_values, array(':month' => $month));
8639 8639
 			} else {
8640 8640
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8641
-				$query_values = array_merge($query_values,array(':month' => $month));
8641
+				$query_values = array_merge($query_values, array(':month' => $month));
8642 8642
 			}
8643 8643
 		}
8644 8644
 		if ($day != '') {
8645 8645
 			if ($globalDBdriver == 'mysql') {
8646 8646
 				$query .= " AND DAY(spotter_output.date) = :day";
8647
-				$query_values = array_merge($query_values,array(':day' => $day));
8647
+				$query_values = array_merge($query_values, array(':day' => $day));
8648 8648
 			} else {
8649 8649
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8650
-				$query_values = array_merge($query_values,array(':day' => $day));
8650
+				$query_values = array_merge($query_values, array(':day' => $day));
8651 8651
 			}
8652 8652
 		}
8653 8653
 		$query .= " GROUP BY spotter_output.departure_airport_country, countries.iso3
@@ -8661,7 +8661,7 @@  discard block
 block discarded – undo
8661 8661
 		$airport_array = array();
8662 8662
 		$temp_array = array();
8663 8663
         
8664
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8664
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8665 8665
 		{
8666 8666
 			$temp_array['airport_departure_country_count'] = $row['airport_departure_country_count'];
8667 8667
 			$temp_array['airport_departure_country'] = $row['departure_airport_country'];
@@ -8679,38 +8679,38 @@  discard block
 block discarded – undo
8679 8679
 	* @return Array the airport arrival list
8680 8680
 	*
8681 8681
 	*/
8682
-	public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '')
8682
+	public function countAllArrivalCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '')
8683 8683
 	{
8684 8684
 		global $globalDBdriver;
8685
-		$filter_query = $this->getFilter($filters,true,true);
8686
-		$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
8685
+		$filter_query = $this->getFilter($filters, true, true);
8686
+		$query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count, countries.iso3 AS airport_arrival_country_iso3 
8687 8687
 			FROM countries, spotter_output".$filter_query." countries.name = spotter_output.arrival_airport_country AND spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''";
8688 8688
 		$query_values = array();
8689 8689
 		if ($year != '') {
8690 8690
 			if ($globalDBdriver == 'mysql') {
8691 8691
 				$query .= " AND YEAR(spotter_output.date) = :year";
8692
-				$query_values = array_merge($query_values,array(':year' => $year));
8692
+				$query_values = array_merge($query_values, array(':year' => $year));
8693 8693
 			} else {
8694 8694
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
8695
-				$query_values = array_merge($query_values,array(':year' => $year));
8695
+				$query_values = array_merge($query_values, array(':year' => $year));
8696 8696
 			}
8697 8697
 		}
8698 8698
 		if ($month != '') {
8699 8699
 			if ($globalDBdriver == 'mysql') {
8700 8700
 				$query .= " AND MONTH(spotter_output.date) = :month";
8701
-				$query_values = array_merge($query_values,array(':month' => $month));
8701
+				$query_values = array_merge($query_values, array(':month' => $month));
8702 8702
 			} else {
8703 8703
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
8704
-				$query_values = array_merge($query_values,array(':month' => $month));
8704
+				$query_values = array_merge($query_values, array(':month' => $month));
8705 8705
 			}
8706 8706
 		}
8707 8707
 		if ($day != '') {
8708 8708
 			if ($globalDBdriver == 'mysql') {
8709 8709
 				$query .= " AND DAY(spotter_output.date) = :day";
8710
-				$query_values = array_merge($query_values,array(':day' => $day));
8710
+				$query_values = array_merge($query_values, array(':day' => $day));
8711 8711
 			} else {
8712 8712
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
8713
-				$query_values = array_merge($query_values,array(':day' => $day));
8713
+				$query_values = array_merge($query_values, array(':day' => $day));
8714 8714
 			}
8715 8715
 		}
8716 8716
 		$query .= " GROUP BY spotter_output.arrival_airport_country, countries.iso3
@@ -8724,7 +8724,7 @@  discard block
 block discarded – undo
8724 8724
 		$airport_array = array();
8725 8725
 		$temp_array = array();
8726 8726
         
8727
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8727
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8728 8728
 		{
8729 8729
 			$temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count'];
8730 8730
 			$temp_array['airport_arrival_country'] = $row['arrival_airport_country'];
@@ -8748,8 +8748,8 @@  discard block
 block discarded – undo
8748 8748
 	*/
8749 8749
 	public function countAllRoutes($filters = array())
8750 8750
 	{
8751
-		$filter_query = $this->getFilter($filters,true,true);
8752
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8751
+		$filter_query = $this->getFilter($filters, true, true);
8752
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8753 8753
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''
8754 8754
                     GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country
8755 8755
                     ORDER BY route_count DESC
@@ -8762,7 +8762,7 @@  discard block
 block discarded – undo
8762 8762
 		$routes_array = array();
8763 8763
 		$temp_array = array();
8764 8764
         
8765
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8765
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8766 8766
 		{
8767 8767
 			$temp_array['route_count'] = $row['route_count'];
8768 8768
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8789,11 +8789,11 @@  discard block
 block discarded – undo
8789 8789
 	* @return Array the route list
8790 8790
 	*
8791 8791
 	*/
8792
-	public function countAllRoutesByAircraft($aircraft_icao,$filters = array())
8792
+	public function countAllRoutesByAircraft($aircraft_icao, $filters = array())
8793 8793
 	{
8794
-		$filter_query = $this->getFilter($filters,true,true);
8795
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
8796
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8794
+		$filter_query = $this->getFilter($filters, true, true);
8795
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
8796
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8797 8797
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao 
8798 8798
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8799 8799
 			    ORDER BY route_count DESC";
@@ -8804,7 +8804,7 @@  discard block
 block discarded – undo
8804 8804
 		$routes_array = array();
8805 8805
 		$temp_array = array();
8806 8806
         
8807
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8807
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8808 8808
 		{
8809 8809
 			$temp_array['route_count'] = $row['route_count'];
8810 8810
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8831,9 +8831,9 @@  discard block
 block discarded – undo
8831 8831
 	*/
8832 8832
 	public function countAllRoutesByRegistration($registration, $filters = array())
8833 8833
 	{
8834
-		$filter_query = $this->getFilter($filters,true,true);
8834
+		$filter_query = $this->getFilter($filters, true, true);
8835 8835
 		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
8836
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8836
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8837 8837
 			FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration 
8838 8838
                     GROUP BY route
8839 8839
                     ORDER BY route_count DESC";
@@ -8845,7 +8845,7 @@  discard block
 block discarded – undo
8845 8845
 		$routes_array = array();
8846 8846
 		$temp_array = array();
8847 8847
         
8848
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8848
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8849 8849
 		{
8850 8850
 			$temp_array['route_count'] = $row['route_count'];
8851 8851
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8873,9 +8873,9 @@  discard block
 block discarded – undo
8873 8873
 	*/
8874 8874
 	public function countAllRoutesByAirline($airline_icao, $filters = array())
8875 8875
 	{
8876
-		$filter_query = $this->getFilter($filters,true,true);
8877
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
8878
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8876
+		$filter_query = $this->getFilter($filters, true, true);
8877
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
8878
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8879 8879
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao 
8880 8880
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8881 8881
 			    ORDER BY route_count DESC";
@@ -8887,7 +8887,7 @@  discard block
 block discarded – undo
8887 8887
 		$routes_array = array();
8888 8888
 		$temp_array = array();
8889 8889
         
8890
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8890
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8891 8891
 		{
8892 8892
 			$temp_array['route_count'] = $row['route_count'];
8893 8893
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8915,9 +8915,9 @@  discard block
 block discarded – undo
8915 8915
 	*/
8916 8916
 	public function countAllRoutesByAirport($airport_icao, $filters = array())
8917 8917
 	{
8918
-		$filter_query = $this->getFilter($filters,true,true);
8919
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
8920
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8918
+		$filter_query = $this->getFilter($filters, true, true);
8919
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
8920
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8921 8921
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
8922 8922
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8923 8923
 			    ORDER BY route_count DESC";
@@ -8928,7 +8928,7 @@  discard block
 block discarded – undo
8928 8928
 		$routes_array = array();
8929 8929
 		$temp_array = array();
8930 8930
         
8931
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8931
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8932 8932
 		{
8933 8933
 			$temp_array['route_count'] = $row['route_count'];
8934 8934
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8956,9 +8956,9 @@  discard block
 block discarded – undo
8956 8956
 	*/
8957 8957
 	public function countAllRoutesByCountry($country, $filters = array())
8958 8958
 	{
8959
-		$filter_query = $this->getFilter($filters,true,true);
8960
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
8961
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8959
+		$filter_query = $this->getFilter($filters, true, true);
8960
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
8961
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
8962 8962
 			    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country 
8963 8963
 			    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country 
8964 8964
 			    ORDER BY route_count DESC";
@@ -8969,7 +8969,7 @@  discard block
 block discarded – undo
8969 8969
 		$routes_array = array();
8970 8970
 		$temp_array = array();
8971 8971
         
8972
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
8972
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
8973 8973
 		{
8974 8974
 			$temp_array['route_count'] = $row['route_count'];
8975 8975
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -8997,8 +8997,8 @@  discard block
 block discarded – undo
8997 8997
 	public function countAllRoutesByDate($date, $filters = array())
8998 8998
 	{
8999 8999
 		global $globalTimezone, $globalDBdriver;
9000
-		$filter_query = $this->getFilter($filters,true,true);
9001
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
9000
+		$filter_query = $this->getFilter($filters, true, true);
9001
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
9002 9002
 		if ($globalTimezone != '') {
9003 9003
 			date_default_timezone_set($globalTimezone);
9004 9004
 			$datetime = new DateTime($date);
@@ -9006,12 +9006,12 @@  discard block
 block discarded – undo
9006 9006
 		} else $offset = '+00:00';
9007 9007
 		
9008 9008
 		if ($globalDBdriver == 'mysql') {
9009
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9009
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9010 9010
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date  
9011 9011
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9012 9012
 				    ORDER BY route_count DESC";
9013 9013
 		} else {
9014
-			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9014
+			$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9015 9015
 				    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date  
9016 9016
 				    GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9017 9017
 				    ORDER BY route_count DESC";
@@ -9023,7 +9023,7 @@  discard block
 block discarded – undo
9023 9023
 		$routes_array = array();
9024 9024
 		$temp_array = array();
9025 9025
         
9026
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9026
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9027 9027
 		{
9028 9028
 			$temp_array['route_count'] = $row['route_count'];
9029 9029
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9050,9 +9050,9 @@  discard block
 block discarded – undo
9050 9050
 	*/
9051 9051
 	public function countAllRoutesByIdent($ident, $filters = array())
9052 9052
 	{
9053
-		$filter_query = $this->getFilter($filters,true,true);
9054
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
9055
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9053
+		$filter_query = $this->getFilter($filters, true, true);
9054
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
9055
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9056 9056
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident   
9057 9057
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9058 9058
                     ORDER BY route_count DESC";
@@ -9064,7 +9064,7 @@  discard block
 block discarded – undo
9064 9064
 		$routes_array = array();
9065 9065
 		$temp_array = array();
9066 9066
         
9067
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9067
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9068 9068
 		{
9069 9069
 			$temp_array['route_count'] = $row['route_count'];
9070 9070
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9088,11 +9088,11 @@  discard block
 block discarded – undo
9088 9088
 	* @return Array the route list
9089 9089
 	*
9090 9090
 	*/
9091
-	public function countAllRoutesByOwner($owner,$filters = array())
9091
+	public function countAllRoutesByOwner($owner, $filters = array())
9092 9092
 	{
9093
-		$filter_query = $this->getFilter($filters,true,true);
9094
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
9095
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9093
+		$filter_query = $this->getFilter($filters, true, true);
9094
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
9095
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9096 9096
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner 
9097 9097
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9098 9098
                     ORDER BY route_count DESC";
@@ -9104,7 +9104,7 @@  discard block
 block discarded – undo
9104 9104
 		$routes_array = array();
9105 9105
 		$temp_array = array();
9106 9106
         
9107
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9107
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9108 9108
 		{
9109 9109
 			$temp_array['route_count'] = $row['route_count'];
9110 9110
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9128,11 +9128,11 @@  discard block
 block discarded – undo
9128 9128
 	* @return Array the route list
9129 9129
 	*
9130 9130
 	*/
9131
-	public function countAllRoutesByPilot($pilot,$filters = array())
9131
+	public function countAllRoutesByPilot($pilot, $filters = array())
9132 9132
 	{
9133
-		$filter_query = $this->getFilter($filters,true,true);
9134
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
9135
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9133
+		$filter_query = $this->getFilter($filters, true, true);
9134
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
9135
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9136 9136
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
9137 9137
                     GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9138 9138
                     ORDER BY route_count DESC";
@@ -9144,7 +9144,7 @@  discard block
 block discarded – undo
9144 9144
 		$routes_array = array();
9145 9145
 		$temp_array = array();
9146 9146
         
9147
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9147
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9148 9148
 		{
9149 9149
 			$temp_array['route_count'] = $row['route_count'];
9150 9150
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9171,9 +9171,9 @@  discard block
 block discarded – undo
9171 9171
 	*/
9172 9172
 	public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array())
9173 9173
 	{
9174
-		$filter_query = $this->getFilter($filters,true,true);
9175
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
9176
-		$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9174
+		$filter_query = $this->getFilter($filters, true, true);
9175
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
9176
+		$query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9177 9177
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer   
9178 9178
                     GROUP BY route
9179 9179
                     ORDER BY route_count DESC";
@@ -9185,7 +9185,7 @@  discard block
 block discarded – undo
9185 9185
 		$routes_array = array();
9186 9186
 		$temp_array = array();
9187 9187
         
9188
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9188
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9189 9189
 		{
9190 9190
 			$temp_array['route_count'] = $row['route_count'];
9191 9191
 			$temp_array['airport_departure_icao'] = $row['departure_airport_icao'];
@@ -9213,8 +9213,8 @@  discard block
 block discarded – undo
9213 9213
 	*/
9214 9214
 	public function countAllRoutesWithWaypoints($filters = array())
9215 9215
 	{
9216
-		$filter_query = $this->getFilter($filters,true,true);
9217
-		$query  = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9216
+		$filter_query = $this->getFilter($filters, true, true);
9217
+		$query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
9218 9218
 		    FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' 
9219 9219
                     GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country
9220 9220
                     ORDER BY route_count DESC
@@ -9227,7 +9227,7 @@  discard block
 block discarded – undo
9227 9227
 		$routes_array = array();
9228 9228
 		$temp_array = array();
9229 9229
         
9230
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9230
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9231 9231
 		{
9232 9232
 			$temp_array['spotter_id'] = $row['spotter_id'];
9233 9233
 			$temp_array['route_count'] = $row['route_count'];
@@ -9252,11 +9252,11 @@  discard block
 block discarded – undo
9252 9252
 	* @return Array the callsign list
9253 9253
 	*
9254 9254
 	*/
9255
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
9255
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
9256 9256
 	{
9257 9257
 		global $globalDBdriver;
9258
-		$filter_query = $this->getFilter($filters,true,true);
9259
-		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9258
+		$filter_query = $this->getFilter($filters, true, true);
9259
+		$query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9260 9260
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9261 9261
 		 if ($olderthanmonths > 0) {
9262 9262
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -9270,28 +9270,28 @@  discard block
 block discarded – undo
9270 9270
 		if ($year != '') {
9271 9271
 			if ($globalDBdriver == 'mysql') {
9272 9272
 				$query .= " AND YEAR(spotter_output.date) = :year";
9273
-				$query_values = array_merge($query_values,array(':year' => $year));
9273
+				$query_values = array_merge($query_values, array(':year' => $year));
9274 9274
 			} else {
9275 9275
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
9276
-				$query_values = array_merge($query_values,array(':year' => $year));
9276
+				$query_values = array_merge($query_values, array(':year' => $year));
9277 9277
 			}
9278 9278
 		}
9279 9279
 		if ($month != '') {
9280 9280
 			if ($globalDBdriver == 'mysql') {
9281 9281
 				$query .= " AND MONTH(spotter_output.date) = :month";
9282
-				$query_values = array_merge($query_values,array(':month' => $month));
9282
+				$query_values = array_merge($query_values, array(':month' => $month));
9283 9283
 			} else {
9284 9284
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
9285
-				$query_values = array_merge($query_values,array(':month' => $month));
9285
+				$query_values = array_merge($query_values, array(':month' => $month));
9286 9286
 			}
9287 9287
 		}
9288 9288
 		if ($day != '') {
9289 9289
 			if ($globalDBdriver == 'mysql') {
9290 9290
 				$query .= " AND DAY(spotter_output.date) = :day";
9291
-				$query_values = array_merge($query_values,array(':day' => $day));
9291
+				$query_values = array_merge($query_values, array(':day' => $day));
9292 9292
 			} else {
9293 9293
 				$query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day";
9294
-				$query_values = array_merge($query_values,array(':day' => $day));
9294
+				$query_values = array_merge($query_values, array(':day' => $day));
9295 9295
 			}
9296 9296
 		}
9297 9297
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
@@ -9303,7 +9303,7 @@  discard block
 block discarded – undo
9303 9303
 		$callsign_array = array();
9304 9304
 		$temp_array = array();
9305 9305
         
9306
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9306
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9307 9307
 		{
9308 9308
 			$temp_array['callsign_icao'] = $row['ident'];
9309 9309
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9325,8 +9325,8 @@  discard block
 block discarded – undo
9325 9325
 	public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
9326 9326
 	{
9327 9327
 		global $globalDBdriver;
9328
-		$filter_query = $this->getFilter($filters,true,true);
9329
-		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9328
+		$filter_query = $this->getFilter($filters, true, true);
9329
+		$query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9330 9330
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9331 9331
 		 if ($olderthanmonths > 0) {
9332 9332
 			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
@@ -9345,7 +9345,7 @@  discard block
 block discarded – undo
9345 9345
 		$callsign_array = array();
9346 9346
 		$temp_array = array();
9347 9347
         
9348
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9348
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9349 9349
 		{
9350 9350
 			$temp_array['callsign_icao'] = $row['ident'];
9351 9351
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -9399,7 +9399,7 @@  discard block
 block discarded – undo
9399 9399
 		$date_array = array();
9400 9400
 		$temp_array = array();
9401 9401
         
9402
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9402
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9403 9403
 		{
9404 9404
 			$temp_array['date_name'] = $row['date_name'];
9405 9405
 			$temp_array['date_count'] = $row['date_count'];
@@ -9424,15 +9424,15 @@  discard block
 block discarded – undo
9424 9424
 			$datetime = new DateTime();
9425 9425
 			$offset = $datetime->format('P');
9426 9426
 		} else $offset = '+00:00';
9427
-		$filter_query = $this->getFilter($filters,true,true);
9427
+		$filter_query = $this->getFilter($filters, true, true);
9428 9428
 		if ($globalDBdriver == 'mysql') {
9429
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9429
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9430 9430
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9431 9431
 								GROUP BY spotter_output.airline_icao, date_name 
9432 9432
 								ORDER BY date_count DESC
9433 9433
 								LIMIT 10 OFFSET 0";
9434 9434
 		} else {
9435
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9435
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9436 9436
 								FROM spotter_output 
9437 9437
 								WHERE spotter_output.airline_icao <> '' 
9438 9438
 								GROUP BY spotter_output.airline_icao, date_name 
@@ -9447,7 +9447,7 @@  discard block
 block discarded – undo
9447 9447
 		$date_array = array();
9448 9448
 		$temp_array = array();
9449 9449
         
9450
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9450
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9451 9451
 		{
9452 9452
 			$temp_array['date_name'] = $row['date_name'];
9453 9453
 			$temp_array['date_count'] = $row['date_count'];
@@ -9473,7 +9473,7 @@  discard block
 block discarded – undo
9473 9473
 			$datetime = new DateTime();
9474 9474
 			$offset = $datetime->format('P');
9475 9475
 		} else $offset = '+00:00';
9476
-		$filter_query = $this->getFilter($filters,true,true);
9476
+		$filter_query = $this->getFilter($filters, true, true);
9477 9477
 		if ($globalDBdriver == 'mysql') {
9478 9478
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9479 9479
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -9494,7 +9494,7 @@  discard block
 block discarded – undo
9494 9494
 		$date_array = array();
9495 9495
 		$temp_array = array();
9496 9496
         
9497
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9497
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9498 9498
 		{
9499 9499
 			$temp_array['date_name'] = $row['date_name'];
9500 9500
 			$temp_array['date_count'] = $row['date_count'];
@@ -9519,7 +9519,7 @@  discard block
 block discarded – undo
9519 9519
 			$datetime = new DateTime();
9520 9520
 			$offset = $datetime->format('P');
9521 9521
 		} else $offset = '+00:00';
9522
-		$filter_query = $this->getFilter($filters,true,true);
9522
+		$filter_query = $this->getFilter($filters, true, true);
9523 9523
 		if ($globalDBdriver == 'mysql') {
9524 9524
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9525 9525
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -9540,7 +9540,7 @@  discard block
 block discarded – undo
9540 9540
 		$date_array = array();
9541 9541
 		$temp_array = array();
9542 9542
         
9543
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9543
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9544 9544
 		{
9545 9545
 			$temp_array['date_name'] = $row['date_name'];
9546 9546
 			$temp_array['date_count'] = $row['date_count'];
@@ -9561,7 +9561,7 @@  discard block
 block discarded – undo
9561 9561
 	public function countAllDatesLastMonthByAirlines($filters = array())
9562 9562
 	{
9563 9563
 		global $globalTimezone, $globalDBdriver;
9564
-		$filter_query = $this->getFilter($filters,true,true);
9564
+		$filter_query = $this->getFilter($filters, true, true);
9565 9565
 		if ($globalTimezone != '') {
9566 9566
 			date_default_timezone_set($globalTimezone);
9567 9567
 			$datetime = new DateTime();
@@ -9569,13 +9569,13 @@  discard block
 block discarded – undo
9569 9569
 		} else $offset = '+00:00';
9570 9570
 		
9571 9571
 		if ($globalDBdriver == 'mysql') {
9572
-			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9572
+			$query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
9573 9573
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)
9574 9574
 								GROUP BY spotter_output.airline_icao, date_name 
9575 9575
 								ORDER BY spotter_output.date ASC";
9576 9576
 			$query_data = array(':offset' => $offset);
9577 9577
 		} else {
9578
-			$query  = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9578
+			$query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count
9579 9579
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS'
9580 9580
 								GROUP BY spotter_output.airline_icao, date_name 
9581 9581
 								ORDER BY date_name ASC";
@@ -9588,7 +9588,7 @@  discard block
 block discarded – undo
9588 9588
 		$date_array = array();
9589 9589
 		$temp_array = array();
9590 9590
         
9591
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9591
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9592 9592
 		{
9593 9593
 			$temp_array['date_name'] = $row['date_name'];
9594 9594
 			$temp_array['date_count'] = $row['date_count'];
@@ -9635,7 +9635,7 @@  discard block
 block discarded – undo
9635 9635
 		$date_array = array();
9636 9636
 		$temp_array = array();
9637 9637
         
9638
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9638
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9639 9639
 		{
9640 9640
 			$temp_array['month_name'] = $row['month_name'];
9641 9641
 			$temp_array['year_name'] = $row['year_name'];
@@ -9656,7 +9656,7 @@  discard block
 block discarded – undo
9656 9656
 	public function countAllMonthsByAirlines($filters = array())
9657 9657
 	{
9658 9658
 		global $globalTimezone, $globalDBdriver;
9659
-		$filter_query = $this->getFilter($filters,true,true);
9659
+		$filter_query = $this->getFilter($filters, true, true);
9660 9660
 		if ($globalTimezone != '') {
9661 9661
 			date_default_timezone_set($globalTimezone);
9662 9662
 			$datetime = new DateTime();
@@ -9664,12 +9664,12 @@  discard block
 block discarded – undo
9664 9664
 		} else $offset = '+00:00';
9665 9665
 
9666 9666
 		if ($globalDBdriver == 'mysql') {
9667
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9667
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9668 9668
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
9669 9669
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
9670 9670
 								ORDER BY date_count DESC";
9671 9671
 		} else {
9672
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9672
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9673 9673
 								FROM spotter_output 
9674 9674
 								WHERE spotter_output.airline_icao <> '' 
9675 9675
 								GROUP BY spotter_output.airline_icao, year_name, month_name 
@@ -9683,7 +9683,7 @@  discard block
 block discarded – undo
9683 9683
 		$date_array = array();
9684 9684
 		$temp_array = array();
9685 9685
         
9686
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9686
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9687 9687
 		{
9688 9688
 			$temp_array['month_name'] = $row['month_name'];
9689 9689
 			$temp_array['year_name'] = $row['year_name'];
@@ -9710,14 +9710,14 @@  discard block
 block discarded – undo
9710 9710
 			$datetime = new DateTime();
9711 9711
 			$offset = $datetime->format('P');
9712 9712
 		} else $offset = '+00:00';
9713
-		$filter_query = $this->getFilter($filters,true,true);
9713
+		$filter_query = $this->getFilter($filters, true, true);
9714 9714
 		if ($globalDBdriver == 'mysql') {
9715
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9715
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
9716 9716
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9717 9717
 								GROUP BY year_name, month_name 
9718 9718
 								ORDER BY date_count DESC";
9719 9719
 		} else {
9720
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9720
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count
9721 9721
 								FROM spotter_output".$filter_query." spotter_output.airline_type = 'military'
9722 9722
 								GROUP BY year_name, month_name 
9723 9723
 								ORDER BY date_count DESC";
@@ -9729,7 +9729,7 @@  discard block
 block discarded – undo
9729 9729
 		$date_array = array();
9730 9730
 		$temp_array = array();
9731 9731
         
9732
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9732
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9733 9733
 		{
9734 9734
 			$temp_array['month_name'] = $row['month_name'];
9735 9735
 			$temp_array['year_name'] = $row['year_name'];
@@ -9755,15 +9755,15 @@  discard block
 block discarded – undo
9755 9755
 			$datetime = new DateTime();
9756 9756
 			$offset = $datetime->format('P');
9757 9757
 		} else $offset = '+00:00';
9758
-		$filter_query = $this->getFilter($filters,true,true);
9758
+		$filter_query = $this->getFilter($filters, true, true);
9759 9759
 
9760 9760
 		if ($globalDBdriver == 'mysql') {
9761
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9761
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9762 9762
 								FROM spotter_output".$filter_query." owner_name <> ''
9763 9763
 								GROUP BY year_name, month_name
9764 9764
 								ORDER BY date_count DESC";
9765 9765
 		} else {
9766
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9766
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9767 9767
 								FROM spotter_output".$filter_query." owner_name <> ''
9768 9768
 								GROUP BY year_name, month_name
9769 9769
 								ORDER BY date_count DESC";
@@ -9775,7 +9775,7 @@  discard block
 block discarded – undo
9775 9775
 		$date_array = array();
9776 9776
 		$temp_array = array();
9777 9777
         
9778
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9778
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9779 9779
 		{
9780 9780
 			$temp_array['month_name'] = $row['month_name'];
9781 9781
 			$temp_array['year_name'] = $row['year_name'];
@@ -9796,7 +9796,7 @@  discard block
 block discarded – undo
9796 9796
 	public function countAllMonthsOwnersByAirlines($filters = array())
9797 9797
 	{
9798 9798
 		global $globalTimezone, $globalDBdriver;
9799
-		$filter_query = $this->getFilter($filters,true,true);
9799
+		$filter_query = $this->getFilter($filters, true, true);
9800 9800
 		if ($globalTimezone != '') {
9801 9801
 			date_default_timezone_set($globalTimezone);
9802 9802
 			$datetime = new DateTime();
@@ -9804,12 +9804,12 @@  discard block
 block discarded – undo
9804 9804
 		} else $offset = '+00:00';
9805 9805
 
9806 9806
 		if ($globalDBdriver == 'mysql') {
9807
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9807
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
9808 9808
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9809 9809
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9810 9810
 								ORDER BY date_count DESC";
9811 9811
 		} else {
9812
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9812
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count
9813 9813
 								FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' 
9814 9814
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9815 9815
 								ORDER BY date_count DESC";
@@ -9821,7 +9821,7 @@  discard block
 block discarded – undo
9821 9821
 		$date_array = array();
9822 9822
 		$temp_array = array();
9823 9823
         
9824
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9824
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9825 9825
 		{
9826 9826
 			$temp_array['month_name'] = $row['month_name'];
9827 9827
 			$temp_array['year_name'] = $row['year_name'];
@@ -9848,15 +9848,15 @@  discard block
 block discarded – undo
9848 9848
 			$datetime = new DateTime();
9849 9849
 			$offset = $datetime->format('P');
9850 9850
 		} else $offset = '+00:00';
9851
-		$filter_query = $this->getFilter($filters,true,true);
9851
+		$filter_query = $this->getFilter($filters, true, true);
9852 9852
 
9853 9853
 		if ($globalDBdriver == 'mysql') {
9854
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9854
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9855 9855
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9856 9856
 								GROUP BY year_name, month_name
9857 9857
 								ORDER BY date_count DESC";
9858 9858
 		} else {
9859
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9859
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9860 9860
 								FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL
9861 9861
 								GROUP BY year_name, month_name
9862 9862
 								ORDER BY date_count DESC";
@@ -9868,7 +9868,7 @@  discard block
 block discarded – undo
9868 9868
 		$date_array = array();
9869 9869
 		$temp_array = array();
9870 9870
         
9871
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9871
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9872 9872
 		{
9873 9873
 			$temp_array['month_name'] = $row['month_name'];
9874 9874
 			$temp_array['year_name'] = $row['year_name'];
@@ -9889,7 +9889,7 @@  discard block
 block discarded – undo
9889 9889
 	public function countAllMonthsPilotsByAirlines($filters = array())
9890 9890
 	{
9891 9891
 		global $globalTimezone, $globalDBdriver;
9892
-		$filter_query = $this->getFilter($filters,true,true);
9892
+		$filter_query = $this->getFilter($filters, true, true);
9893 9893
 		if ($globalTimezone != '') {
9894 9894
 			date_default_timezone_set($globalTimezone);
9895 9895
 			$datetime = new DateTime();
@@ -9897,12 +9897,12 @@  discard block
 block discarded – undo
9897 9897
 		} else $offset = '+00:00';
9898 9898
 
9899 9899
 		if ($globalDBdriver == 'mysql') {
9900
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9900
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
9901 9901
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9902 9902
 								GROUP BY spotter_output.airline_icao,year_name, month_name
9903 9903
 								ORDER BY date_count DESC";
9904 9904
 		} else {
9905
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9905
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count
9906 9906
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL
9907 9907
 								GROUP BY spotter_output.airline_icao, year_name, month_name
9908 9908
 								ORDER BY date_count DESC";
@@ -9914,7 +9914,7 @@  discard block
 block discarded – undo
9914 9914
 		$date_array = array();
9915 9915
 		$temp_array = array();
9916 9916
         
9917
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9917
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9918 9918
 		{
9919 9919
 			$temp_array['month_name'] = $row['month_name'];
9920 9920
 			$temp_array['year_name'] = $row['year_name'];
@@ -9936,7 +9936,7 @@  discard block
 block discarded – undo
9936 9936
 	public function countAllMonthsAirlines($filters = array())
9937 9937
 	{
9938 9938
 		global $globalTimezone, $globalDBdriver;
9939
-		$filter_query = $this->getFilter($filters,true,true);
9939
+		$filter_query = $this->getFilter($filters, true, true);
9940 9940
 		if ($globalTimezone != '') {
9941 9941
 			date_default_timezone_set($globalTimezone);
9942 9942
 			$datetime = new DateTime();
@@ -9944,12 +9944,12 @@  discard block
 block discarded – undo
9944 9944
 		} else $offset = '+00:00';
9945 9945
 
9946 9946
 		if ($globalDBdriver == 'mysql') {
9947
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
9947
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
9948 9948
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9949 9949
 								GROUP BY year_name, month_name
9950 9950
 								ORDER BY date_count DESC";
9951 9951
 		} else {
9952
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
9952
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count
9953 9953
 								FROM spotter_output".$filter_query." airline_icao <> '' 
9954 9954
 								GROUP BY year_name, month_name
9955 9955
 								ORDER BY date_count DESC";
@@ -9961,7 +9961,7 @@  discard block
 block discarded – undo
9961 9961
 		$date_array = array();
9962 9962
 		$temp_array = array();
9963 9963
         
9964
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
9964
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
9965 9965
 		{
9966 9966
 			$temp_array['month_name'] = $row['month_name'];
9967 9967
 			$temp_array['year_name'] = $row['year_name'];
@@ -9987,15 +9987,15 @@  discard block
 block discarded – undo
9987 9987
 			$datetime = new DateTime();
9988 9988
 			$offset = $datetime->format('P');
9989 9989
 		} else $offset = '+00:00';
9990
-		$filter_query = $this->getFilter($filters,true,true);
9990
+		$filter_query = $this->getFilter($filters, true, true);
9991 9991
 
9992 9992
 		if ($globalDBdriver == 'mysql') {
9993
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
9993
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
9994 9994
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
9995 9995
 								GROUP BY year_name, month_name
9996 9996
 								ORDER BY date_count DESC";
9997 9997
 		} else {
9998
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
9998
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
9999 9999
 								FROM spotter_output".$filter_query." aircraft_icao <> '' 
10000 10000
 								GROUP BY year_name, month_name
10001 10001
 								ORDER BY date_count DESC";
@@ -10007,7 +10007,7 @@  discard block
 block discarded – undo
10007 10007
 		$date_array = array();
10008 10008
 		$temp_array = array();
10009 10009
         
10010
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10010
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10011 10011
 		{
10012 10012
 			$temp_array['month_name'] = $row['month_name'];
10013 10013
 			$temp_array['year_name'] = $row['year_name'];
@@ -10029,7 +10029,7 @@  discard block
 block discarded – undo
10029 10029
 	public function countAllMonthsAircraftsByAirlines($filters = array())
10030 10030
 	{
10031 10031
 		global $globalTimezone, $globalDBdriver;
10032
-		$filter_query = $this->getFilter($filters,true,true);
10032
+		$filter_query = $this->getFilter($filters, true, true);
10033 10033
 		if ($globalTimezone != '') {
10034 10034
 			date_default_timezone_set($globalTimezone);
10035 10035
 			$datetime = new DateTime();
@@ -10037,12 +10037,12 @@  discard block
 block discarded – undo
10037 10037
 		} else $offset = '+00:00';
10038 10038
 
10039 10039
 		if ($globalDBdriver == 'mysql') {
10040
-			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
10040
+			$query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
10041 10041
 								FROM spotter_output".$filter_query." aircraft_icao <> ''  AND spotter_output.airline_icao <> '' 
10042 10042
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10043 10043
 								ORDER BY date_count DESC";
10044 10044
 		} else {
10045
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
10045
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count
10046 10046
 								FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' 
10047 10047
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10048 10048
 								ORDER BY date_count DESC";
@@ -10054,7 +10054,7 @@  discard block
 block discarded – undo
10054 10054
 		$date_array = array();
10055 10055
 		$temp_array = array();
10056 10056
         
10057
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10057
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10058 10058
 		{
10059 10059
 			$temp_array['month_name'] = $row['month_name'];
10060 10060
 			$temp_array['year_name'] = $row['year_name'];
@@ -10081,15 +10081,15 @@  discard block
 block discarded – undo
10081 10081
 			$datetime = new DateTime();
10082 10082
 			$offset = $datetime->format('P');
10083 10083
 		} else $offset = '+00:00';
10084
-		$filter_query = $this->getFilter($filters,true,true);
10084
+		$filter_query = $this->getFilter($filters, true, true);
10085 10085
 
10086 10086
 		if ($globalDBdriver == 'mysql') {
10087
-			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10087
+			$query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10088 10088
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10089 10089
 								GROUP BY year_name, month_name
10090 10090
 								ORDER BY date_count DESC";
10091 10091
 		} else {
10092
-			$query  = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10092
+			$query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10093 10093
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' 
10094 10094
 								GROUP BY year_name, month_name
10095 10095
 								ORDER BY date_count DESC";
@@ -10101,7 +10101,7 @@  discard block
 block discarded – undo
10101 10101
 		$date_array = array();
10102 10102
 		$temp_array = array();
10103 10103
         
10104
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10104
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10105 10105
 		{
10106 10106
 			$temp_array['month_name'] = $row['month_name'];
10107 10107
 			$temp_array['year_name'] = $row['year_name'];
@@ -10123,7 +10123,7 @@  discard block
 block discarded – undo
10123 10123
 	public function countAllMonthsRealArrivalsByAirlines($filters = array())
10124 10124
 	{
10125 10125
 		global $globalTimezone, $globalDBdriver;
10126
-		$filter_query = $this->getFilter($filters,true,true);
10126
+		$filter_query = $this->getFilter($filters, true, true);
10127 10127
 		if ($globalTimezone != '') {
10128 10128
 			date_default_timezone_set($globalTimezone);
10129 10129
 			$datetime = new DateTime();
@@ -10131,12 +10131,12 @@  discard block
 block discarded – undo
10131 10131
 		} else $offset = '+00:00';
10132 10132
 
10133 10133
 		if ($globalDBdriver == 'mysql') {
10134
-			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10134
+			$query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
10135 10135
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10136 10136
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10137 10137
 								ORDER BY date_count DESC";
10138 10138
 		} else {
10139
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10139
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count
10140 10140
 								FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' 
10141 10141
 								GROUP BY spotter_output.airline_icao, year_name, month_name
10142 10142
 								ORDER BY date_count DESC";
@@ -10148,7 +10148,7 @@  discard block
 block discarded – undo
10148 10148
 		$date_array = array();
10149 10149
 		$temp_array = array();
10150 10150
         
10151
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10151
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10152 10152
 		{
10153 10153
 			$temp_array['month_name'] = $row['month_name'];
10154 10154
 			$temp_array['year_name'] = $row['year_name'];
@@ -10176,7 +10176,7 @@  discard block
 block discarded – undo
10176 10176
 			$datetime = new DateTime();
10177 10177
 			$offset = $datetime->format('P');
10178 10178
 		} else $offset = '+00:00';
10179
-		$filter_query = $this->getFilter($filters,true,true);
10179
+		$filter_query = $this->getFilter($filters, true, true);
10180 10180
 		if ($globalDBdriver == 'mysql') {
10181 10181
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
10182 10182
 								FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -10197,7 +10197,7 @@  discard block
 block discarded – undo
10197 10197
 		$date_array = array();
10198 10198
 		$temp_array = array();
10199 10199
         
10200
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10200
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10201 10201
 		{
10202 10202
 			$temp_array['year_name'] = $row['year_name'];
10203 10203
 			$temp_array['month_name'] = $row['month_name'];
@@ -10217,7 +10217,7 @@  discard block
 block discarded – undo
10217 10217
 	* @return Array the hour list
10218 10218
 	*
10219 10219
 	*/
10220
-	public function countAllHours($orderby,$filters = array())
10220
+	public function countAllHours($orderby, $filters = array())
10221 10221
 	{
10222 10222
 		global $globalTimezone, $globalDBdriver;
10223 10223
 		if ($globalTimezone != '') {
@@ -10265,7 +10265,7 @@  discard block
 block discarded – undo
10265 10265
 		$hour_array = array();
10266 10266
 		$temp_array = array();
10267 10267
         
10268
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10268
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10269 10269
 		{
10270 10270
 			$temp_array['hour_name'] = $row['hour_name'];
10271 10271
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10285,7 +10285,7 @@  discard block
 block discarded – undo
10285 10285
 	public function countAllHoursByAirlines($orderby, $filters = array())
10286 10286
 	{
10287 10287
 		global $globalTimezone, $globalDBdriver;
10288
-		$filter_query = $this->getFilter($filters,true,true);
10288
+		$filter_query = $this->getFilter($filters, true, true);
10289 10289
 		if ($globalTimezone != '') {
10290 10290
 			date_default_timezone_set($globalTimezone);
10291 10291
 			$datetime = new DateTime();
@@ -10303,7 +10303,7 @@  discard block
 block discarded – undo
10303 10303
 		}
10304 10304
 		
10305 10305
 		if ($globalDBdriver == 'mysql') {
10306
-			$query  = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10306
+			$query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10307 10307
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10308 10308
 								GROUP BY spotter_output.airline_icao, hour_name 
10309 10309
 								".$orderby_sql;
@@ -10316,7 +10316,7 @@  discard block
 block discarded – undo
10316 10316
   */    
10317 10317
 		$query_data = array(':offset' => $offset);
10318 10318
 		} else {
10319
-			$query  = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10319
+			$query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10320 10320
 								FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' 
10321 10321
 								GROUP BY spotter_output.airline_icao, hour_name 
10322 10322
 								".$orderby_sql;
@@ -10329,7 +10329,7 @@  discard block
 block discarded – undo
10329 10329
 		$hour_array = array();
10330 10330
 		$temp_array = array();
10331 10331
         
10332
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10332
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10333 10333
 		{
10334 10334
 			$temp_array['hour_name'] = $row['hour_name'];
10335 10335
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10352,34 +10352,34 @@  discard block
 block discarded – undo
10352 10352
 	public function countAllHoursByAirline($airline_icao, $filters = array())
10353 10353
 	{
10354 10354
 		global $globalTimezone, $globalDBdriver;
10355
-		$filter_query = $this->getFilter($filters,true,true);
10355
+		$filter_query = $this->getFilter($filters, true, true);
10356 10356
 		if ($globalTimezone != '') {
10357 10357
 			date_default_timezone_set($globalTimezone);
10358 10358
 			$datetime = new DateTime();
10359 10359
 			$offset = $datetime->format('P');
10360 10360
 		} else $offset = '+00:00';
10361 10361
 
10362
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10362
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
10363 10363
 
10364 10364
 		if ($globalDBdriver == 'mysql') {
10365
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10365
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10366 10366
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10367 10367
 								GROUP BY hour_name 
10368 10368
 								ORDER BY hour_name ASC";
10369 10369
 		} else {
10370
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10370
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10371 10371
 								FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao
10372 10372
 								GROUP BY hour_name 
10373 10373
 								ORDER BY hour_name ASC";
10374 10374
 		}
10375 10375
 		
10376 10376
 		$sth = $this->db->prepare($query);
10377
-		$sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset));
10377
+		$sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset));
10378 10378
       
10379 10379
 		$hour_array = array();
10380 10380
 		$temp_array = array();
10381 10381
         
10382
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10382
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10383 10383
 		{
10384 10384
 			$temp_array['hour_name'] = $row['hour_name'];
10385 10385
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10402,8 +10402,8 @@  discard block
 block discarded – undo
10402 10402
 	public function countAllHoursByAircraft($aircraft_icao, $filters = array())
10403 10403
 	{
10404 10404
 		global $globalTimezone, $globalDBdriver;
10405
-		$filter_query = $this->getFilter($filters,true,true);
10406
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
10405
+		$filter_query = $this->getFilter($filters, true, true);
10406
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
10407 10407
 		if ($globalTimezone != '') {
10408 10408
 			date_default_timezone_set($globalTimezone);
10409 10409
 			$datetime = new DateTime();
@@ -10411,24 +10411,24 @@  discard block
 block discarded – undo
10411 10411
 		} else $offset = '+00:00';
10412 10412
 
10413 10413
 		if ($globalDBdriver == 'mysql') {
10414
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10414
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10415 10415
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10416 10416
 								GROUP BY hour_name 
10417 10417
 								ORDER BY hour_name ASC";
10418 10418
 		} else {
10419
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10419
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10420 10420
 								FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao
10421 10421
 								GROUP BY hour_name 
10422 10422
 								ORDER BY hour_name ASC";
10423 10423
 		}
10424 10424
 		
10425 10425
 		$sth = $this->db->prepare($query);
10426
-		$sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset));
10426
+		$sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset));
10427 10427
       
10428 10428
 		$hour_array = array();
10429 10429
 		$temp_array = array();
10430 10430
         
10431
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10431
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10432 10432
 		{
10433 10433
 			$temp_array['hour_name'] = $row['hour_name'];
10434 10434
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10449,8 +10449,8 @@  discard block
 block discarded – undo
10449 10449
 	public function countAllHoursByRegistration($registration, $filters = array())
10450 10450
 	{
10451 10451
 		global $globalTimezone, $globalDBdriver;
10452
-		$filter_query = $this->getFilter($filters,true,true);
10453
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
10452
+		$filter_query = $this->getFilter($filters, true, true);
10453
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
10454 10454
 		if ($globalTimezone != '') {
10455 10455
 			date_default_timezone_set($globalTimezone);
10456 10456
 			$datetime = new DateTime();
@@ -10458,24 +10458,24 @@  discard block
 block discarded – undo
10458 10458
 		} else $offset = '+00:00';
10459 10459
 
10460 10460
 		if ($globalDBdriver == 'mysql') {
10461
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10461
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10462 10462
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10463 10463
 								GROUP BY hour_name 
10464 10464
 								ORDER BY hour_name ASC";
10465 10465
 		} else {
10466
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10466
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10467 10467
 								FROM spotter_output".$filter_query." spotter_output.registration = :registration
10468 10468
 								GROUP BY hour_name 
10469 10469
 								ORDER BY hour_name ASC";
10470 10470
 		}
10471 10471
 		
10472 10472
 		$sth = $this->db->prepare($query);
10473
-		$sth->execute(array(':registration' => $registration,':offset' => $offset));
10473
+		$sth->execute(array(':registration' => $registration, ':offset' => $offset));
10474 10474
       
10475 10475
 		$hour_array = array();
10476 10476
 		$temp_array = array();
10477 10477
         
10478
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10478
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10479 10479
 		{
10480 10480
 			$temp_array['hour_name'] = $row['hour_name'];
10481 10481
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10496,8 +10496,8 @@  discard block
 block discarded – undo
10496 10496
 	public function countAllHoursByAirport($airport_icao, $filters = array())
10497 10497
 	{
10498 10498
 		global $globalTimezone, $globalDBdriver;
10499
-		$filter_query = $this->getFilter($filters,true,true);
10500
-		$airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING);
10499
+		$filter_query = $this->getFilter($filters, true, true);
10500
+		$airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING);
10501 10501
 		if ($globalTimezone != '') {
10502 10502
 			date_default_timezone_set($globalTimezone);
10503 10503
 			$datetime = new DateTime();
@@ -10505,24 +10505,24 @@  discard block
 block discarded – undo
10505 10505
 		} else $offset = '+00:00';
10506 10506
 
10507 10507
 		if ($globalDBdriver == 'mysql') {
10508
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10508
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10509 10509
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10510 10510
 								GROUP BY hour_name 
10511 10511
 								ORDER BY hour_name ASC";
10512 10512
 		} else {
10513
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10513
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10514 10514
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao)
10515 10515
 								GROUP BY hour_name 
10516 10516
 								ORDER BY hour_name ASC";
10517 10517
 		}
10518 10518
 		
10519 10519
 		$sth = $this->db->prepare($query);
10520
-		$sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset));
10520
+		$sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset));
10521 10521
       
10522 10522
 		$hour_array = array();
10523 10523
 		$temp_array = array();
10524 10524
         
10525
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10525
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10526 10526
 		{
10527 10527
 			$temp_array['hour_name'] = $row['hour_name'];
10528 10528
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10541,11 +10541,11 @@  discard block
 block discarded – undo
10541 10541
 	* @return Array the hour list
10542 10542
 	*
10543 10543
 	*/
10544
-	public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array())
10544
+	public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array())
10545 10545
 	{
10546 10546
 		global $globalTimezone, $globalDBdriver;
10547
-		$filter_query = $this->getFilter($filters,true,true);
10548
-		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
10547
+		$filter_query = $this->getFilter($filters, true, true);
10548
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
10549 10549
 		if ($globalTimezone != '') {
10550 10550
 			date_default_timezone_set($globalTimezone);
10551 10551
 			$datetime = new DateTime();
@@ -10553,24 +10553,24 @@  discard block
 block discarded – undo
10553 10553
 		} else $offset = '+00:00';
10554 10554
 
10555 10555
 		if ($globalDBdriver == 'mysql') {
10556
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10556
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10557 10557
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10558 10558
 								GROUP BY hour_name 
10559 10559
 								ORDER BY hour_name ASC";
10560 10560
 		} else {
10561
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10561
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10562 10562
 								FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer
10563 10563
 								GROUP BY hour_name 
10564 10564
 								ORDER BY hour_name ASC";
10565 10565
 		}
10566 10566
 		
10567 10567
 		$sth = $this->db->prepare($query);
10568
-		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset));
10568
+		$sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset));
10569 10569
       
10570 10570
 		$hour_array = array();
10571 10571
 		$temp_array = array();
10572 10572
         
10573
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10573
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10574 10574
 		{
10575 10575
 			$temp_array['hour_name'] = $row['hour_name'];
10576 10576
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10592,8 +10592,8 @@  discard block
 block discarded – undo
10592 10592
 	public function countAllHoursByDate($date, $filters = array())
10593 10593
 	{
10594 10594
 		global $globalTimezone, $globalDBdriver;
10595
-		$filter_query = $this->getFilter($filters,true,true);
10596
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
10595
+		$filter_query = $this->getFilter($filters, true, true);
10596
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
10597 10597
 		if ($globalTimezone != '') {
10598 10598
 			date_default_timezone_set($globalTimezone);
10599 10599
 			$datetime = new DateTime($date);
@@ -10601,12 +10601,12 @@  discard block
 block discarded – undo
10601 10601
 		} else $offset = '+00:00';
10602 10602
 
10603 10603
 		if ($globalDBdriver == 'mysql') {
10604
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10604
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10605 10605
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date
10606 10606
 								GROUP BY hour_name 
10607 10607
 								ORDER BY hour_name ASC";
10608 10608
 		} else {
10609
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10609
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10610 10610
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
10611 10611
 								GROUP BY hour_name 
10612 10612
 								ORDER BY hour_name ASC";
@@ -10618,7 +10618,7 @@  discard block
 block discarded – undo
10618 10618
 		$hour_array = array();
10619 10619
 		$temp_array = array();
10620 10620
         
10621
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10621
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10622 10622
 		{
10623 10623
 			$temp_array['hour_name'] = $row['hour_name'];
10624 10624
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10640,8 +10640,8 @@  discard block
 block discarded – undo
10640 10640
 	public function countAllHoursByIdent($ident, $filters = array())
10641 10641
 	{
10642 10642
 		global $globalTimezone, $globalDBdriver;
10643
-		$filter_query = $this->getFilter($filters,true,true);
10644
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
10643
+		$filter_query = $this->getFilter($filters, true, true);
10644
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
10645 10645
 		if ($globalTimezone != '') {
10646 10646
 			date_default_timezone_set($globalTimezone);
10647 10647
 			$datetime = new DateTime();
@@ -10649,12 +10649,12 @@  discard block
 block discarded – undo
10649 10649
 		} else $offset = '+00:00';
10650 10650
 
10651 10651
 		if ($globalDBdriver == 'mysql') {
10652
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10652
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10653 10653
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10654 10654
 								GROUP BY hour_name 
10655 10655
 								ORDER BY hour_name ASC";
10656 10656
 		} else {
10657
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10657
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10658 10658
 								FROM spotter_output".$filter_query." spotter_output.ident = :ident 
10659 10659
 								GROUP BY hour_name 
10660 10660
 								ORDER BY hour_name ASC";
@@ -10662,12 +10662,12 @@  discard block
 block discarded – undo
10662 10662
       
10663 10663
 		
10664 10664
 		$sth = $this->db->prepare($query);
10665
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
10665
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
10666 10666
       
10667 10667
 		$hour_array = array();
10668 10668
 		$temp_array = array();
10669 10669
         
10670
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10670
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10671 10671
 		{
10672 10672
 			$temp_array['hour_name'] = $row['hour_name'];
10673 10673
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10687,8 +10687,8 @@  discard block
 block discarded – undo
10687 10687
 	public function countAllHoursByOwner($owner, $filters = array())
10688 10688
 	{
10689 10689
 		global $globalTimezone, $globalDBdriver;
10690
-		$filter_query = $this->getFilter($filters,true,true);
10691
-		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
10690
+		$filter_query = $this->getFilter($filters, true, true);
10691
+		$owner = filter_var($owner, FILTER_SANITIZE_STRING);
10692 10692
 		if ($globalTimezone != '') {
10693 10693
 			date_default_timezone_set($globalTimezone);
10694 10694
 			$datetime = new DateTime();
@@ -10696,12 +10696,12 @@  discard block
 block discarded – undo
10696 10696
 		} else $offset = '+00:00';
10697 10697
 
10698 10698
 		if ($globalDBdriver == 'mysql') {
10699
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10699
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10700 10700
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10701 10701
 								GROUP BY hour_name 
10702 10702
 								ORDER BY hour_name ASC";
10703 10703
 		} else {
10704
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10704
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10705 10705
 								FROM spotter_output".$filter_query." spotter_output.owner_name = :owner 
10706 10706
 								GROUP BY hour_name 
10707 10707
 								ORDER BY hour_name ASC";
@@ -10709,12 +10709,12 @@  discard block
 block discarded – undo
10709 10709
       
10710 10710
 		
10711 10711
 		$sth = $this->db->prepare($query);
10712
-		$sth->execute(array(':owner' => $owner,':offset' => $offset));
10712
+		$sth->execute(array(':owner' => $owner, ':offset' => $offset));
10713 10713
       
10714 10714
 		$hour_array = array();
10715 10715
 		$temp_array = array();
10716 10716
         
10717
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10717
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10718 10718
 		{
10719 10719
 			$temp_array['hour_name'] = $row['hour_name'];
10720 10720
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10734,8 +10734,8 @@  discard block
 block discarded – undo
10734 10734
 	public function countAllHoursByPilot($pilot, $filters = array())
10735 10735
 	{
10736 10736
 		global $globalTimezone, $globalDBdriver;
10737
-		$filter_query = $this->getFilter($filters,true,true);
10738
-		$pilot = filter_var($pilot,FILTER_SANITIZE_STRING);
10737
+		$filter_query = $this->getFilter($filters, true, true);
10738
+		$pilot = filter_var($pilot, FILTER_SANITIZE_STRING);
10739 10739
 		if ($globalTimezone != '') {
10740 10740
 			date_default_timezone_set($globalTimezone);
10741 10741
 			$datetime = new DateTime();
@@ -10743,12 +10743,12 @@  discard block
 block discarded – undo
10743 10743
 		} else $offset = '+00:00';
10744 10744
 
10745 10745
 		if ($globalDBdriver == 'mysql') {
10746
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10746
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10747 10747
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10748 10748
 								GROUP BY hour_name 
10749 10749
 								ORDER BY hour_name ASC";
10750 10750
 		} else {
10751
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10751
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10752 10752
 								FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) 
10753 10753
 								GROUP BY hour_name 
10754 10754
 								ORDER BY hour_name ASC";
@@ -10756,12 +10756,12 @@  discard block
 block discarded – undo
10756 10756
       
10757 10757
 		
10758 10758
 		$sth = $this->db->prepare($query);
10759
-		$sth->execute(array(':pilot' => $pilot,':offset' => $offset));
10759
+		$sth->execute(array(':pilot' => $pilot, ':offset' => $offset));
10760 10760
       
10761 10761
 		$hour_array = array();
10762 10762
 		$temp_array = array();
10763 10763
         
10764
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10764
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10765 10765
 		{
10766 10766
 			$temp_array['hour_name'] = $row['hour_name'];
10767 10767
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10780,12 +10780,12 @@  discard block
 block discarded – undo
10780 10780
 	* @return Array the hour list
10781 10781
 	*
10782 10782
 	*/
10783
-	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array())
10783
+	public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array())
10784 10784
 	{
10785 10785
 		global $globalTimezone, $globalDBdriver;
10786
-		$filter_query = $this->getFilter($filters,true,true);
10787
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
10788
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
10786
+		$filter_query = $this->getFilter($filters, true, true);
10787
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
10788
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
10789 10789
 		if ($globalTimezone != '') {
10790 10790
 			date_default_timezone_set($globalTimezone);
10791 10791
 			$datetime = new DateTime();
@@ -10793,24 +10793,24 @@  discard block
 block discarded – undo
10793 10793
 		} else $offset = '+00:00';
10794 10794
 
10795 10795
 		if ($globalDBdriver == 'mysql') {
10796
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10796
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10797 10797
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10798 10798
 								GROUP BY hour_name 
10799 10799
 								ORDER BY hour_name ASC";
10800 10800
 		} else {
10801
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10801
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10802 10802
 								FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)
10803 10803
 								GROUP BY hour_name 
10804 10804
 								ORDER BY hour_name ASC";
10805 10805
 		}
10806 10806
 		
10807 10807
 		$sth = $this->db->prepare($query);
10808
-		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset));
10808
+		$sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset));
10809 10809
       
10810 10810
 		$hour_array = array();
10811 10811
 		$temp_array = array();
10812 10812
         
10813
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10813
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10814 10814
 		{
10815 10815
 			$temp_array['hour_name'] = $row['hour_name'];
10816 10816
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10831,8 +10831,8 @@  discard block
 block discarded – undo
10831 10831
 	public function countAllHoursByCountry($country, $filters = array())
10832 10832
 	{
10833 10833
 		global $globalTimezone, $globalDBdriver;
10834
-		$filter_query = $this->getFilter($filters,true,true);
10835
-		$country = filter_var($country,FILTER_SANITIZE_STRING);
10834
+		$filter_query = $this->getFilter($filters, true, true);
10835
+		$country = filter_var($country, FILTER_SANITIZE_STRING);
10836 10836
 		if ($globalTimezone != '') {
10837 10837
 			date_default_timezone_set($globalTimezone);
10838 10838
 			$datetime = new DateTime();
@@ -10840,24 +10840,24 @@  discard block
 block discarded – undo
10840 10840
 		} else $offset = '+00:00';
10841 10841
 
10842 10842
 		if ($globalDBdriver == 'mysql') {
10843
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10843
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
10844 10844
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10845 10845
 								GROUP BY hour_name 
10846 10846
 								ORDER BY hour_name ASC";
10847 10847
 		} else {
10848
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10848
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
10849 10849
 								FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country
10850 10850
 								GROUP BY hour_name 
10851 10851
 								ORDER BY hour_name ASC";
10852 10852
 		}
10853 10853
 		
10854 10854
 		$sth = $this->db->prepare($query);
10855
-		$sth->execute(array(':country' => $country,':offset' => $offset));
10855
+		$sth->execute(array(':country' => $country, ':offset' => $offset));
10856 10856
       
10857 10857
 		$hour_array = array();
10858 10858
 		$temp_array = array();
10859 10859
         
10860
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
10860
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
10861 10861
 		{
10862 10862
 			$temp_array['hour_name'] = $row['hour_name'];
10863 10863
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -10877,29 +10877,29 @@  discard block
 block discarded – undo
10877 10877
 	* @return Integer the number of aircrafts
10878 10878
 	*
10879 10879
 	*/
10880
-	public function countOverallAircrafts($filters = array(),$year = '',$month = '')
10880
+	public function countOverallAircrafts($filters = array(), $year = '', $month = '')
10881 10881
 	{
10882 10882
 		global $globalDBdriver;
10883
-		$filter_query = $this->getFilter($filters,true,true);
10884
-		$query  = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10883
+		$filter_query = $this->getFilter($filters, true, true);
10884
+		$query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count  
10885 10885
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
10886 10886
 		$query_values = array();
10887 10887
 		if ($year != '') {
10888 10888
 			if ($globalDBdriver == 'mysql') {
10889 10889
 				$query .= " AND YEAR(spotter_output.date) = :year";
10890
-				$query_values = array_merge($query_values,array(':year' => $year));
10890
+				$query_values = array_merge($query_values, array(':year' => $year));
10891 10891
 			} else {
10892 10892
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10893
-				$query_values = array_merge($query_values,array(':year' => $year));
10893
+				$query_values = array_merge($query_values, array(':year' => $year));
10894 10894
 			}
10895 10895
 		}
10896 10896
 		if ($month != '') {
10897 10897
 			if ($globalDBdriver == 'mysql') {
10898 10898
 				$query .= " AND MONTH(spotter_output.date) = :month";
10899
-				$query_values = array_merge($query_values,array(':month' => $month));
10899
+				$query_values = array_merge($query_values, array(':month' => $month));
10900 10900
 			} else {
10901 10901
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10902
-				$query_values = array_merge($query_values,array(':month' => $month));
10902
+				$query_values = array_merge($query_values, array(':month' => $month));
10903 10903
 			}
10904 10904
 		}
10905 10905
 
@@ -10914,29 +10914,29 @@  discard block
 block discarded – undo
10914 10914
 	* @return Integer the number of aircrafts
10915 10915
 	*
10916 10916
 	*/
10917
-	public function countOverallArrival($filters = array(),$year = '',$month = '')
10917
+	public function countOverallArrival($filters = array(), $year = '', $month = '')
10918 10918
 	{
10919 10919
 		global $globalDBdriver;
10920
-		$filter_query = $this->getFilter($filters,true,true);
10921
-		$query  = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10920
+		$filter_query = $this->getFilter($filters, true, true);
10921
+		$query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count  
10922 10922
                     FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''";
10923 10923
 		$query_values = array();
10924 10924
 		if ($year != '') {
10925 10925
 			if ($globalDBdriver == 'mysql') {
10926 10926
 				$query .= " AND YEAR(spotter_output.date) = :year";
10927
-				$query_values = array_merge($query_values,array(':year' => $year));
10927
+				$query_values = array_merge($query_values, array(':year' => $year));
10928 10928
 			} else {
10929 10929
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10930
-				$query_values = array_merge($query_values,array(':year' => $year));
10930
+				$query_values = array_merge($query_values, array(':year' => $year));
10931 10931
 			}
10932 10932
 		}
10933 10933
 		if ($month != '') {
10934 10934
 			if ($globalDBdriver == 'mysql') {
10935 10935
 				$query .= " AND MONTH(spotter_output.date) = :month";
10936
-				$query_values = array_merge($query_values,array(':month' => $month));
10936
+				$query_values = array_merge($query_values, array(':month' => $month));
10937 10937
 			} else {
10938 10938
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10939
-				$query_values = array_merge($query_values,array(':month' => $month));
10939
+				$query_values = array_merge($query_values, array(':month' => $month));
10940 10940
 			}
10941 10941
 		}
10942 10942
 		
@@ -10951,29 +10951,29 @@  discard block
 block discarded – undo
10951 10951
 	* @return Integer the number of pilots
10952 10952
 	*
10953 10953
 	*/
10954
-	public function countOverallPilots($filters = array(),$year = '',$month = '')
10954
+	public function countOverallPilots($filters = array(), $year = '', $month = '')
10955 10955
 	{
10956 10956
 		global $globalDBdriver;
10957
-		$filter_query = $this->getFilter($filters,true,true);
10958
-		$query  = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10957
+		$filter_query = $this->getFilter($filters, true, true);
10958
+		$query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count  
10959 10959
                     FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''";
10960 10960
 		$query_values = array();
10961 10961
 		if ($year != '') {
10962 10962
 			if ($globalDBdriver == 'mysql') {
10963 10963
 				$query .= " AND YEAR(spotter_output.date) = :year";
10964
-				$query_values = array_merge($query_values,array(':year' => $year));
10964
+				$query_values = array_merge($query_values, array(':year' => $year));
10965 10965
 			} else {
10966 10966
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
10967
-				$query_values = array_merge($query_values,array(':year' => $year));
10967
+				$query_values = array_merge($query_values, array(':year' => $year));
10968 10968
 			}
10969 10969
 		}
10970 10970
 		if ($month != '') {
10971 10971
 			if ($globalDBdriver == 'mysql') {
10972 10972
 				$query .= " AND MONTH(spotter_output.date) = :month";
10973
-				$query_values = array_merge($query_values,array(':month' => $month));
10973
+				$query_values = array_merge($query_values, array(':month' => $month));
10974 10974
 			} else {
10975 10975
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
10976
-				$query_values = array_merge($query_values,array(':month' => $month));
10976
+				$query_values = array_merge($query_values, array(':month' => $month));
10977 10977
 			}
10978 10978
 		}
10979 10979
 		$sth = $this->db->prepare($query);
@@ -10987,29 +10987,29 @@  discard block
 block discarded – undo
10987 10987
 	* @return Integer the number of owners
10988 10988
 	*
10989 10989
 	*/
10990
-	public function countOverallOwners($filters = array(),$year = '',$month = '')
10990
+	public function countOverallOwners($filters = array(), $year = '', $month = '')
10991 10991
 	{
10992 10992
 		global $globalDBdriver;
10993
-		$filter_query = $this->getFilter($filters,true,true);
10994
-		$query  = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10993
+		$filter_query = $this->getFilter($filters, true, true);
10994
+		$query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count  
10995 10995
                     FROM spotter_output".$filter_query." spotter_output.owner_name <> ''";
10996 10996
 		$query_values = array();
10997 10997
 		if ($year != '') {
10998 10998
 			if ($globalDBdriver == 'mysql') {
10999 10999
 				$query .= " AND YEAR(spotter_output.date) = :year";
11000
-				$query_values = array_merge($query_values,array(':year' => $year));
11000
+				$query_values = array_merge($query_values, array(':year' => $year));
11001 11001
 			} else {
11002 11002
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11003
-				$query_values = array_merge($query_values,array(':year' => $year));
11003
+				$query_values = array_merge($query_values, array(':year' => $year));
11004 11004
 			}
11005 11005
 		}
11006 11006
 		if ($month != '') {
11007 11007
 			if ($globalDBdriver == 'mysql') {
11008 11008
 				$query .= " AND MONTH(spotter_output.date) = :month";
11009
-				$query_values = array_merge($query_values,array(':month' => $month));
11009
+				$query_values = array_merge($query_values, array(':month' => $month));
11010 11010
 			} else {
11011 11011
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11012
-				$query_values = array_merge($query_values,array(':month' => $month));
11012
+				$query_values = array_merge($query_values, array(':month' => $month));
11013 11013
 			}
11014 11014
 		}
11015 11015
 		$sth = $this->db->prepare($query);
@@ -11024,32 +11024,32 @@  discard block
 block discarded – undo
11024 11024
 	* @return Integer the number of flights
11025 11025
 	*
11026 11026
 	*/
11027
-	public function countOverallFlights($filters = array(),$year = '',$month = '')
11027
+	public function countOverallFlights($filters = array(), $year = '', $month = '')
11028 11028
 	{
11029 11029
 		global $globalDBdriver;
11030
-		$queryi  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11030
+		$queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output";
11031 11031
 		$query_values = array();
11032 11032
 		$query = '';
11033 11033
 		if ($year != '') {
11034 11034
 			if ($globalDBdriver == 'mysql') {
11035 11035
 				$query .= " AND YEAR(spotter_output.date) = :year";
11036
-				$query_values = array_merge($query_values,array(':year' => $year));
11036
+				$query_values = array_merge($query_values, array(':year' => $year));
11037 11037
 			} else {
11038 11038
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11039
-				$query_values = array_merge($query_values,array(':year' => $year));
11039
+				$query_values = array_merge($query_values, array(':year' => $year));
11040 11040
 			}
11041 11041
 		}
11042 11042
 		if ($month != '') {
11043 11043
 			if ($globalDBdriver == 'mysql') {
11044 11044
 				$query .= " AND MONTH(spotter_output.date) = :month";
11045
-				$query_values = array_merge($query_values,array(':month' => $month));
11045
+				$query_values = array_merge($query_values, array(':month' => $month));
11046 11046
 			} else {
11047 11047
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11048
-				$query_values = array_merge($query_values,array(':month' => $month));
11048
+				$query_values = array_merge($query_values, array(':month' => $month));
11049 11049
 			}
11050 11050
 		}
11051 11051
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11052
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11052
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11053 11053
 		
11054 11054
 		$sth = $this->db->prepare($queryi);
11055 11055
 		$sth->execute($query_values);
@@ -11062,29 +11062,29 @@  discard block
 block discarded – undo
11062 11062
 	* @return Integer the number of flights
11063 11063
 	*
11064 11064
 	*/
11065
-	public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '')
11065
+	public function countOverallMilitaryFlights($filters = array(), $year = '', $month = '')
11066 11066
 	{
11067 11067
 		global $globalDBdriver;
11068
-		$filter_query = $this->getFilter($filters,true,true);
11069
-		$query  = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11068
+		$filter_query = $this->getFilter($filters, true, true);
11069
+		$query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count  
11070 11070
                     FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'";
11071 11071
 		$query_values = array();
11072 11072
 		if ($year != '') {
11073 11073
 			if ($globalDBdriver == 'mysql') {
11074 11074
 				$query .= " AND YEAR(spotter_output.date) = :year";
11075
-				$query_values = array_merge($query_values,array(':year' => $year));
11075
+				$query_values = array_merge($query_values, array(':year' => $year));
11076 11076
 			} else {
11077 11077
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11078
-				$query_values = array_merge($query_values,array(':year' => $year));
11078
+				$query_values = array_merge($query_values, array(':year' => $year));
11079 11079
 			}
11080 11080
 		}
11081 11081
 		if ($month != '') {
11082 11082
 			if ($globalDBdriver == 'mysql') {
11083 11083
 				$query .= " AND MONTH(spotter_output.date) = :month";
11084
-				$query_values = array_merge($query_values,array(':month' => $month));
11084
+				$query_values = array_merge($query_values, array(':month' => $month));
11085 11085
 			} else {
11086 11086
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11087
-				$query_values = array_merge($query_values,array(':month' => $month));
11087
+				$query_values = array_merge($query_values, array(':month' => $month));
11088 11088
 			}
11089 11089
 		}
11090 11090
       
@@ -11101,10 +11101,10 @@  discard block
 block discarded – undo
11101 11101
 	* @return Integer the number of airlines
11102 11102
 	*
11103 11103
 	*/
11104
-	public function countOverallAirlines($filters = array(),$year = '',$month = '')
11104
+	public function countOverallAirlines($filters = array(), $year = '', $month = '')
11105 11105
 	{
11106 11106
 		global $globalDBdriver;
11107
-		$queryi  = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11107
+		$queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count 
11108 11108
 							FROM spotter_output";
11109 11109
       
11110 11110
 		$query_values = array();
@@ -11112,23 +11112,23 @@  discard block
 block discarded – undo
11112 11112
 		if ($year != '') {
11113 11113
 			if ($globalDBdriver == 'mysql') {
11114 11114
 				$query .= " AND YEAR(spotter_output.date) = :year";
11115
-				$query_values = array_merge($query_values,array(':year' => $year));
11115
+				$query_values = array_merge($query_values, array(':year' => $year));
11116 11116
 			} else {
11117 11117
 				$query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year";
11118
-				$query_values = array_merge($query_values,array(':year' => $year));
11118
+				$query_values = array_merge($query_values, array(':year' => $year));
11119 11119
 			}
11120 11120
 		}
11121 11121
 		if ($month != '') {
11122 11122
 			if ($globalDBdriver == 'mysql') {
11123 11123
 				$query .= " AND MONTH(spotter_output.date) = :month";
11124
-				$query_values = array_merge($query_values,array(':month' => $month));
11124
+				$query_values = array_merge($query_values, array(':month' => $month));
11125 11125
 			} else {
11126 11126
 				$query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month";
11127
-				$query_values = array_merge($query_values,array(':month' => $month));
11127
+				$query_values = array_merge($query_values, array(':month' => $month));
11128 11128
 			}
11129 11129
 		}
11130 11130
                 if ($query == '') $queryi .= $this->getFilter($filters);
11131
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11131
+                else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
11132 11132
 
11133 11133
 
11134 11134
 		$sth = $this->db->prepare($queryi);
@@ -11146,7 +11146,7 @@  discard block
 block discarded – undo
11146 11146
 	public function countAllHoursFromToday($filters = array())
11147 11147
 	{
11148 11148
 		global $globalTimezone, $globalDBdriver;
11149
-		$filter_query = $this->getFilter($filters,true,true);
11149
+		$filter_query = $this->getFilter($filters, true, true);
11150 11150
 		if ($globalTimezone != '') {
11151 11151
 			date_default_timezone_set($globalTimezone);
11152 11152
 			$datetime = new DateTime();
@@ -11154,12 +11154,12 @@  discard block
 block discarded – undo
11154 11154
 		} else $offset = '+00:00';
11155 11155
 
11156 11156
 		if ($globalDBdriver == 'mysql') {
11157
-			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11157
+			$query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
11158 11158
 								FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE()
11159 11159
 								GROUP BY hour_name 
11160 11160
 								ORDER BY hour_name ASC";
11161 11161
 		} else {
11162
-			$query  = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11162
+			$query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
11163 11163
 								FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
11164 11164
 								GROUP BY hour_name 
11165 11165
 								ORDER BY hour_name ASC";
@@ -11171,7 +11171,7 @@  discard block
 block discarded – undo
11171 11171
 		$hour_array = array();
11172 11172
 		$temp_array = array();
11173 11173
         
11174
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11174
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11175 11175
 		{
11176 11176
 			$temp_array['hour_name'] = $row['hour_name'];
11177 11177
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -11190,14 +11190,14 @@  discard block
 block discarded – undo
11190 11190
 	public function getUpcomingFlights($limit = '', $sort = '', $filters = array())
11191 11191
 	{
11192 11192
 		global $global_query, $globalDBdriver, $globalTimezone;
11193
-		$filter_query = $this->getFilter($filters,true,true);
11193
+		$filter_query = $this->getFilter($filters, true, true);
11194 11194
 		date_default_timezone_set('UTC');
11195 11195
 		$limit_query = '';
11196 11196
 		if ($limit != "")
11197 11197
 		{
11198 11198
 			$limit_array = explode(",", $limit);
11199
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
11200
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
11199
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
11200
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
11201 11201
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
11202 11202
 			{
11203 11203
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -11250,7 +11250,7 @@  discard block
 block discarded – undo
11250 11250
 			    GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH')
11251 11251
 			    HAVING count(spotter_output.ident) > 5$orderby_query";
11252 11252
 			//echo $query;
11253
-			$spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone));
11253
+			$spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone));
11254 11254
 			/*
11255 11255
 			$sth = $this->db->prepare($query);
11256 11256
 			$sth->execute(array(':timezone' => $globalTimezone));
@@ -11269,9 +11269,9 @@  discard block
 block discarded – undo
11269 11269
 	*/
11270 11270
 	public function getSpotterIDBasedOnFlightAwareID($flightaware_id)
11271 11271
 	{
11272
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
11272
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
11273 11273
 
11274
-		$query  = "SELECT spotter_output.spotter_id
11274
+		$query = "SELECT spotter_output.spotter_id
11275 11275
 								FROM spotter_output 
11276 11276
 								WHERE spotter_output.flightaware_id = '".$flightaware_id."'";
11277 11277
         
@@ -11279,7 +11279,7 @@  discard block
 block discarded – undo
11279 11279
 		$sth = $this->db->prepare($query);
11280 11280
 		$sth->execute();
11281 11281
 
11282
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11282
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11283 11283
 		{
11284 11284
 			return $row['spotter_id'];
11285 11285
 		}
@@ -11304,23 +11304,23 @@  discard block
 block discarded – undo
11304 11304
 		}
11305 11305
 		
11306 11306
 		$current_date = date("Y-m-d H:i:s");
11307
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
11307
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
11308 11308
 		
11309 11309
 		$diff = abs(strtotime($current_date) - strtotime($date));
11310 11310
 
11311
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
11311
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
11312 11312
 		$years = $time_array['years'];
11313 11313
 		
11314
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
11314
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
11315 11315
 		$months = $time_array['months'];
11316 11316
 		
11317
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
11317
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
11318 11318
 		$days = $time_array['days'];
11319
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
11319
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
11320 11320
 		$hours = $time_array['hours'];
11321
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
11321
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
11322 11322
 		$minutes = $time_array['minutes'];
11323
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11323
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
11324 11324
 		
11325 11325
 		return $time_array;	
11326 11326
 	}	
@@ -11346,63 +11346,63 @@  discard block
 block discarded – undo
11346 11346
 			$temp_array['direction_degree'] = $direction;
11347 11347
 			$temp_array['direction_shortname'] = "N";
11348 11348
 			$temp_array['direction_fullname'] = "North";
11349
-		} elseif ($direction >= 22.5 && $direction < 45){
11349
+		} elseif ($direction >= 22.5 && $direction < 45) {
11350 11350
 			$temp_array['direction_degree'] = $direction;
11351 11351
 			$temp_array['direction_shortname'] = "NNE";
11352 11352
 			$temp_array['direction_fullname'] = "North-Northeast";
11353
-		} elseif ($direction >= 45 && $direction < 67.5){
11353
+		} elseif ($direction >= 45 && $direction < 67.5) {
11354 11354
 			$temp_array['direction_degree'] = $direction;
11355 11355
 			$temp_array['direction_shortname'] = "NE";
11356 11356
 			$temp_array['direction_fullname'] = "Northeast";
11357
-		} elseif ($direction >= 67.5 && $direction < 90){
11357
+		} elseif ($direction >= 67.5 && $direction < 90) {
11358 11358
 			$temp_array['direction_degree'] = $direction;
11359 11359
 			$temp_array['direction_shortname'] = "ENE";
11360 11360
 			$temp_array['direction_fullname'] = "East-Northeast";
11361
-		} elseif ($direction >= 90 && $direction < 112.5){
11361
+		} elseif ($direction >= 90 && $direction < 112.5) {
11362 11362
 			$temp_array['direction_degree'] = $direction;
11363 11363
 			$temp_array['direction_shortname'] = "E";
11364 11364
 			$temp_array['direction_fullname'] = "East";
11365
-		} elseif ($direction >= 112.5 && $direction < 135){
11365
+		} elseif ($direction >= 112.5 && $direction < 135) {
11366 11366
 			$temp_array['direction_degree'] = $direction;
11367 11367
 			$temp_array['direction_shortname'] = "ESE";
11368 11368
 			$temp_array['direction_fullname'] = "East-Southeast";
11369
-		} elseif ($direction >= 135 && $direction < 157.5){
11369
+		} elseif ($direction >= 135 && $direction < 157.5) {
11370 11370
 			$temp_array['direction_degree'] = $direction;
11371 11371
 			$temp_array['direction_shortname'] = "SE";
11372 11372
 			$temp_array['direction_fullname'] = "Southeast";
11373
-		} elseif ($direction >= 157.5 && $direction < 180){
11373
+		} elseif ($direction >= 157.5 && $direction < 180) {
11374 11374
 			$temp_array['direction_degree'] = $direction;
11375 11375
 			$temp_array['direction_shortname'] = "SSE";
11376 11376
 			$temp_array['direction_fullname'] = "South-Southeast";
11377
-		} elseif ($direction >= 180 && $direction < 202.5){
11377
+		} elseif ($direction >= 180 && $direction < 202.5) {
11378 11378
 			$temp_array['direction_degree'] = $direction;
11379 11379
 			$temp_array['direction_shortname'] = "S";
11380 11380
 			$temp_array['direction_fullname'] = "South";
11381
-		} elseif ($direction >= 202.5 && $direction < 225){
11381
+		} elseif ($direction >= 202.5 && $direction < 225) {
11382 11382
 			$temp_array['direction_degree'] = $direction;
11383 11383
 			$temp_array['direction_shortname'] = "SSW";
11384 11384
 			$temp_array['direction_fullname'] = "South-Southwest";
11385
-		} elseif ($direction >= 225 && $direction < 247.5){
11385
+		} elseif ($direction >= 225 && $direction < 247.5) {
11386 11386
 			$temp_array['direction_degree'] = $direction;
11387 11387
 			$temp_array['direction_shortname'] = "SW";
11388 11388
 			$temp_array['direction_fullname'] = "Southwest";
11389
-		} elseif ($direction >= 247.5 && $direction < 270){
11389
+		} elseif ($direction >= 247.5 && $direction < 270) {
11390 11390
 			$temp_array['direction_degree'] = $direction;
11391 11391
 			$temp_array['direction_shortname'] = "WSW";
11392 11392
 			$temp_array['direction_fullname'] = "West-Southwest";
11393
-		} elseif ($direction >= 270 && $direction < 292.5){
11393
+		} elseif ($direction >= 270 && $direction < 292.5) {
11394 11394
 			$temp_array['direction_degree'] = $direction;
11395 11395
 			$temp_array['direction_shortname'] = "W";
11396 11396
 			$temp_array['direction_fullname'] = "West";
11397
-		} elseif ($direction >= 292.5 && $direction < 315){
11397
+		} elseif ($direction >= 292.5 && $direction < 315) {
11398 11398
 			$temp_array['direction_degree'] = $direction;
11399 11399
 			$temp_array['direction_shortname'] = "WNW";
11400 11400
 			$temp_array['direction_fullname'] = "West-Northwest";
11401
-		} elseif ($direction >= 315 && $direction < 337.5){
11401
+		} elseif ($direction >= 315 && $direction < 337.5) {
11402 11402
 			$temp_array['direction_degree'] = $direction;
11403 11403
 			$temp_array['direction_shortname'] = "NW";
11404 11404
 			$temp_array['direction_fullname'] = "Northwest";
11405
-		} elseif ($direction >= 337.5 && $direction < 360){
11405
+		} elseif ($direction >= 337.5 && $direction < 360) {
11406 11406
 			$temp_array['direction_degree'] = $direction;
11407 11407
 			$temp_array['direction_shortname'] = "NNW";
11408 11408
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -11455,8 +11455,8 @@  discard block
 block discarded – undo
11455 11455
 	*/
11456 11456
 	public function getAircraftRegistrationBymodeS($aircraft_modes, $source_type = '')
11457 11457
 	{
11458
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11459
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11458
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11459
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11460 11460
 		if ($source_type == '' || $source_type == 'modes') {
11461 11461
 			$query  = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11462 11462
 		} else {
@@ -11483,10 +11483,10 @@  discard block
 block discarded – undo
11483 11483
 	* @return String the aircraft type
11484 11484
 	*
11485 11485
 	*/
11486
-	public function getAircraftTypeBymodeS($aircraft_modes,$source_type = '')
11486
+	public function getAircraftTypeBymodeS($aircraft_modes, $source_type = '')
11487 11487
 	{
11488
-		$aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING);
11489
-		$source_type = filter_var($source_type,FILTER_SANITIZE_STRING);
11488
+		$aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING);
11489
+		$source_type = filter_var($source_type, FILTER_SANITIZE_STRING);
11490 11490
 		if ($source_type == '' || $source_type == 'modes') {
11491 11491
 			$query  = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes AND aircraft_modes.source_type = 'modes' ORDER BY FirstCreated DESC LIMIT 1";
11492 11492
 		} else {
@@ -11514,11 +11514,11 @@  discard block
 block discarded – undo
11514 11514
 	* @param Float $longitude longitute of the flight
11515 11515
 	* @return String the countrie
11516 11516
 	*/
11517
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
11517
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
11518 11518
 	{
11519 11519
 		global $globalDBdriver, $globalDebug;
11520
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11521
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11520
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11521
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
11522 11522
 	
11523 11523
 		$Connection = new Connection($this->db);
11524 11524
 		if (!$Connection->tableExists('countries')) return '';
@@ -11558,7 +11558,7 @@  discard block
 block discarded – undo
11558 11558
 	public function getCountryFromISO2($iso2)
11559 11559
 	{
11560 11560
 		global $globalDBdriver, $globalDebug;
11561
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11561
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
11562 11562
 	
11563 11563
 		$Connection = new Connection($this->db);
11564 11564
 		if (!$Connection->tableExists('countries')) return '';
@@ -11590,19 +11590,19 @@  discard block
 block discarded – undo
11590 11590
 	*/
11591 11591
 	public function convertAircraftRegistration($registration)
11592 11592
 	{
11593
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11593
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11594 11594
 		$registration_prefix = '';
11595 11595
 		$registration_1 = substr($registration, 0, 1);
11596 11596
 		$registration_2 = substr($registration, 0, 2);
11597 11597
 
11598 11598
 		//first get the prefix based on two characters
11599
-		$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11599
+		$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2";
11600 11600
       
11601 11601
 		
11602 11602
 		$sth = $this->db->prepare($query);
11603 11603
 		$sth->execute(array(':registration_2' => $registration_2));
11604 11604
         
11605
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11605
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11606 11606
 		{
11607 11607
 			$registration_prefix = $row['registration_prefix'];
11608 11608
 		}
@@ -11610,11 +11610,11 @@  discard block
 block discarded – undo
11610 11610
 		//if we didn't find a two chracter prefix lets just search the one with one character
11611 11611
 		if ($registration_prefix == '')
11612 11612
 		{
11613
-			$query  = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11613
+			$query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1";
11614 11614
 			$sth = $this->db->prepare($query);
11615 11615
 			$sth->execute(array(':registration_1' => $registration_1));
11616 11616
 	        
11617
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11617
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11618 11618
 			{
11619 11619
 				$registration_prefix = $row['registration_prefix'];
11620 11620
 			}
@@ -11628,7 +11628,7 @@  discard block
 block discarded – undo
11628 11628
 			} else {
11629 11629
 				$registration = preg_replace("/^(.{1})/", "$1-", $registration);
11630 11630
 			}
11631
-		} else if(strlen($registration_prefix) == 2){
11631
+		} else if (strlen($registration_prefix) == 2) {
11632 11632
 			if (0 === strpos($registration, 'N')) {
11633 11633
 				$registration = preg_replace("/^(.{2})/", "$1", $registration);
11634 11634
 			} else {
@@ -11647,17 +11647,17 @@  discard block
 block discarded – undo
11647 11647
 	*/
11648 11648
 	public function countryFromAircraftRegistration($registration)
11649 11649
 	{
11650
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11650
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11651 11651
 		
11652 11652
 		$registration_prefix = '';
11653
-		$registration_test = explode('-',$registration);
11653
+		$registration_test = explode('-', $registration);
11654 11654
 		$country = '';
11655 11655
 		if ($registration_test[0] != $registration) {
11656 11656
 			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11657 11657
 	      
11658 11658
 			$sth = $this->db->prepare($query);
11659 11659
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11660
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11660
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11661 11661
 			{
11662 11662
 				//$registration_prefix = $row['registration_prefix'];
11663 11663
 				$country = $row['country'];
@@ -11668,13 +11668,13 @@  discard block
 block discarded – undo
11668 11668
 
11669 11669
 			$country = '';
11670 11670
 			//first get the prefix based on two characters
11671
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11671
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11672 11672
       
11673 11673
 			
11674 11674
 			$sth = $this->db->prepare($query);
11675 11675
 			$sth->execute(array(':registration_2' => $registration_2));
11676 11676
         
11677
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11677
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11678 11678
 			{
11679 11679
 				$registration_prefix = $row['registration_prefix'];
11680 11680
 				$country = $row['country'];
@@ -11683,12 +11683,12 @@  discard block
 block discarded – undo
11683 11683
 			//if we didn't find a two chracter prefix lets just search the one with one character
11684 11684
 			if ($registration_prefix == "")
11685 11685
 			{
11686
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11686
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11687 11687
 	      
11688 11688
 				$sth = $this->db->prepare($query);
11689 11689
 				$sth->execute(array(':registration_1' => $registration_1));
11690 11690
 	        
11691
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11691
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11692 11692
 				{
11693 11693
 					//$registration_prefix = $row['registration_prefix'];
11694 11694
 					$country = $row['country'];
@@ -11708,17 +11708,17 @@  discard block
 block discarded – undo
11708 11708
 	*/
11709 11709
 	public function registrationPrefixFromAircraftRegistration($registration)
11710 11710
 	{
11711
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11711
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11712 11712
 		
11713 11713
 		$registration_prefix = '';
11714
-		$registration_test = explode('-',$registration);
11714
+		$registration_test = explode('-', $registration);
11715 11715
 		//$country = '';
11716 11716
 		if ($registration_test[0] != $registration) {
11717
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11717
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11718 11718
 	      
11719 11719
 			$sth = $this->db->prepare($query);
11720 11720
 			$sth->execute(array(':registration_1' => $registration_test[0]));
11721
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11721
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11722 11722
 			{
11723 11723
 				$registration_prefix = $row['registration_prefix'];
11724 11724
 				//$country = $row['country'];
@@ -11728,13 +11728,13 @@  discard block
 block discarded – undo
11728 11728
 		        $registration_2 = substr($registration, 0, 2);
11729 11729
 
11730 11730
 			//first get the prefix based on two characters
11731
-			$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11731
+			$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1";
11732 11732
       
11733 11733
 			
11734 11734
 			$sth = $this->db->prepare($query);
11735 11735
 			$sth->execute(array(':registration_2' => $registration_2));
11736 11736
         
11737
-			while($row = $sth->fetch(PDO::FETCH_ASSOC))
11737
+			while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11738 11738
 			{
11739 11739
 				$registration_prefix = $row['registration_prefix'];
11740 11740
 				//$country = $row['country'];
@@ -11743,12 +11743,12 @@  discard block
 block discarded – undo
11743 11743
 			//if we didn't find a two chracter prefix lets just search the one with one character
11744 11744
 			if ($registration_prefix == "")
11745 11745
 			{
11746
-				$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11746
+				$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1";
11747 11747
 	      
11748 11748
 				$sth = $this->db->prepare($query);
11749 11749
 				$sth->execute(array(':registration_1' => $registration_1));
11750 11750
 	        
11751
-				while($row = $sth->fetch(PDO::FETCH_ASSOC))
11751
+				while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11752 11752
 				{
11753 11753
 					$registration_prefix = $row['registration_prefix'];
11754 11754
 					//$country = $row['country'];
@@ -11769,13 +11769,13 @@  discard block
 block discarded – undo
11769 11769
 	*/
11770 11770
 	public function countryFromAircraftRegistrationCode($registration)
11771 11771
 	{
11772
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
11772
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
11773 11773
 		
11774 11774
 		$country = '';
11775
-		$query  = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11775
+		$query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1";
11776 11776
 		$sth = $this->db->prepare($query);
11777 11777
 		$sth->execute(array(':registration' => $registration));
11778
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11778
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11779 11779
 		{
11780 11780
 			$country = $row['country'];
11781 11781
 		}
@@ -11788,9 +11788,9 @@  discard block
 block discarded – undo
11788 11788
 	* @param String $flightaware_id flightaware_id from spotter_output table
11789 11789
 	* @param String $highlight New highlight value
11790 11790
 	*/
11791
-	public function setHighlightFlight($flightaware_id,$highlight) {
11791
+	public function setHighlightFlight($flightaware_id, $highlight) {
11792 11792
 		
11793
-		$query  = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11793
+		$query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id";
11794 11794
 		$sth = $this->db->prepare($query);
11795 11795
 		$sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight));
11796 11796
 	}
@@ -11802,13 +11802,13 @@  discard block
 block discarded – undo
11802 11802
 	* @param String $date Date of spotted aircraft
11803 11803
 	* @param String $highlight New highlight value
11804 11804
 	*/
11805
-	public function setHighlightFlightByRegistration($registration,$highlight, $date = '') {
11805
+	public function setHighlightFlightByRegistration($registration, $highlight, $date = '') {
11806 11806
 		if ($date == '') {
11807 11807
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)";
11808 11808
 			$query_values = array(':registration' => $registration, ':highlight' => $highlight);
11809 11809
 		} else {
11810 11810
 			$query  = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date";
11811
-			$query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date);
11811
+			$query_values = array(':registration' => $registration, ':highlight' => $highlight, ':date' => $date);
11812 11812
 		}
11813 11813
 		$sth = $this->db->prepare($query);
11814 11814
 		$sth->execute($query_values);
@@ -11838,7 +11838,7 @@  discard block
 block discarded – undo
11838 11838
 		
11839 11839
 		$bitly_data = json_decode($bitly_data);
11840 11840
 		$bitly_url = '';
11841
-		if ($bitly_data->status_txt = "OK"){
11841
+		if ($bitly_data->status_txt = "OK") {
11842 11842
 			$bitly_url = $bitly_data->data->url;
11843 11843
 		}
11844 11844
 
@@ -11848,7 +11848,7 @@  discard block
 block discarded – undo
11848 11848
 
11849 11849
 	public function getOrderBy()
11850 11850
 	{
11851
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
11851
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
11852 11852
 		
11853 11853
 		return $orderby;
11854 11854
 		
@@ -11982,14 +11982,14 @@  discard block
 block discarded – undo
11982 11982
 		}
11983 11983
 		$sth = $this->db->prepare($query);
11984 11984
 		$sth->execute();
11985
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
11985
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
11986 11986
 		{
11987 11987
 			$departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']);
11988 11988
 			$arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']);
11989 11989
 			if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) {
11990
-				$update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
11990
+				$update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id";
11991 11991
 				$sthu = $this->db->prepare($update_query);
11992
-				$sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country']));
11992
+				$sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country']));
11993 11993
 			}
11994 11994
 		}
11995 11995
 		
@@ -12002,7 +12002,7 @@  discard block
 block discarded – undo
12002 12002
 		}
12003 12003
 		$sth = $this->db->prepare($query);
12004 12004
 		$sth->execute();
12005
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12005
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12006 12006
 		{
12007 12007
 			if (is_numeric(substr($row['ident'], -1, 1)))
12008 12008
 			{
@@ -12011,11 +12011,11 @@  discard block
 block discarded – undo
12011 12011
 				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12012 12012
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12013 12013
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12014
-				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12014
+				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource);
12015 12015
 				if (isset($airline_array[0]['name'])) {
12016
-					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
12016
+					$update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
12017 12017
 					$sthu = $this->db->prepare($update_query);
12018
-					$sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
12018
+					$sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id']));
12019 12019
 				}
12020 12020
 			}
12021 12021
 		}
@@ -12035,18 +12035,18 @@  discard block
 block discarded – undo
12035 12035
 		}
12036 12036
 		$sth = $this->db->prepare($query);
12037 12037
 		$sth->execute();
12038
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12038
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12039 12039
 		{
12040 12040
 			if ($row['aircraft_icao'] != '') {
12041 12041
 				$aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']);
12042
-				if ($row['registration'] != ""){
12042
+				if ($row['registration'] != "") {
12043 12043
 					$image_array = $Image->getSpotterImage($row['registration']);
12044 12044
 					if (!isset($image_array[0]['registration'])) {
12045 12045
 						$Image->addSpotterImage($row['registration']);
12046 12046
 					}
12047 12047
 				}
12048 12048
 				if (count($aircraft_name) > 0) {
12049
-					$update_query  = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
12049
+					$update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id";
12050 12050
 					$sthu = $this->db->prepare($update_query);
12051 12051
 					$sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id']));
12052 12052
 				}
@@ -12061,10 +12061,10 @@  discard block
 block discarded – undo
12061 12061
 		$query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output";
12062 12062
 		$sth = $this->db->prepare($query);
12063 12063
 		$sth->execute();
12064
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
12064
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
12065 12065
 		{
12066 12066
 			if ($row['last_latitude'] != '' && $row['last_longitude'] != '') {
12067
-				$closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist);
12067
+				$closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist);
12068 12068
 				$airport_icao = '';
12069 12069
 				 if (isset($closestAirports[0])) {
12070 12070
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
@@ -12078,7 +12078,7 @@  discard block
 block discarded – undo
12078 12078
 								break;
12079 12079
 							}
12080 12080
 						}
12081
-					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12081
+					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) {
12082 12082
 						$airport_icao = $closestAirports[0]['icao'];
12083 12083
 						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12084 12084
 					} else {
@@ -12089,28 +12089,28 @@  discard block
 block discarded – undo
12089 12089
 				}
12090 12090
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12091 12091
 					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12092
-					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12092
+					$update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12093 12093
 					$sthu = $this->db->prepare($update_query);
12094
-					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
12094
+					$sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id']));
12095 12095
 				}
12096 12096
 			}
12097 12097
 		}
12098 12098
 	}
12099 12099
 	
12100
-	public function closestAirports($origLat,$origLon,$dist = 10) {
12100
+	public function closestAirports($origLat, $origLon, $dist = 10) {
12101 12101
 		global $globalDBdriver;
12102
-		$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
12102
+		$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
12103 12103
 /*
12104 12104
 		$query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance 
12105 12105
                       FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
12106 12106
                       having distance < $dist ORDER BY distance limit 100;";
12107 12107
 */
12108 12108
 		if ($globalDBdriver == 'mysql') {
12109
-			$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 
12109
+			$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 
12110 12110
 	                      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)) 
12111 12111
 	                      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;";
12112 12112
                 } else {
12113
-			$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 
12113
+			$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 
12114 12114
 	                      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)) 
12115 12115
 	                      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;";
12116 12116
     		}
Please login to merge, or discard this patch.
Braces   +735 added lines, -257 removed lines patch added patch discarded remove patch
@@ -72,7 +72,9 @@  discard block
 block discarded – undo
72 72
 		if (isset($filter[0]['source'])) {
73 73
 			$filters = array_merge($filters,$filter);
74 74
 		}
75
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
75
+		if (is_array($globalFilter)) {
76
+			$filter = array_merge($filter,$globalFilter);
77
+		}
76 78
 		$filter_query_join = '';
77 79
 		$filter_query_where = '';
78 80
 		foreach($filters as $flt) {
@@ -156,8 +158,11 @@  discard block
 block discarded – undo
156 158
 				$filter_query_where .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
157 159
 			}
158 160
 		}
159
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
160
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
161
+		if ($filter_query_where == '' && $where) {
162
+			$filter_query_where = ' WHERE';
163
+		} elseif ($filter_query_where != '' && $and) {
164
+			$filter_query_where .= ' AND';
165
+		}
161 166
 		if ($filter_query_where != '') {
162 167
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
163 168
 		}
@@ -180,10 +185,18 @@  discard block
 block discarded – undo
180 185
 		$Image = new Image($this->db);
181 186
 		$Schedule = new Schedule($this->db);
182 187
 		$ACARS = new ACARS($this->db);
183
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
184
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
185
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
186
-		if (!isset($globalVAM)) $globalVAM = FALSE;
188
+		if (!isset($globalIVAO)) {
189
+			$globalIVAO = FALSE;
190
+		}
191
+		if (!isset($globalVATSIM)) {
192
+			$globalVATSIM = FALSE;
193
+		}
194
+		if (!isset($globalphpVMS)) {
195
+			$globalphpVMS = FALSE;
196
+		}
197
+		if (!isset($globalVAM)) {
198
+			$globalVAM = FALSE;
199
+		}
187 200
 		date_default_timezone_set('UTC');
188 201
 		
189 202
 		if (!is_string($query))
@@ -230,21 +243,35 @@  discard block
 block discarded – undo
230 243
 			} else {
231 244
 				$temp_array['spotter_id'] = '';
232 245
 			}
233
-			if (isset($row['flightaware_id'])) $temp_array['flightaware_id'] = $row['flightaware_id'];
234
-			if (isset($row['modes'])) $temp_array['modes'] = $row['modes'];
246
+			if (isset($row['flightaware_id'])) {
247
+				$temp_array['flightaware_id'] = $row['flightaware_id'];
248
+			}
249
+			if (isset($row['modes'])) {
250
+				$temp_array['modes'] = $row['modes'];
251
+			}
235 252
 			$temp_array['ident'] = $row['ident'];
236 253
 			if (isset($row['registration']) && $row['registration'] != '') {
237 254
 				$temp_array['registration'] = $row['registration'];
238 255
 			} elseif (isset($temp_array['modes'])) {
239 256
 				$temp_array['registration'] = $this->getAircraftRegistrationBymodeS($temp_array['modes']);
240
-			} else $temp_array['registration'] = '';
241
-			if (isset($row['aircraft_icao'])) $temp_array['aircraft_type'] = $row['aircraft_icao'];
257
+			} else {
258
+				$temp_array['registration'] = '';
259
+			}
260
+			if (isset($row['aircraft_icao'])) {
261
+				$temp_array['aircraft_type'] = $row['aircraft_icao'];
262
+			}
242 263
 			
243 264
 			$temp_array['departure_airport'] = $row['departure_airport_icao'];
244 265
 			$temp_array['arrival_airport'] = $row['arrival_airport_icao'];
245
-			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) $temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
246
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
247
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
266
+			if (isset($row['real_arrival_airport_icao']) && $row['real_arrival_airport_icao'] != NULL) {
267
+				$temp_array['real_arrival_airport'] = $row['real_arrival_airport_icao'];
268
+			}
269
+			if (isset($row['latitude'])) {
270
+				$temp_array['latitude'] = $row['latitude'];
271
+			}
272
+			if (isset($row['longitude'])) {
273
+				$temp_array['longitude'] = $row['longitude'];
274
+			}
248 275
 			/*
249 276
 			if (Connection->tableExists('countries')) {
250 277
 				$country_info = $this->getCountryFromLatitudeLongitude($temp_array['latitude'],$temp_array['longitude']);
@@ -254,8 +281,12 @@  discard block
 block discarded – undo
254 281
 				}
255 282
 			}
256 283
 			*/
257
-			if (isset($row['waypoints'])) $temp_array['waypoints'] = $row['waypoints'];
258
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
284
+			if (isset($row['waypoints'])) {
285
+				$temp_array['waypoints'] = $row['waypoints'];
286
+			}
287
+			if (isset($row['format_source'])) {
288
+				$temp_array['format_source'] = $row['format_source'];
289
+			}
259 290
 			if (isset($row['route_stop']) && $row['route_stop'] != '') {
260 291
 				$temp_array['route_stop'] = $row['route_stop'];
261 292
 				$allroute = explode(' ',$row['route_stop']);
@@ -271,13 +302,19 @@  discard block
 block discarded – undo
271 302
 					}
272 303
 				}
273 304
 			}
274
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
305
+			if (isset($row['altitude'])) {
306
+				$temp_array['altitude'] = $row['altitude'];
307
+			}
275 308
 			if (isset($row['heading'])) {
276 309
 				$temp_array['heading'] = $row['heading'];
277 310
 				$heading_direction = $this->parseDirection($row['heading']);
278
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
311
+				if (isset($heading_direction[0]['direction_fullname'])) {
312
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
313
+				}
314
+			}
315
+			if (isset($row['ground_speed'])) {
316
+				$temp_array['ground_speed'] = $row['ground_speed'];
279 317
 			}
280
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
281 318
 			$temp_array['image'] = "";
282 319
 			$temp_array['image_thumbnail'] = "";
283 320
 			$temp_array['image_source'] = "";
@@ -285,7 +322,9 @@  discard block
 block discarded – undo
285 322
  
286 323
 			if (isset($row['highlight'])) {
287 324
 				$temp_array['highlight'] = $row['highlight'];
288
-			} else $temp_array['highlight'] = '';
325
+			} else {
326
+				$temp_array['highlight'] = '';
327
+			}
289 328
 			
290 329
 			if (isset($row['date'])) {
291 330
 				$dateArray = $this->parseDateString($row['date']);
@@ -341,7 +380,9 @@  discard block
 block discarded – undo
341 380
 				
342 381
 					if ($aircraft_array[0]['aircraft_shadow'] != NULL) {
343 382
 						$temp_array['aircraft_shadow'] = $aircraft_array[0]['aircraft_shadow'];
344
-					} else $temp_array['aircraft_shadow'] = 'default.png';
383
+					} else {
384
+						$temp_array['aircraft_shadow'] = 'default.png';
385
+					}
345 386
                                 } else {
346 387
                             		$temp_array['aircraft_shadow'] = 'default.png';
347 388
 					$temp_array['aircraft_name'] = 'N/A';
@@ -349,11 +390,17 @@  discard block
 block discarded – undo
349 390
                             	}
350 391
 			}
351 392
 			$fromsource = NULL;
352
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
353
-			elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
354
-			elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
355
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
356
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
393
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
394
+				$fromsource = $globalAirlinesSource;
395
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
396
+				$fromsource = 'vatsim';
397
+			} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
398
+				$fromsource = 'ivao';
399
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
400
+				$fromsource = 'vatsim';
401
+			} elseif (isset($globalIVAO) && $globalIVAO) {
402
+				$fromsource = 'ivao';
403
+			}
357 404
 			if (!isset($row['airline_name']) || $row['airline_name'] == '') {
358 405
 				if (!is_numeric(substr($row['ident'], 0, 3))) {
359 406
 					if (is_numeric(substr($row['ident'], 2, 1))) {
@@ -376,12 +423,18 @@  discard block
 block discarded – undo
376 423
 				}
377 424
 			} else {
378 425
 				$temp_array['airline_icao'] = $row['airline_icao'];
379
-				if (isset($row['airline_iata'])) $temp_array['airline_iata'] = $row['airline_iata'];
380
-				else $temp_array['airline_iata'] = 'N/A';
426
+				if (isset($row['airline_iata'])) {
427
+					$temp_array['airline_iata'] = $row['airline_iata'];
428
+				} else {
429
+					$temp_array['airline_iata'] = 'N/A';
430
+				}
381 431
 				$temp_array['airline_name'] = $row['airline_name'];
382 432
 				$temp_array['airline_country'] = $row['airline_country'];
383
-				if (isset($row['airline_callsign'])) $temp_array['airline_callsign'] = $row['airline_callsign'];
384
-				else $temp_array['airline_callsign'] = 'N/A';
433
+				if (isset($row['airline_callsign'])) {
434
+					$temp_array['airline_callsign'] = $row['airline_callsign'];
435
+				} else {
436
+					$temp_array['airline_callsign'] = 'N/A';
437
+				}
385 438
 				$temp_array['airline_type'] = $row['airline_type'];
386 439
 				if ($temp_array['airline_icao'] != '' && $temp_array['airline_iata'] == 'N/A') {
387 440
 					$airline_array = $this->getAllAirlineInfo($temp_array['airline_icao']);
@@ -408,7 +461,9 @@  discard block
 block discarded – undo
408 461
 			}
409 462
 			if ($temp_array['registration'] != "" && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && !isset($temp_array['aircraft_owner'])) {
410 463
 				$owner_info = $this->getAircraftOwnerByRegistration($temp_array['registration']);
411
-				if ($owner_info['owner'] != '') $temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
464
+				if ($owner_info['owner'] != '') {
465
+					$temp_array['aircraft_owner'] = ucwords(strtolower($owner_info['owner']));
466
+				}
412 467
 				$temp_array['aircraft_base'] = $owner_info['base'];
413 468
 				$temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg'];
414 469
 			}
@@ -416,9 +471,14 @@  discard block
 block discarded – undo
416 471
 			if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != ''))
417 472
 			{
418 473
 				if ($globalIVAO) {
419
-					if (isset($temp_array['airline_icao']))	$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
420
-					else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
421
-				} else $image_array = $Image->getSpotterImage($temp_array['registration']);
474
+					if (isset($temp_array['airline_icao'])) {
475
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']);
476
+					} else {
477
+						$image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']);
478
+					}
479
+				} else {
480
+					$image_array = $Image->getSpotterImage($temp_array['registration']);
481
+				}
422 482
 				if (count($image_array) > 0) {
423 483
 					$temp_array['image'] = $image_array[0]['image'];
424 484
 					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
@@ -470,7 +530,9 @@  discard block
 block discarded – undo
470 530
 			//if ($row['departure_airport_icao'] != '' && $row['departure_airport_name'] == '') {
471 531
 			if ($row['departure_airport_icao'] != '') {
472 532
 				$departure_airport_array = $this->getAllAirportInfo($row['departure_airport_icao']);
473
-				if (!isset($departure_airport_array[0]['name'])) $departure_airport_array = $this->getAllAirportInfo('NA');
533
+				if (!isset($departure_airport_array[0]['name'])) {
534
+					$departure_airport_array = $this->getAllAirportInfo('NA');
535
+				}
474 536
 			/*
475 537
 			} elseif ($row['departure_airport_name'] != '') {
476 538
 				$temp_array['departure_airport_name'] = $row['departure_airport_name'];
@@ -478,7 +540,9 @@  discard block
 block discarded – undo
478 540
 				$temp_array['departure_airport_country'] = $row['departure_airport_country'];
479 541
 				$temp_array['departure_airport_icao'] = $row['departure_airport_icao'];
480 542
 			*/
481
-			} else $departure_airport_array = $this->getAllAirportInfo('NA');
543
+			} else {
544
+				$departure_airport_array = $this->getAllAirportInfo('NA');
545
+			}
482 546
 			if (isset($departure_airport_array[0]['name'])) {
483 547
 				$temp_array['departure_airport_name'] = $departure_airport_array[0]['name'];
484 548
 				$temp_array['departure_airport_city'] = $departure_airport_array[0]['city'];
@@ -498,8 +562,12 @@  discard block
 block discarded – undo
498 562
 			
499 563
 			if ($row['arrival_airport_icao'] != '') {
500 564
 				$arrival_airport_array = $this->getAllAirportInfo($row['arrival_airport_icao']);
501
-				if (count($arrival_airport_array) == 0) $arrival_airport_array = $this->getAllAirportInfo('NA');
502
-			} else $arrival_airport_array = $this->getAllAirportInfo('NA');
565
+				if (count($arrival_airport_array) == 0) {
566
+					$arrival_airport_array = $this->getAllAirportInfo('NA');
567
+				}
568
+			} else {
569
+				$arrival_airport_array = $this->getAllAirportInfo('NA');
570
+			}
503 571
 			if (isset($arrival_airport_array[0]['name'])) {
504 572
 				$temp_array['arrival_airport_name'] = $arrival_airport_array[0]['name'];
505 573
 				$temp_array['arrival_airport_city'] = $arrival_airport_array[0]['city'];
@@ -515,27 +583,45 @@  discard block
 block discarded – undo
515 583
 				$temp_array['arrival_airport_time'] = $row['arrival_airport_time'];
516 584
 			}
517 585
 			*/
518
-			if (isset($row['pilot_id']) && $row['pilot_id'] != '') $temp_array['pilot_id'] = $row['pilot_id'];
519
-			if (isset($row['pilot_name']) && $row['pilot_name'] != '') $temp_array['pilot_name'] = $row['pilot_name'];
520
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
521
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
522
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
586
+			if (isset($row['pilot_id']) && $row['pilot_id'] != '') {
587
+				$temp_array['pilot_id'] = $row['pilot_id'];
588
+			}
589
+			if (isset($row['pilot_name']) && $row['pilot_name'] != '') {
590
+				$temp_array['pilot_name'] = $row['pilot_name'];
591
+			}
592
+			if (isset($row['source_name']) && $row['source_name'] != '') {
593
+				$temp_array['source_name'] = $row['source_name'];
594
+			}
595
+			if (isset($row['over_country']) && $row['over_country'] != '') {
596
+				$temp_array['over_country'] = $row['over_country'];
597
+			}
598
+			if (isset($row['distance']) && $row['distance'] != '') {
599
+				$temp_array['distance'] = $row['distance'];
600
+			}
523 601
 			if (isset($row['squawk'])) {
524 602
 				$temp_array['squawk'] = $row['squawk'];
525 603
 				if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) {
526 604
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']);
527
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
605
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
606
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
607
+					}
528 608
 				} elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) {
529 609
 					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']);
530
-					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
531
-				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
610
+					if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) {
611
+						$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
612
+					}
613
+				} elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) {
614
+					$temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry);
615
+				}
532 616
 			}
533 617
     			
534 618
 			$temp_array['query_number_rows'] = $num_rows;
535 619
 			
536 620
 			$spotter_array[] = $temp_array;
537 621
 		}
538
-		if ($num_rows == 0) return array();
622
+		if ($num_rows == 0) {
623
+			return array();
624
+		}
539 625
 		$spotter_array[0]['query_number_rows'] = $num_rows;
540 626
 		return $spotter_array;
541 627
 	}	
@@ -568,7 +654,9 @@  discard block
 block discarded – undo
568 654
 				foreach ($q_array as $q_item){
569 655
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
570 656
 					$additional_query .= " AND (";
571
-					if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
657
+					if (is_int($q_item)) {
658
+						$additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR ";
659
+					}
572 660
 					$additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR ";
573 661
 					$additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR ";
574 662
 					$additional_query .= "(spotter_output.aircraft_manufacturer like '%".$q_item."%') OR ";
@@ -589,7 +677,9 @@  discard block
 block discarded – undo
589 677
 					$additional_query .= "(spotter_output.pilot_name like '%".$q_item."%') OR ";
590 678
 					$additional_query .= "(spotter_output.ident like '%".$q_item."%') OR ";
591 679
 					$translate = $Translation->ident2icao($q_item);
592
-					if ($translate != $q_item) $additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
680
+					if ($translate != $q_item) {
681
+						$additional_query .= "(spotter_output.ident like '%".$translate."%') OR ";
682
+					}
593 683
 					$additional_query .= "(spotter_output.highlight like '%".$q_item."%')";
594 684
 					$additional_query .= ")";
595 685
 				}
@@ -816,7 +906,9 @@  discard block
 block discarded – undo
816 906
 				date_default_timezone_set($globalTimezone);
817 907
 				$datetime = new DateTime();
818 908
 				$offset = $datetime->format('P');
819
-			} else $offset = '+00:00';
909
+			} else {
910
+				$offset = '+00:00';
911
+			}
820 912
 
821 913
 			if ($date_array[1] != "")
822 914
 			{
@@ -848,8 +940,12 @@  discard block
 block discarded – undo
848 940
 			{
849 941
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
850 942
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
851
-			} else $limit_query = "";
852
-		} else $limit_query = "";
943
+			} else {
944
+				$limit_query = "";
945
+			}
946
+		} else {
947
+			$limit_query = "";
948
+		}
853 949
 
854 950
 
855 951
 		if ($sort != "")
@@ -917,8 +1013,12 @@  discard block
 block discarded – undo
917 1013
 			{
918 1014
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
919 1015
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
920
-			} else $limit_query = "";
921
-		} else $limit_query = "";
1016
+			} else {
1017
+				$limit_query = "";
1018
+			}
1019
+		} else {
1020
+			$limit_query = "";
1021
+		}
922 1022
 		
923 1023
 		if ($sort != "")
924 1024
 		{
@@ -1242,7 +1342,9 @@  discard block
 block discarded – undo
1242 1342
 		global $global_query;
1243 1343
 		
1244 1344
 		date_default_timezone_set('UTC');
1245
-		if ($id == '') return array();
1345
+		if ($id == '') {
1346
+			return array();
1347
+		}
1246 1348
 		$additional_query = "spotter_output.spotter_id = :id";
1247 1349
 		$query_values = array(':id' => $id);
1248 1350
 
@@ -1357,8 +1459,11 @@  discard block
 block discarded – undo
1357 1459
 		if ($sort != "")
1358 1460
 		{
1359 1461
 			$search_orderby_array = $this->getOrderBy();
1360
-			if (isset($search_orderby_array[$sort]['sql'])) $orderby_query = $search_orderby_array[$sort]['sql'];
1361
-			else $orderby_query = " ORDER BY spotter_output.date DESC";
1462
+			if (isset($search_orderby_array[$sort]['sql'])) {
1463
+				$orderby_query = $search_orderby_array[$sort]['sql'];
1464
+			} else {
1465
+				$orderby_query = " ORDER BY spotter_output.date DESC";
1466
+			}
1362 1467
 		} else {
1363 1468
 			$orderby_query = " ORDER BY spotter_output.date DESC";
1364 1469
 		}
@@ -1983,7 +2088,9 @@  discard block
 block discarded – undo
1983 2088
 		{
1984 2089
 			$highlight = $row['highlight'];
1985 2090
 		}
1986
-		if (isset($highlight)) return $highlight;
2091
+		if (isset($highlight)) {
2092
+			return $highlight;
2093
+		}
1987 2094
 	}
1988 2095
 
1989 2096
 	
@@ -2011,7 +2118,9 @@  discard block
 block discarded – undo
2011 2118
 		$sth->closeCursor();
2012 2119
 		if (count($row) > 0) {
2013 2120
 			return $row['usage'];
2014
-		} else return '';
2121
+		} else {
2122
+			return '';
2123
+		}
2015 2124
 	}
2016 2125
 
2017 2126
 	/**
@@ -2036,7 +2145,9 @@  discard block
 block discarded – undo
2036 2145
 		$sth->closeCursor();
2037 2146
 		if (count($row) > 0) {
2038 2147
 			return $row['icao'];
2039
-		} else return '';
2148
+		} else {
2149
+			return '';
2150
+		}
2040 2151
 	}
2041 2152
 
2042 2153
 	/**
@@ -2064,7 +2175,9 @@  discard block
 block discarded – undo
2064 2175
 			$airport_longitude = $row['longitude'];
2065 2176
 			$Common = new Common();
2066 2177
 			return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude);
2067
-		} else return '';
2178
+		} else {
2179
+			return '';
2180
+		}
2068 2181
 	}
2069 2182
 	
2070 2183
 	/**
@@ -2176,7 +2289,9 @@  discard block
 block discarded – undo
2176 2289
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2177 2290
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2178 2291
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2179
-		} else return array();
2292
+		} else {
2293
+			return array();
2294
+		}
2180 2295
 		if ($globalDBdriver == 'mysql') {
2181 2296
 			$query  = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'";
2182 2297
 		} else {
@@ -2211,7 +2326,9 @@  discard block
 block discarded – undo
2211 2326
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2212 2327
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2213 2328
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2214
-		} else return array();
2329
+		} else {
2330
+			return array();
2331
+		}
2215 2332
 		//$query  = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong;
2216 2333
 		$query  = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")";
2217 2334
 		//$query  = "SELECT waypoints.* FROM waypoints";
@@ -2246,7 +2363,9 @@  discard block
 block discarded – undo
2246 2363
 	public function getAllAirlineInfo($airline_icao, $fromsource = NULL)
2247 2364
 	{
2248 2365
 		global $globalUseRealAirlines;
2249
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2366
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2367
+			$fromsource = NULL;
2368
+		}
2250 2369
 		$airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING));
2251 2370
 		if ($airline_icao == 'NA') {
2252 2371
 			$airline_array = array();
@@ -2315,7 +2434,9 @@  discard block
 block discarded – undo
2315 2434
 	public function getAllAirlineInfoByName($airline_name, $fromsource = NULL)
2316 2435
 	{
2317 2436
 		global $globalUseRealAirlines;
2318
-		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL;
2437
+		if (isset($globalUseRealAirlines) && $globalUseRealAirlines) {
2438
+			$fromsource = NULL;
2439
+		}
2319 2440
 		$airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING));
2320 2441
 		$query  = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1";
2321 2442
 		$sth = $this->db->prepare($query);
@@ -2331,7 +2452,9 @@  discard block
 block discarded – undo
2331 2452
 			$sth->execute(array(':fromsource' => $fromsource));
2332 2453
 			$row = $sth->fetch(PDO::FETCH_ASSOC);
2333 2454
 			$sth->closeCursor();
2334
-			if ($row['nb'] == 0) $result = $this->getAllAirlineInfoByName($airline_name);
2455
+			if ($row['nb'] == 0) {
2456
+				$result = $this->getAllAirlineInfoByName($airline_name);
2457
+			}
2335 2458
 		}
2336 2459
 		return $result;
2337 2460
 	}
@@ -2394,15 +2517,20 @@  discard block
 block discarded – undo
2394 2517
 				'A320-211' => 'A320',
2395 2518
 				'747-8i' => 'B748',
2396 2519
 				'A380' => 'A388');
2397
-		if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type];
2520
+		if (isset($all_aircraft[$aircraft_type])) {
2521
+			return $all_aircraft[$aircraft_type];
2522
+		}
2398 2523
 
2399 2524
 		$query  = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1";
2400 2525
 		$aircraft_type = strtoupper($aircraft_type);
2401 2526
 		$sth = $this->db->prepare($query);
2402 2527
 		$sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,));
2403 2528
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2404
-		if (isset($result[0]['icao'])) return $result[0]['icao'];
2405
-		else return '';
2529
+		if (isset($result[0]['icao'])) {
2530
+			return $result[0]['icao'];
2531
+		} else {
2532
+			return '';
2533
+		}
2406 2534
 	}
2407 2535
 	
2408 2536
 	/**
@@ -2430,11 +2558,15 @@  discard block
 block discarded – undo
2430 2558
 		$sth->closeCursor();
2431 2559
 		if (isset($row['icaotypecode'])) {
2432 2560
 			$icao = $row['icaotypecode'];
2433
-			if (isset($this->aircraft_correct_icaotype[$icao])) $icao = $this->aircraft_correct_icaotype[$icao];
2561
+			if (isset($this->aircraft_correct_icaotype[$icao])) {
2562
+				$icao = $this->aircraft_correct_icaotype[$icao];
2563
+			}
2434 2564
 			return $icao;
2435 2565
 		} elseif ($source_type == 'flarm') {
2436 2566
 			return $this->getAllAircraftType($aircraft_modes);
2437
-		} else  return '';
2567
+		} else {
2568
+			return '';
2569
+		}
2438 2570
 	}
2439 2571
 
2440 2572
 	/**
@@ -2457,7 +2589,9 @@  discard block
 block discarded – undo
2457 2589
 		$sth->closeCursor();
2458 2590
 		if (isset($row['icaotypecode'])) {
2459 2591
 			return $row['icaotypecode'];
2460
-		} else return '';
2592
+		} else {
2593
+			return '';
2594
+		}
2461 2595
 	}
2462 2596
 
2463 2597
 	/**
@@ -2503,7 +2637,9 @@  discard block
 block discarded – undo
2503 2637
 		$sth->closeCursor();
2504 2638
 		if (isset($row['operator_correct'])) {
2505 2639
 			return $row['operator_correct'];
2506
-		} else return $operator;
2640
+		} else {
2641
+			return $operator;
2642
+		}
2507 2643
 	}
2508 2644
 
2509 2645
 	/**
@@ -2516,7 +2652,9 @@  discard block
 block discarded – undo
2516 2652
 	public function getRouteInfo($callsign)
2517 2653
 	{
2518 2654
 		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
2519
-                if ($callsign == '') return array();
2655
+                if ($callsign == '') {
2656
+                	return array();
2657
+                }
2520 2658
 		$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 2659
 		
2522 2660
 		$sth = $this->db->prepare($query);
@@ -2526,7 +2664,9 @@  discard block
 block discarded – undo
2526 2664
 		$sth->closeCursor();
2527 2665
 		if (count($row) > 0) {
2528 2666
 			return $row;
2529
-		} else return array();
2667
+		} else {
2668
+			return array();
2669
+		}
2530 2670
 	}
2531 2671
 	
2532 2672
 	/**
@@ -2579,7 +2719,9 @@  discard block
 block discarded – undo
2579 2719
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
2580 2720
 			$sth->closeCursor();
2581 2721
 			return $result;
2582
-		} else return array();
2722
+		} else {
2723
+			return array();
2724
+		}
2583 2725
 	}
2584 2726
 	
2585 2727
   
@@ -2738,8 +2880,11 @@  discard block
 block discarded – undo
2738 2880
 		$query .= " ORDER BY spotter_output.source_name ASC";
2739 2881
 
2740 2882
 		$sth = $this->db->prepare($query);
2741
-		if (!empty($query_values)) $sth->execute($query_values);
2742
-		else $sth->execute();
2883
+		if (!empty($query_values)) {
2884
+			$sth->execute($query_values);
2885
+		} else {
2886
+			$sth->execute();
2887
+		}
2743 2888
 
2744 2889
 		$source_array = array();
2745 2890
 		$temp_array = array();
@@ -2772,9 +2917,13 @@  discard block
 block discarded – undo
2772 2917
 								WHERE spotter_output.airline_icao <> '' 
2773 2918
 								ORDER BY spotter_output.airline_name ASC";
2774 2919
 			*/
2775
-			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2776
-			elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2777
-			elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2920
+			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2921
+				$forsource = $globalAirlinesSource;
2922
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
2923
+				$forsource = 'vatsim';
2924
+			} elseif (isset($globalIVAO) && $globalIVAO) {
2925
+				$forsource = 'ivao';
2926
+			}
2778 2927
 			if ($forsource === NULL) {
2779 2928
 				$query = "SELECT DISTINCT icao AS airline_icao, name AS airline_name, type AS airline_type FROM airlines WHERE forsource IS NULL ORDER BY name ASC";
2780 2929
 				$query_data = array();
@@ -2817,9 +2966,13 @@  discard block
 block discarded – undo
2817 2966
 	{
2818 2967
 		global $globalAirlinesSource,$globalVATSIM, $globalIVAO;
2819 2968
 		$filter_query = $this->getFilter($filters,true,true);
2820
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource;
2821
-		elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim';
2822
-		elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao';
2969
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
2970
+			$forsource = $globalAirlinesSource;
2971
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
2972
+			$forsource = 'vatsim';
2973
+		} elseif (isset($globalIVAO) && $globalIVAO) {
2974
+			$forsource = 'ivao';
2975
+		}
2823 2976
 		if ($forsource === NULL) {
2824 2977
 			$query = "SELECT DISTINCT alliance FROM airlines WHERE alliance IS NOT NULL AND forsource IS NULL ORDER BY alliance ASC";
2825 2978
 			$query_data = array();
@@ -3130,7 +3283,9 @@  discard block
 block discarded – undo
3130 3283
 			date_default_timezone_set($globalTimezone);
3131 3284
 			$datetime = new DateTime();
3132 3285
 			$offset = $datetime->format('P');
3133
-		} else $offset = '+00:00';
3286
+		} else {
3287
+			$offset = '+00:00';
3288
+		}
3134 3289
 		if ($airport_icao == '') {
3135 3290
 			if ($globalDBdriver == 'mysql') {
3136 3291
 				$query = "SELECT COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' GROUP BY departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3162,7 +3317,9 @@  discard block
 block discarded – undo
3162 3317
 			date_default_timezone_set($globalTimezone);
3163 3318
 			$datetime = new DateTime();
3164 3319
 			$offset = $datetime->format('P');
3165
-		} else $offset = '+00:00';
3320
+		} else {
3321
+			$offset = '+00:00';
3322
+		}
3166 3323
 		if ($airport_icao == '') {
3167 3324
 			if ($globalDBdriver == 'mysql') {
3168 3325
 				$query = "SELECT spotter_output.airline_icao, COUNT(departure_airport_icao) AS departure_airport_count, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND departure_airport_icao <> 'NA' AND departure_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, departure_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), departure_airport_name, departure_airport_city, departure_airport_country ORDER BY departure_airport_count DESC";
@@ -3195,7 +3352,9 @@  discard block
 block discarded – undo
3195 3352
 			date_default_timezone_set($globalTimezone);
3196 3353
 			$datetime = new DateTime();
3197 3354
 			$offset = $datetime->format('P');
3198
-		} else $offset = '+00:00';
3355
+		} else {
3356
+			$offset = '+00:00';
3357
+		}
3199 3358
 		if ($airport_icao == '') {
3200 3359
 			if ($globalDBdriver == 'mysql') {
3201 3360
 				$query = "SELECT COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3234,7 +3393,9 @@  discard block
 block discarded – undo
3234 3393
 			date_default_timezone_set($globalTimezone);
3235 3394
 			$datetime = new DateTime();
3236 3395
 			$offset = $datetime->format('P');
3237
-		} else $offset = '+00:00';
3396
+		} else {
3397
+			$offset = '+00:00';
3398
+		}
3238 3399
 		if ($airport_icao == '') {
3239 3400
 			if ($globalDBdriver == 'mysql') {
3240 3401
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_departure_airport_icao) AS departure_airport_count, real_departure_airport_icao AS departure_airport_icao, airport.name AS departure_airport_name, airport.city AS departure_airport_city, airport.country AS departure_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3279,7 +3440,9 @@  discard block
 block discarded – undo
3279 3440
 			date_default_timezone_set($globalTimezone);
3280 3441
 			$datetime = new DateTime();
3281 3442
 			$offset = $datetime->format('P');
3282
-		} else $offset = '+00:00';
3443
+		} else {
3444
+			$offset = '+00:00';
3445
+		}
3283 3446
 		if ($airport_icao == '') {
3284 3447
 			if ($globalDBdriver == 'mysql') {
3285 3448
 				$query = "SELECT COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output`".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' GROUP BY arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3314,7 +3477,9 @@  discard block
 block discarded – undo
3314 3477
 			date_default_timezone_set($globalTimezone);
3315 3478
 			$datetime = new DateTime();
3316 3479
 			$offset = $datetime->format('P');
3317
-		} else $offset = '+00:00';
3480
+		} else {
3481
+			$offset = '+00:00';
3482
+		}
3318 3483
 		if ($airport_icao == '') {
3319 3484
 			if ($globalDBdriver == 'mysql') {
3320 3485
 				$query = "SELECT COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3356,7 +3521,9 @@  discard block
 block discarded – undo
3356 3521
 			date_default_timezone_set($globalTimezone);
3357 3522
 			$datetime = new DateTime();
3358 3523
 			$offset = $datetime->format('P');
3359
-		} else $offset = '+00:00';
3524
+		} else {
3525
+			$offset = '+00:00';
3526
+		}
3360 3527
 		if ($airport_icao == '') {
3361 3528
 			if ($globalDBdriver == 'mysql') {
3362 3529
 				$query = "SELECT spotter_output.airline_icao, COUNT(arrival_airport_icao) AS arrival_airport_count, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date FROM `spotter_output` WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 7 DAY) AND arrival_airport_icao <> 'NA' AND arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' GROUP BY spotter_output.airline_icao, arrival_airport_icao, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d'), arrival_airport_name, arrival_airport_city, arrival_airport_country ORDER BY arrival_airport_count DESC";
@@ -3390,7 +3557,9 @@  discard block
 block discarded – undo
3390 3557
 			date_default_timezone_set($globalTimezone);
3391 3558
 			$datetime = new DateTime();
3392 3559
 			$offset = $datetime->format('P');
3393
-		} else $offset = '+00:00';
3560
+		} else {
3561
+			$offset = '+00:00';
3562
+		}
3394 3563
 		if ($airport_icao == '') {
3395 3564
 			if ($globalDBdriver == 'mysql') {
3396 3565
 				$query = "SELECT spotter_output.airline_icao, COUNT(real_arrival_airport_icao) AS arrival_airport_count, real_arrival_airport_icao AS arrival_airport_icao, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country, DATE_FORMAT(DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)),'%Y-%m-%d') as date 
@@ -3438,7 +3607,9 @@  discard block
 block discarded – undo
3438 3607
 			date_default_timezone_set($globalTimezone);
3439 3608
 			$datetime = new DateTime();
3440 3609
 			$offset = $datetime->format('P');
3441
-		} else $offset = '+00:00';
3610
+		} else {
3611
+			$offset = '+00:00';
3612
+		}
3442 3613
 
3443 3614
 		if ($globalDBdriver == 'mysql') {
3444 3615
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date
@@ -3558,7 +3729,9 @@  discard block
 block discarded – undo
3558 3729
 	*/	
3559 3730
 	public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '')
3560 3731
 	{
3561
-		if ($groundspeed == '') $groundspeed = NULL;
3732
+		if ($groundspeed == '') {
3733
+			$groundspeed = NULL;
3734
+		}
3562 3735
 		$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 3736
                 $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 3737
 
@@ -3608,10 +3781,18 @@  discard block
 block discarded – undo
3608 3781
 		$Image = new Image($this->db);
3609 3782
 		$Common = new Common();
3610 3783
 		
3611
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
3612
-		if (!isset($globalVATSIM)) $globalVATSIM = FALSE;
3613
-		if (!isset($globalphpVMS)) $globalphpVMS = FALSE;
3614
-		if (!isset($globalVAM)) $globalVAM = FALSE;
3784
+		if (!isset($globalIVAO)) {
3785
+			$globalIVAO = FALSE;
3786
+		}
3787
+		if (!isset($globalVATSIM)) {
3788
+			$globalVATSIM = FALSE;
3789
+		}
3790
+		if (!isset($globalphpVMS)) {
3791
+			$globalphpVMS = FALSE;
3792
+		}
3793
+		if (!isset($globalVAM)) {
3794
+			$globalVAM = FALSE;
3795
+		}
3615 3796
 		date_default_timezone_set('UTC');
3616 3797
 		
3617 3798
 		//getting the registration
@@ -3624,23 +3805,33 @@  discard block
 block discarded – undo
3624 3805
 				if ($ModeS != '') {
3625 3806
 					$timeelapsed = microtime(true);
3626 3807
 					$registration = $this->getAircraftRegistrationBymodeS($ModeS,$source_type);
3627
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3808
+					if ($globalDebugTimeElapsed) {
3809
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3810
+					}
3628 3811
 				} else {
3629 3812
 					$myhex = explode('-',$flightaware_id);
3630 3813
 					if (count($myhex) > 0) {
3631 3814
 						$timeelapsed = microtime(true);
3632 3815
 						$registration = $this->getAircraftRegistrationBymodeS($myhex[0],$source_type);
3633
-						if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3816
+						if ($globalDebugTimeElapsed) {
3817
+							echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3818
+						}
3634 3819
 					}
3635 3820
 				}
3636 3821
 			}
3637 3822
 		}
3638 3823
 		$fromsource = NULL;
3639
-		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
3640
-		elseif ($format_source == 'vatsimtxt') $fromsource = 'vatsim';
3641
-		elseif ($format_source == 'whazzup') $fromsource = 'ivao';
3642
-		elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
3643
-		elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
3824
+		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
3825
+			$fromsource = $globalAirlinesSource;
3826
+		} elseif ($format_source == 'vatsimtxt') {
3827
+			$fromsource = 'vatsim';
3828
+		} elseif ($format_source == 'whazzup') {
3829
+			$fromsource = 'ivao';
3830
+		} elseif (isset($globalVATSIM) && $globalVATSIM) {
3831
+			$fromsource = 'vatsim';
3832
+		} elseif (isset($globalIVAO) && $globalIVAO) {
3833
+			$fromsource = 'ivao';
3834
+		}
3644 3835
 		//getting the airline information
3645 3836
 		if ($ident != "")
3646 3837
 		{
@@ -3664,15 +3855,21 @@  discard block
 block discarded – undo
3664 3855
 					if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){
3665 3856
 						$airline_array = $this->getAllAirlineInfo("NA");
3666 3857
 					}
3667
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3858
+					if ($globalDebugTimeElapsed) {
3859
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3860
+					}
3668 3861
 
3669 3862
 				} else {
3670 3863
 					$timeelapsed = microtime(true);
3671 3864
 					$airline_array = $this->getAllAirlineInfo("NA");
3672
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3865
+					if ($globalDebugTimeElapsed) {
3866
+						echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3867
+					}
3673 3868
 				}
3674 3869
 			}
3675
-		} else $airline_array = array();
3870
+		} else {
3871
+			$airline_array = array();
3872
+		}
3676 3873
 		
3677 3874
 		//getting the aircraft information
3678 3875
 		$aircraft_array = array();
@@ -3686,27 +3883,37 @@  discard block
 block discarded – undo
3686 3883
 				{
3687 3884
 					$timeelapsed = microtime(true);
3688 3885
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3689
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3886
+					if ($globalDebugTimeElapsed) {
3887
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3888
+					}
3690 3889
 				} else {
3691 3890
 					$timeelapsed = microtime(true);
3692 3891
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3693
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3892
+					if ($globalDebugTimeElapsed) {
3893
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3894
+					}
3694 3895
 				}
3695 3896
 			}
3696 3897
 		} else {
3697 3898
 			if ($ModeS != '') {
3698 3899
 				$timeelapsed = microtime(true);
3699 3900
 				$aircraft_icao = $this->getAllAircraftType($ModeS,$source_type);
3700
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3901
+				if ($globalDebugTimeElapsed) {
3902
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3903
+				}
3701 3904
 				if ($aircraft_icao == "" || $aircraft_icao == "XXXX")
3702 3905
 				{
3703 3906
 					$timeelapsed = microtime(true);
3704 3907
 					$aircraft_array = $this->getAllAircraftInfo("NA");
3705
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3908
+					if ($globalDebugTimeElapsed) {
3909
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3910
+					}
3706 3911
 				} else {
3707 3912
 					$timeelapsed = microtime(true);
3708 3913
 					$aircraft_array = $this->getAllAircraftInfo($aircraft_icao);
3709
-					if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3914
+					if ($globalDebugTimeElapsed) {
3915
+						echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3916
+					}
3710 3917
 				}
3711 3918
 			}
3712 3919
 		}
@@ -3722,7 +3929,9 @@  discard block
 block discarded – undo
3722 3929
 			} else {
3723 3930
 				$timeelapsed = microtime(true);
3724 3931
 				$departure_airport_array = $this->getAllAirportInfo($departure_airport_icao);
3725
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3932
+				if ($globalDebugTimeElapsed) {
3933
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3934
+				}
3726 3935
 			}
3727 3936
 		}
3728 3937
 		
@@ -3737,7 +3946,9 @@  discard block
 block discarded – undo
3737 3946
 			} else {
3738 3947
 				$timeelapsed = microtime(true);
3739 3948
 				$arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao);
3740
-				if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3949
+				if ($globalDebugTimeElapsed) {
3950
+					echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3951
+				}
3741 3952
 			}
3742 3953
 		}
3743 3954
 
@@ -3771,7 +3982,9 @@  discard block
 block discarded – undo
3771 3982
 			{
3772 3983
 				return false;
3773 3984
 			}
3774
-		} else $altitude = 0;
3985
+		} else {
3986
+			$altitude = 0;
3987
+		}
3775 3988
 		
3776 3989
 		if ($heading != "")
3777 3990
 		{
@@ -3800,7 +4013,9 @@  discard block
 block discarded – undo
3800 4013
 		{
3801 4014
 			$timeelapsed = microtime(true);
3802 4015
 			$image_array = $Image->getSpotterImage($registration);
3803
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4016
+			if ($globalDebugTimeElapsed) {
4017
+				echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4018
+			}
3804 4019
 			if (!isset($image_array[0]['registration']))
3805 4020
 			{
3806 4021
 				//echo "Add image !!!! \n";
@@ -3808,14 +4023,21 @@  discard block
 block discarded – undo
3808 4023
 			}
3809 4024
 			$timeelapsed = microtime(true);
3810 4025
 			$owner_info = $this->getAircraftOwnerByRegistration($registration);
3811
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
3812
-			if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner']));
4026
+			if ($globalDebugTimeElapsed) {
4027
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4028
+			}
4029
+			if ($owner_info['owner'] != '') {
4030
+				$aircraft_owner = ucwords(strtolower($owner_info['owner']));
4031
+			}
3813 4032
 		}
3814 4033
     
3815 4034
 		if ($globalIVAO && $aircraft_icao != '')
3816 4035
 		{
3817
-            		if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao'];
3818
-            		else $airline_icao = '';
4036
+            		if (isset($airline_array[0]['icao'])) {
4037
+            			$airline_icao = $airline_array[0]['icao'];
4038
+            		} else {
4039
+            			$airline_icao = '';
4040
+            		}
3819 4041
 			$image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao);
3820 4042
 			if (!isset($image_array[0]['registration']))
3821 4043
 			{
@@ -3860,16 +4082,28 @@  discard block
 block discarded – undo
3860 4082
                 {
3861 4083
                         $arrival_airport_array = $this->getAllAirportInfo('NA');
3862 4084
                 }
3863
-                if ($registration == '') $registration = 'NA';
4085
+                if ($registration == '') {
4086
+                	$registration = 'NA';
4087
+                }
3864 4088
                 if ($latitude == '' && $longitude == '') {
3865 4089
             		$latitude = 0;
3866 4090
             		$longitude = 0;
3867 4091
             	}
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;
4092
+                if ($squawk == '' || $Common->isInteger($squawk) === false) {
4093
+                	$squawk = NULL;
4094
+                }
4095
+                if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) {
4096
+                	$verticalrate = NULL;
4097
+                }
4098
+                if ($heading == '' || $Common->isInteger($heading) === false) {
4099
+                	$heading = 0;
4100
+                }
4101
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
4102
+                	$groundspeed = 0;
4103
+                }
4104
+                if (!isset($aircraft_owner)) {
4105
+                	$aircraft_owner = NULL;
4106
+                }
3873 4107
                 $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 4108
                 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 4109
 
@@ -3880,9 +4114,13 @@  discard block
 block discarded – undo
3880 4114
 		if ($airline_type == '') {
3881 4115
 			$timeelapsed = microtime(true);
3882 4116
 			$airline_type = $this->getAircraftTypeBymodeS($ModeS);
3883
-			if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4117
+			if ($globalDebugTimeElapsed) {
4118
+				echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
4119
+			}
4120
+		}
4121
+		if ($airline_type == null) {
4122
+			$airline_type = '';
3884 4123
 		}
3885
-		if ($airline_type == null) $airline_type = '';
3886 4124
                 $aircraft_type = $aircraft_array[0]['type'];
3887 4125
                 $aircraft_manufacturer = $aircraft_array[0]['manufacturer'];
3888 4126
                 $departure_airport_name = $departure_airport_array[0]['name'];
@@ -4046,7 +4284,9 @@  discard block
 block discarded – undo
4046 4284
 			}
4047 4285
 		}
4048 4286
 		$query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC";
4049
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4287
+		if ($limit) {
4288
+			$query .= " LIMIT 10 OFFSET 0";
4289
+		}
4050 4290
 
4051 4291
 		$sth = $this->db->prepare($query);
4052 4292
 		$sth->execute($query_values);
@@ -4119,7 +4359,9 @@  discard block
 block discarded – undo
4119 4359
 		}
4120 4360
 		
4121 4361
 		$query .= " GROUP BY spotter_output.pilot_id,s.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4122
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4362
+		if ($limit) {
4363
+			$query .= " LIMIT 10 OFFSET 0";
4364
+		}
4123 4365
       
4124 4366
 		
4125 4367
 		$sth = $this->db->prepare($query);
@@ -4163,7 +4405,9 @@  discard block
 block discarded – undo
4163 4405
 			}
4164 4406
 		}
4165 4407
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.format_source ORDER BY pilot_count DESC";
4166
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4408
+		if ($limit) {
4409
+			$query .= " LIMIT 10 OFFSET 0";
4410
+		}
4167 4411
       
4168 4412
 		
4169 4413
 		$sth = $this->db->prepare($query);
@@ -4239,7 +4483,9 @@  discard block
 block discarded – undo
4239 4483
 			}
4240 4484
 		}
4241 4485
 		$query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC";
4242
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4486
+		if ($limit) {
4487
+			$query .= " LIMIT 10 OFFSET 0";
4488
+		}
4243 4489
 		
4244 4490
 		$sth = $this->db->prepare($query);
4245 4491
 		$sth->execute($query_values);
@@ -4281,7 +4527,9 @@  discard block
 block discarded – undo
4281 4527
 			}
4282 4528
 		}
4283 4529
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.owner_name ORDER BY owner_count DESC";
4284
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
4530
+		if ($limit) {
4531
+			$query .= " LIMIT 10 OFFSET 0";
4532
+		}
4285 4533
       
4286 4534
 		
4287 4535
 		$sth = $this->db->prepare($query);
@@ -4525,7 +4773,9 @@  discard block
 block discarded – undo
4525 4773
 			date_default_timezone_set($globalTimezone);
4526 4774
 			$datetime = new DateTime($date);
4527 4775
 			$offset = $datetime->format('P');
4528
-		} else $offset = '+00:00';
4776
+		} else {
4777
+			$offset = '+00:00';
4778
+		}
4529 4779
 
4530 4780
 		if ($globalDBdriver == 'mysql') {
4531 4781
 			$query  = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count
@@ -4573,7 +4823,9 @@  discard block
 block discarded – undo
4573 4823
 			date_default_timezone_set($globalTimezone);
4574 4824
 			$datetime = new DateTime($date);
4575 4825
 			$offset = $datetime->format('P');
4576
-		} else $offset = '+00:00';
4826
+		} else {
4827
+			$offset = '+00:00';
4828
+		}
4577 4829
 		
4578 4830
 		if ($globalDBdriver == 'mysql') {
4579 4831
 			$query  = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count
@@ -4693,9 +4945,13 @@  discard block
 block discarded – undo
4693 4945
 		$sth = $this->db->prepare($query);
4694 4946
 		$sth->execute($query_values);
4695 4947
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4696
-		if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4697
-		elseif ($result[0]['duration'] == '') return 0;
4698
-		else return $result[0]['duration'];
4948
+		if (is_numeric($result[0]['duration'])) {
4949
+			return gmdate('H:i:s',$result[0]['duration']);
4950
+		} elseif ($result[0]['duration'] == '') {
4951
+			return 0;
4952
+		} else {
4953
+			return $result[0]['duration'];
4954
+		}
4699 4955
 	}
4700 4956
 
4701 4957
 	/**
@@ -4784,8 +5040,11 @@  discard block
 block discarded – undo
4784 5040
 		$sth = $this->db->prepare($query);
4785 5041
 		$sth->execute($query_values);
4786 5042
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
4787
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
4788
-		else return $result[0]['duration'];
5043
+		if (is_int($result[0]['duration'])) {
5044
+			return gmdate('H:i:s',$result[0]['duration']);
5045
+		} else {
5046
+			return $result[0]['duration'];
5047
+		}
4789 5048
 	}
4790 5049
 
4791 5050
 	/**
@@ -4990,7 +5249,9 @@  discard block
 block discarded – undo
4990 5249
 		}
4991 5250
 		$query .= " GROUP BY spotter_output.airline_country, countries.iso3
4992 5251
 					ORDER BY airline_country_count DESC";
4993
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5252
+		if ($limit) {
5253
+			$query .= " LIMIT 10 OFFSET 0";
5254
+		}
4994 5255
       
4995 5256
 		$sth = $this->db->prepare($query);
4996 5257
 		$sth->execute($query_values);
@@ -5019,7 +5280,9 @@  discard block
 block discarded – undo
5019 5280
 		global $globalDBdriver;
5020 5281
 		//$filter_query = $this->getFilter($filters,true,true);
5021 5282
 		$Connection= new Connection($this->db);
5022
-		if (!$Connection->tableExists('countries')) return array();
5283
+		if (!$Connection->tableExists('countries')) {
5284
+			return array();
5285
+		}
5023 5286
 		/*
5024 5287
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
5025 5288
 					FROM countries c, spotter_output s
@@ -5051,7 +5314,9 @@  discard block
 block discarded – undo
5051 5314
 		}
5052 5315
 		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT flightaware_id,over_country FROM spotter_live".$filter_query.") l ON c.iso2 = l.over_country ";
5053 5316
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
5054
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5317
+		if ($limit) {
5318
+			$query .= " LIMIT 10 OFFSET 0";
5319
+		}
5055 5320
       
5056 5321
 		
5057 5322
 		$sth = $this->db->prepare($query);
@@ -5128,7 +5393,9 @@  discard block
 block discarded – undo
5128 5393
 		}
5129 5394
 
5130 5395
 		$query .= " GROUP BY spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5131
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5396
+		if ($limit) {
5397
+			$query .= " LIMIT 10 OFFSET 0";
5398
+		}
5132 5399
  
5133 5400
 		$sth = $this->db->prepare($query);
5134 5401
 		$sth->execute($query_values);
@@ -5202,7 +5469,9 @@  discard block
 block discarded – undo
5202 5469
 		}
5203 5470
 
5204 5471
 		$query .= " GROUP BY spotter_output.airline_icao, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5205
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5472
+		if ($limit) {
5473
+			$query .= " LIMIT 10 OFFSET 0";
5474
+		}
5206 5475
  
5207 5476
 		$sth = $this->db->prepare($query);
5208 5477
 		$sth->execute($query_values);
@@ -5249,7 +5518,9 @@  discard block
 block discarded – undo
5249 5518
 		}
5250 5519
 
5251 5520
 		$query .= "GROUP BY EXTRACT(month from spotter_output.date), EXTRACT(year from spotter_output.date), spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer ORDER BY aircraft_icao_count DESC";
5252
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
5521
+		if ($limit) {
5522
+			$query .= " LIMIT 10 OFFSET 0";
5523
+		}
5253 5524
  
5254 5525
 		$sth = $this->db->prepare($query);
5255 5526
 		$sth->execute();
@@ -5302,7 +5573,9 @@  discard block
 block discarded – undo
5302 5573
 			if($row['registration'] != "")
5303 5574
 			{
5304 5575
 				$image_array = $Image->getSpotterImage($row['registration']);
5305
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5576
+				if (isset($image_array[0]['image_thumbnail'])) {
5577
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5578
+				}
5306 5579
 			}
5307 5580
 			$temp_array['registration_count'] = $row['registration_count'];
5308 5581
 
@@ -5377,7 +5650,9 @@  discard block
 block discarded – undo
5377 5650
 			if($row['registration'] != "")
5378 5651
 			{
5379 5652
 				$image_array = $Image->getSpotterImage($row['registration']);
5380
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5653
+				if (isset($image_array[0]['image_thumbnail'])) {
5654
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5655
+				}
5381 5656
 			}
5382 5657
 			$temp_array['registration_count'] = $row['registration_count'];
5383 5658
 
@@ -5484,7 +5759,9 @@  discard block
 block discarded – undo
5484 5759
 			if($row['registration'] != "")
5485 5760
 			{
5486 5761
 				$image_array = $Image->getSpotterImage($row['registration']);
5487
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5762
+				if (isset($image_array[0]['image_thumbnail'])) {
5763
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5764
+				}
5488 5765
 			}
5489 5766
 			$temp_array['registration_count'] = $row['registration_count'];
5490 5767
 			$aircraft_array[] = $temp_array;
@@ -5609,7 +5886,9 @@  discard block
 block discarded – undo
5609 5886
 			date_default_timezone_set($globalTimezone);
5610 5887
 			$datetime = new DateTime($date);
5611 5888
 			$offset = $datetime->format('P');
5612
-		} else $offset = '+00:00';
5889
+		} else {
5890
+			$offset = '+00:00';
5891
+		}
5613 5892
 
5614 5893
 		if ($globalDBdriver == 'mysql') {
5615 5894
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name  
@@ -5656,7 +5935,9 @@  discard block
 block discarded – undo
5656 5935
 			date_default_timezone_set($globalTimezone);
5657 5936
 			$datetime = new DateTime($date);
5658 5937
 			$offset = $datetime->format('P');
5659
-		} else $offset = '+00:00';
5938
+		} else {
5939
+			$offset = '+00:00';
5940
+		}
5660 5941
 
5661 5942
 		if ($globalDBdriver == 'mysql') {
5662 5943
 			$query  = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name 
@@ -5685,7 +5966,9 @@  discard block
 block discarded – undo
5685 5966
 			if($row['registration'] != "")
5686 5967
 			{
5687 5968
 				$image_array = $Image->getSpotterImage($row['registration']);
5688
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5969
+				if (isset($image_array[0]['image_thumbnail'])) {
5970
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5971
+				}
5689 5972
 			}
5690 5973
 			$temp_array['registration_count'] = $row['registration_count'];
5691 5974
  
@@ -5710,7 +5993,9 @@  discard block
 block discarded – undo
5710 5993
 			date_default_timezone_set($globalTimezone);
5711 5994
 			$datetime = new DateTime($date);
5712 5995
 			$offset = $datetime->format('P');
5713
-		} else $offset = '+00:00';
5996
+		} else {
5997
+			$offset = '+00:00';
5998
+		}
5714 5999
 
5715 6000
 		if ($globalDBdriver == 'mysql') {
5716 6001
 			$query  = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count  
@@ -5906,8 +6191,11 @@  discard block
 block discarded – undo
5906 6191
 			if($row['registration'] != "")
5907 6192
 			{
5908 6193
 				$image_array = $Image->getSpotterImage($row['registration']);
5909
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5910
-				else $temp_array['image_thumbnail'] = '';
6194
+				if (isset($image_array[0]['image_thumbnail'])) {
6195
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6196
+				} else {
6197
+					$temp_array['image_thumbnail'] = '';
6198
+				}
5911 6199
 			}
5912 6200
 			$temp_array['registration_count'] = $row['registration_count'];
5913 6201
 			$aircraft_array[] = $temp_array;
@@ -5981,8 +6269,11 @@  discard block
 block discarded – undo
5981 6269
 			if($row['registration'] != "")
5982 6270
 			{
5983 6271
 				$image_array = $Image->getSpotterImage($row['registration']);
5984
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
5985
-				else $temp_array['image_thumbnail'] = '';
6272
+				if (isset($image_array[0]['image_thumbnail'])) {
6273
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6274
+				} else {
6275
+					$temp_array['image_thumbnail'] = '';
6276
+				}
5986 6277
 			}
5987 6278
 			$temp_array['registration_count'] = $row['registration_count'];
5988 6279
 			$aircraft_array[] = $temp_array;
@@ -6056,8 +6347,11 @@  discard block
 block discarded – undo
6056 6347
 			if($row['registration'] != "")
6057 6348
 			{
6058 6349
 				$image_array = $Image->getSpotterImage($row['registration']);
6059
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6060
-				else $temp_array['image_thumbnail'] = '';
6350
+				if (isset($image_array[0]['image_thumbnail'])) {
6351
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6352
+				} else {
6353
+					$temp_array['image_thumbnail'] = '';
6354
+				}
6061 6355
 			}
6062 6356
 			$temp_array['registration_count'] = $row['registration_count'];
6063 6357
 			$aircraft_array[] = $temp_array;
@@ -6268,7 +6562,9 @@  discard block
 block discarded – undo
6268 6562
 			if($row['registration'] != "")
6269 6563
 			{
6270 6564
 				$image_array = $Image->getSpotterImage($row['registration']);
6271
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6565
+				if (isset($image_array[0]['image_thumbnail'])) {
6566
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6567
+				}
6272 6568
 			}
6273 6569
 			$temp_array['registration_count'] = $row['registration_count'];
6274 6570
           
@@ -6385,7 +6681,9 @@  discard block
 block discarded – undo
6385 6681
 			if($row['registration'] != "")
6386 6682
 			{
6387 6683
 				$image_array = $Image->getSpotterImage($row['registration']);
6388
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6684
+				if (isset($image_array[0]['image_thumbnail'])) {
6685
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6686
+				}
6389 6687
 			}
6390 6688
 			$temp_array['registration_count'] = $row['registration_count'];
6391 6689
           
@@ -6551,7 +6849,9 @@  discard block
 block discarded – undo
6551 6849
 			}
6552 6850
 		}
6553 6851
 		$query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC";
6554
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6852
+		if ($limit) {
6853
+			$query .= " LIMIT 10 OFFSET 0";
6854
+		}
6555 6855
 		
6556 6856
 		$sth = $this->db->prepare($query);
6557 6857
 		$sth->execute($query_values);
@@ -6570,7 +6870,9 @@  discard block
 block discarded – undo
6570 6870
 			if($row['registration'] != "")
6571 6871
 			{
6572 6872
 				$image_array = $Image->getSpotterImage($row['registration']);
6573
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6873
+				if (isset($image_array[0]['image_thumbnail'])) {
6874
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6875
+				}
6574 6876
 			}
6575 6877
           
6576 6878
 			$aircraft_array[] = $temp_array;
@@ -6611,7 +6913,9 @@  discard block
 block discarded – undo
6611 6913
 		// if ($olderthanmonths > 0) $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
6612 6914
 		//if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6613 6915
                 $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";
6614
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
6916
+		if ($limit) {
6917
+			$query .= " LIMIT 10 OFFSET 0";
6918
+		}
6615 6919
 		
6616 6920
 		$sth = $this->db->prepare($query);
6617 6921
 		$sth->execute();
@@ -6631,7 +6935,9 @@  discard block
 block discarded – undo
6631 6935
 			if($row['registration'] != "")
6632 6936
 			{
6633 6937
 				$image_array = $Image->getSpotterImage($row['registration']);
6634
-				if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6938
+				if (isset($image_array[0]['image_thumbnail'])) {
6939
+					$temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail'];
6940
+				}
6635 6941
 			}
6636 6942
           
6637 6943
 			$aircraft_array[] = $temp_array;
@@ -6697,7 +7003,9 @@  discard block
 block discarded – undo
6697 7003
 		}
6698 7004
                 $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, airport.latitude, airport.longitude
6699 7005
 				ORDER BY airport_departure_icao_count DESC";
6700
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7006
+		if ($limit) {
7007
+			$query .= " LIMIT 10 OFFSET 0";
7008
+		}
6701 7009
 
6702 7010
 		$sth = $this->db->prepare($query);
6703 7011
 		$sth->execute($query_values);
@@ -6749,7 +7057,9 @@  discard block
 block discarded – undo
6749 7057
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6750 7058
                 $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
6751 7059
 				ORDER BY airport_departure_icao_count DESC";
6752
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7060
+		if ($limit) {
7061
+			$query .= " LIMIT 10 OFFSET 0";
7062
+		}
6753 7063
       
6754 7064
 		$sth = $this->db->prepare($query);
6755 7065
 		$sth->execute();
@@ -6827,7 +7137,9 @@  discard block
 block discarded – undo
6827 7137
 		}
6828 7138
                 $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
6829 7139
 				ORDER BY airport_departure_icao_count DESC";
6830
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7140
+		if ($limit) {
7141
+			$query .= " LIMIT 10 OFFSET 0";
7142
+		}
6831 7143
     		//echo $query;
6832 7144
 		$sth = $this->db->prepare($query);
6833 7145
 		$sth->execute($query_values);
@@ -6881,7 +7193,9 @@  discard block
 block discarded – undo
6881 7193
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
6882 7194
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country
6883 7195
 				ORDER BY airport_departure_icao_count DESC";
6884
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
7196
+		if ($limit) {
7197
+			$query .= " LIMIT 10 OFFSET 0";
7198
+		}
6885 7199
       
6886 7200
 		$sth = $this->db->prepare($query);
6887 7201
 		$sth->execute();
@@ -7274,7 +7588,9 @@  discard block
 block discarded – undo
7274 7588
 			date_default_timezone_set($globalTimezone);
7275 7589
 			$datetime = new DateTime($date);
7276 7590
 			$offset = $datetime->format('P');
7277
-		} else $offset = '+00:00';
7591
+		} else {
7592
+			$offset = '+00:00';
7593
+		}
7278 7594
 
7279 7595
 		if ($globalDBdriver == 'mysql') {
7280 7596
 			$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 
@@ -7324,7 +7640,9 @@  discard block
 block discarded – undo
7324 7640
 			date_default_timezone_set($globalTimezone);
7325 7641
 			$datetime = new DateTime($date);
7326 7642
 			$offset = $datetime->format('P');
7327
-		} else $offset = '+00:00';
7643
+		} else {
7644
+			$offset = '+00:00';
7645
+		}
7328 7646
 
7329 7647
 		if ($globalDBdriver == 'mysql') {
7330 7648
 			$query  = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count 
@@ -7673,7 +7991,9 @@  discard block
 block discarded – undo
7673 7991
 		}
7674 7992
                 $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, airport.latitude, airport.longitude
7675 7993
 					ORDER BY airport_arrival_icao_count DESC";
7676
-		if ($limit) $query .= " LIMIT 10";
7994
+		if ($limit) {
7995
+			$query .= " LIMIT 10";
7996
+		}
7677 7997
       
7678 7998
 		
7679 7999
 		$sth = $this->db->prepare($query);
@@ -7695,7 +8015,9 @@  discard block
 block discarded – undo
7695 8015
 			if ($icaoaskey) {
7696 8016
 				$icao = $row['arrival_airport_icao'];
7697 8017
 				$airport_array[$icao] = $temp_array;
7698
-			} else $airport_array[] = $temp_array;
8018
+			} else {
8019
+				$airport_array[] = $temp_array;
8020
+			}
7699 8021
 		}
7700 8022
 
7701 8023
 		return $airport_array;
@@ -7732,7 +8054,9 @@  discard block
 block discarded – undo
7732 8054
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7733 8055
                 $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, countries.iso3
7734 8056
 					ORDER BY airport_arrival_icao_count DESC";
7735
-		if ($limit) $query .= " LIMIT 10";
8057
+		if ($limit) {
8058
+			$query .= " LIMIT 10";
8059
+		}
7736 8060
       
7737 8061
 		
7738 8062
 		$sth = $this->db->prepare($query);
@@ -7754,7 +8078,9 @@  discard block
 block discarded – undo
7754 8078
 			if ($icaoaskey) {
7755 8079
 				$icao = $row['arrival_airport_icao'];
7756 8080
 				$airport_array[$icao] = $temp_array;
7757
-			} else $airport_array[] = $temp_array;
8081
+			} else {
8082
+				$airport_array[] = $temp_array;
8083
+			}
7758 8084
 		}
7759 8085
 
7760 8086
 		return $airport_array;
@@ -7817,7 +8143,9 @@  discard block
 block discarded – undo
7817 8143
 		}
7818 8144
 		$query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country, airport.latitude, airport.longitude
7819 8145
 					ORDER BY airport_arrival_icao_count DESC";
7820
-		if ($limit) $query .= " LIMIT 10";
8146
+		if ($limit) {
8147
+			$query .= " LIMIT 10";
8148
+		}
7821 8149
       
7822 8150
 		
7823 8151
 		$sth = $this->db->prepare($query);
@@ -7836,7 +8164,9 @@  discard block
 block discarded – undo
7836 8164
 			if ($icaoaskey) {
7837 8165
 				$icao = $row['arrival_airport_icao'];
7838 8166
 				$airport_array[$icao] = $temp_array;
7839
-			} else $airport_array[] = $temp_array;
8167
+			} else {
8168
+				$airport_array[] = $temp_array;
8169
+			}
7840 8170
 		}
7841 8171
 
7842 8172
 		return $airport_array;
@@ -7873,7 +8203,9 @@  discard block
 block discarded – undo
7873 8203
                 //if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
7874 8204
                 $query .= "GROUP BY spotter_output.airline_icao, spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country
7875 8205
 					ORDER BY airport_arrival_icao_count DESC";
7876
-		if ($limit) $query .= " LIMIT 10";
8206
+		if ($limit) {
8207
+			$query .= " LIMIT 10";
8208
+		}
7877 8209
       
7878 8210
 		
7879 8211
 		$sth = $this->db->prepare($query);
@@ -7894,7 +8226,9 @@  discard block
 block discarded – undo
7894 8226
 			if ($icaoaskey) {
7895 8227
 				$icao = $row['arrival_airport_icao'];
7896 8228
 				$airport_array[$icao] = $temp_array;
7897
-			} else $airport_array[] = $temp_array;
8229
+			} else {
8230
+				$airport_array[] = $temp_array;
8231
+			}
7898 8232
 		}
7899 8233
 
7900 8234
 		return $airport_array;
@@ -8274,7 +8608,9 @@  discard block
 block discarded – undo
8274 8608
 			date_default_timezone_set($globalTimezone);
8275 8609
 			$datetime = new DateTime($date);
8276 8610
 			$offset = $datetime->format('P');
8277
-		} else $offset = '+00:00';
8611
+		} else {
8612
+			$offset = '+00:00';
8613
+		}
8278 8614
 
8279 8615
 		if ($globalDBdriver == 'mysql') {
8280 8616
 			$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 
@@ -8324,7 +8660,9 @@  discard block
 block discarded – undo
8324 8660
 			date_default_timezone_set($globalTimezone);
8325 8661
 			$datetime = new DateTime($date);
8326 8662
 			$offset = $datetime->format('P');
8327
-		} else $offset = '+00:00';
8663
+		} else {
8664
+			$offset = '+00:00';
8665
+		}
8328 8666
 
8329 8667
 		if ($globalDBdriver == 'mysql') {
8330 8668
 			$query  = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count 
@@ -8715,7 +9053,9 @@  discard block
 block discarded – undo
8715 9053
 		}
8716 9054
 		$query .= " GROUP BY spotter_output.arrival_airport_country, countries.iso3
8717 9055
 					ORDER BY airport_arrival_country_count DESC";
8718
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9056
+		if ($limit) {
9057
+			$query .= " LIMIT 10 OFFSET 0";
9058
+		}
8719 9059
       
8720 9060
 		
8721 9061
 		$sth = $this->db->prepare($query);
@@ -9003,7 +9343,9 @@  discard block
 block discarded – undo
9003 9343
 			date_default_timezone_set($globalTimezone);
9004 9344
 			$datetime = new DateTime($date);
9005 9345
 			$offset = $datetime->format('P');
9006
-		} else $offset = '+00:00';
9346
+		} else {
9347
+			$offset = '+00:00';
9348
+		}
9007 9349
 		
9008 9350
 		if ($globalDBdriver == 'mysql') {
9009 9351
 			$query  = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ',  spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country
@@ -9259,12 +9601,18 @@  discard block
 block discarded – undo
9259 9601
 		$query  = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao  
9260 9602
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''";
9261 9603
 		 if ($olderthanmonths > 0) {
9262
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9263
-			else $query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9604
+			if ($globalDBdriver == 'mysql') {
9605
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
9606
+			} else {
9607
+				$query .= " AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
9608
+			}
9264 9609
 		}
9265 9610
 		if ($sincedate != '') {
9266
-			if ($globalDBdriver == 'mysql') $query .= " AND spotter_output.date > '".$sincedate."'";
9267
-			else $query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9611
+			if ($globalDBdriver == 'mysql') {
9612
+				$query .= " AND spotter_output.date > '".$sincedate."'";
9613
+			} else {
9614
+				$query .= " AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
9615
+			}
9268 9616
 		}
9269 9617
 		$query_values = array();
9270 9618
 		if ($year != '') {
@@ -9295,7 +9643,9 @@  discard block
 block discarded – undo
9295 9643
 			}
9296 9644
 		}
9297 9645
 		$query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9298
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9646
+		if ($limit) {
9647
+			$query .= " LIMIT 10 OFFSET 0";
9648
+		}
9299 9649
       		
9300 9650
 		$sth = $this->db->prepare($query);
9301 9651
 		$sth->execute($query_values);
@@ -9329,15 +9679,23 @@  discard block
 block discarded – undo
9329 9679
 		$query  = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name  
9330 9680
                     FROM spotter_output".$filter_query." spotter_output.ident <> ''  AND spotter_output.airline_icao <> '' ";
9331 9681
 		 if ($olderthanmonths > 0) {
9332
-			if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9333
-			else $query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9682
+			if ($globalDBdriver == 'mysql') {
9683
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
9684
+			} else {
9685
+				$query .= "AND spotter_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS' ";
9686
+			}
9334 9687
 		}
9335 9688
 		if ($sincedate != '') {
9336
-			if ($globalDBdriver == 'mysql') $query .= "AND spotter_output.date > '".$sincedate."' ";
9337
-			else $query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9689
+			if ($globalDBdriver == 'mysql') {
9690
+				$query .= "AND spotter_output.date > '".$sincedate."' ";
9691
+			} else {
9692
+				$query .= "AND spotter_output.date > CAST('".$sincedate."' AS TIMESTAMP) ";
9693
+			}
9338 9694
 		}
9339 9695
 		$query .= "GROUP BY spotter_output.airline_icao, spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC";
9340
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
9696
+		if ($limit) {
9697
+			$query .= " LIMIT 10 OFFSET 0";
9698
+		}
9341 9699
       		
9342 9700
 		$sth = $this->db->prepare($query);
9343 9701
 		$sth->execute();
@@ -9374,7 +9732,9 @@  discard block
 block discarded – undo
9374 9732
 			date_default_timezone_set($globalTimezone);
9375 9733
 			$datetime = new DateTime();
9376 9734
 			$offset = $datetime->format('P');
9377
-		} else $offset = '+00:00';
9735
+		} else {
9736
+			$offset = '+00:00';
9737
+		}
9378 9738
 
9379 9739
 		if ($globalDBdriver == 'mysql') {
9380 9740
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9423,7 +9783,9 @@  discard block
 block discarded – undo
9423 9783
 			date_default_timezone_set($globalTimezone);
9424 9784
 			$datetime = new DateTime();
9425 9785
 			$offset = $datetime->format('P');
9426
-		} else $offset = '+00:00';
9786
+		} else {
9787
+			$offset = '+00:00';
9788
+		}
9427 9789
 		$filter_query = $this->getFilter($filters,true,true);
9428 9790
 		if ($globalDBdriver == 'mysql') {
9429 9791
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9472,7 +9834,9 @@  discard block
 block discarded – undo
9472 9834
 			date_default_timezone_set($globalTimezone);
9473 9835
 			$datetime = new DateTime();
9474 9836
 			$offset = $datetime->format('P');
9475
-		} else $offset = '+00:00';
9837
+		} else {
9838
+			$offset = '+00:00';
9839
+		}
9476 9840
 		$filter_query = $this->getFilter($filters,true,true);
9477 9841
 		if ($globalDBdriver == 'mysql') {
9478 9842
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9518,7 +9882,9 @@  discard block
 block discarded – undo
9518 9882
 			date_default_timezone_set($globalTimezone);
9519 9883
 			$datetime = new DateTime();
9520 9884
 			$offset = $datetime->format('P');
9521
-		} else $offset = '+00:00';
9885
+		} else {
9886
+			$offset = '+00:00';
9887
+		}
9522 9888
 		$filter_query = $this->getFilter($filters,true,true);
9523 9889
 		if ($globalDBdriver == 'mysql') {
9524 9890
 			$query  = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9566,7 +9932,9 @@  discard block
 block discarded – undo
9566 9932
 			date_default_timezone_set($globalTimezone);
9567 9933
 			$datetime = new DateTime();
9568 9934
 			$offset = $datetime->format('P');
9569
-		} else $offset = '+00:00';
9935
+		} else {
9936
+			$offset = '+00:00';
9937
+		}
9570 9938
 		
9571 9939
 		if ($globalDBdriver == 'mysql') {
9572 9940
 			$query  = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -9614,7 +9982,9 @@  discard block
 block discarded – undo
9614 9982
 			date_default_timezone_set($globalTimezone);
9615 9983
 			$datetime = new DateTime();
9616 9984
 			$offset = $datetime->format('P');
9617
-		} else $offset = '+00:00';
9985
+		} else {
9986
+			$offset = '+00:00';
9987
+		}
9618 9988
 
9619 9989
 		if ($globalDBdriver == 'mysql') {
9620 9990
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9661,7 +10031,9 @@  discard block
 block discarded – undo
9661 10031
 			date_default_timezone_set($globalTimezone);
9662 10032
 			$datetime = new DateTime();
9663 10033
 			$offset = $datetime->format('P');
9664
-		} else $offset = '+00:00';
10034
+		} else {
10035
+			$offset = '+00:00';
10036
+		}
9665 10037
 
9666 10038
 		if ($globalDBdriver == 'mysql') {
9667 10039
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9709,7 +10081,9 @@  discard block
 block discarded – undo
9709 10081
 			date_default_timezone_set($globalTimezone);
9710 10082
 			$datetime = new DateTime();
9711 10083
 			$offset = $datetime->format('P');
9712
-		} else $offset = '+00:00';
10084
+		} else {
10085
+			$offset = '+00:00';
10086
+		}
9713 10087
 		$filter_query = $this->getFilter($filters,true,true);
9714 10088
 		if ($globalDBdriver == 'mysql') {
9715 10089
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -9754,7 +10128,9 @@  discard block
 block discarded – undo
9754 10128
 			date_default_timezone_set($globalTimezone);
9755 10129
 			$datetime = new DateTime();
9756 10130
 			$offset = $datetime->format('P');
9757
-		} else $offset = '+00:00';
10131
+		} else {
10132
+			$offset = '+00:00';
10133
+		}
9758 10134
 		$filter_query = $this->getFilter($filters,true,true);
9759 10135
 
9760 10136
 		if ($globalDBdriver == 'mysql') {
@@ -9801,7 +10177,9 @@  discard block
 block discarded – undo
9801 10177
 			date_default_timezone_set($globalTimezone);
9802 10178
 			$datetime = new DateTime();
9803 10179
 			$offset = $datetime->format('P');
9804
-		} else $offset = '+00:00';
10180
+		} else {
10181
+			$offset = '+00:00';
10182
+		}
9805 10183
 
9806 10184
 		if ($globalDBdriver == 'mysql') {
9807 10185
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count
@@ -9847,7 +10225,9 @@  discard block
 block discarded – undo
9847 10225
 			date_default_timezone_set($globalTimezone);
9848 10226
 			$datetime = new DateTime();
9849 10227
 			$offset = $datetime->format('P');
9850
-		} else $offset = '+00:00';
10228
+		} else {
10229
+			$offset = '+00:00';
10230
+		}
9851 10231
 		$filter_query = $this->getFilter($filters,true,true);
9852 10232
 
9853 10233
 		if ($globalDBdriver == 'mysql') {
@@ -9894,7 +10274,9 @@  discard block
 block discarded – undo
9894 10274
 			date_default_timezone_set($globalTimezone);
9895 10275
 			$datetime = new DateTime();
9896 10276
 			$offset = $datetime->format('P');
9897
-		} else $offset = '+00:00';
10277
+		} else {
10278
+			$offset = '+00:00';
10279
+		}
9898 10280
 
9899 10281
 		if ($globalDBdriver == 'mysql') {
9900 10282
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count
@@ -9941,7 +10323,9 @@  discard block
 block discarded – undo
9941 10323
 			date_default_timezone_set($globalTimezone);
9942 10324
 			$datetime = new DateTime();
9943 10325
 			$offset = $datetime->format('P');
9944
-		} else $offset = '+00:00';
10326
+		} else {
10327
+			$offset = '+00:00';
10328
+		}
9945 10329
 
9946 10330
 		if ($globalDBdriver == 'mysql') {
9947 10331
 			$query  = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count
@@ -9986,7 +10370,9 @@  discard block
 block discarded – undo
9986 10370
 			date_default_timezone_set($globalTimezone);
9987 10371
 			$datetime = new DateTime();
9988 10372
 			$offset = $datetime->format('P');
9989
-		} else $offset = '+00:00';
10373
+		} else {
10374
+			$offset = '+00:00';
10375
+		}
9990 10376
 		$filter_query = $this->getFilter($filters,true,true);
9991 10377
 
9992 10378
 		if ($globalDBdriver == 'mysql') {
@@ -10034,7 +10420,9 @@  discard block
 block discarded – undo
10034 10420
 			date_default_timezone_set($globalTimezone);
10035 10421
 			$datetime = new DateTime();
10036 10422
 			$offset = $datetime->format('P');
10037
-		} else $offset = '+00:00';
10423
+		} else {
10424
+			$offset = '+00:00';
10425
+		}
10038 10426
 
10039 10427
 		if ($globalDBdriver == 'mysql') {
10040 10428
 			$query  = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count
@@ -10080,7 +10468,9 @@  discard block
 block discarded – undo
10080 10468
 			date_default_timezone_set($globalTimezone);
10081 10469
 			$datetime = new DateTime();
10082 10470
 			$offset = $datetime->format('P');
10083
-		} else $offset = '+00:00';
10471
+		} else {
10472
+			$offset = '+00:00';
10473
+		}
10084 10474
 		$filter_query = $this->getFilter($filters,true,true);
10085 10475
 
10086 10476
 		if ($globalDBdriver == 'mysql') {
@@ -10128,7 +10518,9 @@  discard block
 block discarded – undo
10128 10518
 			date_default_timezone_set($globalTimezone);
10129 10519
 			$datetime = new DateTime();
10130 10520
 			$offset = $datetime->format('P');
10131
-		} else $offset = '+00:00';
10521
+		} else {
10522
+			$offset = '+00:00';
10523
+		}
10132 10524
 
10133 10525
 		if ($globalDBdriver == 'mysql') {
10134 10526
 			$query  = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count
@@ -10175,7 +10567,9 @@  discard block
 block discarded – undo
10175 10567
 			date_default_timezone_set($globalTimezone);
10176 10568
 			$datetime = new DateTime();
10177 10569
 			$offset = $datetime->format('P');
10178
-		} else $offset = '+00:00';
10570
+		} else {
10571
+			$offset = '+00:00';
10572
+		}
10179 10573
 		$filter_query = $this->getFilter($filters,true,true);
10180 10574
 		if ($globalDBdriver == 'mysql') {
10181 10575
 			$query  = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -10224,7 +10618,9 @@  discard block
 block discarded – undo
10224 10618
 			date_default_timezone_set($globalTimezone);
10225 10619
 			$datetime = new DateTime();
10226 10620
 			$offset = $datetime->format('P');
10227
-		} else $offset = '+00:00';
10621
+		} else {
10622
+			$offset = '+00:00';
10623
+		}
10228 10624
 
10229 10625
 		$orderby_sql = '';
10230 10626
 		if ($orderby == "hour")
@@ -10290,7 +10686,9 @@  discard block
 block discarded – undo
10290 10686
 			date_default_timezone_set($globalTimezone);
10291 10687
 			$datetime = new DateTime();
10292 10688
 			$offset = $datetime->format('P');
10293
-		} else $offset = '+00:00';
10689
+		} else {
10690
+			$offset = '+00:00';
10691
+		}
10294 10692
 
10295 10693
 		$orderby_sql = '';
10296 10694
 		if ($orderby == "hour")
@@ -10357,7 +10755,9 @@  discard block
 block discarded – undo
10357 10755
 			date_default_timezone_set($globalTimezone);
10358 10756
 			$datetime = new DateTime();
10359 10757
 			$offset = $datetime->format('P');
10360
-		} else $offset = '+00:00';
10758
+		} else {
10759
+			$offset = '+00:00';
10760
+		}
10361 10761
 
10362 10762
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
10363 10763
 
@@ -10408,7 +10808,9 @@  discard block
 block discarded – undo
10408 10808
 			date_default_timezone_set($globalTimezone);
10409 10809
 			$datetime = new DateTime();
10410 10810
 			$offset = $datetime->format('P');
10411
-		} else $offset = '+00:00';
10811
+		} else {
10812
+			$offset = '+00:00';
10813
+		}
10412 10814
 
10413 10815
 		if ($globalDBdriver == 'mysql') {
10414 10816
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10455,7 +10857,9 @@  discard block
 block discarded – undo
10455 10857
 			date_default_timezone_set($globalTimezone);
10456 10858
 			$datetime = new DateTime();
10457 10859
 			$offset = $datetime->format('P');
10458
-		} else $offset = '+00:00';
10860
+		} else {
10861
+			$offset = '+00:00';
10862
+		}
10459 10863
 
10460 10864
 		if ($globalDBdriver == 'mysql') {
10461 10865
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10502,7 +10906,9 @@  discard block
 block discarded – undo
10502 10906
 			date_default_timezone_set($globalTimezone);
10503 10907
 			$datetime = new DateTime();
10504 10908
 			$offset = $datetime->format('P');
10505
-		} else $offset = '+00:00';
10909
+		} else {
10910
+			$offset = '+00:00';
10911
+		}
10506 10912
 
10507 10913
 		if ($globalDBdriver == 'mysql') {
10508 10914
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10550,7 +10956,9 @@  discard block
 block discarded – undo
10550 10956
 			date_default_timezone_set($globalTimezone);
10551 10957
 			$datetime = new DateTime();
10552 10958
 			$offset = $datetime->format('P');
10553
-		} else $offset = '+00:00';
10959
+		} else {
10960
+			$offset = '+00:00';
10961
+		}
10554 10962
 
10555 10963
 		if ($globalDBdriver == 'mysql') {
10556 10964
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10598,7 +11006,9 @@  discard block
 block discarded – undo
10598 11006
 			date_default_timezone_set($globalTimezone);
10599 11007
 			$datetime = new DateTime($date);
10600 11008
 			$offset = $datetime->format('P');
10601
-		} else $offset = '+00:00';
11009
+		} else {
11010
+			$offset = '+00:00';
11011
+		}
10602 11012
 
10603 11013
 		if ($globalDBdriver == 'mysql') {
10604 11014
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10646,7 +11056,9 @@  discard block
 block discarded – undo
10646 11056
 			date_default_timezone_set($globalTimezone);
10647 11057
 			$datetime = new DateTime();
10648 11058
 			$offset = $datetime->format('P');
10649
-		} else $offset = '+00:00';
11059
+		} else {
11060
+			$offset = '+00:00';
11061
+		}
10650 11062
 
10651 11063
 		if ($globalDBdriver == 'mysql') {
10652 11064
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10693,7 +11105,9 @@  discard block
 block discarded – undo
10693 11105
 			date_default_timezone_set($globalTimezone);
10694 11106
 			$datetime = new DateTime();
10695 11107
 			$offset = $datetime->format('P');
10696
-		} else $offset = '+00:00';
11108
+		} else {
11109
+			$offset = '+00:00';
11110
+		}
10697 11111
 
10698 11112
 		if ($globalDBdriver == 'mysql') {
10699 11113
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10740,7 +11154,9 @@  discard block
 block discarded – undo
10740 11154
 			date_default_timezone_set($globalTimezone);
10741 11155
 			$datetime = new DateTime();
10742 11156
 			$offset = $datetime->format('P');
10743
-		} else $offset = '+00:00';
11157
+		} else {
11158
+			$offset = '+00:00';
11159
+		}
10744 11160
 
10745 11161
 		if ($globalDBdriver == 'mysql') {
10746 11162
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10790,7 +11206,9 @@  discard block
 block discarded – undo
10790 11206
 			date_default_timezone_set($globalTimezone);
10791 11207
 			$datetime = new DateTime();
10792 11208
 			$offset = $datetime->format('P');
10793
-		} else $offset = '+00:00';
11209
+		} else {
11210
+			$offset = '+00:00';
11211
+		}
10794 11212
 
10795 11213
 		if ($globalDBdriver == 'mysql') {
10796 11214
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -10837,7 +11255,9 @@  discard block
 block discarded – undo
10837 11255
 			date_default_timezone_set($globalTimezone);
10838 11256
 			$datetime = new DateTime();
10839 11257
 			$offset = $datetime->format('P');
10840
-		} else $offset = '+00:00';
11258
+		} else {
11259
+			$offset = '+00:00';
11260
+		}
10841 11261
 
10842 11262
 		if ($globalDBdriver == 'mysql') {
10843 11263
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11048,8 +11468,11 @@  discard block
 block discarded – undo
11048 11468
 				$query_values = array_merge($query_values,array(':month' => $month));
11049 11469
 			}
11050 11470
 		}
11051
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
11052
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11471
+		if (empty($query_values)) {
11472
+			$queryi .= $this->getFilter($filters);
11473
+		} else {
11474
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11475
+		}
11053 11476
 		
11054 11477
 		$sth = $this->db->prepare($queryi);
11055 11478
 		$sth->execute($query_values);
@@ -11127,8 +11550,11 @@  discard block
 block discarded – undo
11127 11550
 				$query_values = array_merge($query_values,array(':month' => $month));
11128 11551
 			}
11129 11552
 		}
11130
-                if ($query == '') $queryi .= $this->getFilter($filters);
11131
-                else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
11553
+                if ($query == '') {
11554
+                	$queryi .= $this->getFilter($filters);
11555
+                } else {
11556
+                	$queryi .= $this->getFilter($filters,true,true).substr($query,4);
11557
+                }
11132 11558
 
11133 11559
 
11134 11560
 		$sth = $this->db->prepare($queryi);
@@ -11151,7 +11577,9 @@  discard block
 block discarded – undo
11151 11577
 			date_default_timezone_set($globalTimezone);
11152 11578
 			$datetime = new DateTime();
11153 11579
 			$offset = $datetime->format('P');
11154
-		} else $offset = '+00:00';
11580
+		} else {
11581
+			$offset = '+00:00';
11582
+		}
11155 11583
 
11156 11584
 		if ($globalDBdriver == 'mysql') {
11157 11585
 			$query  = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -11337,7 +11765,9 @@  discard block
 block discarded – undo
11337 11765
 	*/
11338 11766
 	public function parseDirection($direction = 0)
11339 11767
 	{
11340
-		if ($direction == '') $direction = 0;
11768
+		if ($direction == '') {
11769
+			$direction = 0;
11770
+		}
11341 11771
 		$direction_array = array();
11342 11772
 		$temp_array = array();
11343 11773
 
@@ -11438,7 +11868,9 @@  discard block
 block discarded – undo
11438 11868
 		if (isset($result->AirlineFlightInfoResult))
11439 11869
 		{
11440 11870
 			$registration = $result->AirlineFlightInfoResult->tailnumber;
11441
-		} else return '';
11871
+		} else {
11872
+			return '';
11873
+		}
11442 11874
 		
11443 11875
 		$registration = $this->convertAircraftRegistration($registration);
11444 11876
 		
@@ -11472,7 +11904,9 @@  discard block
 block discarded – undo
11472 11904
 		    return $row['registration'];
11473 11905
 		} elseif ($source_type == 'flarm') {
11474 11906
 			return $this->getAircraftRegistrationBymodeS($aircraft_modes);
11475
-		} else return '';
11907
+		} else {
11908
+			return '';
11909
+		}
11476 11910
 	
11477 11911
 	}
11478 11912
 
@@ -11499,11 +11933,16 @@  discard block
 block discarded – undo
11499 11933
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
11500 11934
 		$sth->closeCursor();
11501 11935
 		if (count($row) > 0) {
11502
-			if ($row['type_flight'] == null) return '';
11503
-			else return $row['type_flight'];
11936
+			if ($row['type_flight'] == null) {
11937
+				return '';
11938
+			} else {
11939
+				return $row['type_flight'];
11940
+			}
11504 11941
 		} elseif ($source_type == 'flarm') {
11505 11942
 			return $this->getAircraftTypeBymodeS($aircraft_modes);
11506
-		} else return '';
11943
+		} else {
11944
+			return '';
11945
+		}
11507 11946
 	
11508 11947
 	}
11509 11948
 
@@ -11521,7 +11960,9 @@  discard block
 block discarded – undo
11521 11960
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
11522 11961
 	
11523 11962
 		$Connection = new Connection($this->db);
11524
-		if (!$Connection->tableExists('countries')) return '';
11963
+		if (!$Connection->tableExists('countries')) {
11964
+			return '';
11965
+		}
11525 11966
 	
11526 11967
 		try {
11527 11968
 			/*
@@ -11541,9 +11982,13 @@  discard block
 block discarded – undo
11541 11982
 			$sth->closeCursor();
11542 11983
 			if (count($row) > 0) {
11543 11984
 				return $row;
11544
-			} else return '';
11985
+			} else {
11986
+				return '';
11987
+			}
11545 11988
 		} catch (PDOException $e) {
11546
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
11989
+			if (isset($globalDebug) && $globalDebug) {
11990
+				echo 'Error : '.$e->getMessage()."\n";
11991
+			}
11547 11992
 			return '';
11548 11993
 		}
11549 11994
 	
@@ -11561,7 +12006,9 @@  discard block
 block discarded – undo
11561 12006
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
11562 12007
 	
11563 12008
 		$Connection = new Connection($this->db);
11564
-		if (!$Connection->tableExists('countries')) return '';
12009
+		if (!$Connection->tableExists('countries')) {
12010
+			return '';
12011
+		}
11565 12012
 	
11566 12013
 		try {
11567 12014
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -11573,9 +12020,13 @@  discard block
 block discarded – undo
11573 12020
 			$sth->closeCursor();
11574 12021
 			if (count($row) > 0) {
11575 12022
 				return $row;
11576
-			} else return '';
12023
+			} else {
12024
+				return '';
12025
+			}
11577 12026
 		} catch (PDOException $e) {
11578
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
12027
+			if (isset($globalDebug) && $globalDebug) {
12028
+				echo 'Error : '.$e->getMessage()."\n";
12029
+			}
11579 12030
 			return '';
11580 12031
 		}
11581 12032
 	
@@ -11825,7 +12276,9 @@  discard block
 block discarded – undo
11825 12276
 	{
11826 12277
 		global $globalBitlyAccessToken;
11827 12278
 		
11828
-		if ($globalBitlyAccessToken == '') return $url;
12279
+		if ($globalBitlyAccessToken == '') {
12280
+			return $url;
12281
+		}
11829 12282
         
11830 12283
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
11831 12284
 		
@@ -11974,7 +12427,9 @@  discard block
 block discarded – undo
11974 12427
 		
11975 12428
 
11976 12429
 		// routes
11977
-		if ($globalDebug) print "Routes...\n";
12430
+		if ($globalDebug) {
12431
+			print "Routes...\n";
12432
+		}
11978 12433
 		if ($globalDBdriver == 'mysql') {
11979 12434
 			$query = "SELECT spotter_output.spotter_id, routes.FromAirport_ICAO, routes.ToAirport_ICAO FROM spotter_output, routes WHERE spotter_output.ident = routes.CallSign AND ( spotter_output.departure_airport_icao != routes.FromAirport_ICAO OR spotter_output.arrival_airport_icao != routes.ToAirport_ICAO) AND routes.FromAirport_ICAO != '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
11980 12435
 		} else {
@@ -11993,7 +12448,9 @@  discard block
 block discarded – undo
11993 12448
 			}
11994 12449
 		}
11995 12450
 		
11996
-		if ($globalDebug) print "Airlines...\n";
12451
+		if ($globalDebug) {
12452
+			print "Airlines...\n";
12453
+		}
11997 12454
 		//airlines
11998 12455
 		if ($globalDBdriver == 'mysql') {
11999 12456
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.ident FROM spotter_output WHERE (spotter_output.airline_name = '' OR spotter_output.airline_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 DAY)";
@@ -12007,10 +12464,15 @@  discard block
 block discarded – undo
12007 12464
 			if (is_numeric(substr($row['ident'], -1, 1)))
12008 12465
 			{
12009 12466
 				$fromsource = NULL;
12010
-				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
12011
-				elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao';
12012
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
12013
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
12467
+				if (isset($row['format_source']) && $row['format_source'] == 'vatsimtxt') {
12468
+					$fromsource = 'vatsim';
12469
+				} elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') {
12470
+					$fromsource = 'ivao';
12471
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
12472
+					$fromsource = 'vatsim';
12473
+				} elseif (isset($globalIVAO) && $globalIVAO) {
12474
+					$fromsource = 'ivao';
12475
+				}
12014 12476
 				$airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource);
12015 12477
 				if (isset($airline_array[0]['name'])) {
12016 12478
 					$update_query  = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id";
@@ -12020,13 +12482,17 @@  discard block
 block discarded – undo
12020 12482
 			}
12021 12483
 		}
12022 12484
 
12023
-		if ($globalDebug) print "Remove Duplicate in aircraft_modes...\n";
12485
+		if ($globalDebug) {
12486
+			print "Remove Duplicate in aircraft_modes...\n";
12487
+		}
12024 12488
 		//duplicate modes
12025 12489
 		$query = "DELETE aircraft_modes FROM aircraft_modes LEFT OUTER JOIN (SELECT max(`AircraftID`) as `AircraftID`,`ModeS` FROM `aircraft_modes` group by ModeS) as KeepRows ON aircraft_modes.AircraftID = KeepRows.AircraftID WHERE KeepRows.AircraftID IS NULL";
12026 12490
 		$sth = $this->db->prepare($query);
12027 12491
 		$sth->execute();
12028 12492
 		
12029
-		if ($globalDebug) print "Aircraft...\n";
12493
+		if ($globalDebug) {
12494
+			print "Aircraft...\n";
12495
+		}
12030 12496
 		//aircraft
12031 12497
 		if ($globalDBdriver == 'mysql') {
12032 12498
 			$query  = "SELECT spotter_output.spotter_id, spotter_output.aircraft_icao, spotter_output.registration FROM spotter_output WHERE (spotter_output.aircraft_name = '' OR spotter_output.aircraft_name = 'Not Available') AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -12069,26 +12535,38 @@  discard block
 block discarded – undo
12069 12535
 				 if (isset($closestAirports[0])) {
12070 12536
 					if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) {
12071 12537
 						$airport_icao = $closestAirports[0]['icao'];
12072
-						if ($globalDebug) echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12538
+						if ($globalDebug) {
12539
+							echo "\o/ 1st ---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12540
+						}
12073 12541
 					} elseif (count($closestAirports > 1) && $row['arrival_airport_icao'] != '' && $row['arrival_airport_icao'] != 'NA') {
12074 12542
 						foreach ($closestAirports as $airport) {
12075 12543
 							if ($row['arrival_airport_icao'] == $airport['icao']) {
12076 12544
 								$airport_icao = $airport['icao'];
12077
-								if ($globalDebug) echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12545
+								if ($globalDebug) {
12546
+									echo "\o/ try --++ Find arrival airport. airport_icao : ".$airport_icao."\n";
12547
+								}
12078 12548
 								break;
12079 12549
 							}
12080 12550
 						}
12081 12551
 					} elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) {
12082 12552
 						$airport_icao = $closestAirports[0]['icao'];
12083
-						if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12553
+						if ($globalDebug) {
12554
+							echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." !  Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12555
+						}
12084 12556
 					} else {
12085
-						if ($globalDebug) echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12557
+						if ($globalDebug) {
12558
+							echo "----- Can't find arrival airport. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n";
12559
+						}
12086 12560
 					}
12087 12561
 				} else {
12088
-					if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12562
+					if ($globalDebug) {
12563
+						echo "----- No Airport near last coord. Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist."\n";
12564
+					}
12089 12565
 				}
12090 12566
 				if ($row['real_arrival_airport_icao'] != $airport_icao) {
12091
-					if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n";
12567
+					if ($globalDebug) {
12568
+						echo "Updating airport to ".$airport_icao."...\n";
12569
+					}
12092 12570
 					$update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id";
12093 12571
 					$sthu = $this->db->prepare($update_query);
12094 12572
 					$sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id']));
Please login to merge, or discard this patch.
require/class.SpotterImport.php 3 patches
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, $globalNoDB;
26 26
 	if (!(isset($globalNoDB) && $globalNoDB)) {
27 27
 		$Connection = new Connection($dbc);
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
37
-		    	$type = $srcst['stats_type'];
36
+			foreach($sourcestat as $srcst) {
37
+				$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39
-			    $source = $srcst['source_name'];
40
-			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
-	    		}
43
-		    }
39
+				$source = $srcst['source_name'];
40
+				$data = $srcst['source_data'];
41
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
42
+				}
43
+			}
44 44
 		}
45 45
 	}
46 46
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 		//$APRSSpotter->connect();
49 49
 	}
50 50
 
51
-    }
51
+	}
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+	public function get_Schedule($id,$ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -70,42 +70,42 @@  discard block
 block discarded – undo
70 70
 	$operator = $Spotter->getOperator($ident);
71 71
 	$scheduleexist = false;
72 72
 	if ($Schedule->checkSchedule($operator) == 0) {
73
-	    $operator = $Translation->checkTranslation($ident);
74
-	    if ($Schedule->checkSchedule($operator) == 0) {
73
+		$operator = $Translation->checkTranslation($ident);
74
+		if ($Schedule->checkSchedule($operator) == 0) {
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
-		    // Should also check if route schedule = route from DB
81
-		    if ($schedule['DepartureAirportIATA'] != '') {
77
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80
+			// Should also check if route schedule = route from DB
81
+			if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
83
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
-			    if (trim($airport_icao) != '') {
83
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84
+				if (trim($airport_icao) != '') {
85 85
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86 86
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
87
-			    }
87
+				}
88
+			}
88 89
 			}
89
-		    }
90
-		    if ($schedule['ArrivalAirportIATA'] != '') {
90
+			if ($schedule['ArrivalAirportIATA'] != '') {
91 91
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
92
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
-			    if (trim($airport_icao) != '') {
92
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93
+				if (trim($airport_icao) != '') {
94 94
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95 95
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
96
-			    }
96
+				}
97 97
 			}
98
-		    }
99
-		    $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
+			}
99
+			$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']);
100 100
 		}
101
-	    } else $scheduleexist = true;
101
+		} else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
103 103
 	// close connection, at least one way will work ?
104
-       if ($scheduleexist) {
104
+	   if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106
-    		$sch = $Schedule->getSchedule($operator);
106
+			$sch = $Schedule->getSchedule($operator);
107 107
 		$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']));
108
-       }
108
+	   }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
111 111
 	$Translation->db = null;
@@ -120,96 +120,96 @@  discard block
 block discarded – undo
120 120
 	}
121 121
 	  */
122 122
 	}
123
-    }
123
+	}
124 124
 
125
-    public function checkAll() {
125
+	public function checkAll() {
126 126
 	global $globalDebug, $globalNoImport;
127 127
 	if ($globalDebug) echo "Update last seen flights data...\n";
128 128
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129
-	    foreach ($this->all_flights as $key => $flight) {
129
+		foreach ($this->all_flights as $key => $flight) {
130 130
 		if (isset($this->all_flights[$key]['id'])) {
131
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
-    		    $Spotter = new Spotter($this->db);
133
-        	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
135
-        	}
136
-	    }
131
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132
+				$Spotter = new Spotter($this->db);
133
+				$real_arrival = $this->arrival($key);
134
+				if (isset($this->all_flights[$key]['altitude'])) $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']);
135
+			}
136
+		}
137
+	}
137 138
 	}
138
-    }
139 139
 
140
-    public function arrival($key) {
140
+	public function arrival($key) {
141 141
 	global $globalClosestMinDist, $globalDebug;
142 142
 	if ($globalDebug) echo 'Update arrival...'."\n";
143 143
 	$Spotter = new Spotter($this->db);
144
-        $airport_icao = '';
145
-        $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
144
+		$airport_icao = '';
145
+		$airport_time = '';
146
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
-    	    if (isset($closestAirports[0])) {
150
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
-        	    $airport_icao = $closestAirports[0]['icao'];
152
-        	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
-        	    foreach ($closestAirports as $airport) {
156
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
-        		    $airport_icao = $airport['icao'];
158
-        		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
-        		    break;
161
-        		}
162
-        	    }
163
-        	} 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))) {
164
-        		$airport_icao = $closestAirports[0]['icao'];
165
-        		$airport_time = $this->all_flights[$key]['datetime'];
166
-        	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
-        	}
169
-    	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
-    	    }
172
-
173
-        } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
-        }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
-    }
178
-
179
-
180
-
181
-    public function del() {
148
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149
+			if (isset($closestAirports[0])) {
150
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151
+				$airport_icao = $closestAirports[0]['icao'];
152
+				$airport_time = $this->all_flights[$key]['datetime'];
153
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
154
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155
+				foreach ($closestAirports as $airport) {
156
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157
+					$airport_icao = $airport['icao'];
158
+					$airport_time = $this->all_flights[$key]['datetime'];
159
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
160
+					break;
161
+				}
162
+				}
163
+			} 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))) {
164
+				$airport_icao = $closestAirports[0]['icao'];
165
+				$airport_time = $this->all_flights[$key]['datetime'];
166
+			} else {
167
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
168
+			}
169
+			} else {
170
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
171
+			}
172
+
173
+		} else {
174
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175
+		}
176
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177
+	}
178
+
179
+
180
+
181
+	public function del() {
182 182
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 183
 	// Delete old infos
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186
-    	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
188
-            	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
186
+			if (isset($flight['lastupdate'])) {
187
+			if ($flight['lastupdate'] < (time()-3000)) {
188
+					if (isset($this->all_flights[$key]['id'])) {
189
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
191 191
 			$SpotterLive = new SpotterLive();
192 192
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
193 193
 			$SpotterLive->db = null;
194 194
 			*/
195 195
 			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
196
-            		    $real_arrival = $this->arrival($key);
197
-            		    $Spotter = new Spotter($this->db);
198
-            	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
196
+						$real_arrival = $this->arrival($key);
197
+						$Spotter = new Spotter($this->db);
198
+							if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 199
 				$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']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201
-			    }
201
+				}
202 202
 			// Put in archive
203 203
 //				$Spotter->db = null;
204 204
 			}
205
-            	    }
206
-            	    unset($this->all_flights[$key]);
207
-    	        }
208
-	    }
209
-        }
210
-    }
205
+					}
206
+					unset($this->all_flights[$key]);
207
+				}
208
+		}
209
+		}
210
+	}
211 211
 
212
-    public function add($line) {
212
+	public function add($line) {
213 213
 	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;
214 214
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215 215
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 	
235 235
 	// SBS format is CSV format
236 236
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237
-	    //print_r($line);
238
-  	    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
+		//print_r($line);
238
+  		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)) {
239 239
 
240 240
 		// Increment message number
241 241
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242
-		    $current_date = date('Y-m-d');
243
-		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
242
+			$current_date = date('Y-m-d');
243
+			$source = $line['source_name'];
244
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
245
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
246
+				$this->stats[$current_date][$source]['msg']['date'] = time();
247
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
249 249
 		}
250 250
 		
251 251
 		/*
@@ -261,49 +261,49 @@  discard block
 block discarded – undo
261 261
 		//$this->db = $dbc;
262 262
 
263 263
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
264
+			if (!isset($line['id'])) $id = trim($line['hex']);
265
+			else $id = trim($line['id']);
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268
-		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $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' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
-		    if (!isset($line['id'])) {
268
+			$this->all_flights[$id] = array();
269
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
+			$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' => ''));
271
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
+			if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			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')));
275 275
 //			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')));
276 276
 			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')));
277
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
277
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
+			if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
287
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
288
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
-		    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
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
291
+			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') {
292 292
 			$timeelapsed = microtime(true);
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294
-			    $Spotter = new Spotter($this->db);
295
-			    if (isset($this->all_flights[$id]['source_type'])) {
294
+				$Spotter = new Spotter($this->db);
295
+				if (isset($this->all_flights[$id]['source_type'])) {
296 296
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
297
-			    } else {
297
+				} else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299
-			    }
300
-			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
299
+				}
300
+				$Spotter->db = null;
301
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304
-		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
304
+			}
305
+			if ($globalAllFlights !== FALSE) $dataFound = true;
306
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
307 307
 		}
308 308
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 309
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -329,9 +329,9 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
331 331
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
332
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
332
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333 333
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
334
-		    } else {
334
+			} else {
335 335
 				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";
336 336
 				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";
337 337
 				/*
@@ -340,43 +340,43 @@  discard block
 block discarded – undo
340 340
 				print_r($line);
341 341
 				*/
342 342
 				return '';
343
-		    }
343
+			}
344 344
 		} else {
345 345
 			date_default_timezone_set('UTC');
346 346
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
347 347
 		}
348 348
 
349 349
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
350
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
350
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
351 351
 		}
352 352
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
353
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
353
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
354 354
 		}
355 355
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
356
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
356
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
357 357
 		}
358 358
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
359
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
359
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
360 360
 		}
361 361
  
362 362
 		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'])) {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
364
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
364
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
365 365
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
366
-			    $timeelapsed = microtime(true);
367
-            		    $Spotter = new Spotter($this->db);
368
-            		    $fromsource = NULL;
369
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376
-			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
-			}
379
-		    }
366
+				$timeelapsed = microtime(true);
367
+						$Spotter = new Spotter($this->db);
368
+						$fromsource = NULL;
369
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
+				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
+				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
+				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
+				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376
+				$Spotter->db = null;
377
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
+			}
379
+			}
380 380
 
381 381
 /*
382 382
 		    if (!isset($line['id'])) {
@@ -386,104 +386,104 @@  discard block
 block discarded – undo
386 386
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 387
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 388
   */
389
-		    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']));
389
+			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']));
390 390
 
391
-		    //$putinarchive = true;
392
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
391
+			//$putinarchive = true;
392
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
393 393
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
394
-		    }
395
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
394
+			}
395
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
396 396
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
397
-		    }
398
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
-		    		$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' => ''));
400
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
397
+			}
398
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
+					$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' => ''));
400
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
401 401
 			$timeelapsed = microtime(true);
402 402
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$Spotter = new Spotter($this->db);
404 404
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 405
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406
-		    		$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' => ''));
406
+					$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' => ''));
407 407
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
408
-                        }
409
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
408
+						}
409
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 410
 			$timeelapsed = microtime(true);
411 411
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
412
-			    $Spotter = new Spotter($this->db);
413
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
414
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
412
+				$Spotter = new Spotter($this->db);
413
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
414
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
415 415
 				$Translation = new Translation($this->db);
416 416
 				$ident = $Translation->checkTranslation(trim($line['ident']));
417 417
 				$route = $Spotter->getRouteInfo($ident);
418 418
 				$Translation->db = null;
419
-			    }
420
-			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
-                    	}
419
+				}
420
+				$Spotter->db = null;
421
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
422
+						}
423 423
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
424
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
426 426
 				//    $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']));
427
-		    		$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']));
428
-		    	    }
427
+					$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']));
428
+					}
429 429
 			}
430 430
 			if (!isset($globalFork)) $globalFork = TRUE;
431 431
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432 432
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
433 433
 			}
434
-		    }
434
+			}
435 435
 		}
436 436
 
437 437
 		if (isset($line['speed']) && $line['speed'] != '') {
438 438
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
439
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
441
-		    //$dataFound = true;
439
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
441
+			//$dataFound = true;
442 442
 		} 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'])) {
443
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
444
-		    if ($distance > 1000 && $distance < 10000) {
445
-		    // use datetime
443
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
444
+			if ($distance > 1000 && $distance < 10000) {
445
+			// use datetime
446 446
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 447
 			$speed = $speed*3.6;
448 448
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
449 449
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
450
-		    }
450
+			}
451 451
 		}
452 452
 
453 453
 
454 454
 
455
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
-	    	    else unset($timediff);
458
-	    	    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')))) {
455
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
+				else unset($timediff);
458
+				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')))) {
459 459
 			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'])) {
460
-			    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'])) {
460
+				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'])) {
461 461
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
462 462
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463 463
 				$this->all_flights[$id]['putinarchive'] = true;
464 464
 				$this->tmd = 0;
465 465
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
466
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
467
-				    $timeelapsed = microtime(true);
468
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
467
+					$timeelapsed = microtime(true);
468
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 469
 					$Spotter = new Spotter($this->db);
470 470
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
471 471
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
472 472
 					$Spotter->db = null;
473 473
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
474 474
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
475
-				    }
475
+					}
476
+				}
476 477
 				}
477
-			    }
478 478
 			}
479 479
 
480 480
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481
-			    //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) {
481
+				//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) {
482 482
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
483 483
 				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') {
484
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485
-				    $dataFound = true;
486
-				    $this->all_flights[$id]['time_last_coord'] = time();
484
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485
+					$dataFound = true;
486
+					$this->all_flights[$id]['time_last_coord'] = time();
487 487
 				}
488 488
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
489 489
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -494,20 +494,20 @@  discard block
 block discarded – undo
494 494
 				    //$putinarchive = true;
495 495
 				}
496 496
 				*/
497
-			    /*
497
+				/*
498 498
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
499 499
 				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";
500 500
 			    }
501 501
 			    */
502 502
 			}
503 503
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
504
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505
-			    //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
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505
+				//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) {
506 506
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
507 507
 				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') {
508
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509
-				    $dataFound = true;
510
-				    $this->all_flights[$id]['time_last_coord'] = time();
508
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509
+					$dataFound = true;
510
+					$this->all_flights[$id]['time_last_coord'] = time();
511 511
 				}
512 512
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
513 513
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -525,95 +525,95 @@  discard block
 block discarded – undo
525 525
 			    */
526 526
 			}
527 527
 
528
-		    } else if ($globalDebug && $timediff > 30) {
528
+			} else if ($globalDebug && $timediff > 30) {
529 529
 			$this->tmd = $this->tmd + 1;
530 530
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
531 531
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
532 532
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
533 533
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
534
-		    }
534
+			}
535 535
 		}
536 536
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
537
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
539 539
 		}
540 540
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
541
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
542
-		    //$dataFound = true;
541
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
542
+			//$dataFound = true;
543 543
 		}
544 544
 		if (isset($line['format_source']) && $line['format_source'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
545
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
546 546
 		}
547 547
 		if (isset($line['source_name']) && $line['source_name'] != '') {
548
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
548
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
549 549
 		}
550 550
 		if (isset($line['emergency']) && $line['emergency'] != '') {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
552
-		    //$dataFound = true;
551
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
552
+			//$dataFound = true;
553 553
 		}
554 554
 		if (isset($line['ground']) && $line['ground'] != '') {
555
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
555
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
556 556
 			// Here we force archive of flight because after ground it's a new one (or should be)
557 557
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558 558
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559 559
 			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')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
560
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561 561
 			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']));
562
-		    }
563
-		    if ($line['ground'] != 1) $line['ground'] = 0;
564
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565
-		    //$dataFound = true;
562
+			}
563
+			if ($line['ground'] != 1) $line['ground'] = 0;
564
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565
+			//$dataFound = true;
566 566
 		}
567 567
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568
-		    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'])) {
569
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571
-			    $highlight = '';
572
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
575
-			    if ($highlight != '') {
568
+			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'])) {
569
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571
+				$highlight = '';
572
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
575
+				if ($highlight != '') {
576 576
 				$timeelapsed = microtime(true);
577 577
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578
-				    $Spotter = new Spotter($this->db);
579
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580
-				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
578
+					$Spotter = new Spotter($this->db);
579
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580
+					$Spotter->db = null;
581
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
582 582
 				}
583 583
 				//$putinarchive = true;
584 584
 				//$highlight = '';
585
-			    }
585
+				}
586 586
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
588
-		    //$dataFound = true;
587
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
588
+			//$dataFound = true;
589 589
 		}
590 590
 
591 591
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
592
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593 593
 			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;
594 594
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595 595
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
596 596
 			//$dataFound = true;
597
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
597
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
598 598
   		}
599 599
 
600 600
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
601
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
601
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
602 602
 		}
603 603
 		
604 604
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608
-		    //$dataFound = true;
605
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608
+			//$dataFound = true;
609 609
   		} 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']) {
610
-  		    $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']);
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
610
+  			$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']);
611
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
614 614
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615
-  		    // If not enough messages and ACARS set heading to 0
616
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
615
+  			// If not enough messages and ACARS set heading to 0
616
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
617 617
   		}
618 618
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619 619
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -624,125 +624,125 @@  discard block
 block discarded – undo
624 624
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
625 625
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
626 626
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
627
-		    $this->all_flights[$id]['lastupdate'] = time();
628
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
-		        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'])) {
630
-			    //print_r($this->all_flights);
631
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
627
+			$this->all_flights[$id]['lastupdate'] = time();
628
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
+				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'])) {
630
+				//print_r($this->all_flights);
631
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
634 634
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
635
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
636
-				    $timeelapsed = microtime(true);
637
-				    $SpotterLive = new SpotterLive($this->db);
638
-				    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')) {
635
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
636
+					$timeelapsed = microtime(true);
637
+					$SpotterLive = new SpotterLive($this->db);
638
+					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')) {
639 639
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640 640
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
641
-				    } elseif (isset($line['id'])) {
641
+					} elseif (isset($line['id'])) {
642 642
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643 643
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
644
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
644
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 645
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646 646
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
-				    } else $recent_ident = '';
648
-				    $SpotterLive->db=null;
649
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
647
+					} else $recent_ident = '';
648
+					$SpotterLive->db=null;
649
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651 651
 				} else $recent_ident = '';
652
-			    } else {
652
+				} else {
653 653
 				$recent_ident = '';
654 654
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
655
-			    }
656
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
-			    if($recent_ident == "")
658
-			    {
655
+				}
656
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
+				if($recent_ident == "")
658
+				{
659 659
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
660 660
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 661
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 662
 				//adds the spotter data for the archive
663 663
 				$ignoreImport = false;
664 664
 				foreach($globalAirportIgnore as $airportIgnore) {
665
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
665
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
666 666
 					$ignoreImport = true;
667
-				    }
667
+					}
668 668
 				}
669 669
 				if (count($globalAirportAccept) > 0) {
670
-				    $ignoreImport = true;
671
-				    foreach($globalAirportIgnore as $airportIgnore) {
670
+					$ignoreImport = true;
671
+					foreach($globalAirportIgnore as $airportIgnore) {
672 672
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
673
-					    $ignoreImport = false;
673
+						$ignoreImport = false;
674
+					}
674 675
 					}
675
-				    }
676 676
 				}
677 677
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
678
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
678
+					foreach($globalAirlineIgnore as $airlineIgnore) {
679 679
 					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)) {
680
-					    $ignoreImport = true;
680
+						$ignoreImport = true;
681
+					}
681 682
 					}
682
-				    }
683 683
 				}
684 684
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
685
-				    $ignoreImport = true;
686
-				    foreach($globalAirlineAccept as $airlineAccept) {
685
+					$ignoreImport = true;
686
+					foreach($globalAirlineAccept as $airlineAccept) {
687 687
 					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)) {
688
-					    $ignoreImport = false;
688
+						$ignoreImport = false;
689
+					}
689 690
 					}
690
-				    }
691 691
 				}
692 692
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
693
-				    $ignoreImport = true;
694
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
693
+					$ignoreImport = true;
694
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
695 695
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
696
-					    $ignoreImport = false;
696
+						$ignoreImport = false;
697
+					}
697 698
 					}
698
-				    }
699 699
 				}
700 700
 				
701 701
 				if (!$ignoreImport) {
702
-				    $highlight = '';
703
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
707
-				    $timeelapsed = microtime(true);
708
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
702
+					$highlight = '';
703
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
+					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')));
707
+					$timeelapsed = microtime(true);
708
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 709
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710
-					    $Spotter = new Spotter($this->db);
711
-					    $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']);
712
-					    $Spotter->db = null;
713
-					    if ($globalDebug && isset($result)) echo $result."\n";
710
+						$Spotter = new Spotter($this->db);
711
+						$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']);
712
+						$Spotter->db = null;
713
+						if ($globalDebug && isset($result)) echo $result."\n";
714
+					}
714 715
 					}
715
-				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
716
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 718
 
719
-				    // Add source stat in DB
720
-				    $Stats = new Stats($this->db);
721
-				    if (!empty($this->stats)) {
719
+					// Add source stat in DB
720
+					$Stats = new Stats($this->db);
721
+					if (!empty($this->stats)) {
722 722
 					if ($globalDebug) echo 'Add source stats : ';
723
-				        foreach($this->stats as $date => $data) {
724
-					    foreach($data as $source => $sourced) {
725
-					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
728
-				    		if (isset($sourced['msg'])) {
729
-				    		    if (time() - $sourced['msg']['date'] > 10) {
730
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
732
-			    			        unset($this->stats[$date][$source]['msg']);
733
-			    			    }
734
-			    			}
735
-			    		    }
736
-			    		    if ($date != date('Y-m-d')) {
737
-			    			unset($this->stats[$date]);
738
-			    		    }
739
-				    	}
740
-				    	if ($globalDebug) echo 'Done'."\n";
741
-
742
-				    }
743
-				    $Stats->db = null;
744
-				    }
745
-				    $this->del();
723
+						foreach($this->stats as $date => $data) {
724
+						foreach($data as $source => $sourced) {
725
+							//print_r($sourced);
726
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
728
+							if (isset($sourced['msg'])) {
729
+								if (time() - $sourced['msg']['date'] > 10) {
730
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
732
+									unset($this->stats[$date][$source]['msg']);
733
+								}
734
+							}
735
+							}
736
+							if ($date != date('Y-m-d')) {
737
+							unset($this->stats[$date]);
738
+							}
739
+						}
740
+						if ($globalDebug) echo 'Done'."\n";
741
+
742
+					}
743
+					$Stats->db = null;
744
+					}
745
+					$this->del();
746 746
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
747 747
 				//$ignoreImport = false;
748 748
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -760,41 +760,41 @@  discard block
 block discarded – undo
760 760
 			*/
761 761
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
762 762
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
763
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
764
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
765
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
763
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
764
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
765
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
766 766
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
767
-					    $SpotterLive = new SpotterLive($this->db);
768
-					    $SpotterLive->deleteLiveSpotterData();
769
-					    $SpotterLive->db=null;
767
+						$SpotterLive = new SpotterLive($this->db);
768
+						$SpotterLive->deleteLiveSpotterData();
769
+						$SpotterLive->db=null;
770
+					}
770 771
 					}
771
-				    }
772
-				    if ($globalDebug) echo " Done\n";
773
-				    $this->last_delete = time();
772
+					if ($globalDebug) echo " Done\n";
773
+					$this->last_delete = time();
774 774
 				}
775
-			    } else {
775
+				} else {
776 776
 				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')) {
777
-				    $this->all_flights[$id]['id'] = $recent_ident;
778
-				    $this->all_flights[$id]['addedSpotter'] = 1;
777
+					$this->all_flights[$id]['id'] = $recent_ident;
778
+					$this->all_flights[$id]['addedSpotter'] = 1;
779 779
 				}
780 780
 				if (isset($globalDaemon) && !$globalDaemon) {
781
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
781
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
782 782
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
783
-					    $Spotter = new Spotter($this->db);
784
-					    $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']);
785
-					    $Spotter->db = null;
783
+						$Spotter = new Spotter($this->db);
784
+						$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']);
785
+						$Spotter->db = null;
786
+					}
786 787
 					}
787
-				    }
788 788
 				}
789 789
 				
790
-			    }
790
+				}
791
+			}
791 792
 			}
792
-		    }
793
-		    //adds the spotter LIVE data
794
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
795
-		    //echo "\nAdd in Live !! \n";
796
-		    //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";
797
-		    if ($globalDebug) {
793
+			//adds the spotter LIVE data
794
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
795
+			//echo "\nAdd in Live !! \n";
796
+			//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";
797
+			if ($globalDebug) {
798 798
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
799 799
 				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";
800 800
 				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";
@@ -802,60 +802,60 @@  discard block
 block discarded – undo
802 802
 				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";
803 803
 				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";
804 804
 			}
805
-		    }
806
-		    $ignoreImport = false;
807
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
805
+			}
806
+			$ignoreImport = false;
807
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 
810
-		    foreach($globalAirportIgnore as $airportIgnore) {
811
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
-			    $ignoreImport = true;
810
+			foreach($globalAirportIgnore as $airportIgnore) {
811
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812
+				$ignoreImport = true;
813 813
 			}
814
-		    }
815
-		    if (count($globalAirportAccept) > 0) {
816
-		        $ignoreImport = true;
817
-		        foreach($globalAirportIgnore as $airportIgnore) {
818
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
814
+			}
815
+			if (count($globalAirportAccept) > 0) {
816
+				$ignoreImport = true;
817
+				foreach($globalAirportIgnore as $airportIgnore) {
818
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
819 819
 				$ignoreImport = false;
820
-			    }
820
+				}
821
+			}
821 822
 			}
822
-		    }
823
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
823
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
824 824
 			foreach($globalAirlineIgnore as $airlineIgnore) {
825
-			    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)) {
825
+				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)) {
826 826
 				$ignoreImport = true;
827
-			    }
827
+				}
828 828
 			}
829
-		    }
830
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
829
+			}
830
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
831 831
 			$ignoreImport = true;
832 832
 			foreach($globalAirlineAccept as $airlineAccept) {
833
-			    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)) {
833
+				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)) {
834 834
 				$ignoreImport = false;
835
-			    }
835
+				}
836
+			}
836 837
 			}
837
-		    }
838
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
838
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
839 839
 			$ignoreImport = true;
840 840
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
841
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842
-			        $ignoreImport = false;
843
-			    }
841
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842
+					$ignoreImport = false;
843
+				}
844
+			}
844 845
 			}
845
-		    }
846 846
 
847
-		    if (!$ignoreImport) {
847
+			if (!$ignoreImport) {
848 848
 			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'])) {
849 849
 				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')));
850 850
 				$timeelapsed = microtime(true);
851 851
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
852
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853 853
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
854 854
 					$SpotterLive = new SpotterLive($this->db);
855 855
 					$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']);
856 856
 					$SpotterLive->db = null;
857 857
 					if ($globalDebug) echo $result."\n";
858
-				    }
858
+					}
859 859
 				}
860 860
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861 861
 					$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']);
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 				//if ($line['format_source'] != 'aprs') {
868 868
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
869 869
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
870
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
871 871
 					$source = $this->all_flights[$id]['source_name'];
872 872
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
873 873
 					if (!isset($this->source_location[$source])) {
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 					if ($stats_heading == 16) $stats_heading = 0;
894 894
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895 895
 						for ($i=0;$i<=15;$i++) {
896
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
896
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
897 897
 						}
898 898
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
899 899
 					} else {
@@ -906,17 +906,17 @@  discard block
 block discarded – undo
906 906
 					//var_dump($this->stats);
907 907
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
908 908
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909
-						    end($this->stats[$current_date][$source]['hist']);
910
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
909
+							end($this->stats[$current_date][$source]['hist']);
910
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
911 911
 						} else $mini = 0;
912 912
 						for ($i=$mini;$i<=$distance;$i+=10) {
913
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
913
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
914 914
 						}
915 915
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
916 916
 					} else {
917 917
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
918 918
 					}
919
-				    }
919
+					}
920 920
 				}
921 921
 
922 922
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 			//$this->del();
927 927
 			
928 928
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
929
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
929
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
930 930
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
931 931
 				$SpotterLive = new SpotterLive($this->db);
932 932
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -934,19 +934,19 @@  discard block
 block discarded – undo
934 934
 				//SpotterLive->deleteLiveSpotterData();
935 935
 				if ($globalDebug) echo " Done\n";
936 936
 				$this->last_delete_hourly = time();
937
-			    } else {
937
+				} else {
938 938
 				$this->del();
939 939
 				$this->last_delete_hourly = time();
940
-			    }
940
+				}
941 941
 			}
942 942
 			
943
-		    }
944
-		    //$ignoreImport = false;
943
+			}
944
+			//$ignoreImport = false;
945 945
 		}
946 946
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
947 947
 		if ($send) return $this->all_flights[$id];
948
-	    }
948
+		}
949
+	}
949 950
 	}
950
-    }
951 951
 }
952 952
 ?>
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $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']);
99
+		    $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']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$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']));
107
+		$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']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} 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))) {
163
+        	} 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))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
     	    if (isset($flight['lastupdate'])) {
187
-        	if ($flight['lastupdate'] < (time()-3000)) {
187
+        	if ($flight['lastupdate'] < (time() - 3000)) {
188 188
             	    if (isset($this->all_flights[$key]['id'])) {
189 189
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
190 190
 			/*
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             		    $real_arrival = $this->arrival($key);
197 197
             		    $Spotter = new Spotter($this->db);
198 198
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199
-				$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']);
199
+				$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']);
200 200
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
201 201
 			    }
202 202
 			// Put in archive
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
   	    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)) {
239 239
 
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
 		
267 267
 		if (!isset($this->all_flights[$id])) {
268 268
 		    $this->all_flights[$id] = array();
269
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270
-		    $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' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
269
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
270
+		    $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' => ''));
271
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
272 272
 		    if (!isset($line['id'])) {
273 273
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274 274
 //			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')));
275 275
 //			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')));
276
-			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')));
276
+			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')));
277 277
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
278
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
279 279
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
280 280
 		}
281 281
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
282
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
283 283
 		}
284 284
 		
285 285
 		//print_r($this->all_flights);
286 286
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
287
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
287
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
288 288
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
289 289
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
290 290
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
294 294
 			    $Spotter = new Spotter($this->db);
295 295
 			    if (isset($this->all_flights[$id]['source_type'])) {
296
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
296
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
297 297
 			    } else {
298 298
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 299
 			    }
300 300
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
301
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
302
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
303 303
 			}
304 304
 		    }
305 305
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
306 306
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
307 307
 		}
308 308
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
309
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao']));
310 310
 		}
311 311
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
312 312
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 				$Spotter = new Spotter($this->db);
315 315
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
316 316
 				$Spotter->db = null;
317
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
317
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
318 318
 			}
319 319
 		}
320 320
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -322,15 +322,15 @@  discard block
 block discarded – undo
322 322
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
323 323
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
324 324
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
325
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
325
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
326 326
 		}
327 327
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
328
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
328
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
329 329
 		}
330 330
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
331
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
331
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) {
332 332
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
333
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
334 334
 		    } else {
335 335
 				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";
336 336
 				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";
@@ -343,24 +343,24 @@  discard block
 block discarded – undo
343 343
 		    }
344 344
 		} else {
345 345
 			date_default_timezone_set('UTC');
346
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
346
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
347 347
 		}
348 348
 
349 349
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
350
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
350
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
351 351
 		}
352 352
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
353
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
353
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
354 354
 		}
355 355
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
356
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
356
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id']));
357 357
 		}
358 358
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
359
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
359
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name']));
360 360
 		}
361 361
  
362 362
 		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'])) {
363
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
363
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
364 364
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
365 365
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
366 366
 			    $timeelapsed = microtime(true);
@@ -371,10 +371,10 @@  discard block
 block discarded – undo
371 371
 			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372 372
 			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373 373
 			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
374
-            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
374
+            		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
375 375
 			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
376 376
 			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
377
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
378 378
 			}
379 379
 		    }
380 380
 
@@ -386,25 +386,25 @@  discard block
 block discarded – undo
386 386
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 387
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 388
   */
389
-		    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']));
389
+		    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']));
390 390
 
391 391
 		    //$putinarchive = true;
392 392
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
393
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
393
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
394 394
 		    }
395 395
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
396
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
396
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
397 397
 		    }
398 398
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
399
-		    		$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' => ''));
399
+		    		$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' => ''));
400 400
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
401 401
 			$timeelapsed = microtime(true);
402 402
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
403 403
 				$Spotter = new Spotter($this->db);
404 404
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 405
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406
-		    		$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' => ''));
407
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
406
+		    		$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' => ''));
407
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
408 408
                         }
409 409
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 410
 			$timeelapsed = microtime(true);
@@ -418,34 +418,34 @@  discard block
 block discarded – undo
418 418
 				$Translation->db = null;
419 419
 			    }
420 420
 			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
422 422
                     	}
423 423
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424 424
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
425 425
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
426 426
 				//    $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']));
427
-		    		$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']));
427
+		    		$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']));
428 428
 		    	    }
429 429
 			}
430 430
 			if (!isset($globalFork)) $globalFork = TRUE;
431 431
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
432
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
433 433
 			}
434 434
 		    }
435 435
 		}
436 436
 
437 437
 		if (isset($line['speed']) && $line['speed'] != '') {
438 438
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
439
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
440
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
439
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
440
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
441 441
 		    //$dataFound = true;
442 442
 		} 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'])) {
443
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
443
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
444 444
 		    if ($distance > 1000 && $distance < 10000) {
445 445
 		    // use datetime
446 446
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 447
 			$speed = $speed*3.6;
448
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
448
+			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
449 449
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
450 450
 		    }
451 451
 		}
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 
454 454
 
455 455
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
456
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
457 457
 	    	    else unset($timediff);
458
-	    	    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')))) {
458
+	    	    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')))) {
459 459
 			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'])) {
460
-			    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'])) {
460
+			    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'])) {
461 461
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
462 462
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
463 463
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -467,10 +467,10 @@  discard block
 block discarded – undo
467 467
 				    $timeelapsed = microtime(true);
468 468
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 469
 					$Spotter = new Spotter($this->db);
470
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
470
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
471 471
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
472 472
 					$Spotter->db = null;
473
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
473
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
474 474
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
475 475
 				    }
476 476
 				}
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481 481
 			    //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) {
482 482
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
483
-				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') {
483
+				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') {
484 484
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485 485
 				    $dataFound = true;
486 486
 				    $this->all_flights[$id]['time_last_coord'] = time();
487 487
 				}
488 488
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
489
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
489
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
490 490
 				/*
491 491
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
492 492
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
505 505
 			    //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) {
506 506
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
507
-				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') {
507
+				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') {
508 508
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509 509
 				    $dataFound = true;
510 510
 				    $this->all_flights[$id]['time_last_coord'] = time();
511 511
 				}
512 512
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
513
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
513
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
514 514
 				/*
515 515
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
516 516
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -528,46 +528,46 @@  discard block
 block discarded – undo
528 528
 		    } else if ($globalDebug && $timediff > 30) {
529 529
 			$this->tmd = $this->tmd + 1;
530 530
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
531
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
532
-			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
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
532
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
533 533
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
534 534
 		    }
535 535
 		}
536 536
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537 537
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
538
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
538
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
539 539
 		}
540 540
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
541
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
541
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
542 542
 		    //$dataFound = true;
543 543
 		}
544 544
 		if (isset($line['format_source']) && $line['format_source'] != '') {
545
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
545
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
546 546
 		}
547 547
 		if (isset($line['source_name']) && $line['source_name'] != '') {
548
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
548
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
549 549
 		}
550 550
 		if (isset($line['emergency']) && $line['emergency'] != '') {
551
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
551
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
552 552
 		    //$dataFound = true;
553 553
 		}
554 554
 		if (isset($line['ground']) && $line['ground'] != '') {
555 555
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
556 556
 			// Here we force archive of flight because after ground it's a new one (or should be)
557
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559
-			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')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561
-			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']));
557
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
558
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
559
+			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')));
560
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
561
+			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']));
562 562
 		    }
563 563
 		    if ($line['ground'] != 1) $line['ground'] = 0;
564
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
564
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
565 565
 		    //$dataFound = true;
566 566
 		}
567 567
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568 568
 		    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'])) {
569 569
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
570
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
570
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
571 571
 			    $highlight = '';
572 572
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573 573
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -576,47 +576,47 @@  discard block
 block discarded – undo
576 576
 				$timeelapsed = microtime(true);
577 577
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578 578
 				    $Spotter = new Spotter($this->db);
579
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
579
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
580 580
 				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
581
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
582 582
 				}
583 583
 				//$putinarchive = true;
584 584
 				//$highlight = '';
585 585
 			    }
586 586
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
587
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
588 588
 		    //$dataFound = true;
589 589
 		}
590 590
 
591 591
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592 592
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593
-			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;
594
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
593
+			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;
594
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
595
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
596 596
 			//$dataFound = true;
597 597
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
598 598
   		}
599 599
 
600 600
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
601
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
601
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
602 602
 		}
603 603
 		
604 604
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
605
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
606
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
607
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
608 608
 		    //$dataFound = true;
609 609
   		} 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']) {
610
-  		    $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']);
611
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
610
+  		    $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']);
611
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
612
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613 613
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
614 614
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615 615
   		    // If not enough messages and ACARS set heading to 0
616
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
616
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
617 617
   		}
618
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
618
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
620 620
 
621 621
 //		print_r($this->all_flights[$id]);
622 622
 		//gets the callsign from the last hour
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
627 627
 		    $this->all_flights[$id]['lastupdate'] = time();
628 628
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
629
-		        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'])) {
629
+		        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'])) {
630 630
 			    //print_r($this->all_flights);
631 631
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
632 632
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -637,61 +637,61 @@  discard block
 block discarded – undo
637 637
 				    $SpotterLive = new SpotterLive($this->db);
638 638
 				    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')) {
639 639
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
640
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
641 641
 				    } elseif (isset($line['id'])) {
642 642
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
643
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
644 644
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 645
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
646
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
647 647
 				    } else $recent_ident = '';
648
-				    $SpotterLive->db=null;
648
+				    $SpotterLive->db = null;
649 649
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650 650
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651 651
 				} else $recent_ident = '';
652 652
 			    } else {
653 653
 				$recent_ident = '';
654
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
654
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
655 655
 			    }
656 656
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657
-			    if($recent_ident == "")
657
+			    if ($recent_ident == "")
658 658
 			    {
659 659
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
660 660
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 661
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 662
 				//adds the spotter data for the archive
663 663
 				$ignoreImport = false;
664
-				foreach($globalAirportIgnore as $airportIgnore) {
664
+				foreach ($globalAirportIgnore as $airportIgnore) {
665 665
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
666 666
 					$ignoreImport = true;
667 667
 				    }
668 668
 				}
669 669
 				if (count($globalAirportAccept) > 0) {
670 670
 				    $ignoreImport = true;
671
-				    foreach($globalAirportIgnore as $airportIgnore) {
671
+				    foreach ($globalAirportIgnore as $airportIgnore) {
672 672
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
673 673
 					    $ignoreImport = false;
674 674
 					}
675 675
 				    }
676 676
 				}
677 677
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
678
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
679
-					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
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
679
+					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)) {
680 680
 					    $ignoreImport = true;
681 681
 					}
682 682
 				    }
683 683
 				}
684 684
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
685 685
 				    $ignoreImport = true;
686
-				    foreach($globalAirlineAccept as $airlineAccept) {
687
-					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
+				    foreach ($globalAirlineAccept as $airlineAccept) {
687
+					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)) {
688 688
 					    $ignoreImport = false;
689 689
 					}
690 690
 				    }
691 691
 				}
692 692
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
693 693
 				    $ignoreImport = true;
694
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
694
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
695 695
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
696 696
 					    $ignoreImport = false;
697 697
 					}
@@ -703,32 +703,32 @@  discard block
 block discarded – undo
703 703
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704 704
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705 705
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
706
+				    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')));
707 707
 				    $timeelapsed = microtime(true);
708 708
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 709
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710 710
 					    $Spotter = new Spotter($this->db);
711
-					    $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']);
711
+					    $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']);
712 712
 					    $Spotter->db = null;
713 713
 					    if ($globalDebug && isset($result)) echo $result."\n";
714 714
 					}
715 715
 				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
716
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
717 717
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 718
 
719 719
 				    // Add source stat in DB
720 720
 				    $Stats = new Stats($this->db);
721 721
 				    if (!empty($this->stats)) {
722 722
 					if ($globalDebug) echo 'Add source stats : ';
723
-				        foreach($this->stats as $date => $data) {
724
-					    foreach($data as $source => $sourced) {
723
+				        foreach ($this->stats as $date => $data) {
724
+					    foreach ($data as $source => $sourced) {
725 725
 					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
726
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
727
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
728 728
 				    		if (isset($sourced['msg'])) {
729 729
 				    		    if (time() - $sourced['msg']['date'] > 10) {
730 730
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
731
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
731
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
732 732
 			    			        unset($this->stats[$date][$source]['msg']);
733 733
 			    			    }
734 734
 			    			}
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
767 767
 					    $SpotterLive = new SpotterLive($this->db);
768 768
 					    $SpotterLive->deleteLiveSpotterData();
769
-					    $SpotterLive->db=null;
769
+					    $SpotterLive->db = null;
770 770
 					}
771 771
 				    }
772 772
 				    if ($globalDebug) echo " Done\n";
773 773
 				    $this->last_delete = time();
774 774
 				}
775 775
 			    } else {
776
-				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')) {
776
+				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')) {
777 777
 				    $this->all_flights[$id]['id'] = $recent_ident;
778 778
 				    $this->all_flights[$id]['addedSpotter'] = 1;
779 779
 				}
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
782 782
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
783 783
 					    $Spotter = new Spotter($this->db);
784
-					    $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']);
784
+					    $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']);
785 785
 					    $Spotter->db = null;
786 786
 					}
787 787
 				    }
@@ -807,37 +807,37 @@  discard block
 block discarded – undo
807 807
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 808
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 809
 
810
-		    foreach($globalAirportIgnore as $airportIgnore) {
810
+		    foreach ($globalAirportIgnore as $airportIgnore) {
811 811
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
812 812
 			    $ignoreImport = true;
813 813
 			}
814 814
 		    }
815 815
 		    if (count($globalAirportAccept) > 0) {
816 816
 		        $ignoreImport = true;
817
-		        foreach($globalAirportIgnore as $airportIgnore) {
817
+		        foreach ($globalAirportIgnore as $airportIgnore) {
818 818
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
819 819
 				$ignoreImport = false;
820 820
 			    }
821 821
 			}
822 822
 		    }
823 823
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
824
-			foreach($globalAirlineIgnore as $airlineIgnore) {
825
-			    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
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
825
+			    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)) {
826 826
 				$ignoreImport = true;
827 827
 			    }
828 828
 			}
829 829
 		    }
830 830
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
831 831
 			$ignoreImport = true;
832
-			foreach($globalAirlineAccept as $airlineAccept) {
833
-			    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
+			foreach ($globalAirlineAccept as $airlineAccept) {
833
+			    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)) {
834 834
 				$ignoreImport = false;
835 835
 			    }
836 836
 			}
837 837
 		    }
838 838
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
839 839
 			$ignoreImport = true;
840
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
840
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
841 841
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
842 842
 			        $ignoreImport = false;
843 843
 			    }
@@ -845,23 +845,23 @@  discard block
 block discarded – undo
845 845
 		    }
846 846
 
847 847
 		    if (!$ignoreImport) {
848
-			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'])) {
849
-				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
+			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'])) {
849
+				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')));
850 850
 				$timeelapsed = microtime(true);
851 851
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852 852
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853 853
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
854 854
 					$SpotterLive = new SpotterLive($this->db);
855
-					$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']);
855
+					$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']);
856 856
 					$SpotterLive->db = null;
857 857
 					if ($globalDebug) echo $result."\n";
858 858
 				    }
859 859
 				}
860 860
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861
-					$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']);
861
+					$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']);
862 862
 				}
863 863
 				$this->all_flights[$id]['putinarchive'] = false;
864
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
864
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
865 865
 
866 866
 				// Put statistics in $this->stats variable
867 867
 				//if ($line['format_source'] != 'aprs') {
@@ -880,19 +880,19 @@  discard block
 block discarded – undo
880 880
 							$latitude = $globalCenterLatitude;
881 881
 							$longitude = $globalCenterLongitude;
882 882
 						}
883
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
883
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
884 884
 					} else {
885 885
 						$latitude = $this->source_location[$source]['latitude'];
886 886
 						$longitude = $this->source_location[$source]['longitude'];
887 887
 					}
888
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
888
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
889 889
 					//$stats_heading = $stats_heading%22.5;
890 890
 					$stats_heading = round($stats_heading/22.5);
891
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
891
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
892 892
 					$current_date = date('Y-m-d');
893 893
 					if ($stats_heading == 16) $stats_heading = 0;
894 894
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895
-						for ($i=0;$i<=15;$i++) {
895
+						for ($i = 0; $i <= 15; $i++) {
896 896
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
897 897
 						}
898 898
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -907,9 +907,9 @@  discard block
 block discarded – undo
907 907
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
908 908
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909 909
 						    end($this->stats[$current_date][$source]['hist']);
910
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
910
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
911 911
 						} else $mini = 0;
912
-						for ($i=$mini;$i<=$distance;$i+=10) {
912
+						for ($i = $mini; $i <= $distance; $i += 10) {
913 913
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
914 914
 						}
915 915
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 				$this->all_flights[$id]['lastupdate'] = time();
923 923
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
924 924
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
926 926
 			//$this->del();
927 927
 			
928 928
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.
Braces   +343 added lines, -121 removed lines patch added patch discarded remove patch
@@ -63,7 +63,9 @@  discard block
 block discarded – undo
63 63
 	$dbc = $this->db;
64 64
 	$this->all_flights[$id]['schedule_check'] = true;
65 65
 	if ($globalSchedulesFetch) {
66
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
66
+	if ($globalDebug) {
67
+		echo 'Getting schedule info...'."\n";
68
+	}
67 69
 	$Spotter = new Spotter($dbc);
68 70
 	$Schedule = new Schedule($dbc);
69 71
 	$Translation = new Translation($dbc);
@@ -74,7 +76,9 @@  discard block
 block discarded – undo
74 76
 	    if ($Schedule->checkSchedule($operator) == 0) {
75 77
 		$schedule = $Schedule->fetchSchedule($operator);
76 78
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
79
+		    if ($globalDebug) {
80
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
81
+		    }
78 82
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79 83
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
80 84
 		    // Should also check if route schedule = route from DB
@@ -83,7 +87,9 @@  discard block
 block discarded – undo
83 87
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
84 88
 			    if (trim($airport_icao) != '') {
85 89
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
86
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
90
+				if ($globalDebug) {
91
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
92
+				}
87 93
 			    }
88 94
 			}
89 95
 		    }
@@ -92,17 +98,25 @@  discard block
 block discarded – undo
92 98
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
93 99
 			    if (trim($airport_icao) != '') {
94 100
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
95
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
101
+				if ($globalDebug) {
102
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
103
+				}
96 104
 			    }
97 105
 			}
98 106
 		    }
99 107
 		    $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']);
100 108
 		}
101
-	    } else $scheduleexist = true;
102
-	} else $scheduleexist = true;
109
+	    } else {
110
+	    	$scheduleexist = true;
111
+	    }
112
+	} else {
113
+		$scheduleexist = true;
114
+	}
103 115
 	// close connection, at least one way will work ?
104 116
        if ($scheduleexist) {
105
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
117
+		if ($globalDebug) {
118
+			echo "-> get arrival/departure airport info for ".$ident."\n";
119
+		}
106 120
     		$sch = $Schedule->getSchedule($operator);
107 121
 		$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']));
108 122
        }
@@ -124,14 +138,18 @@  discard block
 block discarded – undo
124 138
 
125 139
     public function checkAll() {
126 140
 	global $globalDebug, $globalNoImport;
127
-	if ($globalDebug) echo "Update last seen flights data...\n";
141
+	if ($globalDebug) {
142
+		echo "Update last seen flights data...\n";
143
+	}
128 144
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
129 145
 	    foreach ($this->all_flights as $key => $flight) {
130 146
 		if (isset($this->all_flights[$key]['id'])) {
131 147
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 148
     		    $Spotter = new Spotter($this->db);
133 149
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $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']);
150
+        	    if (isset($this->all_flights[$key]['altitude'])) {
151
+        	    	$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']);
152
+        	    }
135 153
         	}
136 154
 	    }
137 155
 	}
@@ -139,24 +157,32 @@  discard block
 block discarded – undo
139 157
 
140 158
     public function arrival($key) {
141 159
 	global $globalClosestMinDist, $globalDebug;
142
-	if ($globalDebug) echo 'Update arrival...'."\n";
160
+	if ($globalDebug) {
161
+		echo 'Update arrival...'."\n";
162
+	}
143 163
 	$Spotter = new Spotter($this->db);
144 164
         $airport_icao = '';
145 165
         $airport_time = '';
146
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
166
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
167
+        	$globalClosestMinDist = 50;
168
+        }
147 169
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148 170
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
149 171
     	    if (isset($closestAirports[0])) {
150 172
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 173
         	    $airport_icao = $closestAirports[0]['icao'];
152 174
         	    $airport_time = $this->all_flights[$key]['datetime'];
153
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
175
+        	    if ($globalDebug) {
176
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
177
+        	    }
154 178
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
155 179
         	    foreach ($closestAirports as $airport) {
156 180
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
157 181
         		    $airport_icao = $airport['icao'];
158 182
         		    $airport_time = $this->all_flights[$key]['datetime'];
159
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
183
+        		    if ($globalDebug) {
184
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
185
+        		    }
160 186
         		    break;
161 187
         		}
162 188
         	    }
@@ -164,14 +190,20 @@  discard block
 block discarded – undo
164 190
         		$airport_icao = $closestAirports[0]['icao'];
165 191
         		$airport_time = $this->all_flights[$key]['datetime'];
166 192
         	} else {
167
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
193
+        		if ($globalDebug) {
194
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
195
+        		}
168 196
         	}
169 197
     	    } else {
170
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
198
+    		    if ($globalDebug) {
199
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
200
+    		    }
171 201
     	    }
172 202
 
173 203
         } else {
174
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
204
+        	if ($globalDebug) {
205
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
206
+        	}
175 207
         }
176 208
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
177 209
     }
@@ -181,12 +213,16 @@  discard block
 block discarded – undo
181 213
     public function del() {
182 214
 	global $globalDebug, $globalNoImport, $globalNoDB;
183 215
 	// Delete old infos
184
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
216
+	if ($globalDebug) {
217
+		echo 'Delete old values and update latest data...'."\n";
218
+	}
185 219
 	foreach ($this->all_flights as $key => $flight) {
186 220
     	    if (isset($flight['lastupdate'])) {
187 221
         	if ($flight['lastupdate'] < (time()-3000)) {
188 222
             	    if (isset($this->all_flights[$key]['id'])) {
189
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
223
+            		if ($globalDebug) {
224
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
225
+            		}
190 226
 			/*
191 227
 			$SpotterLive = new SpotterLive();
192 228
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
             		    $Spotter = new Spotter($this->db);
198 234
             	    	    if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
199 235
 				$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']);
200
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
236
+				if ($globalDebug && $result != 'success') {
237
+					echo '!!! ERROR : '.$result."\n";
238
+				}
201 239
 			    }
202 240
 			// Put in archive
203 241
 //				$Spotter->db = null;
@@ -212,8 +250,10 @@  discard block
 block discarded – undo
212 250
     public function add($line) {
213 251
 	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;
214 252
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
215
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
216
-/*
253
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
254
+		$globalCoordMinChange = '0.02';
255
+	}
256
+	/*
217 257
 	$Spotter = new Spotter();
218 258
 	$dbc = $Spotter->db;
219 259
 	$SpotterLive = new SpotterLive($dbc);
@@ -241,11 +281,15 @@  discard block
 block discarded – undo
241 281
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
242 282
 		    $current_date = date('Y-m-d');
243 283
 		    $source = $line['source_name'];
244
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
284
+		    if ($source == '' || $line['format_source'] == 'aprs') {
285
+		    	$source = $line['format_source'];
286
+		    }
245 287
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
246 288
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
247 289
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
248
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
290
+		    } else {
291
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
292
+		    }
249 293
 		}
250 294
 		
251 295
 		/*
@@ -261,22 +305,35 @@  discard block
 block discarded – undo
261 305
 		//$this->db = $dbc;
262 306
 
263 307
 		//$hex = trim($line['hex']);
264
-	        if (!isset($line['id'])) $id = trim($line['hex']);
265
-	        else $id = trim($line['id']);
308
+	        if (!isset($line['id'])) {
309
+	        	$id = trim($line['hex']);
310
+	        } else {
311
+	        	$id = trim($line['id']);
312
+	        }
266 313
 		
267 314
 		if (!isset($this->all_flights[$id])) {
268 315
 		    $this->all_flights[$id] = array();
269 316
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
270 317
 		    $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' => ''));
271
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
318
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
319
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
320
+		    }
272 321
 		    if (!isset($line['id'])) {
273
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
274
-//			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')));
322
+			if (!isset($globalDaemon)) {
323
+				$globalDaemon = TRUE;
324
+			}
325
+			//			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')));
275 326
 //			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')));
276
-			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')));
327
+			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')) {
328
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
329
+			}
277 330
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
278
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
279
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
331
+		     } else {
332
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
333
+		     }
334
+		    if ($globalAllFlights !== FALSE) {
335
+		    	$dataFound = true;
336
+		    }
280 337
 		}
281 338
 		if (isset($line['source_type']) && $line['source_type'] != '') {
282 339
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -298,12 +355,20 @@  discard block
 block discarded – undo
298 355
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
299 356
 			    }
300 357
 			    $Spotter->db = null;
301
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
302
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
358
+			    if ($globalDebugTimeElapsed) {
359
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
360
+			    }
361
+			    if ($aircraft_icao != '') {
362
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
363
+			    }
303 364
 			}
304 365
 		    }
305
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
306
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
366
+		    if ($globalAllFlights !== FALSE) {
367
+		    	$dataFound = true;
368
+		    }
369
+		    if ($globalDebug) {
370
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
371
+		    }
307 372
 		}
308 373
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
309 374
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
@@ -314,15 +379,24 @@  discard block
 block discarded – undo
314 379
 				$Spotter = new Spotter($this->db);
315 380
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
316 381
 				$Spotter->db = null;
317
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
382
+				if ($aircraft_icao != '') {
383
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
384
+				}
318 385
 			}
319 386
 		}
320 387
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
321
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
322
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
323
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
324
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
325
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
388
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
389
+				$aircraft_icao = 'GLID';
390
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
391
+				$aircraft_icao = 'UHEL';
392
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
393
+				$aircraft_icao = 'TOWPLANE';
394
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
395
+				$aircraft_icao = 'POWAIRC';
396
+			}
397
+			if (isset($aircraft_icao)) {
398
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
399
+			}
326 400
 		}
327 401
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
328 402
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -332,8 +406,11 @@  discard block
 block discarded – undo
332 406
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
333 407
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
334 408
 		    } else {
335
-				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";
336
-				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";
409
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
410
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
411
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
412
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
413
+				}
337 414
 				/*
338 415
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
339 416
 				print_r($this->all_flights[$id]);
@@ -366,15 +443,25 @@  discard block
 block discarded – undo
366 443
 			    $timeelapsed = microtime(true);
367 444
             		    $Spotter = new Spotter($this->db);
368 445
             		    $fromsource = NULL;
369
-            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
370
-            		    elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
371
-			    elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
372
-			    elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
373
-			    elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
446
+            		    if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
447
+            		    	$fromsource = $globalAirlinesSource;
448
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
449
+            		    	$fromsource = 'vatsim';
450
+            		    } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
451
+			    	$fromsource = 'ivao';
452
+			    } elseif (isset($globalVATSIM) && $globalVATSIM) {
453
+			    	$fromsource = 'vatsim';
454
+			    } elseif (isset($globalIVAO) && $globalIVAO) {
455
+			    	$fromsource = 'ivao';
456
+			    }
374 457
             		    $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
375
-			    if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
458
+			    if ($globalDebug && $result != 'success') {
459
+			    	echo '!!! ERROR : '.$result."\n";
460
+			    }
376 461
 			    $Spotter->db = null;
377
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
462
+			    if ($globalDebugTimeElapsed) {
463
+			    	echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
464
+			    }
378 465
 			}
379 466
 		    }
380 467
 
@@ -386,7 +473,9 @@  discard block
 block discarded – undo
386 473
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387 474
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
388 475
   */
389
-		    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']));
476
+		    if (!isset($this->all_flights[$id]['id'])) {
477
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
478
+		    }
390 479
 
391 480
 		    //$putinarchive = true;
392 481
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -404,7 +493,9 @@  discard block
 block discarded – undo
404 493
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
405 494
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
406 495
 		    		$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' => ''));
407
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
496
+				if ($globalDebugTimeElapsed) {
497
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
498
+				}
408 499
                         }
409 500
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
410 501
 			$timeelapsed = microtime(true);
@@ -418,7 +509,9 @@  discard block
 block discarded – undo
418 509
 				$Translation->db = null;
419 510
 			    }
420 511
 			    $Spotter->db = null;
421
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
512
+			    if ($globalDebugTimeElapsed) {
513
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
514
+			    }
422 515
                     	}
423 516
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
424 517
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -427,9 +520,13 @@  discard block
 block discarded – undo
427 520
 		    		$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']));
428 521
 		    	    }
429 522
 			}
430
-			if (!isset($globalFork)) $globalFork = TRUE;
523
+			if (!isset($globalFork)) {
524
+				$globalFork = TRUE;
525
+			}
431 526
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
432
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
527
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
528
+					$this->get_Schedule($id,trim($line['ident']));
529
+				}
433 530
 			}
434 531
 		    }
435 532
 		}
@@ -445,16 +542,23 @@  discard block
 block discarded – undo
445 542
 		    // use datetime
446 543
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
447 544
 			$speed = $speed*3.6;
448
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
449
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
545
+			if ($speed < 1000) {
546
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
547
+			}
548
+  			if ($globalDebug) {
549
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
550
+  			}
450 551
 		    }
451 552
 		}
452 553
 
453 554
 
454 555
 
455 556
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
456
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
457
-	    	    else unset($timediff);
557
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
558
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
559
+	    	    } else {
560
+	    	    	unset($timediff);
561
+	    	    }
458 562
 	    	    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')))) {
459 563
 			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'])) {
460 564
 			    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'])) {
@@ -463,15 +567,23 @@  discard block
 block discarded – undo
463 567
 				$this->all_flights[$id]['putinarchive'] = true;
464 568
 				$this->tmd = 0;
465 569
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
466
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
570
+				    if ($globalDebug) {
571
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
572
+				    }
467 573
 				    $timeelapsed = microtime(true);
468 574
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
469 575
 					$Spotter = new Spotter($this->db);
470 576
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
471
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
577
+					if (!empty($all_country)) {
578
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
579
+					}
472 580
 					$Spotter->db = null;
473
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
474
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
581
+					if ($globalDebugTimeElapsed) {
582
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+					}
584
+					if ($globalDebug) {
585
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
586
+					}
475 587
 				    }
476 588
 				}
477 589
 			    }
@@ -479,7 +591,9 @@  discard block
 block discarded – undo
479 591
 
480 592
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
481 593
 			    //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) {
482
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
594
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
595
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
596
+				}
483 597
 				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') {
484 598
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
485 599
 				    $dataFound = true;
@@ -501,9 +615,13 @@  discard block
 block discarded – undo
501 615
 			    */
502 616
 			}
503 617
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
504
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
618
+			    if ($line['longitude'] > 180) {
619
+			    	$line['longitude'] = $line['longitude'] - 360;
620
+			    }
505 621
 			    //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) {
506
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
622
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
623
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
624
+				}
507 625
 				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') {
508 626
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
509 627
 				    $dataFound = true;
@@ -534,7 +652,9 @@  discard block
 block discarded – undo
534 652
 		    }
535 653
 		}
536 654
 		if (isset($line['last_update']) && $line['last_update'] != '') {
537
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
655
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
656
+		    	$dataFound = true;
657
+		    }
538 658
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
539 659
 		}
540 660
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -556,41 +676,61 @@  discard block
 block discarded – undo
556 676
 			// Here we force archive of flight because after ground it's a new one (or should be)
557 677
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
558 678
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
559
-			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')));
560
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
561
-			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']));
679
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
680
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
681
+			} elseif (isset($line['id'])) {
682
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
683
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
684
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
685
+			}
686
+		    }
687
+		    if ($line['ground'] != 1) {
688
+		    	$line['ground'] = 0;
562 689
 		    }
563
-		    if ($line['ground'] != 1) $line['ground'] = 0;
564 690
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
565 691
 		    //$dataFound = true;
566 692
 		}
567 693
 		if (isset($line['squawk']) && $line['squawk'] != '') {
568 694
 		    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'])) {
569
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
695
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
696
+			    	$this->all_flights[$id]['putinarchive'] = true;
697
+			    }
570 698
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
571 699
 			    $highlight = '';
572
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
573
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
574
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
700
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
701
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
702
+			    }
703
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
704
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
705
+			    }
706
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
707
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
708
+			    }
575 709
 			    if ($highlight != '') {
576 710
 				$timeelapsed = microtime(true);
577 711
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
578 712
 				    $Spotter = new Spotter($this->db);
579 713
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
580 714
 				    $Spotter->db = null;
581
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
715
+				    if ($globalDebugTimeElapsed) {
716
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
717
+				    }
582 718
 				}
583 719
 				//$putinarchive = true;
584 720
 				//$highlight = '';
585 721
 			    }
586 722
 			    
587
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
723
+		    } else {
724
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
725
+		    }
588 726
 		    //$dataFound = true;
589 727
 		}
590 728
 
591 729
 		if (isset($line['altitude']) && $line['altitude'] != '') {
592 730
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
593
-			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;
731
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
732
+				$this->all_flights[$id]['putinarchive'] = true;
733
+			}
594 734
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
595 735
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
596 736
 			//$dataFound = true;
@@ -602,21 +742,30 @@  discard block
 block discarded – undo
602 742
 		}
603 743
 		
604 744
 		if (isset($line['heading']) && $line['heading'] != '') {
605
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
745
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
746
+		    	$this->all_flights[$id]['putinarchive'] = true;
747
+		    }
606 748
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
607 749
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
608 750
 		    //$dataFound = true;
609 751
   		} 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']) {
610 752
   		    $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']);
611 753
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
612
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
613
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
754
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
755
+		    	$this->all_flights[$id]['putinarchive'] = true;
756
+		    }
757
+  		    if ($globalDebug) {
758
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
759
+  		    }
614 760
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
615 761
   		    // If not enough messages and ACARS set heading to 0
616 762
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
617 763
   		}
618
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
619
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
764
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
765
+			$dataFound = false;
766
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
767
+			$dataFound = false;
768
+		}
620 769
 
621 770
 //		print_r($this->all_flights[$id]);
622 771
 		//gets the callsign from the last hour
@@ -632,23 +781,38 @@  discard block
 block discarded – undo
632 781
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
633 782
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
634 783
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
635
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
784
+				    if ($globalDebug) {
785
+				    	echo "Check if aircraft is already in DB...";
786
+				    }
636 787
 				    $timeelapsed = microtime(true);
637 788
 				    $SpotterLive = new SpotterLive($this->db);
638 789
 				    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')) {
639 790
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
640
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
791
+					if ($globalDebugTimeElapsed) {
792
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
793
+					}
641 794
 				    } elseif (isset($line['id'])) {
642 795
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
643
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
796
+					if ($globalDebugTimeElapsed) {
797
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
798
+					}
644 799
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
645 800
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
646
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
647
-				    } else $recent_ident = '';
801
+					if ($globalDebugTimeElapsed) {
802
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
803
+					}
804
+				    } else {
805
+				    	$recent_ident = '';
806
+				    }
648 807
 				    $SpotterLive->db=null;
649
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
650
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
651
-				} else $recent_ident = '';
808
+				    if ($globalDebug && $recent_ident == '') {
809
+				    	echo " Not in DB.\n";
810
+				    } elseif ($globalDebug && $recent_ident != '') {
811
+				    	echo " Already in DB.\n";
812
+				    }
813
+				} else {
814
+					$recent_ident = '';
815
+				}
652 816
 			    } else {
653 817
 				$recent_ident = '';
654 818
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -656,7 +820,9 @@  discard block
 block discarded – undo
656 820
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
657 821
 			    if($recent_ident == "")
658 822
 			    {
659
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
823
+				if ($globalDebug) {
824
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
825
+				}
660 826
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
661 827
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
662 828
 				//adds the spotter data for the archive
@@ -700,31 +866,49 @@  discard block
 block discarded – undo
700 866
 				
701 867
 				if (!$ignoreImport) {
702 868
 				    $highlight = '';
703
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
704
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
705
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
706
-				    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')));
869
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
870
+				    	$highlight = 'Squawk 7500 : Hijack';
871
+				    }
872
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
873
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
874
+				    }
875
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
876
+				    	$highlight = 'Squawk 7700 : Emergency';
877
+				    }
878
+				    if (!isset($this->all_flights[$id]['id'])) {
879
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
880
+				    }
707 881
 				    $timeelapsed = microtime(true);
708 882
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
709 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
710 884
 					    $Spotter = new Spotter($this->db);
711 885
 					    $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']);
712 886
 					    $Spotter->db = null;
713
-					    if ($globalDebug && isset($result)) echo $result."\n";
887
+					    if ($globalDebug && isset($result)) {
888
+					    	echo $result."\n";
889
+					    }
714 890
 					}
715 891
 				    }
716
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
892
+				    if ($globalDebugTimeElapsed) {
893
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
894
+				    }
717 895
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
718 896
 
719 897
 				    // Add source stat in DB
720 898
 				    $Stats = new Stats($this->db);
721 899
 				    if (!empty($this->stats)) {
722
-					if ($globalDebug) echo 'Add source stats : ';
900
+					if ($globalDebug) {
901
+						echo 'Add source stats : ';
902
+					}
723 903
 				        foreach($this->stats as $date => $data) {
724 904
 					    foreach($data as $source => $sourced) {
725 905
 					        //print_r($sourced);
726
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
727
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
906
+				    	        if (isset($sourced['polar'])) {
907
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
908
+				    	        }
909
+				    	        if (isset($sourced['hist'])) {
910
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
911
+				    	        }
728 912
 				    		if (isset($sourced['msg'])) {
729 913
 				    		    if (time() - $sourced['msg']['date'] > 10) {
730 914
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -737,13 +921,17 @@  discard block
 block discarded – undo
737 921
 			    			unset($this->stats[$date]);
738 922
 			    		    }
739 923
 				    	}
740
-				    	if ($globalDebug) echo 'Done'."\n";
924
+				    	if ($globalDebug) {
925
+				    		echo 'Done'."\n";
926
+				    	}
741 927
 
742 928
 				    }
743 929
 				    $Stats->db = null;
744 930
 				    }
745 931
 				    $this->del();
746
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
932
+				} elseif ($globalDebug) {
933
+					echo 'Ignore data'."\n";
934
+				}
747 935
 				//$ignoreImport = false;
748 936
 				$this->all_flights[$id]['addedSpotter'] = 1;
749 937
 				//print_r($this->all_flights[$id]);
@@ -760,7 +948,9 @@  discard block
 block discarded – undo
760 948
 			*/
761 949
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
762 950
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
763
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
951
+				    if ($globalDebug) {
952
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
953
+				    }
764 954
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
765 955
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
766 956
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -769,7 +959,9 @@  discard block
 block discarded – undo
769 959
 					    $SpotterLive->db=null;
770 960
 					}
771 961
 				    }
772
-				    if ($globalDebug) echo " Done\n";
962
+				    if ($globalDebug) {
963
+				    	echo " Done\n";
964
+				    }
773 965
 				    $this->last_delete = time();
774 966
 				}
775 967
 			    } else {
@@ -796,11 +988,17 @@  discard block
 block discarded – undo
796 988
 		    //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";
797 989
 		    if ($globalDebug) {
798 990
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
799
-				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";
800
-				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";
991
+				if (isset($this->all_flights[$id]['source_name'])) {
992
+					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";
993
+				} else {
994
+					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";
995
+				}
801 996
 			} else {
802
-				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";
803
-				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";
997
+				if (isset($this->all_flights[$id]['source_name'])) {
998
+					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";
999
+				} else {
1000
+					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";
1001
+				}
804 1002
 			}
805 1003
 		    }
806 1004
 		    $ignoreImport = false;
@@ -846,22 +1044,30 @@  discard block
 block discarded – undo
846 1044
 
847 1045
 		    if (!$ignoreImport) {
848 1046
 			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'])) {
849
-				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')));
1047
+				if (!isset($this->all_flights[$id]['id'])) {
1048
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1049
+				}
850 1050
 				$timeelapsed = microtime(true);
851 1051
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
852 1052
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
853
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1053
+					if ($globalDebug) {
1054
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1055
+					}
854 1056
 					$SpotterLive = new SpotterLive($this->db);
855 1057
 					$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']);
856 1058
 					$SpotterLive->db = null;
857
-					if ($globalDebug) echo $result."\n";
1059
+					if ($globalDebug) {
1060
+						echo $result."\n";
1061
+					}
858 1062
 				    }
859 1063
 				}
860 1064
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
861 1065
 					$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']);
862 1066
 				}
863 1067
 				$this->all_flights[$id]['putinarchive'] = false;
864
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1068
+				if ($globalDebugTimeElapsed) {
1069
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1070
+				}
865 1071
 
866 1072
 				// Put statistics in $this->stats variable
867 1073
 				//if ($line['format_source'] != 'aprs') {
@@ -869,7 +1075,9 @@  discard block
 block discarded – undo
869 1075
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
870 1076
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
871 1077
 					$source = $this->all_flights[$id]['source_name'];
872
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1078
+					if ($source == '') {
1079
+						$source = $this->all_flights[$id]['format_source'];
1080
+					}
873 1081
 					if (!isset($this->source_location[$source])) {
874 1082
 						$Location = new Source();
875 1083
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -890,7 +1098,9 @@  discard block
 block discarded – undo
890 1098
 					$stats_heading = round($stats_heading/22.5);
891 1099
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
892 1100
 					$current_date = date('Y-m-d');
893
-					if ($stats_heading == 16) $stats_heading = 0;
1101
+					if ($stats_heading == 16) {
1102
+						$stats_heading = 0;
1103
+					}
894 1104
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
895 1105
 						for ($i=0;$i<=15;$i++) {
896 1106
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -908,7 +1118,9 @@  discard block
 block discarded – undo
908 1118
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
909 1119
 						    end($this->stats[$current_date][$source]['hist']);
910 1120
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
911
-						} else $mini = 0;
1121
+						} else {
1122
+							$mini = 0;
1123
+						}
912 1124
 						for ($i=$mini;$i<=$distance;$i+=10) {
913 1125
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
914 1126
 						}
@@ -920,19 +1132,27 @@  discard block
 block discarded – undo
920 1132
 				}
921 1133
 
922 1134
 				$this->all_flights[$id]['lastupdate'] = time();
923
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1135
+				if ($this->all_flights[$id]['putinarchive']) {
1136
+					$send = true;
1137
+				}
924 1138
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
925
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1139
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1140
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1141
+			}
926 1142
 			//$this->del();
927 1143
 			
928 1144
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
929 1145
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
930
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1146
+				if ($globalDebug) {
1147
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1148
+				}
931 1149
 				$SpotterLive = new SpotterLive($this->db);
932 1150
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
933 1151
 				$SpotterLive->db = null;
934 1152
 				//SpotterLive->deleteLiveSpotterData();
935
-				if ($globalDebug) echo " Done\n";
1153
+				if ($globalDebug) {
1154
+					echo " Done\n";
1155
+				}
936 1156
 				$this->last_delete_hourly = time();
937 1157
 			    } else {
938 1158
 				$this->del();
@@ -944,7 +1164,9 @@  discard block
 block discarded – undo
944 1164
 		    //$ignoreImport = false;
945 1165
 		}
946 1166
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
947
-		if ($send) return $this->all_flights[$id];
1167
+		if ($send) {
1168
+			return $this->all_flights[$id];
1169
+		}
948 1170
 	    }
949 1171
 	}
950 1172
     }
Please login to merge, or discard this patch.
airline-statistics-departure-airport-country.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['airline'])) {
7
-        header('Location: '.$globalURL.'/airline');
8
-        die();
7
+		header('Location: '.$globalURL.'/airline');
8
+		die();
9 9
 }
10 10
 $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 	$country_data = substr($country_data, 0, -1);
78 78
 	print $country_data;
79
-        print '];';
80
-        print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
81
-        print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
82
-        print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
83
-        print 'new Datamap({
79
+		print '];';
80
+		print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
81
+		print 'var paletteScale = d3.scale.linear().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
82
+		print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
83
+		print 'new Datamap({
84 84
 	    element: document.getElementById("chartCountry"),
85 85
 	    projection: "mercator", // big world map
86 86
 	    fills: { defaultFill: "#F5F5F5" },
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         header('Location: '.$globalURL.'/airline');
8 8
         die();
9 9
 }
10
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
12
-$spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1","");
12
+$spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", "");
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Departure Airports by Country from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
16
+	$title = sprintf(_("Most Common Departure Airports by Country from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="select-item">';
19 19
 	print '<form action="'.$globalURL.'/airline" method="post">';
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	$Stats = new Stats();
23 23
 	$airline_names = $Stats->getAllAirlineNames();
24 24
 	if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
25
-	foreach($airline_names as $airline_name)
25
+	foreach ($airline_names as $airline_name)
26 26
 	{
27
-		if($airline == $airline_name['airline_icao'])
27
+		if ($airline == $airline_name['airline_icao'])
28 28
 		{
29 29
 			print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
30 30
 		} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	include('airline-sub-menu.php');
63 63
 	print '<div class="column">';
64 64
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
65
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
65
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>';
66 66
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByAirline($airline);
67 67
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
68 68
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
71 71
 	print 'var series = [';
72 72
 	$country_data = '';
73
-	foreach($airport_country_array as $airport_item)
73
+	foreach ($airport_country_array as $airport_item)
74 74
 	{
75 75
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
76 76
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		print '</thead>';
118 118
 		print '<tbody>';
119 119
 		$i = 1;
120
-		foreach($airport_country_array as $airport_item)
120
+		foreach ($airport_country_array as $airport_item)
121 121
 		{
122 122
 			print '<tr>';
123 123
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
airline-statistics-arrival-airport-country.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 if (!isset($_GET['airline'])) {
7
-        header('Location: '.$globalURL.'/airline');
8
-        die();
7
+		header('Location: '.$globalURL.'/airline');
8
+		die();
9 9
 }
10 10
 $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@  discard block
 block discarded – undo
7 7
         header('Location: '.$globalURL.'/airline');
8 8
         die();
9 9
 }
10
-$airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10
+$airline = filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
12
-$spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1","");
12
+$spotter_array = $Spotter->getSpotterDataByAirline($airline, "0,1", "");
13 13
 
14 14
 if (!empty($spotter_array))
15 15
 {
16
-	$title = sprintf(_("Most Common Arrival Airports by Country from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
16
+	$title = sprintf(_("Most Common Arrival Airports by Country from %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']);
17 17
 	require_once('header.php');
18 18
 	print '<div class="select-item">';
19 19
 	print '<form action="'.$globalURL.'/airline" method="post">';
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	$Stats = new Stats();
23 23
 	$airline_names = $Stats->getAllAirlineNames();
24 24
 	if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
25
-	foreach($airline_names as $airline_name)
25
+	foreach ($airline_names as $airline_name)
26 26
 	{
27
-		if($_GET['airline'] == $airline_name['airline_icao'])
27
+		if ($_GET['airline'] == $airline_name['airline_icao'])
28 28
 		{
29 29
 			print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
30 30
 		} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	include('airline-sub-menu.php');
63 63
 	print '<div class="column">';
64 64
 	print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
65
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
65
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>';
66 66
 	$airport_country_array = $Spotter->countAllArrivalAirportCountriesByAirline($airline);
67 67
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
68 68
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
71 71
 	print 'var series = [';
72 72
 	$country_data = '';
73
-	foreach($airport_country_array as $airport_item)
73
+	foreach ($airport_country_array as $airport_item)
74 74
 	{
75 75
 		$country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
76 76
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		print '</thead>';
119 119
 		print '<tbody>';
120 120
 		$i = 1;
121
-		foreach($airport_country_array as $airport_item)
121
+		foreach ($airport_country_array as $airport_item)
122 122
 		{
123 123
 			print '<tr>';
124 124
 			print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.