Completed
Push — master ( c226f4...93b000 )
by Yannick
22:23 queued 15:29
created
require/class.SpotterLive.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$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";
39
+						$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 40
 					} else {
41
-						$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";
41
+						$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 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$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";
47
+					$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 48
 				} else {
49
-					$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";
49
+					$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 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$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";
54
+					$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 55
 				} else {
56
-					$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";
56
+					$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 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$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";
61
+					$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 62
 				} else {
63
-					$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";
63
+					$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 64
 				}
65 65
 			}
66 66
 			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']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$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";
68
+					$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 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$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";
74
+				$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 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$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 ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$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";
84
+			$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 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$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";
116
+			$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";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} else {
169 169
 			$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;
170 170
 		}
171
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
171
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
172 172
 
173 173
 		return $spotter_array;
174 174
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		global $globalDBdriver, $globalLiveInterval;
185 185
 		date_default_timezone_set('UTC');
186 186
 
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 
189 189
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190 190
 		if ($globalDBdriver == 'mysql') {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			$query  = 'SELECT a.aircraft_shadow, 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 
196 196
 			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 LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
197 197
 */
198
-			$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 
198
+			$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 
199 199
 			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";
200 200
 
201 201
 //			$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 FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			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 LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
211 211
 */
212 212
 
213
-			$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 
213
+			$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 
214 214
 			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'";
215 215
 
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		global $globalDBdriver, $globalLiveInterval;
242 242
 		date_default_timezone_set('UTC');
243 243
 
244
-		$filter_query = $this->getFilter($filter,true,true);
244
+		$filter_query = $this->getFilter($filter, true, true);
245 245
 
246 246
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
247 247
 		if ($globalDBdriver == 'mysql') {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
251 251
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
252 252
 */
253
-			$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 
253
+			$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 
254 254
 			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' 
255 255
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
256 256
                 } else {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
260 260
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
261 261
 */
262
-			$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 
262
+			$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 
263 263
 			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' 
264 264
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
265 265
 //			echo $query;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	public function getLiveSpotterCount($filter = array())
286 286
 	{
287 287
 		global $globalDBdriver, $globalLiveInterval;
288
-		$filter_query = $this->getFilter($filter,true,true);
288
+		$filter_query = $this->getFilter($filter, true, true);
289 289
 
290 290
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291 291
 		if ($globalDBdriver == 'mysql') {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		try {
299 299
 			$sth = $this->db->prepare($query);
300 300
 			$sth->execute();
301
-		} catch(PDOException $e) {
301
+		} catch (PDOException $e) {
302 302
 			echo $e->getMessage();
303 303
 			die;
304 304
 		}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		$filter_query = $this->getFilter($filter);
322 322
 
323 323
 		if (is_array($coord)) {
324
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
327
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
328 328
 		} else return array();
329 329
 		if ($globalDBdriver == 'mysql') {
330 330
 			$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;
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 		global $globalDBdriver, $globalLiveInterval;
348 348
 		$Spotter = new Spotter($this->db);
349 349
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
350
-		$filter_query = $this->getFilter($filter,true,true);
350
+		$filter_query = $this->getFilter($filter, true, true);
351 351
 
352 352
 		if (is_array($coord)) {
353
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
354
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
353
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
354
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
355
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
356
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
357 357
 		} else return array();
358 358
 		if ($globalDBdriver == 'mysql') {
359 359
 			$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 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 			) s on spotter_live.flightaware_id = s.flightaware_id 
367 367
 			AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
368 368
 		} else {
369
-			$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 
369
+			$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 
370 370
 			FROM spotter_live 
371 371
 			INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
372 372
 			    FROM spotter_live l 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 		try {
381 381
 			$sth = $this->db->prepare($query);
382 382
 			$sth->execute();
383
-		} catch(PDOException $e) {
383
+		} catch (PDOException $e) {
384 384
 			echo $e->getMessage();
385 385
 			die;
386 386
 		}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
                 if ($interval == '1m')
430 430
                 {
431 431
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
432
-                } else if ($interval == '15m'){
432
+                } else if ($interval == '15m') {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
434 434
                 } 
435 435
             }
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
438 438
         }
439 439
 
440
-                $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 
440
+                $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 
441 441
                    WHERE spotter_live.latitude <> '' 
442 442
                                    AND spotter_live.longitude <> '' 
443 443
                    ".$additional_query."
444 444
                    HAVING distance < :radius  
445 445
                                    ORDER BY distance";
446 446
 
447
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
447
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
448 448
 
449 449
                 return $spotter_array;
450 450
         }
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
 		date_default_timezone_set('UTC');
463 463
 
464 464
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
465
-                $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';
465
+                $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';
466 466
 
467
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
467
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
468 468
 
469 469
 		return $spotter_array;
470 470
 	}
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
 	* @return Array the spotter information
476 476
 	*
477 477
 	*/
478
-	public function getDateLiveSpotterDataByIdent($ident,$date)
478
+	public function getDateLiveSpotterDataByIdent($ident, $date)
479 479
 	{
480 480
 		$Spotter = new Spotter($this->db);
481 481
 		date_default_timezone_set('UTC');
482 482
 
483 483
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
484
-                $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';
484
+                $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';
485 485
 
486
-                $date = date('c',$date);
487
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
486
+                $date = date('c', $date);
487
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
488 488
 
489 489
 		return $spotter_array;
490 490
 	}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 		date_default_timezone_set('UTC');
502 502
 
503 503
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
504
-                $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';
504
+                $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';
505 505
 
506
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
506
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
507 507
 
508 508
 		return $spotter_array;
509 509
 	}
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	* @return Array the spotter information
515 515
 	*
