Completed
Push — master ( 4ef644...1a000c )
by Yannick
37:19
created
require/class.SpotterLive.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '' && $flt['airlines'][0] != 'all') {
39 39
 					if (isset($flt['source'])) {
40
-						$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_live.flightaware_id";
40
+						$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_live.flightaware_id";
41 41
 					} else {
42
-						$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_live.flightaware_id";
42
+						$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_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$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'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$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'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$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'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$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_live.flightaware_id";
62
+					$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_live.flightaware_id";
63 63
 				} else {
64
-					$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_live.flightaware_id";
64
+					$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_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '' && $filter['airlines'][0] != 'all') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['blocked']) && $filter['blocked'] == true) {
88 88
 			$filter_query_join .= " INNER JOIN (SELECT callsign FROM aircraft_block) cblk ON cblk.callsign = spotter_live.ident";
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			if (count($filter['source']) == 1) {
92 92
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
93 93
 			} else {
94
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
94
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
95 95
 			}
96 96
 		}
97 97
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
125 125
 				}
126 126
 			}
127
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
127
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
128 128
 		}
129 129
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
130
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
131 131
 		}
132 132
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133 133
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
134 134
 		if ($filter_query_where != '') {
135
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
135
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
136 136
 		}
137 137
 		$filter_query = $filter_query_join.$filter_query_where;
138 138
 		return $filter_query;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 		if ($limit != '')
156 156
 		{
157 157
 			$limit_array = explode(',', $limit);
158
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
159
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
158
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
159
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
160 160
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
161 161
 			{
162 162
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		} else {
181 181
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query;
182 182
 		}
183
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
183
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
184 184
 
185 185
 		return $spotter_array;
186 186
 	}
@@ -195,30 +195,30 @@  discard block
 block discarded – undo
