Completed
Push — master ( 078d82...094023 )
by Yannick
06:07
created
require/class.SpotterLive.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -16,64 +16,64 @@  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;
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
-		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_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
36
+						$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'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
37 37
 					} else {
38
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
38
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.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_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
44
+					$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'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
45 45
 				} else {
46
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
46
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
47 47
 				}
48 48
 			}
49 49
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
50 50
 				if (isset($flt['source'])) {
51
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
51
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
52 52
 				}
53 53
 			}
54 54
 		}
55 55
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
56 56
 			if ($filter['airlines'][0] != '') {
57
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
57
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
58 58
 			}
59 59
 		}
60 60
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
61 61
 			$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 ";
62 62
 		}
63 63
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
64
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
64
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id";
65 65
 		}
66 66
 		if (isset($filter['source']) && !empty($filter['source'])) {
67
-			$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
67
+			$filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
68 68
 		}
69 69
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
70 70
 			$filter_query_where = " WHERE ident = '".$filter['ident']."'";
71 71
 		}
72 72
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
73 73
 			if ($filter_query_where == '') {
74
-				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+				$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 			} else {
76
-				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
76
+				$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
77 77
 			}
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 		if ($limit != '')
100 100
 		{
101 101
 			$limit_array = explode(',', $limit);
102
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
103
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
102
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
103
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
104 104
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
105 105
 			{
106 106
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		} else {
121 121
 			$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;
122 122
 		}
123
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
123
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
124 124
 
125 125
 		return $spotter_array;
126 126
 	}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		global $globalDBdriver, $globalLiveInterval;
137 137
 		date_default_timezone_set('UTC');
138 138
 
139
-		$filter_query = $this->getFilter($filter,true,true);
139
+		$filter_query = $this->getFilter($filter, true, true);
140 140
 
141 141
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
142 142
 		if ($globalDBdriver == 'mysql') {
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 //			$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, a.aircraft_shadow 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 INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
145 145
 //			$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 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;
146 146
 
147
-			$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 
147
+			$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 
148 148
 			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'";
149 149
 
150 150
 //			$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;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '30 SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
155 155
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE NOW() AT TIME ZONE 'UTC' - '".$globalLiveInterval." SECONDS'->INTERVAL <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query";
156 156
 			//$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, a.aircraft_shadow 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.'INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao';
157
-			$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 
157
+			$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 
158 158
 			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'";
159 159
 		}
160 160
 //		$spotter_array = Spotter->getDataFromDB($query.$limit_query);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute();
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			echo $e->getMessage();
168 168
 			die;
169 169
 		}
@@ -183,12 +183,12 @@  discard block
 block discarded – undo
183 183
 		global $globalDBdriver, $globalLiveInterval;
184 184
 		date_default_timezone_set('UTC');
185 185
 
186
-		$filter_query = $this->getFilter($filter,true,true);
186
+		$filter_query = $this->getFilter($filter, true, true);
187 187
 
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 
191
-			$query  = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, 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 
191
+			$query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, 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 
192 192
 			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' 
