Completed
Push — master ( 1a000c...b7b4dc )
by Yannick
67:34 queued 34:03
created
require/class.SpotterLive.php 1 patch
Spacing   +148 added lines, -148 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;
@@ -475,26 +475,26 @@  discard block
 block discarded – undo
475 475
 	*/
476 476
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
477 477
 	{
478
-		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
478
+		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
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 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
515 515
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
516 516
 				*/
517
-				$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
+				$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 
518 518
 				FROM spotter_live 
519 519
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
520 520
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 				) s on spotter_live.flightaware_id = s.flightaware_id 
534 534
 				AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' ORDER BY date DESC";
535 535
 				*/
536
-				$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 
536
+				$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 
537 537
 				FROM spotter_live 
538 538
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
539 539
 				    FROM spotter_live l 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		try {
552 552
 			$sth = $this->db->prepare($query);
553 553
 			$sth->execute();
554
-		} catch(PDOException $e) {
554
+		} catch (PDOException $e) {
555 555
 			echo $e->getMessage();
556 556
 			die;
557 557
 		}
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
                 if ($interval == '1m')
601 601
                 {
602 602
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
603
-                } else if ($interval == '15m'){
603
+                } else if ($interval == '15m') {
604 604
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
605 605
                 } 
606 606
             }
@@ -608,14 +608,14 @@  discard block
 block discarded – undo
608 608
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
609 609
         }
610 610
 
611
-                $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 
611
+                $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 
612 612
                    WHERE spotter_live.latitude <> '' 
613 613
                                    AND spotter_live.longitude <> '' 
614 614
                    ".$additional_query."
615 615
                    HAVING distance < :radius  
616 616
                                    ORDER BY distance";
617 617
 
618
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
618
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
619 619
 
620 620
                 return $spotter_array;
621 621
         }
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 		date_default_timezone_set('UTC');
634 634
 
635 635
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
636
-                $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';
636
+                $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';
637 637
 
638
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
638
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
639 639
 
640 640
 		return $spotter_array;
641 641
 	}
@@ -646,16 +646,16 @@  discard block
 block discarded – undo
646 646
 	* @return Array the spotter information
647 647
 	*
648 648
 	*/
649
-	public function getDateLiveSpotterDataByIdent($ident,$date)
649
+	public function getDateLiveSpotterDataByIdent($ident, $date)
650 650
 	{
651 651
 		$Spotter = new Spotter($this->db);
652 652
 		date_default_timezone_set('UTC');
653 653
 
654 654
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
655
-                $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';
655
+                $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';
656 656
 
657
-                $date = date('c',$date);
658
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
657
+                $date = date('c', $date);
658
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
659 659
 
660 660
 		return $spotter_array;
661 661
 	}
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 		$Spotter = new Spotter($this->db);
672 672
 		date_default_timezone_set('UTC');
673 673
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
674
-		$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';
675
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
674
+		$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';
675
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
676 676
 		return $spotter_array;
677 677
 	}
678 678
 
@@ -682,15 +682,15 @@  discard block
 block discarded – undo
682 682
 	* @return Array the spotter information
683 683
 	*
684 684
 	*/
685
-	public function getDateLiveSpotterDataById($id,$date)
685
+	public function getDateLiveSpotterDataById($id, $date)
686 686
 	{
687 687
 		$Spotter = new Spotter($this->db);
688 688
 		date_default_timezone_set('UTC');
689 689
 
690 690
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
691
-		$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';
692
-		$date = date('c',$date);
693
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
691
+		$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';
692
+		$date = date('c', $date);
693
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
694 694
 		return $spotter_array;
695 695
 	}
696 696
 
@@ -706,13 +706,13 @@  discard block
 block discarded – undo
706 706
 		date_default_timezone_set('UTC');
707 707
 
708 708
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
709
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
709
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
710 710
 