516 516
 	*/
517
-	public function getDateLiveSpotterDataById($id,$date)
517
+	public function getDateLiveSpotterDataById($id, $date)
518 518
 	{
519 519
 		$Spotter = new Spotter($this->db);
520 520
 		date_default_timezone_set('UTC');
521 521
 
522 522
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
523
-                $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';
524
-                $date = date('c',$date);
525
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
523
+                $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';
524
+                $date = date('c', $date);
525
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
526 526
 
527 527
 		return $spotter_array;
528 528
 	}
@@ -539,13 +539,13 @@  discard block
 block discarded – undo
539 539
 		date_default_timezone_set('UTC');
540 540
 
541 541
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
542
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
542
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
543 543
 
544 544
     		try {
545 545
 			
546 546
 			$sth = $this->db->prepare($query);
547 547
 			$sth->execute(array(':ident' => $ident));
548
-		} catch(PDOException $e) {
548
+		} catch (PDOException $e) {
549 549
 			echo $e->getMessage();
550 550
 			die;
551 551
 		}
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	* @return Array the spotter information
561 561
 	*
562 562
 	*/
563
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
563
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
564 564
 	{
565 565
 		global $globalDBdriver, $globalLiveInterval;
566 566
 		date_default_timezone_set('UTC');
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		try {
580 580
 			$sth = $this->db->prepare($query);
581 581
 			$sth->execute(array(':id' => $id));
582
-		} catch(PDOException $e) {
582
+		} catch (PDOException $e) {
583 583
 			echo $e->getMessage();
584 584
 			die;
585 585
 		}
@@ -597,12 +597,12 @@  discard block
 block discarded – undo
597 597
 	{
598 598
 		date_default_timezone_set('UTC');
599 599
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
600
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
600
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
601 601
     		try {
602 602
 			
603 603
 			$sth = $this->db->prepare($query);
604 604
 			$sth->execute(array(':ident' => $ident));
605
-		} catch(PDOException $e) {
605
+		} catch (PDOException $e) {
606 606
 			echo $e->getMessage();
607 607
 			die;
608 608
 		}
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 			
633 633
 			$sth = $this->db->prepare($query);
634 634
 			$sth->execute();
635
-		} catch(PDOException $e) {
635
+		} catch (PDOException $e) {
636 636
 			return "error";
637 637
 		}
638 638
 
@@ -655,14 +655,14 @@  discard block
 block discarded – undo
655 655
 				
656 656
 				$sth = $this->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error";
660 660
 			}