193 193
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
194 194
                 } else {
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 			FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
198 198
 			".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date';
199 199
 */
200
-			$query  = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, 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 
200
+			$query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, 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 
201 201
 			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' 
202 202
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
203 203
 //			echo $query;
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     		try {
207 207
 			$sth = $this->db->prepare($query);
208 208
 			$sth->execute();
209
-		} catch(PDOException $e) {
209
+		} catch (PDOException $e) {
210 210
 			echo $e->getMessage();
211 211
 			die;
212 212
 		}
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	public function getLiveSpotterCount($filter = array())
224 224
 	{
225 225
 		global $globalDBdriver, $globalLiveInterval;
226
-		$filter_query = $this->getFilter($filter,true,true);
226
+		$filter_query = $this->getFilter($filter, true, true);
227 227
 
228 228
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
229 229
 		if ($globalDBdriver == 'mysql') {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		try {
237 237
 			$sth = $this->db->prepare($query);
238 238
 			$sth->execute();
239
-		} catch(PDOException $e) {
239
+		} catch (PDOException $e) {
240 240
 			echo $e->getMessage();
241 241
 			die;
242 242
 		}
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 		$filter_query = $this->getFilter($filter);
260 260
 
261 261
 		if (is_array($coord)) {
262
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
263
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
262
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
263
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
264
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
265
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
266 266
 		} else return array();
267 267
 		if ($globalDBdriver == 'mysql') {
268 268
 			//$query  = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id 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.")";
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
                 if ($interval == '1m')
316 316
                 {
317 317
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
318
-                } else if ($interval == '15m'){
318
+                } else if ($interval == '15m') {
319 319
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
320 320
                 } 
321 321
             }
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
324 324
         }
325 325
 
326
-                $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 
326
+                $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 
327 327
                    WHERE spotter_live.latitude <> '' 
328 328
                                    AND spotter_live.longitude <> '' 
329 329
                    ".$additional_query."
330 330
                    HAVING distance < :radius  
331 331
                                    ORDER BY distance";
332 332
 
333
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
333
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
334 334
 
335 335
                 return $spotter_array;
336 336
         }
@@ -348,9 +348,9 @@  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_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';
351
+                $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';
352 352
 
353
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
353
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
354 354
 
355 355
 		return $spotter_array;
356 356
 	}
@@ -361,16 +361,16 @@  discard block
 block discarded – undo
361 361
 	* @return Array the spotter information
362 362
 	*
363 363
 	*/
364
-	public function getDateLiveSpotterDataByIdent($ident,$date)
364
+	public function getDateLiveSpotterDataByIdent($ident, $date)
365 365
 	{
366 366
 		$Spotter = new Spotter($this->db);
367 367
 		date_default_timezone_set('UTC');
368 368
 
369 369
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
370
-                $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';
370
+                $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';
371 371
 
372
-                $date = date('c',$date);
373
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
372
+                $date = date('c', $date);
373
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
374 374
 
375 375
 		return $spotter_array;
376 376
 	}
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 		date_default_timezone_set('UTC');
388 388
 
389 389
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
390
-                $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';
390
+                $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';
391 391
 
392
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
392
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
393 393
 
394 394
 		return $spotter_array;
395 395
 	}
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
 	* @return Array the spotter information
401 401
 	*
402 402
 	*/
403
-	public function getDateLiveSpotterDataById($id,$date)
403
+	public function getDateLiveSpotterDataById($id, $date)
404 404
 	{
405 405
 		$Spotter = new Spotter($this->db);
406 406
 		date_default_timezone_set('UTC');
407 407
 
408 408
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
409
-                $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';
410
-                $date = date('c',$date);
411
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
409
+                $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';
410
+                $date = date('c', $date);
411
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
412 412
 
413 413
 		return $spotter_array;
414 414
 	}
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
 		date_default_timezone_set('UTC');
426 426
 
427 427
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
428
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
428
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
429 429
 
430 430
     		try {
431 431
 			
432 432
 			$sth = $this->db->prepare($query);
433 433
 			$sth->execute(array(':ident' => $ident));
434
-		} catch(PDOException $e) {
434
+		} catch (PDOException $e) {
435 435
 			echo $e->getMessage();
436 436
 			die;
437 437
 		}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	* @return Array the spotter information
447 447
 	*
448 448
 	*/
449
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
449
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
450 450
 	{
451 451
 		global $globalDBdriver, $globalLiveInterval;
452 452
 		date_default_timezone_set('UTC');
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		try {
466 466
 			$sth = $this->db->prepare($query);
467 467
 			$sth->execute(array(':id' => $id));
468
-		} catch(PDOException $e) {
468
+		} catch (PDOException $e) {
469 469
 			echo $e->getMessage();
470 470
 			die;
471 471
 		}
@@ -483,12 +483,12 @@  discard block
 block discarded – undo
483 483
 	{
484 484
 		date_default_timezone_set('UTC');
485 485
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
486
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
486
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
487 487
     		try {
488 488
 			
489 489
 			$sth = $this->db->prepare($query);
490 490
 			$sth->execute(array(':ident' => $ident));
491
-		} catch(PDOException $e) {
491
+		} catch (PDOException $e) {
492 492
 			echo $e->getMessage();
493 493
 			die;
494 494
 		}
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 			
519 519
 			$sth = $this->db->prepare($query);
520 520
 			$sth->execute();
521
-		} catch(PDOException $e) {
521
+		} catch (PDOException $e) {
522 522
 			return "error";
523 523
 		}
524 524
 
@@ -541,14 +541,14 @@  discard block
 block discarded – undo
541 541
 				
542 542
 				$sth = $this->db->prepare($query);
543 543
 				$sth->execute();
544
-			} catch(PDOException $e) {
544
+			} catch (PDOException $e) {
545 545
 				return "error";
546 546
 			}