195 195
 	{
196 196
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
197 197
 		date_default_timezone_set('UTC');
198
-		$filter_query = $this->getFilter($filter,true,true);
198
+		$filter_query = $this->getFilter($filter, true, true);
199 199
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
200 200
 		if ($globalDBdriver == 'mysql') {
201 201
 			if (isset($globalArchive) && $globalArchive === TRUE) {
202 202
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
203 203
 			//	FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
204
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
204
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
205 205
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date AND'." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
206 206
 			} else {
207 207
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
208 208
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC";
209
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
209
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
210 210
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
211 211
 			}
212 212
 		} else {
213 213
 			if (isset($globalArchive) && $globalArchive === TRUE) {
214 214
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
215 215
 			//	FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
216
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
216
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
217 217
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND  spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
218 218
 			} else {
219 219
 			//	$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
220 220
 			//	FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
221
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
221
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
222 222
 				FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
223 223
 			}
224 224
 		}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		try {
230 230
 			$sth = $this->db->prepare($query);
231 231
 			$sth->execute();
232
-		} catch(PDOException $e) {
232
+		} catch (PDOException $e) {
233 233
 			echo $e->getMessage();
234 234
 			die;
235 235
 		}
@@ -243,20 +243,20 @@  discard block
 block discarded – undo
243 243
 	* @return Array the spotter information
244 244
 	*
245 245
 	*/
246
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false, $id = '')
246
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false, $id = '')
247 247
 	{
248 248
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
249 249
 		date_default_timezone_set('UTC');
250 250
 		$usecoord = false;
251 251
 		if (is_array($coord) && !empty($coord)) {
252
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
254
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
255
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
253
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
254
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
255
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
256 256
 			$usecoord = true;
257 257
 		}
258
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
259
-		$filter_query = $this->getFilter($filter,true,true);
258
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
259
+		$filter_query = $this->getFilter($filter, true, true);
260 260
 
261 261
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
262 262
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
269 269
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
270 270
 				*/
271
-				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
271
+				$query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
272 272
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id ";
273 273
 				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
274 274
 				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 				ORDER BY flightaware_id, date";
283 283
 				if ($limit) $query .= " LIMIT ".$globalMap3DAircraftsLimit;
284 284
 			} else {
285
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
285
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
286 286
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
287 287
 				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
288 288
 				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
299 299
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
300 300
                                */
301
-				$query  = "SELECT * FROM (
301
+				$query = "SELECT * FROM (
302 302
 				SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
303 303
 				FROM spotter_archive 
304 304
 				INNER JOIN (
305 305
 				    SELECT flightaware_id 
306 306
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
307
-				$query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
307
+				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
308 308
 				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
309 309
 				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
310 310
 				$query .= "UNION
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		try {
331 331
 			$sth = $this->db->prepare($query);
332 332
 			$sth->execute($query_values);
333
-		} catch(PDOException $e) {
333
+		} catch (PDOException $e) {
334 334
 			echo $e->getMessage();
335 335
 			die;
336 336
 		}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 	* @return Array the spotter information
345 345
 	*
346 346
 	*/
347
-	public function getMinLastLiveSpotterDataByID($id = '',$filter = array(), $limit = false)
347
+	public function getMinLastLiveSpotterDataByID($id = '', $filter = array(), $limit = false)
348 348
 	{
349 349
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
350 350
 		date_default_timezone_set('UTC');
351
-		$id = filter_var($id,FILTER_SANITIZE_STRING);
352
-		$filter_query = $this->getFilter($filter,true,true);
351
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
352
+		$filter_query = $this->getFilter($filter, true, true);
353 353
 
354 354
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
355 355
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -373,13 +373,13 @@  discard block
 block discarded – undo
373 373
 			}
374 374
 		} else {
375 375
 			if (isset($globalArchive) && $globalArchive === TRUE) {
376
-				$query  = "SELECT * FROM (
376
+				$query = "SELECT * FROM (
377 377
 				SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
378 378
 				FROM spotter_archive 
379 379
 				INNER JOIN (
380 380
 				    SELECT flightaware_id 
381 381
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
382
-				$query.= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
382
+				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
383 383
 				$query .= "UNION
384 384
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
385 385
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 		try {
400 400
 			$sth = $this->db->prepare($query);
401 401
 			$sth->execute($query_values);
402
-		} catch(PDOException $e) {
402
+		} catch (PDOException $e) {
403 403
 			echo $e->getMessage();
404 404
 			die;
405 405
 		}
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	public function getLiveSpotterCount($filter = array())
417 417
 	{
418 418
 		global $globalDBdriver, $globalLiveInterval;
419
-		$filter_query = $this->getFilter($filter,true,true);
419
+		$filter_query = $this->getFilter($filter, true, true);
420 420
 
421 421
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
422 422
 		if ($globalDBdriver == 'mysql') {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		try {
430 430
 			$sth = $this->db->prepare($query);
431 431
 			$sth->execute();
432
-		} catch(PDOException $e) {
432
+		} catch (PDOException $e) {
433 433
 			echo $e->getMessage();
434 434
 			die;
435 435
 		}
@@ -452,10 +452,10 @@  discard block
 block discarded – undo
452 452
 		$filter_query = $this->getFilter($filter);
453 453
 
454 454
 		if (is_array($coord)) {
455
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
456
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
457
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
458
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
455
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
456
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
457
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
458
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
459 459
 		} else return array();
460 460
 		if ($globalDBdriver == 'mysql') {
461 461
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -478,23 +478,23 @@  discard block
 block discarded – undo
478 478
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
479 479
 		$Spotter = new Spotter($this->db);
480 480
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
481
-		$filter_query = $this->getFilter($filter,true,true);
481
+		$filter_query = $this->getFilter($filter, true, true);
482 482
 
483 483
 		if (is_array($coord)) {
484
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
485
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
486
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
487
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
484
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
485
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
486
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
487
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
488 488
 		} else return array();
489 489
 		if ($globalDBdriver == 'mysql') {
490 490
 			if (isset($globalArchive) && $globalArchive === TRUE) {
491
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
491
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
492 492
 				FROM spotter_live 
493 493
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
494 494
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
495 495
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0 ORDER BY date DESC';
496 496
 			} else {
497
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
497
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
498 498
 				FROM spotter_live 
499 499
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
500 500
 				    FROM spotter_live l 
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
 			}
507 507
 		} else {
508 508
 			if (isset($globalArchive) && $globalArchive === TRUE) {
509
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
509
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
510 510
 				FROM spotter_live 
511 511
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
512 512
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
513 513
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
514 514
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
515 515
 			} else {
516
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
516
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
517 517
 				FROM spotter_live 
518 518
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
519 519
 				    FROM spotter_live l 
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
 		try {
529 529
 			$sth = $this->db->prepare($query);
530 530
 			$sth->execute();
531
-		} catch(PDOException $e) {
531
+		} catch (PDOException $e) {
532 532
 			echo $e->getMessage();
533 533
 			die;
534 534
 		}
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                 if ($interval == '1m')
578 578
                 {
579 579
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
580
-                } else if ($interval == '15m'){
580
+                } else if ($interval == '15m') {
581 581
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
582 582
                 } 
583 583
             }
@@ -585,14 +585,14 @@  discard block
 block discarded – undo
585 585
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
586 586
         }
587 587
 
588
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
588
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
589 589
                    WHERE spotter_live.latitude <> '' 
590 590
                                    AND spotter_live.longitude <> '' 
591 591
                    ".$additional_query."
592 592
                    HAVING distance < :radius  
593 593
                                    ORDER BY distance";
594 594
 
595
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
595
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
596 596
 
597 597
                 return $spotter_array;
598 598
         }
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
 		date_default_timezone_set('UTC');
611 611
 
612 612
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
613
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
613
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
614 614
 
615
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
615
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
616 616
 
617 617
 		return $spotter_array;
618 618
 	}
@@ -623,16 +623,16 @@  discard block
 block discarded – undo
623 623
 	* @return Array the spotter information
624 624
 	*
625 625
 	*/
626
-	public function getDateLiveSpotterDataByIdent($ident,$date)
626
+	public function getDateLiveSpotterDataByIdent($ident, $date)
627 627
 	{
628 628
 		$Spotter = new Spotter($this->db);
629 629
 		date_default_timezone_set('UTC');
630 630
 
631 631
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
632
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
632
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
633 633
 
634
-                $date = date('c',$date);
635
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
634
+                $date = date('c', $date);
635
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
636 636
 
637 637
 		return $spotter_array;
638 638
 	}
@@ -648,8 +648,8 @@  discard block
 block discarded – undo
648 648
 		$Spotter = new Spotter($this->db);
649 649
 		date_default_timezone_set('UTC');
650 650
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
651
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
652
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
651
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
652
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
653 653
 		return $spotter_array;
654 654
 	}
655 655
 
@@ -659,15 +659,15 @@  discard block
 block discarded – undo
659 659
 	* @return Array the spotter information
660 660
 	*
661 661
 	*/
662
-	public function getDateLiveSpotterDataById($id,$date)
662
+	public function getDateLiveSpotterDataById($id, $date)
663 663
 	{
664 664
 		$Spotter = new Spotter($this->db);
665 665
 		date_default_timezone_set('UTC');
666 666
 
667 667
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
668
-		$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
669
-		$date = date('c',$date);
670
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
668
+		$query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
669
+		$date = date('c', $date);
670
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
671 671
 		return $spotter_array;
672 672
 	}
673 673
 
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
 		date_default_timezone_set('UTC');
684 684
 
685 685
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
686
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
686
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
687 687
 
688 688
     		try {
689 689
 			
690 690
 			$sth = $this->db->prepare($query);
691 691
 			$sth->execute(array(':ident' => $ident));
692
-		} catch(PDOException $e) {
692
+		} catch (PDOException $e) {
693 693
 			echo $e->getMessage();
694 694
 			die;
695 695
 		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	* @return Array the spotter information
705 705
 	*
706 706
 	*/
707
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
707
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
708 708
 	{
709 709
 		global $globalDBdriver, $globalLiveInterval;
710 710
 		date_default_timezone_set('UTC');
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 		try {
724 724
 			$sth = $this->db->prepare($query);
725 725
 			$sth->execute(array(':id' => $id));
726
-		} catch(PDOException $e) {
726
+		} catch (PDOException $e) {
727 727
 			echo $e->getMessage();
728 728
 			die;
729 729
 		}
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 	{
742 742
 		date_default_timezone_set('UTC');
743 743
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
744
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
744
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
745 745
     		try {
746 746
 			
747 747
 			$sth = $this->db->prepare($query);
748 748
 			$sth->execute(array(':ident' => $ident));
749
-		} catch(PDOException $e) {
749
+		} catch (PDOException $e) {
750 750
 			echo $e->getMessage();
751 751
 			die;
752 752
 		}
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 			
777 777
 			$sth = $this->db->prepare($query);
778 778
 			$sth->execute();
779
-		} catch(PDOException $e) {
779
+		} catch (PDOException $e) {
780 780
 			return "error";
781 781
 		}
782 782
 
@@ -799,14 +799,14 @@  discard block
 block discarded – undo
799 799
 				
800 800
 				$sth = $this->db->prepare($query);
801 801
 				$sth->execute();
802
-			} catch(PDOException $e) {
802
+			} catch (PDOException $e) {
803 803
 				return "error";
804 804
 			}
805 805
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
806 806
                         $i = 0;
807
-                        $j =0;
807
+                        $j = 0;
808 808
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
809
-			foreach($all as $row)
809
+			foreach ($all as $row)
810 810
 			{
811 811
 				$i++;
812 812
 				$j++;
@@ -814,9 +814,9 @@  discard block
 block discarded – undo
814 814
 					if ($globalDebug) echo ".";
815 815
 				    	try {
816 816
 						
817
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
817
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
818 818
 						$sth->execute();
819
-					} catch(PDOException $e) {
819
+					} catch (PDOException $e) {
820 820
 						return "error";
821 821
 					}
822 822
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 			if ($i > 0) {
828 828
     				try {
829 829
 					
830
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
830
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
831 831
 					$sth->execute();
832
-				} catch(PDOException $e) {
832
+				} catch (PDOException $e) {
833 833
 					return "error";
834 834
 				}
835 835
 			}
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 				
843 843
 				$sth = $this->db->prepare($query);
844 844
 				$sth->execute();
845
-			} catch(PDOException $e) {
845
+			} catch (PDOException $e) {
846 846
 				return "error";
847 847
 			}
848 848
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -890,13 +890,13 @@  discard block
 block discarded – undo
890 890
 	public function deleteLiveSpotterDataByIdent($ident)
891 891
 	{
892 892
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
893
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
893
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
894 894
         
895 895
     		try {
896 896
 			
897 897
 			$sth = $this->db->prepare($query);
898 898
 			$sth->execute(array(':ident' => $ident));
899
-		} catch(PDOException $e) {
899
+		} catch (PDOException $e) {
900 900
 			return "error";
901 901
 		}
902 902
 
@@ -912,13 +912,13 @@  discard block
 block discarded – undo
912 912
 	public function deleteLiveSpotterDataById($id)
913 913
 	{
914 914
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
915
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
915
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
916 916
         
917 917
     		try {
918 918
 			
919 919
 			$sth = $this->db->prepare($query);
920 920
 			$sth->execute(array(':id' => $id));
921
-		} catch(PDOException $e) {
921
+		} catch (PDOException $e) {
922 922
 			return "error";
923 923
 		}
924 924
 
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
 	{
937 937
 		global $globalDBdriver, $globalTimezone;
938 938
 		if ($globalDBdriver == 'mysql') {
939
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
939
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
940 940
 				WHERE spotter_live.ident = :ident 
941 941
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
942 942
 				AND spotter_live.date < UTC_TIMESTAMP()';
943 943
 			$query_data = array(':ident' => $ident);
944 944
 		} else {
945
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
945
+			$query = "SELECT spotter_live.ident FROM spotter_live 
946 946
 				WHERE spotter_live.ident = :ident 
947 947
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
948 948
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 		
952 952
 		$sth = $this->db->prepare($query);
953 953
 		$sth->execute($query_data);
954
-		$ident_result='';
955
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
954
+		$ident_result = '';
955
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
956 956
 		{
957 957
 			$ident_result = $row['ident'];
958 958
 		}
@@ -969,13 +969,13 @@  discard block
 block discarded – undo
969 969
 	{
970 970
 		global $globalDBdriver, $globalTimezone;
971 971
 		if ($globalDBdriver == 'mysql') {
972
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
972
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
973 973
 				WHERE spotter_live.ident = :ident 
974 974
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
975 975
 //				AND spotter_live.date < UTC_TIMESTAMP()";
976 976
 			$query_data = array(':ident' => $ident);
977 977
 		} else {
978
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
978
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
979 979
 				WHERE spotter_live.ident = :ident 
980 980
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
981 981
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
 		
985 985
 		$sth = $this->db->prepare($query);
986 986
 		$sth->execute($query_data);
987
-		$ident_result='';
988
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
987
+		$ident_result = '';
988
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
989 989
 		{
990 990
 			$ident_result = $row['flightaware_id'];
991 991
 		}
@@ -1002,13 +1002,13 @@  discard block
 block discarded – undo
1002 1002
 	{
1003 1003
 		global $globalDBdriver, $globalTimezone;
1004 1004
 		if ($globalDBdriver == 'mysql') {
1005
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1005
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1006 1006
 				WHERE spotter_live.flightaware_id = :id 
1007 1007
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
1008 1008
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1009 1009
 			$query_data = array(':id' => $id);
1010 1010
 		} else {
1011
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1011
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1012 1012
 				WHERE spotter_live.flightaware_id = :id 
1013 1013
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
1014 1014
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
 		
1018 1018
 		$sth = $this->db->prepare($query);
1019 1019
 		$sth->execute($query_data);
1020
-		$ident_result='';
1021
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1020
+		$ident_result = '';
1021
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1022 1022
 		{
1023 1023
 			$ident_result = $row['flightaware_id'];
1024 1024
 		}
@@ -1035,13 +1035,13 @@  discard block
 block discarded – undo
1035 1035
 	{
1036 1036
 		global $globalDBdriver, $globalTimezone;
1037 1037
 		if ($globalDBdriver == 'mysql') {
1038
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1038
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1039 1039
 				WHERE spotter_live.ModeS = :modes 
1040 1040
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1041 1041
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1042 1042
 			$query_data = array(':modes' => $modes);
1043 1043
 		} else {
1044
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1044
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1045 1045
 				WHERE spotter_live.ModeS = :modes 
1046 1046
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
1047 1047
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 		
1051 1051
 		$sth = $this->db->prepare($query);
1052 1052
 		$sth->execute($query_data);
1053
-		$ident_result='';
1054
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1053
+		$ident_result = '';
1054
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1055 1055
 		{
1056 1056
 			//$ident_result = $row['spotter_live_id'];
1057 1057
 			$ident_result = $row['flightaware_id'];
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 				return array();
1077 1077
 			} else {
1078 1078
 				$q_array = explode(" ", $q);
1079
-				foreach ($q_array as $q_item){
1080
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1079
+				foreach ($q_array as $q_item) {
1080
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1081 1081
 					$additional_query .= " AND (";
1082 1082
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
1083 1083
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -1092,11 +1092,11 @@  discard block
 block discarded – undo
1092 1092
 			}
1093 1093
 		}
1094 1094
 		if ($globalDBdriver == 'mysql') {
1095
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1095
+			$query = "SELECT spotter_live.* FROM spotter_live 
1096 1096
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1097 1097
 			    AND spotter_live.date < UTC_TIMESTAMP()";
1098 1098
 		} else {
1099
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1099
+			$query = "SELECT spotter_live.* FROM spotter_live 
1100 1100
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1101 1101
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1102 1102
 		}
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	* @return String success or false
1117 1117
 	*
1118 1118
 	*/
1119
-	public function addLiveSpotterData($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 = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1119
+	public function addLiveSpotterData($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 = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
1120 1120
 	{
1121 1121
 		global $globalURL, $globalArchive, $globalDebug;
1122 1122
 		$Common = new Common();
@@ -1216,27 +1216,27 @@  discard block
 block discarded – undo
1216 1216
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1217 1217
 
1218 1218
         
1219
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1220
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1221
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1222
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1223
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1224
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1225
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1226
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1227
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1228
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1229
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1230
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1231
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1232
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1233
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1234
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1235
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1236
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1237
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1238
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1239
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1219
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1220
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1221
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1222
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1223
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1224
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1225
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1226
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1227
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1228
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1229
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1230
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1231
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1232
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1233
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1234
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1235
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1236
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1237
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1238
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1239
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1240 1240
 
1241 1241
 		$airline_name = '';
1242 1242
 		$airline_icao = '';
@@ -1258,10 +1258,10 @@  discard block
 block discarded – undo
1258 1258
 		$arrival_airport_country = '';
1259 1259
 		
1260 1260
             	
1261
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1262
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1263
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1264
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1261
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1262
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1263
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1264
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1265 1265
 		
1266 1266
 		$query = '';
1267 1267
 		if ($globalArchive) {
@@ -1272,19 +1272,19 @@  discard block
 block discarded – undo
1272 1272
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, 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, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1273 1273
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,: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,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1274 1274
 
1275
-		$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_shadow' => $aircraft_shadow,':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,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1275
+		$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_shadow' => $aircraft_shadow, ':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, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1276 1276
 		try {
1277 1277
 			
1278 1278
 			$sth = $this->db->prepare($query);
1279 1279
 			$sth->execute($query_values);
1280 1280
 			$sth->closeCursor();
1281
-		} catch(PDOException $e) {
1281
+		} catch (PDOException $e) {
1282 1282
 			return "error : ".$e->getMessage();
1283 1283
 		}
1284 1284
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1285 1285
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1286 1286
 		    $SpotterArchive = new SpotterArchive($this->db);
1287
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1287
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1288 1288
 		    if ($globalDebug) echo $result.')';
1289 1289
 		} elseif ($globalDebug && $putinarchive !== true) {
1290 1290
 			echo '(Not adding to archive)';
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 
1298 1298
 	public function getOrderBy()
1299 1299
 	{
1300
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1300
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1301 1301
 		return $orderby;
1302 1302
 	}
1303 1303
 
Please login to merge, or discard this patch.