661 661
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
662 662
                         $i = 0;
663
-                        $j =0;
663
+                        $j = 0;
664 664
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
665
-			foreach($all as $row)
665
+			foreach ($all as $row)
666 666
 			{
667 667
 				$i++;
668 668
 				$j++;
@@ -670,9 +670,9 @@  discard block
 block discarded – undo
670 670
 					if ($globalDebug) echo ".";
671 671
 				    	try {
672 672
 						
673
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
673
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
674 674
 						$sth->execute();
675
-					} catch(PDOException $e) {
675
+					} catch (PDOException $e) {
676 676
 						return "error";
677 677
 					}
678 678
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 			if ($i > 0) {
684 684
     				try {
685 685
 					
686
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
686
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
687 687
 					$sth->execute();
688
-				} catch(PDOException $e) {
688
+				} catch (PDOException $e) {
689 689
 					return "error";
690 690
 				}
691 691
 			}
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 				
699 699
 				$sth = $this->db->prepare($query);
700 700
 				$sth->execute();
701
-			} catch(PDOException $e) {
701
+			} catch (PDOException $e) {
702 702
 				return "error";
703 703
 			}
704 704
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 	public function deleteLiveSpotterDataByIdent($ident)
747 747
 	{
748 748
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
749
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
749
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
750 750
         
751 751
     		try {
752 752
 			
753 753
 			$sth = $this->db->prepare($query);
754 754
 			$sth->execute(array(':ident' => $ident));
755
-		} catch(PDOException $e) {
755
+		} catch (PDOException $e) {
756 756
 			return "error";
757 757
 		}
758 758
 
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	public function deleteLiveSpotterDataById($id)
769 769
 	{
770 770
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
771
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
771
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
772 772
         
773 773
     		try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':id' => $id));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			return "error";
779 779
 		}