547 547
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
548 548
                         $i = 0;
549
-                        $j =0;
549
+                        $j = 0;
550 550
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
551
-			foreach($all as $row)
551
+			foreach ($all as $row)
552 552
 			{
553 553
 				$i++;
554 554
 				$j++;
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
 					if ($globalDebug) echo ".";
557 557
 				    	try {
558 558
 						
559
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
559
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
560 560
 						$sth->execute();
561
-					} catch(PDOException $e) {
561
+					} catch (PDOException $e) {
562 562
 						return "error";
563 563
 					}
564 564
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 			if ($i > 0) {
570 570
     				try {
571 571
 					
572
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
572
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
573 573
 					$sth->execute();
574
-				} catch(PDOException $e) {
574
+				} catch (PDOException $e) {
575 575
 					return "error";
576 576
 				}
577 577
 			}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 				
585 585
 				$sth = $this->db->prepare($query);
586 586
 				$sth->execute();
587
-			} catch(PDOException $e) {
587
+			} catch (PDOException $e) {
588 588
 				return "error";
589 589
 			}
590 590
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
 	public function deleteLiveSpotterDataByIdent($ident)
633 633
 	{
634 634
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
635
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
635
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
636 636
         
637 637
     		try {
638 638
 			
639 639
 			$sth = $this->db->prepare($query);
640 640
 			$sth->execute(array(':ident' => $ident));
641
-		} catch(PDOException $e) {
641
+		} catch (PDOException $e) {
642 642
 			return "error";
643 643
 		}
644 644
 
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 	public function deleteLiveSpotterDataById($id)
655 655
 	{
656 656
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
657
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
657
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
658 658
         
659 659
     		try {
660 660
 			
661 661
 			$sth = $this->db->prepare($query);
662 662
 			$sth->execute(array(':id' => $id));
663
-		} catch(PDOException $e) {
663
+		} catch (PDOException $e) {
664 664
 			return "error";
665 665
 		}
666 666
 
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 	{
679 679
 		global $globalDBdriver, $globalTimezone;
680 680
 		if ($globalDBdriver == 'mysql') {
681
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
681
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
682 682
 				WHERE spotter_live.ident = :ident 
683 683
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
684 684
 				AND spotter_live.date < UTC_TIMESTAMP()';
685 685
 			$query_data = array(':ident' => $ident);
686 686
 		} else {
687
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
687
+			$query = "SELECT spotter_live.ident FROM spotter_live 
688 688
 				WHERE spotter_live.ident = :ident 
689 689
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
690 690
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 		
694 694
 		$sth = $this->db->prepare($query);
695 695
 		$sth->execute($query_data);
696
-		$ident_result='';
697
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
696
+		$ident_result = '';
697
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
698 698
 		{
699 699
 			$ident_result = $row['ident'];
700 700
 		}
@@ -711,13 +711,13 @@  discard block
 block discarded – undo
711 711
 	{
712 712
 		global $globalDBdriver, $globalTimezone;
713 713
 		if ($globalDBdriver == 'mysql') {
714
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
714
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
715 715
 				WHERE spotter_live.ident = :ident 
716 716
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
717 717
 //				AND spotter_live.date < UTC_TIMESTAMP()";
718 718
 			$query_data = array(':ident' => $ident);
719 719
 		} else {
720
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
720
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
721 721
 				WHERE spotter_live.ident = :ident 
722 722
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
723 723
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 		
727 727
 		$sth = $this->db->prepare($query);
728 728
 		$sth->execute($query_data);
729
-		$ident_result='';
730
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
729
+		$ident_result = '';
730
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
731 731
 		{
732 732
 			$ident_result = $row['flightaware_id'];
733 733
 		}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
 	{
745 745
 		global $globalDBdriver, $globalTimezone;
746 746
 		if ($globalDBdriver == 'mysql') {
747
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
747
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
748 748
 				WHERE spotter_live.flightaware_id = :id 
749 749
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
750 750
 //				AND spotter_live.date < UTC_TIMESTAMP()";
751 751
 			$query_data = array(':id' => $id);
752 752
 		} else {
753
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
753
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
754 754
 				WHERE spotter_live.flightaware_id = :id 
755 755
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
756 756
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 		
760 760
 		$sth = $this->db->prepare($query);
761 761
 		$sth->execute($query_data);
762
-		$ident_result='';
763
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
762
+		$ident_result = '';
763
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
764 764
 		{
765 765
 			$ident_result = $row['flightaware_id'];
766 766
 		}
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
 	{
778 778
 		global $globalDBdriver, $globalTimezone;
779 779
 		if ($globalDBdriver == 'mysql') {
780
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
780
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
781 781
 				WHERE spotter_live.ModeS = :modes 
782 782
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
783 783
 //				AND spotter_live.date < UTC_TIMESTAMP()";
784 784
 			$query_data = array(':modes' => $modes);
785 785
 		} else {
786
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
786
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
787 787
 				WHERE spotter_live.ModeS = :modes 
788 788
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
789 789
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 		
793 793
 		$sth = $this->db->prepare($query);
794 794
 		$sth->execute($query_data);
795
-		$ident_result='';
796
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
795
+		$ident_result = '';
796
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
797 797
 		{
798 798
 			//$ident_result = $row['spotter_live_id'];
799 799
 			$ident_result = $row['flightaware_id'];
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
 	* @return String success or false
813 813
 	*
814 814
 	*/
815
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $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 = '')
815
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $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 = '')
816 816
 	{
817 817
 		global $globalURL, $globalArchive, $globalDebug;
818 818
 		$Common = new Common();
@@ -906,26 +906,26 @@  discard block
 block discarded – undo
906 906
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
907 907
 
908 908
         
909
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
910
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
911
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
912
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
913
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
914
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
915
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
916
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
917
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
918
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
919
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
920
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
921
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
922
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
923
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
924
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
925
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
926
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
927
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
928
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
909
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
910
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
911
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
912
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
913
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
914
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
915
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
916
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
917
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
918
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
919
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
920
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
921
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
922
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
923
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
924
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
925
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
926
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
927
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
928
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
929 929
 
930 930
 		$airline_name = '';
931 931
 		$airline_icao = '';
@@ -947,26 +947,26 @@  discard block
 block discarded – undo
947 947
 		$arrival_airport_country = '';
948 948
 		
949 949
             	
950
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
951
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
952
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
953
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
950
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
951
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
952
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
953
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
954 954
             	
955
-		$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) 
955
+		$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) 
956 956
 		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)';
957 957
 
958
-		$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);
958
+		$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);
959 959
 		//$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'],':airline_country' => $airline_array[0]['country'],':airline_type' => $airline_array[0]['type'],':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_array[0]['type'],':aircraft_manufacturer' => $aircraft_array[0]['manufacturer'],':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date);
960 960
 		try {
961 961
 			
962 962
 			$sth = $this->db->prepare($query);
963 963
 			$sth->execute($query_values);
964
-                } catch(PDOException $e) {
964
+                } catch (PDOException $e) {
965 965
                 	return "error : ".$e->getMessage();
966 966
                 }
967 967
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
968 968
 		    if ($globalDebug) echo '(Add to SBS archive : ';
969
-		    $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);
969
+		    $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);
970 970
 		    if ($globalDebug) echo $result.')';
971 971
 		}
972 972
 		return "success";
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 
976 976
 	public function getOrderBy()
977 977
 	{
978
-		$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"));
978
+		$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"));
979 979
 		return $orderby;
980 980
 	}
981 981
 
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -13,45 +13,45 @@  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;
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
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
26
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29
-	foreach($filters as $flt) {
29
+	foreach ($filters as $flt) {
30 30
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32 32
 		    if (isset($flt['source'])) {
33
-			$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'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
33
+			$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'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
34 34
 		    } else {
35
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
35
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
36 36
 		    }
37 37
 		}
38 38
 	    }
39 39
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $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'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
41
+		    $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'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
43
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45 45
 	    }
46 46
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
48
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
49 49
 		}