711 711
     		try {
712 712
 			
713 713
 			$sth = $this->db->prepare($query);
714 714
 			$sth->execute(array(':ident' => $ident));
715
-		} catch(PDOException $e) {
715
+		} catch (PDOException $e) {
716 716
 			echo $e->getMessage();
717 717
 			die;
718 718
 		}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	* @return Array the spotter information
728 728
 	*
729 729
 	*/
730
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
730
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
731 731
 	{
732 732
 		global $globalDBdriver, $globalLiveInterval;
733 733
 		date_default_timezone_set('UTC');
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 		try {
747 747
 			$sth = $this->db->prepare($query);
748 748
 			$sth->execute(array(':id' => $id));
749
-		} catch(PDOException $e) {
749
+		} catch (PDOException $e) {
750 750
 			echo $e->getMessage();
751 751
 			die;
752 752
 		}
@@ -764,12 +764,12 @@  discard block
 block discarded – undo
764 764
 	{
765 765
 		date_default_timezone_set('UTC');
766 766
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
767
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
767
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
768 768
     		try {
769 769
 			
770 770
 			$sth = $this->db->prepare($query);
771 771
 			$sth->execute(array(':ident' => $ident));
772
-		} catch(PDOException $e) {
772
+		} catch (PDOException $e) {
773 773
 			echo $e->getMessage();
774 774
 			die;
775 775
 		}
@@ -799,7 +799,7 @@  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
 
@@ -822,14 +822,14 @@  discard block
 block discarded – undo
822 822
 				
823 823
 				$sth = $this->db->prepare($query);
824 824
 				$sth->execute();
825
-			} catch(PDOException $e) {
825
+			} catch (PDOException $e) {
826 826
 				return "error";
827 827
 			}
828 828
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
829 829
                         $i = 0;
830
-                        $j =0;
830
+                        $j = 0;
831 831
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
832
-			foreach($all as $row)
832
+			foreach ($all as $row)
833 833
 			{
834 834
 				$i++;
835 835
 				$j++;
@@ -837,9 +837,9 @@  discard block
 block discarded – undo
837 837
 					if ($globalDebug) echo ".";
838 838
 				    	try {
839 839
 						
840
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
840
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
841 841
 						$sth->execute();
842
-					} catch(PDOException $e) {
842
+					} catch (PDOException $e) {
843 843
 						return "error";
844 844
 					}
845 845
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -850,9 +850,9 @@  discard block
 block discarded – undo
850 850
 			if ($i > 0) {
851 851
     				try {
852 852
 					
853
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
853
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
854 854
 					$sth->execute();
855
-				} catch(PDOException $e) {
855
+				} catch (PDOException $e) {
856 856
 					return "error";
857 857
 				}
858 858
 			}
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 				
866 866
 				$sth = $this->db->prepare($query);
867 867
 				$sth->execute();
868
-			} catch(PDOException $e) {
868
+			} catch (PDOException $e) {
869 869
 				return "error";
870 870
 			}
871 871
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -913,13 +913,13 @@  discard block
 block discarded – undo
913 913
 	public function deleteLiveSpotterDataByIdent($ident)
914 914
 	{
915 915
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
916
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
916
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
917 917
         
918 918
     		try {
919 919
 			
920 920
 			$sth = $this->db->prepare($query);
921 921
 			$sth->execute(array(':ident' => $ident));
922
-		} catch(PDOException $e) {
922
+		} catch (PDOException $e) {
923 923
 			return "error";
924 924
 		}
925 925
 
@@ -935,13 +935,13 @@  discard block
 block discarded – undo
935 935
 	public function deleteLiveSpotterDataById($id)
936 936
 	{
937 937
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
938
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
938
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
939 939
         
940 940
     		try {
941 941
 			
942 942
 			$sth = $this->db->prepare($query);
943 943
 			$sth->execute(array(':id' => $id));
944
-		} catch(PDOException $e) {
944
+		} catch (PDOException $e) {
945 945
 			return "error";
946 946
 		}
947 947
 
@@ -959,13 +959,13 @@  discard block
 block discarded – undo
959 959
 	{
960 960
 		global $globalDBdriver, $globalTimezone;
961 961
 		if ($globalDBdriver == 'mysql') {
962
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
962
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
963 963
 				WHERE spotter_live.ident = :ident 
964 964
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
965 965
 				AND spotter_live.date < UTC_TIMESTAMP()';
966 966
 			$query_data = array(':ident' => $ident);
967 967
 		} else {
968
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
968
+			$query = "SELECT spotter_live.ident FROM spotter_live 
969 969
 				WHERE spotter_live.ident = :ident 
970 970
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
971 971
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
 		
975 975
 		$sth = $this->db->prepare($query);
976 976
 		$sth->execute($query_data);
977
-		$ident_result='';
978
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
977
+		$ident_result = '';
978
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
979 979
 		{
980 980
 			$ident_result = $row['ident'];
981 981
 		}
@@ -992,13 +992,13 @@  discard block
 block discarded – undo
992 992
 	{
993 993
 		global $globalDBdriver, $globalTimezone;
994 994
 		if ($globalDBdriver == 'mysql') {
995
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
995
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
996 996
 				WHERE spotter_live.ident = :ident 
997 997
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
998 998
 //				AND spotter_live.date < UTC_TIMESTAMP()";
999 999
 			$query_data = array(':ident' => $ident);
1000 1000
 		} else {
1001
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1001
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1002 1002
 				WHERE spotter_live.ident = :ident 
1003 1003
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '20 MINUTES'";
1004 1004
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
 		
1008 1008
 		$sth = $this->db->prepare($query);
1009 1009
 		$sth->execute($query_data);
1010
-		$ident_result='';
1011
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1010
+		$ident_result = '';
1011
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1012 1012
 		{
1013 1013
 			$ident_result = $row['flightaware_id'];
1014 1014
 		}
@@ -1025,13 +1025,13 @@  discard block
 block discarded – undo
1025 1025
 	{
1026 1026
 		global $globalDBdriver, $globalTimezone;
1027 1027
 		if ($globalDBdriver == 'mysql') {
1028
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1028
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1029 1029
 				WHERE spotter_live.flightaware_id = :id 
1030 1030
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
1031 1031
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1032 1032
 			$query_data = array(':id' => $id);
1033 1033
 		} else {
1034
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1034
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
1035 1035
 				WHERE spotter_live.flightaware_id = :id 
1036 1036
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
1037 1037
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -1040,8 +1040,8 @@  discard block
 block discarded – undo
1040 1040
 		
1041 1041
 		$sth = $this->db->prepare($query);
1042 1042
 		$sth->execute($query_data);
1043
-		$ident_result='';
1044
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1043
+		$ident_result = '';
1044
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1045 1045
 		{
1046 1046
 			$ident_result = $row['flightaware_id'];
1047 1047
 		}
@@ -1058,13 +1058,13 @@  discard block
 block discarded – undo
1058 1058
 	{
1059 1059
 		global $globalDBdriver, $globalTimezone;
1060 1060
 		if ($globalDBdriver == 'mysql') {
1061
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1061
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1062 1062
 				WHERE spotter_live.ModeS = :modes 
1063 1063
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 MINUTE)'; 
1064 1064
 //				AND spotter_live.date < UTC_TIMESTAMP()";
1065 1065
 			$query_data = array(':modes' => $modes);
1066 1066
 		} else {
1067
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1067
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
1068 1068
 				WHERE spotter_live.ModeS = :modes 
1069 1069
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 MINUTE'";
1070 1070
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 		
1074 1074
 		$sth = $this->db->prepare($query);
1075 1075
 		$sth->execute($query_data);
1076
-		$ident_result='';
1077
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1076
+		$ident_result = '';
1077
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1078 1078
 		{
1079 1079
 			//$ident_result = $row['spotter_live_id'];
1080 1080
 			$ident_result = $row['flightaware_id'];
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 				return array();
1100 1100
 			} else {
1101 1101
 				$q_array = explode(" ", $q);
1102
-				foreach ($q_array as $q_item){
1103
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1102
+				foreach ($q_array as $q_item) {
1103
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1104 1104
 					$additional_query .= " AND (";
1105 1105
 					$additional_query .= "(spotter_live.aircraft_icao like '%".$q_item."%') OR ";
1106 1106
 					$additional_query .= "(spotter_live.aircraft_name like '%".$q_item."%') OR ";
@@ -1115,11 +1115,11 @@  discard block
 block discarded – undo
1115 1115
 			}
1116 1116
 		}
1117 1117
 		if ($globalDBdriver == 'mysql') {
1118
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1118
+			$query = "SELECT spotter_live.* FROM spotter_live 
1119 1119
 			    WHERE spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
1120 1120
 			    AND spotter_live.date < UTC_TIMESTAMP()";
1121 1121
 		} else {
1122
-			$query  = "SELECT spotter_live.* FROM spotter_live 
1122
+			$query = "SELECT spotter_live.* FROM spotter_live 
1123 1123
 			    WHERE spotter_live.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
1124 1124
 			    AND spotter_live.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
1125 1125
 		}
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	* @return String success or false
1140 1140
 	*
1141 1141
 	*/
1142
-	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 = '')
1142
+	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 = '')
1143 1143
 	{
1144 1144
 		global $globalURL, $globalArchive, $globalDebug;
1145 1145
 		$Common = new Common();
@@ -1239,27 +1239,27 @@  discard block
 block discarded – undo
1239 1239
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1240 1240
 
1241 1241
         
1242
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1243
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1244
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1245
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1246
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1247
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1248
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1249
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1250
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1251
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1252
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1253
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1254
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1255
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1256
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1257
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1258
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1259
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1260
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1261
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1262
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1242
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1243
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1244
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1245
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1246
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1247
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1248
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1249
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1250
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1251
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1252
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1253
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1254
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1255
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1256
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1257
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1258
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1259
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1260
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1261
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1262
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1263 1263
 
1264 1264
 		$airline_name = '';
1265 1265
 		$airline_icao = '';
@@ -1281,10 +1281,10 @@  discard block
 block discarded – undo
1281 1281
 		$arrival_airport_country = '';
1282 1282
 		
1283 1283
             	
1284
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1285
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1286
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1287
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1284
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1285
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1286
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1287
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1288 1288
 		
1289 1289
 		$query = '';
1290 1290
 		if ($globalArchive) {
@@ -1295,19 +1295,19 @@  discard block
 block discarded – undo
1295 1295
 		$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) 
1296 1296
 		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)';
1297 1297
 
1298
-		$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);
1298
+		$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);
1299 1299
 		try {
1300 1300
 			
1301 1301
 			$sth = $this->db->prepare($query);
1302 1302
 			$sth->execute($query_values);
1303 1303
 			$sth->closeCursor();
1304
-		} catch(PDOException $e) {
1304
+		} catch (PDOException $e) {
1305 1305
 			return "error : ".$e->getMessage();
1306 1306
 		}
1307 1307
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1308 1308
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1309 1309
 		    $SpotterArchive = new SpotterArchive($this->db);
1310
-		    $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);
1310
+		    $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);
1311 1311
 		    if ($globalDebug) echo $result.')';
1312 1312
 		} elseif ($globalDebug && $putinarchive !== true) {
1313 1313
 			echo '(Not adding to archive)';
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 
1321 1321
 	public function getOrderBy()
1322 1322
 	{
1323
-		$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"));
1323
+		$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"));
1324 1324
 		return $orderby;
1325 1325
 	}
1326 1326
 
Please login to merge, or discard this patch.