780 780
 
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 	{
793 793
 		global $globalDBdriver, $globalTimezone;
794 794
 		if ($globalDBdriver == 'mysql') {
795
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
795
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
796 796
 				WHERE spotter_live.ident = :ident 
797 797
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
798 798
 				AND spotter_live.date < UTC_TIMESTAMP()';
799 799
 			$query_data = array(':ident' => $ident);
800 800
 		} else {
801
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
801
+			$query = "SELECT spotter_live.ident FROM spotter_live 
802 802
 				WHERE spotter_live.ident = :ident 
803 803
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
804 804
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 		
808 808
 		$sth = $this->db->prepare($query);
809 809
 		$sth->execute($query_data);
810
-		$ident_result='';
811
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
810
+		$ident_result = '';
811
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
812 812
 		{
813 813
 			$ident_result = $row['ident'];
814 814
 		}
@@ -825,13 +825,13 @@  discard block
 block discarded – undo
825 825
 	{
826 826
 		global $globalDBdriver, $globalTimezone;
827 827
 		if ($globalDBdriver == 'mysql') {
828
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
828
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
829 829
 				WHERE spotter_live.ident = :ident 
830 830
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
831 831
 //				AND spotter_live.date < UTC_TIMESTAMP()";
832 832
 			$query_data = array(':ident' => $ident);
833 833
 		} else {
834
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
834
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
835 835
 				WHERE spotter_live.ident = :ident 
836 836
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
837 837
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 		
841 841
 		$sth = $this->db->prepare($query);
842 842
 		$sth->execute($query_data);
843
-		$ident_result='';
844
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
843
+		$ident_result = '';
844
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
845 845
 		{
846 846
 			$ident_result = $row['flightaware_id'];
847 847
 		}
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
 	{
859 859
 		global $globalDBdriver, $globalTimezone;
860 860
 		if ($globalDBdriver == 'mysql') {
861
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
861
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
862 862
 				WHERE spotter_live.flightaware_id = :id 
863 863
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
864 864
 //				AND spotter_live.date < UTC_TIMESTAMP()";
865 865
 			$query_data = array(':id' => $id);
866 866
 		} else {
867
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
867
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
868 868
 				WHERE spotter_live.flightaware_id = :id 
869 869
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
870 870
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 		
874 874
 		$sth = $this->db->prepare($query);
875 875
 		$sth->execute($query_data);
876
-		$ident_result='';
877
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
876
+		$ident_result = '';
877
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
878 878
 		{
879 879
 			$ident_result = $row['flightaware_id'];
880 880
 		}
@@ -891,13 +891,13 @@  discard block
 block discarded – undo
891 891
 	{
892 892
 		global $globalDBdriver, $globalTimezone;
893 893
 		if ($globalDBdriver == 'mysql') {
894
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
894
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
895 895
 				WHERE spotter_live.ModeS = :modes 
896 896
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
897 897
 //				AND spotter_live.date < UTC_TIMESTAMP()";
898 898
 			$query_data = array(':modes' => $modes);
899 899
 		} else {
900
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
900
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
901 901
 				WHERE spotter_live.ModeS = :modes 
902 902
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
903 903
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 		
907 907
 		$sth = $this->db->prepare($query);
908 908
 		$sth->execute($query_data);
909
-		$ident_result='';
910
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
909
+		$ident_result = '';
910
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
911 911
 		{
912 912
 			//$ident_result = $row['spotter_live_id'];
913 913
 			$ident_result = $row['flightaware_id'];
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	* @return String success or false
927 927
 	*
928 928
 	*/
929
-	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 = '')
929
+	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 = '')
930 930
 	{
931 931
 		global $globalURL, $globalArchive, $globalDebug;
932 932
 		$Common = new Common();
@@ -1019,26 +1019,26 @@  discard block
 block discarded – undo
1019 1019
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1020 1020
 
1021 1021
         
1022
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1023
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1024
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1025
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1026
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1027
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1028
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1029
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1030
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1031
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1032
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1033
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1034
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1035
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1036
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1037
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1038
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1039
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1040
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1041
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1022
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1023
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1024
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1025
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1026
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1027
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1028
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1029
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1030
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1031
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1032
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1033
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1034
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1035
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1036
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1037
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1038
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1039
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1040
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1041
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1042 1042
 
1043 1043
 		$airline_name = '';
1044 1044
 		$airline_icao = '';
@@ -1060,10 +1060,10 @@  discard block
 block discarded – undo
1060 1060
 		$arrival_airport_country = '';
1061 1061
 		
1062 1062
             	
1063
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1063
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1064
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1065
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1066
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1067 1067
 		
1068 1068
 		$query = '';
1069 1069
 		if ($globalArchive) {
@@ -1074,19 +1074,19 @@  discard block
 block discarded – undo
1074 1074
 		$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) 
1075 1075
 		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)';
1076 1076
 
1077
-		$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);
1077
+		$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);
1078 1078
 		try {
1079 1079
 			
1080 1080
 			$sth = $this->db->prepare($query);
1081 1081
 			$sth->execute($query_values);
1082 1082
 			$sth->closeCursor();
1083
-		} catch(PDOException $e) {
1083
+		} catch (PDOException $e) {
1084 1084
 			return "error : ".$e->getMessage();
1085 1085
 		}
1086 1086
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1087 1087
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1088 1088
 		    $SpotterArchive = new SpotterArchive($this->db);
1089
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1089
+		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1090 1090
 		    if ($globalDebug) echo $result.')';
1091 1091
 		}
1092 1092
 		return "success";
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
 	public function getOrderBy()
1097 1097
 	{
1098
-		$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"));
1098
+		$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"));
1099 1099
 		return $orderby;
1100 1100
 	}
1101 1101
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26 26
 	if (isset($filter[0]['source'])) {
27
-		$filters = array_merge($filters,$filter);
27
+		$filters = array_merge($filters, $filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32
-	foreach($filters as $flt) {
32
+	foreach ($filters as $flt) {
33 33
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35 35
 		    if (isset($flt['source'])) {
36
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37 37
 		    } else {
38
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39 39
 		    }
40 40
 		}
41 41
 	    }
42 42
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48 48
 	    }
49 49
 	    if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54 54
 		}
55 55
 	    }
56 56
 	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61 61
 		}
62 62
 	    }
63 63
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
65
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66 66
 		}