50 50
 	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53 53
 	    if ($filter['airlines'][0] != '') {
54
-		$filter_query_join .= " 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_output.flightaware_id";
54
+		$filter_query_join .= " 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_output.flightaware_id";
55 55
 	    }
56 56
 	}
57 57
 	
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 	    $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 ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
62
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
65
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68 68
 	    $filter_query_where = " WHERE ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71 71
 	    if ($filter_query_where == '') {
72
-		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
72
+		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
73 73
 	    } else {
74
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
74
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
75 75
 	    }
76 76
 	}
77 77
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
 	// Spotter_archive
84
-	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 = '') {
84
+	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 = '') {
85 85
 		require_once(dirname(__FILE__).'/class.Spotter.php');
86 86
 		if ($over_country == '') {
87 87
 			$Spotter = new Spotter($this->db);
88
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
88
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
89 89
 			if (!empty($data_country)) $country = $data_country['iso2'];
90 90
 			else $country = '';
91 91
 		} else $country = $over_country;
92
-		if ($airline_type === NULL) $airline_type ='';
92
+		if ($airline_type === NULL) $airline_type = '';
93 93
 	
94 94
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
95 95
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
96 96
 
97 97
 		// Route is not added in spotter_archive
98
-		$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)
98
+		$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)
99 99
 		        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)";