67 67
 	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70 70
 	    if ($filter['airlines'][0] != '') {
71
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
71
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72 72
 	    }
73 73
 	}
74 74
 	
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+	    $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85 85
 	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91 91
 	    $filter_query_date = '';
@@ -111,41 +111,41 @@  discard block
 block discarded – undo
111 111
 		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112 112
 		}
113 113
 	    }
114
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
114
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
118 118
 	if ($filter_query_where != '') {
119
-		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
119
+		$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123 123
     }
124 124
 
125 125
 	// Spotter_archive
126
-	public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
126
+	public function 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 = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
127 127
 		require_once(dirname(__FILE__).'/class.Spotter.php');
128 128
 		if ($over_country == '') {
129 129
 			$Spotter = new Spotter($this->db);
130
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
130
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
131 131
 			if (!empty($data_country)) $country = $data_country['iso2'];
132 132
 			else $country = '';
133 133
 		} else $country = $over_country;
134
-		if ($airline_type === NULL) $airline_type ='';
134
+		if ($airline_type === NULL) $airline_type = '';
135 135
 	
136 136
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
137 137
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
138 138
 
139 139
 		// Route is not added in spotter_archive
140
-		$query  = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
140
+		$query = "INSERT INTO spotter_archive (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, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
141 141
 		        VALUES (: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, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
142 142
 
143
-		$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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
143
+		$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_name' => $aircraft_name, ':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, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147 147
 			$sth->closeCursor();
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 		return "success";
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 
166 166
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167 167
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
171 171
 
172 172
                 return $spotter_array;
173 173
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
187 187
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188 188
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192 192
                   /*
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
203 203
 
204 204
                 return $spotter_array;
205 205
         }
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
         {
215 215
                 date_default_timezone_set('UTC');
216 216
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221 221
                 try {
222 222
                         $sth = $this->db->prepare($query);
223 223
                         $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
224
+                } catch (PDOException $e) {
225 225
                         echo $e->getMessage();
226 226
                         die;
227 227
                 }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         {
241 241
                 date_default_timezone_set('UTC');
242 242
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247 247
                 try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo $e->getMessage();
252 252
                         die;
253 253
                 }
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
                 date_default_timezone_set('UTC');
270 270
 
271 271
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
273 273
 
274 274
                 try {
275 275
                         $sth = $this->db->prepare($query);
276 276
                         $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
277
+                } catch (PDOException $e) {
278 278
                         echo $e->getMessage();
279 279
                         die;
280 280
                 }
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
                 date_default_timezone_set('UTC');
296 296
 
297 297
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
299 299
 
300 300
                 try {
301 301
                         $sth = $this->db->prepare($query);
302 302
                         $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
303
+                } catch (PDOException $e) {
304 304
                         echo $e->getMessage();
305 305
                         die;
306 306
                 }
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
                 date_default_timezone_set('UTC');
322 322
 
323 323
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326 326
                 try {
327 327
                         $sth = $this->db->prepare($query);
328 328
                         $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
329
+                } catch (PDOException $e) {
330 330
                         echo $e->getMessage();
331 331
                         die;
332 332
                 }
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
                 date_default_timezone_set('UTC');
349 349
 
350 350
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
351
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354 354
                 try {
355 355
                         $sth = $this->db->prepare($query);
356 356
                         $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
357
+                } catch (PDOException $e) {
358 358
                         echo $e->getMessage();
359 359
                         die;
360 360
                 }
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
         * @return Array the spotter information
372 372
         *
373 373
         */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
375 375
         {
376 376
     		$Spotter = new Spotter($this->db);
377 377
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
378
+                $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.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
381 381
 
382 382
                 return $spotter_array;
383 383
         }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 try {
391 391
                         $sth = $this->db->prepare($query);
392 392
                         $sth->execute();
393
-                } catch(PDOException $e) {
393
+                } catch (PDOException $e) {
394 394
                         echo $e->getMessage();
395 395
                         die;
396 396
                 }
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
         * @return Array the spotter information
403 403
         *
404 404
         */
405
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
406 406
         {
407 407
                 global $globalDBdriver, $globalLiveInterval;
408 408
                 date_default_timezone_set('UTC');
409 409
 
410 410
                 $filter_query = '';
411 411
                 if (isset($filter['source']) && !empty($filter['source'])) {
412
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
413 413
                 }
414 414
                 // Use spotter_output also ?
415 415
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
417 417
                 }
418 418
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
420 420
                 }