100 100
 
101
-		$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);
101
+		$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);
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			return "error : ".$e->getMessage();
107 107
 		}
108 108
 		return "success";
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 
123 123
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
124 124
                 //$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";
125
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
125
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126 126
 
127
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
127
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
128 128
 
129 129
                 return $spotter_array;
130 130
         }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
144 144
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
145 145
                 //$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";
146
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
146
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
147 147
 
148 148
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
149 149
                   /*
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 }
157 157
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
158 158
                 */
159
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
159
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
160 160
 
161 161
                 return $spotter_array;
162 162
         }
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
         {
172 172
                 date_default_timezone_set('UTC');
173 173
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
174
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
174
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
175 175
 
176 176
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
177 177
 
178 178
                 try {
179 179
                         $sth = $this->db->prepare($query);
180 180
                         $sth->execute(array(':id' => $id));
181
-                } catch(PDOException $e) {
181
+                } catch (PDOException $e) {
182 182
                         echo $e->getMessage();
183 183
                         die;
184 184
                 }
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
         {
198 198
                 date_default_timezone_set('UTC');
199 199
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
200
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
200
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
201 201
 
202 202
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
203 203
 
204 204
                 try {
205 205
                         $sth = $this->db->prepare($query);
206 206
                         $sth->execute(array(':id' => $id));
207
-                } catch(PDOException $e) {
207
+                } catch (PDOException $e) {
208 208
                         echo $e->getMessage();
209 209
                         die;
210 210
                 }
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
                 date_default_timezone_set('UTC');
227 227
 
228 228
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
229
-                $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";
229
+                $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";
230 230
 
231 231
                 try {
232 232
                         $sth = $this->db->prepare($query);
233 233
                         $sth->execute(array(':ident' => $ident));
234
-                } catch(PDOException $e) {
234
+                } catch (PDOException $e) {
235 235
                         echo $e->getMessage();
236 236
                         die;
237 237
                 }
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
                 date_default_timezone_set('UTC');
253 253
 
254 254
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
255
-                $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";
255
+                $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";
256 256
 
257 257
                 try {
258 258
                         $sth = $this->db->prepare($query);
259 259
                         $sth->execute(array(':id' => $id));
260
-                } catch(PDOException $e) {
260
+                } catch (PDOException $e) {
261 261
                         echo $e->getMessage();
262 262
                         die;
263 263
                 }
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
                 date_default_timezone_set('UTC');
279 279
 
280 280
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
281
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
281
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
282 282
 
283 283
                 try {
284 284
                         $sth = $this->db->prepare($query);
285 285
                         $sth->execute(array(':id' => $id));
286
-                } catch(PDOException $e) {
286
+                } catch (PDOException $e) {
287 287
                         echo $e->getMessage();
288 288
                         die;
289 289
                 }
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
                 date_default_timezone_set('UTC');
306 306
 
307 307
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
308
-                $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";
308
+                $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";
309 309
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
310 310
 
311 311
                 try {
312 312
                         $sth = $this->db->prepare($query);
313 313
                         $sth->execute(array(':ident' => $ident));
314
-                } catch(PDOException $e) {
314
+                } catch (PDOException $e) {
315 315
                         echo $e->getMessage();
316 316
                         die;
317 317
                 }
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         * @return Array the spotter information
329 329
         *
330 330
         */
331
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
331
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
332 332
         {
333 333
     		$Spotter = new Spotter($this->db);
334 334
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
335
-                $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";
335
+                $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";
336 336
 
337
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
337
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
338 338
 
339 339
                 return $spotter_array;
340 340
         }
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
                 try {
348 348
                         $sth = $this->db->prepare($query);
349 349
                         $sth->execute();
350
-                } catch(PDOException $e) {
350
+                } catch (PDOException $e) {
351 351
                         echo $e->getMessage();
352 352
                         die;
353 353
                 }
@@ -359,24 +359,24 @@  discard block
 block discarded – undo
359 359
         * @return Array the spotter information
360 360
         *
361 361
         */
362
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
362
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
363 363
         {
364 364
                 global $globalDBdriver, $globalLiveInterval;
365 365
                 date_default_timezone_set('UTC');
366 366
 
367 367
                 $filter_query = '';
368 368
                 if (isset($filter['source']) && !empty($filter['source'])) {
369
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
369
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
370 370
                 }
371 371
                 // Use spotter_output also ?
372 372
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
373
-                        $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 ";
373
+                        $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 ";
374 374
                 }
375 375
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
376 376
                         $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 ";
377 377
                 }
378 378
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
379
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
379
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
380 380
                 }
381 381
 
382 382
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
396 396
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
397 397
 */
398
-			$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 
398
+			$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 
399 399
 				    FROM spotter_archive 
400 400
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
401 401
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
402 402
                         	    '.$filter_query.' ORDER BY flightaware_id';
403 403
                 } else {
404 404
                         //$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';
405
-                        $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 
405
+                        $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 
406 406
                         	    FROM spotter_archive 
407 407
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
408 408
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
                 try {
413 413
                         $sth = $this->db->prepare($query);
414 414
                         $sth->execute();
415
-                } catch(PDOException $e) {
415
+                } catch (PDOException $e) {
416 416
                         echo $e->getMessage();
417 417
                         die;
418 418
                 }
@@ -427,24 +427,24 @@  discard block
 block discarded – undo
427 427
         * @return Array the spotter information
428 428
         *
429 429
         */
430
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
430
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
431 431
         {
432 432
                 global $globalDBdriver, $globalLiveInterval;
433 433
                 date_default_timezone_set('UTC');
434 434
 
435 435
                 $filter_query = '';
436 436
                 if (isset($filter['source']) && !empty($filter['source'])) {
437
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
437
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
438 438
                 }
439 439
                 // Should use spotter_output also ?
440 440
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
441
-                        $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 ";
441
+                        $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 ";
442 442
                 }
443 443
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
444 444
                         $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 ";
445 445
                 }
446 446
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
447
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
447
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
448 448
                 }
449 449
 
450 450
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                     		    FROM spotter_archive 
455 455
                     		    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';
456 456
 			*/
457
-			$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 
457
+			$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 
458 458
 				    FROM spotter_archive_output 
459 459
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
460 460
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
470 470
                         	    '.$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';
471 471
                         */
472
-                        $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
472
+                        $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
473 473
                         	    FROM spotter_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
                 try {
482 482
                         $sth = $this->db->prepare($query);
483 483
                         $sth->execute();
484
-                } catch(PDOException $e) {
484
+                } catch (PDOException $e) {
485 485
                         echo $e->getMessage();
486 486
                         die;
487 487
                 }
@@ -496,23 +496,23 @@  discard block
 block discarded – undo