421 421
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
423 423
                 }
424 424
 
425 425
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
439 439
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
440 440
 */
441
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
441
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
442 442
 				    FROM spotter_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
444 444
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY flightaware_id';
446 446
                 } else {
447 447
                         //$query  = '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, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
448
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
448
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, 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, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
449 449
                         	    FROM spotter_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
451 451
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 try {
456 456
                         $sth = $this->db->prepare($query);
457 457
                         $sth->execute();
458
-                } catch(PDOException $e) {
458
+                } catch (PDOException $e) {
459 459
                         echo $e->getMessage();
460 460
                         die;
461 461
                 }
@@ -470,24 +470,24 @@  discard block
 block discarded – undo
470 470
         * @return Array the spotter information
471 471
         *
472 472
         */
473
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
474 474
         {
475 475
                 global $globalDBdriver, $globalLiveInterval;
476 476
                 date_default_timezone_set('UTC');
477 477
 
478 478
                 $filter_query = '';
479 479
                 if (isset($filter['source']) && !empty($filter['source'])) {
480
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
481 481
                 }
482 482
                 // Should use spotter_output also ?
483 483
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
484
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
484
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
485 485
                 }
486 486
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
487 487
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
488 488
                 }
489 489
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
490
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
491 491
                 }
492 492
 
493 493
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                     		    FROM spotter_archive 
498 498
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
499 499
 			*/
500
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
500
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
501 501
 				    FROM spotter_archive_output 
502 502
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
503 503
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
513 513
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
514 514
                         */
515
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
515
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
516 516
                         	    FROM spotter_archive_output 
517 517
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
518 518
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 try {
525 525
                         $sth = $this->db->prepare($query);
526 526
                         $sth->execute();
527
-                } catch(PDOException $e) {
527
+                } catch (PDOException $e) {
528 528
                         echo $e->getMessage();
529 529
                         die;
530 530
                 }
@@ -539,23 +539,23 @@  discard block
 block discarded – undo
539 539
         * @return Array the spotter information
540 540
         *
541 541
         */
542
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
543 543
         {
544 544
                 global $globalDBdriver, $globalLiveInterval;
545 545
                 date_default_timezone_set('UTC');
546 546
 
547 547
                 $filter_query = '';
548 548
                 if (isset($filter['source']) && !empty($filter['source'])) {
549
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
550 550
                 }
551 551
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
552
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
552
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
553 553
                 }
554 554
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
555 555
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
556 556
                 }
557 557
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
558
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
559 559
                 }
560 560
 
561 561
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                 try {
571 571
                         $sth = $this->db->prepare($query);
572 572
                         $sth->execute();
573
-                } catch(PDOException $e) {
573
+                } catch (PDOException $e) {
574 574
                         echo $e->getMessage();
575 575
                         die;
576 576
                 }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     * @return Array the spotter information
591 591
     *
592 592
     */
593
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
593
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
594 594
     {
595 595
 	global $globalTimezone, $globalDBdriver;
596 596
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	        
613 613
 		$q_array = explode(" ", $q);
614 614
 		
615
-		foreach ($q_array as $q_item){
615
+		foreach ($q_array as $q_item) {
616 616
 		    $additional_query .= " AND (";
617 617
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
618 618
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($registration != "")
646 646
 	{
647
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($registration))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($aircraft_icao != "")
657 657
 	{
658
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($aircraft_icao))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($aircraft_manufacturer != "")
668 668
 	{
669
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($aircraft_manufacturer))
671 671
 	    {
672 672
 		return false;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	
688 688
 	if ($airline_icao != "")
689 689
 	{
690
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
691 691
 	    if (!is_string($airline_icao))
692 692
 	    {
693 693
 		return false;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	
699 699
 	if ($airline_country != "")
700 700
 	{
701
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
702 702
 	    if (!is_string($airline_country))
703 703
 	    {
704 704
 		return false;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	
710 710
 	if ($airline_type != "")
711 711
 	{
712
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
713 713
 	    if (!is_string($airline_type))
714 714
 	    {
715 715
 		return false;
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 	
732 732
 	if ($airport != "")
733 733
 	{
734
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
735 735
 	    if (!is_string($airport))
736 736
 	    {
737 737
 		return false;
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 	
743 743
 	if ($airport_country != "")
744 744
 	{
745
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
746 746
 	    if (!is_string($airport_country))
747 747
 	    {
748 748
 		return false;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
     
754 754
 	if ($callsign != "")
755 755
 	{
756
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
757 757
 	    if (!is_string($callsign))
758 758
 	    {
759 759
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		$translate = $Translation->ident2icao($callsign);
762 762
 		if ($translate != $callsign) {
763 763
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
764
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
764
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
765 765
 		} else {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
767 767
 		}
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 
771 771
 	if ($owner != "")
772 772
 	{
773
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
774 774
 	    if (!is_string($owner))
775 775
 	    {
776 776
 		return false;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
 	if ($pilot_name != "")
783 783
 	{
784
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
785 785
 	    if (!is_string($pilot_name))
786 786
 	    {
787 787
 		return false;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	
793 793
 	if ($pilot_id != "")
794 794
 	{
795
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
796 796
 	    if (!is_string($pilot_id))
797 797
 	    {
798 798
 		return false;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	
804 804
 	if ($departure_airport_route != "")
805 805
 	{
806
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
807 807
 	    if (!is_string($departure_airport_route))
808 808
 	    {
809 809
 		return false;
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 	
815 815
 	if ($arrival_airport_route != "")
816 816
 	{
817
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
818 818
 	    if (!is_string($arrival_airport_route))
819 819
 	    {
820 820
 		return false;
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	{
828 828
 	    $altitude_array = explode(",", $altitude);
829 829
 	    
830
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
831
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
832 832
 	    
833 833
 
834 834
 	    if ($altitude_array[1] != "")
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	{
847 847
 	    $date_array = explode(",", $date_posted);
848 848
 	    
849
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
850
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
849
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
850
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
851 851
 	    
852 852
 	    if ($globalTimezone != '') {
853 853
 		date_default_timezone_set($globalTimezone);
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	{
880 880
 	    $limit_array = explode(",", $limit);
881 881
 	    
882
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
883
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
882
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
883
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
884 884
 	    
885 885
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
886 886
 	    {
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	
892 892
 
893 893
 	if ($origLat != "" && $origLon != "" && $dist != "") {
894
-		$dist = number_format($dist*0.621371,2,'.','');
895
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
894
+		$dist = number_format($dist*0.621371, 2, '.', '');
895
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
896 896
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
897 897
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
898 898
 	} else {
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
910 910
 		}
911 911
 
912
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
912
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
913 913
 		    WHERE spotter_archive_output.ident <> '' 
914 914
 		    ".$additional_query."
915 915
 		    ".$filter_query.$orderby_query;
916 916
 	}
917
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
917
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
918 918
 
919 919
 	return $spotter_array;
920 920
     }
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                 try {
932 932
                         $sth = $this->db->prepare($query);
933 933
                         $sth->execute();
934
-                } catch(PDOException $e) {
934
+                } catch (PDOException $e) {
935 935
                         return "error";
936 936
                 }
937 937
 	}
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	{
969 969
 	    $limit_array = explode(",", $limit);
970 970
 	    
971
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
972
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
971
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
972
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
973 973
 	    
974 974
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
975 975
 	    {
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	$query_values = array();
1011 1011
 	$limit_query = '';
1012 1012
 	$additional_query = '';
1013
-	$filter_query = $this->getFilter($filter,true,true);
1013
+	$filter_query = $this->getFilter($filter, true, true);
1014 1014
 	
1015 1015
 	if ($owner != "")
1016 1016
 	{
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	{
1028 1028
 	    $limit_array = explode(",", $limit);
1029 1029
 	    
1030
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1031
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1030
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1031
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1032 1032
 	    
1033 1033
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1034 1034
 	    {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	$query_values = array();
1069 1069
 	$limit_query = '';
1070 1070
 	$additional_query = '';
1071
-	$filter_query = $this->getFilter($filter,true,true);
1071
+	$filter_query = $this->getFilter($filter, true, true);
1072 1072
 	
1073 1073
 	if ($pilot != "")
1074 1074
 	{
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	{
1081 1081
 	    $limit_array = explode(",", $limit);
1082 1082
 	    
1083
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1084
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1083
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1084
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1085 1085
 	    
1086 1086
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1087 1087
 	    {
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
     * @return Array the airline country list
1112 1112
     *
1113 1113
     */
1114
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1115 1115
     {
1116 1116
 	global $globalDBdriver;
1117 1117
 	/*
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 	$flight_array = array();
1141 1141
 	$temp_array = array();
1142 1142
         
1143
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1143
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1144 1144
 	{
1145 1145
 	    $temp_array['flight_count'] = $row['nb'];
1146 1146
 	    $temp_array['flight_country'] = $row['name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
     * @return Array the airline country list
1158 1158
     *
1159 1159
     */
1160
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1161 1161
     {
1162 1162
 	global $globalDBdriver;
1163 1163
 	/*
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	$flight_array = array();
1187 1187
 	$temp_array = array();
1188 1188
         
1189
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1190 1190
 	{
1191 1191
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1192 1192
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * @return Array the spotter information
1205 1205
     *
1206 1206
     */
1207
-    public function getDateArchiveSpotterDataById($id,$date)
1207
+    public function getDateArchiveSpotterDataById($id, $date)
1208 1208
     {
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1212
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
-	$date = date('c',$date);
1214
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1212
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1213
+	$date = date('c', $date);
1214
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1215 1215
 	return $spotter_array;
1216 1216
     }
1217 1217
 
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
     * @return Array the spotter information
1222 1222
     *
1223 1223
     */
1224
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1225 1225
     {
1226 1226
 	$Spotter = new Spotter($this->db);
1227 1227
 	date_default_timezone_set('UTC');
1228 1228
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1229
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1230
-	$date = date('c',$date);
1231
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1229
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1230
+	$date = date('c', $date);
1231
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1232 1232
 	return $spotter_array;
1233 1233
     }
1234 1234
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
     * @return Array the spotter information
1239 1239
     *
1240 1240
     */
1241
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1242 1242
     {
1243 1243
 	global $global_query;
1244 1244
 	$Spotter = new Spotter();
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 	$query_values = array();
1247 1247
 	$limit_query = '';
1248 1248
 	$additional_query = '';
1249
-	$filter_query = $this->getFilter($filters,true,true);
1249
+	$filter_query = $this->getFilter($filters, true, true);
1250 1250
 	
1251 1251
 	if ($airport != "")
1252 1252
 	{
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	{
1264 1264
 	    $limit_array = explode(",", $limit);
1265 1265
 	    
1266
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1267
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1266
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1267
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1268 1268
 	    
1269 1269
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1270 1270
 	    {
Please login to merge, or discard this patch.