496 496
         * @return Array the spotter information
497 497
         *
498 498
         */
499
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
499
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
500 500
         {
501 501
                 global $globalDBdriver, $globalLiveInterval;
502 502
                 date_default_timezone_set('UTC');
503 503
 
504 504
                 $filter_query = '';
505 505
                 if (isset($filter['source']) && !empty($filter['source'])) {
506
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
506
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
507 507
                 }
508 508
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
509
-                        $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 ";
509
+                        $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 ";
510 510
                 }
511 511
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
512 512
                         $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 ";
513 513
                 }
514 514
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
515
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
515
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
516 516
                 }
517 517
 
518 518
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
                 try {
528 528
                         $sth = $this->db->prepare($query);
529 529
                         $sth->execute();
530
-                } catch(PDOException $e) {
530
+                } catch (PDOException $e) {
531 531
                         echo $e->getMessage();
532 532
                         die;
533 533
                 }
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
     * @return Array the spotter information
548 548
     *
549 549
     */
550
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
550
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
551 551
     {
552 552
 	global $globalTimezone, $globalDBdriver;
553 553
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 	        
570 570
 		$q_array = explode(" ", $q);
571 571
 		
572
-		foreach ($q_array as $q_item){
572
+		foreach ($q_array as $q_item) {
573 573
 		    $additional_query .= " AND (";
574 574
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
575 575
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	
602 602
 	if ($registration != "")
603 603
 	{
604
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
604
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
605 605
 	    if (!is_string($registration))
606 606
 	    {
607 607
 		return false;
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	
613 613
 	if ($aircraft_icao != "")
614 614
 	{
615
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
615
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
616 616
 	    if (!is_string($aircraft_icao))
617 617
 	    {
618 618
 		return false;
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 	
624 624
 	if ($aircraft_manufacturer != "")
625 625
 	{
626
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
626
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
627 627
 	    if (!is_string($aircraft_manufacturer))
628 628
 	    {
629 629
 		return false;
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($airline_icao != "")
646 646
 	{
647
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
647
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($airline_icao))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($airline_country != "")
657 657
 	{
658
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
658
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($airline_country))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($airline_type != "")
668 668
 	{
669
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
669
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($airline_type))
671 671
 	    {
672 672
 		return false;
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	
689 689
 	if ($airport != "")
690 690
 	{
691
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
691
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
692 692
 	    if (!is_string($airport))
693 693
 	    {
694 694
 		return false;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	
700 700
 	if ($airport_country != "")
701 701
 	{
702
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
702
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
703 703
 	    if (!is_string($airport_country))
704 704
 	    {
705 705
 		return false;
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
     
711 711
 	if ($callsign != "")
712 712
 	{
713
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
713
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
714 714
 	    if (!is_string($callsign))
715 715
 	    {
716 716
 		return false;
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 		$translate = $Translation->ident2icao($callsign);
719 719
 		if ($translate != $callsign) {
720 720
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
721
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
721
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
722 722
 		} else {
723 723
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
724 724
 		}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 
728 728
 	if ($owner != "")
729 729
 	{
730
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
730
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
731 731
 	    if (!is_string($owner))
732 732
 	    {
733 733
 		return false;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
 	if ($pilot_name != "")
740 740
 	{
741
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
741
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
742 742
 	    if (!is_string($pilot_name))
743 743
 	    {
744 744
 		return false;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	
750 750
 	if ($pilot_id != "")
751 751
 	{
752
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
752
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
753 753
 	    if (!is_string($pilot_id))
754 754
 	    {
755 755
 		return false;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 	
761 761
 	if ($departure_airport_route != "")
762 762
 	{
763
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
763
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
764 764
 	    if (!is_string($departure_airport_route))
765 765
 	    {
766 766
 		return false;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	
772 772
 	if ($arrival_airport_route != "")
773 773
 	{
774
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
774
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
775 775
 	    if (!is_string($arrival_airport_route))
776 776
 	    {
777 777
 		return false;
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	{
785 785
 	    $altitude_array = explode(",", $altitude);
786 786
 	    
787
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
788
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
789 789
 	    
790 790
 
791 791
 	    if ($altitude_array[1] != "")
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	{
804 804
 	    $date_array = explode(",", $date_posted);
805 805
 	    
806
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
807
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
806
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
807
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
808 808
 	    
809 809
 	    if ($globalTimezone != '') {
810 810
 		date_default_timezone_set($globalTimezone);
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 	    $limit_array = explode(",", $limit);
838 838
 	    
839
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
840
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
839
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
840
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
841 841
 	    
842 842
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
843 843
 	    {
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	
849 849
 
850 850
 	if ($origLat != "" && $origLon != "" && $dist != "") {
851
-		$dist = number_format($dist*0.621371,2,'.','');
852
-		$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 
851
+		$dist = number_format($dist*0.621371, 2, '.', '');
852
+		$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 
853 853
                           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)) 
854 854
                           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";
855 855
 	} else {
@@ -866,12 +866,12 @@  discard block
 block discarded – undo
866 866
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
867 867
 		}
868 868
 
869
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
869
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
870 870
 		    WHERE spotter_archive_output.ident <> '' 
871 871
 		    ".$additional_query."
872 872
 		    ".$filter_query.$orderby_query;
873 873
 	}
874
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
874
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
875 875
 
876 876
 	return $spotter_array;
877 877
     }
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                 try {
889 889
                         $sth = $this->db->prepare($query);
890 890
                         $sth->execute();
891
-                } catch(PDOException $e) {
891
+                } catch (PDOException $e) {
892 892
                         return "error";
893 893
                 }
894 894
 	}
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	{
926 926
 	    $limit_array = explode(",", $limit);
927 927
 	    
928
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
928
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
929
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
930 930
 	    
931 931
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932 932
 	    {
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
     * @return Array the airline country list
957 957
     *
958 958
     */
959
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
959
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
960 960
     {
961 961
 	global $globalDBdriver;
962 962
 	/*
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 	$flight_array = array();
986 986
 	$temp_array = array();
987 987
         
988
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
988
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
989 989
 	{
990 990
 	    $temp_array['flight_count'] = $row['nb'];
991 991
 	    $temp_array['flight_country'] = $row['name'];
@@ -1002,14 +1002,14 @@  discard block
 block discarded – undo
1002 1002
     * @return Array the spotter information
1003 1003
     *
1004 1004
     */
1005
-    public function getDateArchiveSpotterDataById($id,$date)
1005
+    public function getDateArchiveSpotterDataById($id, $date)
1006 1006
     {
1007 1007
 	$Spotter = new Spotter($this->db);
1008 1008
 	date_default_timezone_set('UTC');
1009 1009
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1010
-	$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';
1011
-	$date = date('c',$date);
1012
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1010
+	$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';
1011
+	$date = date('c', $date);
1012
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1013 1013
 	return $spotter_array;
1014 1014
     }
1015 1015
 
@@ -1019,14 +1019,14 @@  discard block
 block discarded – undo
1019 1019
     * @return Array the spotter information
1020 1020
     *
1021 1021
     */
1022
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1022
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1023 1023
     {
1024 1024
 	$Spotter = new Spotter($this->db);
1025 1025
 	date_default_timezone_set('UTC');
1026 1026
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1027
-	$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';
1028
-	$date = date('c',$date);
1029
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1027
+	$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';
1028
+	$date = date('c', $date);
1029
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1030 1030
 	return $spotter_array;
1031 1031
     }
1032 1032
 
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
     * @return Array the spotter information
1037 1037
     *
1038 1038
     */
1039
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1039
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1040 1040
     {
1041 1041
 	global $global_query;
1042 1042
 	$Spotter = new Spotter();
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	$query_values = array();
1045 1045
 	$limit_query = '';
1046 1046
 	$additional_query = '';
1047
-	$filter_query = $this->getFilter($filters,true,true);
1047
+	$filter_query = $this->getFilter($filters, true, true);
1048 1048
 	
1049 1049
 	if ($airport != "")
1050 1050
 	{
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	{
1062 1062
 	    $limit_array = explode(",", $limit);
1063 1063
 	    
1064
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1065
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1064
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1065
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1066 1066
 	    
1067 1067
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1068 1068
 	    {
Please login to merge, or discard this patch.