Completed
Push — master ( 365b9c...3b2ef5 )
by Yannick
36:24 queued 05:07
created
require/class.SpotterArchive.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -14,82 +14,82 @@  discard block
 block discarded – undo
14 14
 	* @param Array $filter the filter
15 15
 	* @return Array the SQL part
16 16
 	*/
17
-	public function getFilter($filter = array(),$where = false,$and = false) {
17
+	public function getFilter($filter = array(), $where = false, $and = false) {
18 18
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
19 19
 		$filters = array();
20 20
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 				$filters = $globalStatsFilters[$globalFilterName];
23 23
 			} else {
24
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
24
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
25 25
 			}
26 26
 		}
27 27
 		if (isset($filter[0]['source'])) {
28
-			$filters = array_merge($filters,$filter);
28
+			$filters = array_merge($filters, $filter);
29 29
 		}
30
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
31 31
 		$filter_query_join = '';
32 32
 		$filter_query_where = '';
33
-		foreach($filters as $flt) {
33
+		foreach ($filters as $flt) {
34 34
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
35 35
 				if ($flt['airlines'][0] != '') {
36 36
 					if (isset($flt['source'])) {
37
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38 38
 					} else {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
40 40
 					}
41 41
 				}
42 42
 			}
43 43
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
48 48
 				}
49 49
 			}
50 50
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
51 51
 				if (isset($flt['source'])) {
52
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53 53
 				} else {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
55 55
 				}
56 56
 			}
57 57
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
58 58
 				if (isset($flt['source'])) {
59
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60 60
 				} else {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
62 62
 				}
63 63
 			}
64 64
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
65 65
 				if (isset($flt['source'])) {
66
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
67 67
 				}
68 68
 			}
69 69
 		}
70 70
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
71 71
 			if ($filter['airlines'][0] != '') {
72
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
73 73
 			}
74 74
 		}
75 75
 		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
76 76
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 		}
78 78
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 		}
81 81
 		if (isset($filter['source']) && !empty($filter['source'])) {
82 82
 			if (count($filter['source']) == 1) {
83 83
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
84 84
 			} else {
85
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
85
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
86 86
 			}
87 87
 		}
88 88
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
89 89
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
90 90
 		}
91 91
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
92
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
92
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
93 93
 		}
94 94
 		if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
95 95
 			$filter_query_date = '';
@@ -114,41 +114,41 @@  discard block
 block discarded – undo
114 114
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
115 115
 				}
116 116
 			}
117
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
117
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
118 118
 		}
119 119
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
120 120
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
121 121
 		if ($filter_query_where != '') {
122
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
122
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
123 123
 		}
124 124
 		$filter_query = $filter_query_join.$filter_query_where;
125 125
 		return $filter_query;
126 126
 	}
127 127
 
128 128
 	// Spotter_archive
129
-	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 = '', $real_altitude = '',$heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
129
+	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 = '', $real_altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
130 130
 		require_once(dirname(__FILE__).'/class.Spotter.php');
131 131
 		if ($over_country == '') {
132 132
 			$Spotter = new Spotter($this->db);
133
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
133
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
134 134
 			if (!empty($data_country)) $country = $data_country['iso2'];
135 135
 			else $country = '';
136 136
 		} else $country = $over_country;
137
-		if ($airline_type === NULL) $airline_type ='';
137
+		if ($airline_type === NULL) $airline_type = '';
138 138
 	
139 139
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
140 140
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
141 141
 
142 142
 		// Route is not added in spotter_archive
143
-		$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,real_altitude)
143
+		$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,real_altitude)
144 144
 		        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,:real_altitude)";
145 145
 
146
-		$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,':real_altitude' => $real_altitude);
146
+		$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, ':real_altitude' => $real_altitude);
147 147
 		try {
148 148
 			$sth = $this->db->prepare($query);
149 149
 			$sth->execute($query_values);
150 150
 			$sth->closeCursor();
151
-		} catch(PDOException $e) {
151
+		} catch (PDOException $e) {
152 152
 			return "error : ".$e->getMessage();
153 153
 		}
154 154
 		return "success";
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
 
169 169
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
170 170
                 //$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";
171
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
171
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
172 172
 
173
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
173
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
174 174
 
175 175
                 return $spotter_array;
176 176
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
190 190
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
191 191
                 //$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";
192
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
192
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
193 193
 
194 194
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
195 195
                   /*
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
                 }
203 203
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
204 204
                 */
205
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
205
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
206 206
 
207 207
                 return $spotter_array;
208 208
         }
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	{
218 218
                 date_default_timezone_set('UTC');
219 219
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
220
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
220
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
221 221
 
222 222
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
223 223
 
224 224
                 try {
225 225
                         $sth = $this->db->prepare($query);
226 226
                         $sth->execute(array(':id' => $id));
227
-                } catch(PDOException $e) {
227
+                } catch (PDOException $e) {
228 228
                         echo $e->getMessage();
229 229
                         die;
230 230
                 }
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
         {
244 244
                 date_default_timezone_set('UTC');
245 245
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
246
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
246
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
247 247
 
248 248
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
249 249
 
250 250
                 try {
251 251
                         $sth = $this->db->prepare($query);
252 252
                         $sth->execute(array(':id' => $id));
253
-                } catch(PDOException $e) {
253
+                } catch (PDOException $e) {
254 254
                         echo $e->getMessage();
255 255
                         die;
256 256
                 }
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
                 date_default_timezone_set('UTC');
273 273
 
274 274
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
275
-                $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";
275
+                $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";
276 276
 
277 277
                 try {
278 278
                         $sth = $this->db->prepare($query);
279 279
                         $sth->execute(array(':ident' => $ident));
280
-                } catch(PDOException $e) {
280
+                } catch (PDOException $e) {
281 281
                         echo $e->getMessage();
282 282
                         die;
283 283
                 }
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
                 date_default_timezone_set('UTC');
299 299
 
300 300
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
301
-                $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";
301
+                $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";
302 302
 
303 303
                 try {
304 304
                         $sth = $this->db->prepare($query);
305 305
                         $sth->execute(array(':id' => $id));
306
-                } catch(PDOException $e) {
306
+                } catch (PDOException $e) {
307 307
                         echo $e->getMessage();
308 308
                         die;
309 309
                 }
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
 	{
323 323
 		date_default_timezone_set('UTC');
324 324
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
325
-		$query  = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325
+		$query = "SELECT spotter_archive.altitude, spotter_archive.real_altitude,spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
326 326
 		try {
327 327
 			$sth = $this->db->prepare($query);
328 328
 			$sth->execute(array(':id' => $id));
329
-		} catch(PDOException $e) {
329
+		} catch (PDOException $e) {
330 330
 			echo $e->getMessage();
331 331
 			die;
332 332
 		}
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
 	{
345 345
 		date_default_timezone_set('UTC');
346 346
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
347
-		$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";
347
+		$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";
348 348
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
349 349
 		try {
350 350
 			$sth = $this->db->prepare($query);
351 351
 			$sth->execute(array(':ident' => $ident));
352
-		} catch(PDOException $e) {
352
+		} catch (PDOException $e) {
353 353
 			echo $e->getMessage();
354 354
 			die;
355 355
 		}
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
         * @return Array the spotter information
366 366
         *
367 367
         */
368
-	public function getSpotterArchiveData($ident,$flightaware_id,$date)
368
+	public function getSpotterArchiveData($ident, $flightaware_id, $date)
369 369
 	{
370 370
 		$Spotter = new Spotter($this->db);
371 371
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
372
-		$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";
373
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
372
+		$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";
373
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
374 374
 		return $spotter_array;
375 375
 	}
376 376
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 		try {
386 386
 			$sth = $this->db->prepare($query);
387 387
 			$sth->execute();
388
-		} catch(PDOException $e) {
388
+		} catch (PDOException $e) {
389 389
 			echo $e->getMessage();
390 390
 			die;
391 391
 		}
@@ -397,24 +397,24 @@  discard block
 block discarded – undo
397 397
         * @return Array the spotter information
398 398
         *
399 399
         */
400
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
400
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
401 401
         {
402 402
                 global $globalDBdriver, $globalLiveInterval;
403 403
                 date_default_timezone_set('UTC');
404 404
 
405 405
                 $filter_query = '';
406 406
                 if (isset($filter['source']) && !empty($filter['source'])) {
407
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
407
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
408 408
                 }
409 409
                 // Use spotter_output also ?
410 410
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
411
-                        $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 ";
411
+                        $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 ";
412 412
                 }
413 413
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
414 414
                         $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 ";
415 415
                 }
416 416
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
417
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
417
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
418 418
                 }
419 419
 
420 420
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
434 434
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
435 435
 */
436
-			$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 
436
+			$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 
437 437
 				    FROM spotter_archive 
438 438
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
439 439
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
440 440
                         	    '.$filter_query.' ORDER BY flightaware_id';
441 441
                 } else {
442 442
                         //$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';
443
-                        $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 
443
+                        $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 
444 444
                         	    FROM spotter_archive 
445 445
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
446 446
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
                 try {
451 451
                         $sth = $this->db->prepare($query);
452 452
                         $sth->execute();
453
-                } catch(PDOException $e) {
453
+                } catch (PDOException $e) {
454 454
                         echo $e->getMessage();
455 455
                         die;
456 456
                 }
@@ -465,24 +465,24 @@  discard block
 block discarded – undo
465 465
         * @return Array the spotter information
466 466
         *
467 467
         */
468
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
468
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
469 469
         {
470 470
                 global $globalDBdriver, $globalLiveInterval;
471 471
                 date_default_timezone_set('UTC');
472 472
 
473 473
                 $filter_query = '';
474 474
                 if (isset($filter['source']) && !empty($filter['source'])) {
475
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
475
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
476 476
                 }
477 477
                 // Should use spotter_output also ?
478 478
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
479
-                        $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 ";
479
+                        $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 ";
480 480
                 }
481 481
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
482 482
                         $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 ";
483 483
                 }
484 484
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
485
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
485
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
486 486
                 }
487 487
 
488 488
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
                     		    FROM spotter_archive 
493 493
                     		    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';
494 494
 			*/
495
-			$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 
495
+			$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 
496 496
 				    FROM spotter_archive_output 
497 497
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
498 498
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
508 508
                         	    '.$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';
509 509
                         */
510
-                        $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
510
+                        $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
511 511
                         	    FROM spotter_archive_output 
512 512
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
513 513
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
                 try {
520 520
                         $sth = $this->db->prepare($query);
521 521
                         $sth->execute();
522
-                } catch(PDOException $e) {
522
+                } catch (PDOException $e) {
523 523
                         echo $e->getMessage();
524 524
                         die;
525 525
                 }
@@ -534,23 +534,23 @@  discard block
 block discarded – undo
534 534
         * @return Array the spotter information
535 535
         *
536 536
         */
537
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
537
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
538 538
         {
539 539
                 global $globalDBdriver, $globalLiveInterval;
540 540
                 date_default_timezone_set('UTC');
541 541
 
542 542
                 $filter_query = '';
543 543
                 if (isset($filter['source']) && !empty($filter['source'])) {
544
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
544
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
545 545
                 }
546 546
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
547
-                        $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 ";
547
+                        $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 ";
548 548
                 }
549 549
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
550 550
                         $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 ";
551 551
                 }
552 552
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
553
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
553
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
554 554
                 }
555 555
 
556 556
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
                 try {
566 566
                         $sth = $this->db->prepare($query);
567 567
                         $sth->execute();
568
-                } catch(PDOException $e) {
568
+                } catch (PDOException $e) {
569 569
                         echo $e->getMessage();
570 570
                         die;
571 571
                 }
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
     * @return Array the spotter information
586 586
     *
587 587
     */
588
-    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())
588
+    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())
589 589
     {
590 590
 	global $globalTimezone, $globalDBdriver;
591 591
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 	        
608 608
 		$q_array = explode(" ", $q);
609 609
 		
610
-		foreach ($q_array as $q_item){
610
+		foreach ($q_array as $q_item) {
611 611
 		    $additional_query .= " AND (";
612 612
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
613 613
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 	
640 640
 	if ($registration != "")
641 641
 	{
642
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
642
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
643 643
 	    if (!is_string($registration))
644 644
 	    {
645 645
 		return false;
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 	
651 651
 	if ($aircraft_icao != "")
652 652
 	{
653
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
653
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
654 654
 	    if (!is_string($aircraft_icao))
655 655
 	    {
656 656
 		return false;
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	
662 662
 	if ($aircraft_manufacturer != "")
663 663
 	{
664
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
664
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
665 665
 	    if (!is_string($aircraft_manufacturer))
666 666
 	    {
667 667
 		return false;
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	
683 683
 	if ($airline_icao != "")
684 684
 	{
685
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
685
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
686 686
 	    if (!is_string($airline_icao))
687 687
 	    {
688 688
 		return false;
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	
694 694
 	if ($airline_country != "")
695 695
 	{
696
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
696
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
697 697
 	    if (!is_string($airline_country))
698 698
 	    {
699 699
 		return false;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	
705 705
 	if ($airline_type != "")
706 706
 	{
707
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
707
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
708 708
 	    if (!is_string($airline_type))
709 709
 	    {
710 710
 		return false;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	
727 727
 	if ($airport != "")
728 728
 	{
729
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
729
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
730 730
 	    if (!is_string($airport))
731 731
 	    {
732 732
 		return false;
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 	
738 738
 	if ($airport_country != "")
739 739
 	{
740
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
740
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
741 741
 	    if (!is_string($airport_country))
742 742
 	    {
743 743
 		return false;
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
     
749 749
 	if ($callsign != "")
750 750
 	{
751
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
751
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
752 752
 	    if (!is_string($callsign))
753 753
 	    {
754 754
 		return false;
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		$translate = $Translation->ident2icao($callsign);
757 757
 		if ($translate != $callsign) {
758 758
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
759
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
759
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
760 760
 		} else {
761 761
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
762 762
 		}
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
 
766 766
 	if ($owner != "")
767 767
 	{
768
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
768
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
769 769
 	    if (!is_string($owner))
770 770
 	    {
771 771
 		return false;
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 
777 777
 	if ($pilot_name != "")
778 778
 	{
779
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
779
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
780 780
 	    if (!is_string($pilot_name))
781 781
 	    {
782 782
 		return false;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	
788 788
 	if ($pilot_id != "")
789 789
 	{
790
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
790
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
791 791
 	    if (!is_string($pilot_id))
792 792
 	    {
793 793
 		return false;
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
 	
799 799
 	if ($departure_airport_route != "")
800 800
 	{
801
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
801
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
802 802
 	    if (!is_string($departure_airport_route))
803 803
 	    {
804 804
 		return false;
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	
810 810
 	if ($arrival_airport_route != "")
811 811
 	{
812
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
812
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
813 813
 	    if (!is_string($arrival_airport_route))
814 814
 	    {
815 815
 		return false;
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	{
823 823
 	    $altitude_array = explode(",", $altitude);
824 824
 	    
825
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
826
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
825
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
826
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
827 827
 	    
828 828
 
829 829
 	    if ($altitude_array[1] != "")
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 	if ($date_posted != "")
841 841
 	{
842 842
 		$date_array = explode(",", $date_posted);
843
-		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
844
-		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
843
+		$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
844
+		$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
845 845
 		if ($globalTimezone != '') {
846 846
 			date_default_timezone_set($globalTimezone);
847 847
 			$datetime = new DateTime();
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 		if ($limit != "")
869 869
 		{
870 870
 			$limit_array = explode(",", $limit);
871
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
872
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
871
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
872
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
873 873
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
874 874
 			{
875 875
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 			}
878 878
 		}
879 879
 		if ($origLat != "" && $origLon != "" && $dist != "") {
880
-			$dist = number_format($dist*0.621371,2,'.','');
881
-			$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 
880
+			$dist = number_format($dist*0.621371, 2, '.', '');
881
+			$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 
882 882
 			      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)) 
883 883
 			      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";
884 884
 		} else {
@@ -894,12 +894,12 @@  discard block
 block discarded – undo
894 894
 				$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
895 895
 			}
896 896
 
897
-			$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
897
+			$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
898 898
 			    WHERE spotter_archive_output.ident <> '' 
899 899
 			    ".$additional_query."
900 900
 			    ".$filter_query.$orderby_query;
901 901
 		}
902
-		$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
902
+		$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
903 903
 		return $spotter_array;
904 904
 	}
905 905
 
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 		try {
915 915
 			$sth = $this->db->prepare($query);
916 916
 			$sth->execute();
917
-		} catch(PDOException $e) {
917
+		} catch (PDOException $e) {
918 918
 			return "error";
919 919
 		}
920 920
 	}
@@ -951,8 +951,8 @@  discard block
 block discarded – undo
951 951
 	{
952 952
 	    $limit_array = explode(",", $limit);
953 953
 	    
954
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
955
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
954
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
955
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
956 956
 	    
957 957
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
958 958
 	    {
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
 	$query_values = array();
994 994
 	$limit_query = '';
995 995
 	$additional_query = '';
996
-	$filter_query = $this->getFilter($filter,true,true);
996
+	$filter_query = $this->getFilter($filter, true, true);
997 997
 	
998 998
 	if ($owner != "")
999 999
 	{
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	{
1011 1011
 	    $limit_array = explode(",", $limit);
1012 1012
 	    
1013
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1014
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1013
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1014
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1015 1015
 	    
1016 1016
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1017 1017
 	    {
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	$query_values = array();
1052 1052
 	$limit_query = '';
1053 1053
 	$additional_query = '';
1054
-	$filter_query = $this->getFilter($filter,true,true);
1054
+	$filter_query = $this->getFilter($filter, true, true);
1055 1055
 	
1056 1056
 	if ($pilot != "")
1057 1057
 	{
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 	{
1064 1064
 	    $limit_array = explode(",", $limit);
1065 1065
 	    
1066
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1067
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1066
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1067
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1068 1068
 	    
1069 1069
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1070 1070
 	    {
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
     * @return Array the airline country list
1095 1095
     *
1096 1096
     */
1097
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1097
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1098 1098
     {
1099 1099
 	global $globalDBdriver;
1100 1100
 	/*
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 	$flight_array = array();
1124 1124
 	$temp_array = array();
1125 1125
         
1126
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1126
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1127 1127
 	{
1128 1128
 	    $temp_array['flight_count'] = $row['nb'];
1129 1129
 	    $temp_array['flight_country'] = $row['name'];
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
     * @return Array the airline country list
1141 1141
     *
1142 1142
     */
1143
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1143
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1144 1144
     {
1145 1145
 	global $globalDBdriver;
1146 1146
 	/*
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	$flight_array = array();
1170 1170
 	$temp_array = array();
1171 1171
         
1172
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1172
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1173 1173
 	{
1174 1174
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1175 1175
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1187,14 +1187,14 @@  discard block
 block discarded – undo
1187 1187
     * @return Array the spotter information
1188 1188
     *
1189 1189
     */
1190
-    public function getDateArchiveSpotterDataById($id,$date)
1190
+    public function getDateArchiveSpotterDataById($id, $date)
1191 1191
     {
1192 1192
 	$Spotter = new Spotter($this->db);
1193 1193
 	date_default_timezone_set('UTC');
1194 1194
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1195
-	$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';
1196
-	$date = date('c',$date);
1197
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1195
+	$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';
1196
+	$date = date('c', $date);
1197
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1198 1198
 	return $spotter_array;
1199 1199
     }
1200 1200
 
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * @return Array the spotter information
1205 1205
     *
1206 1206
     */
1207
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1207
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1208 1208
     {
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1212
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.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';
1213
-	$date = date('c',$date);
1214
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1212
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.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';
1213
+	$date = date('c', $date);
1214
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1215 1215
 	return $spotter_array;
1216 1216
     }
1217 1217
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
     * @return Array the spotter information
1222 1222
     *
1223 1223
     */
1224
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1224
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1225 1225
     {
1226 1226
 	global $global_query;
1227 1227
 	$Spotter = new Spotter($this->db);
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 	$query_values = array();
1230 1230
 	$limit_query = '';
1231 1231
 	$additional_query = '';
1232
-	$filter_query = $this->getFilter($filters,true,true);
1232
+	$filter_query = $this->getFilter($filters, true, true);
1233 1233
 	
1234 1234
 	if ($airport != "")
1235 1235
 	{
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	{
1247 1247
 	    $limit_array = explode(",", $limit);
1248 1248
 	    
1249
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1250
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1249
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1250
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1251 1251
 	    
1252 1252
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1253 1253
 	    {
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -17,62 +17,62 @@  discard block
 block discarded – undo
17 17
 	* @param Array $filter the filter
18 18
 	* @return Array the SQL part
19 19
 	*/
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
38 38
 				if ($flt['airlines'][0] != '') {
39 39
 					if (isset($flt['source'])) {
40
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41 41
 					} else {
42
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
43 43
 					}
44 44
 				}
45 45
 			}
46 46
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
47 47
 				if (isset($flt['source'])) {
48
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49 49
 				} else {
50
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
51 51
 				}
52 52
 			}
53 53
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
54 54
 				if (isset($flt['source'])) {
55
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56 56
 				} else {
57
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
58 58
 				}
59 59
 			}
60 60
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
61 61
 				if (isset($flt['source'])) {
62
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63 63
 				} else {
64
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
65 65
 				}
66 66
 			}
67 67
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
68 68
 				if (isset($flt['source'])) {
69
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
70 70
 				}
71 71
 			}
72 72
 		}
73 73
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
74 74
 			if ($filter['airlines'][0] != '') {
75
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
76 76
 			}
77 77
 		}
78 78
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
83 83
 		}
84 84
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
85
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
86 86
 		}
87 87
 		if (isset($filter['source']) && !empty($filter['source'])) {
88 88
 			if (count($filter['source']) == 1) {
89 89
 				$filter_query_where .= " AND format_source = '".$filter['source'][0]."'";
90 90
 			} else {
91
-				$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
91
+				$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
92 92
 			}
93 93
 		}
94 94
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
119 119
 				}
120 120
 			}
121
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
121
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
122 122
 		}
123 123
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
124
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
124
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
125 125
 		}
126 126
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
127 127
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
128 128
 		if ($filter_query_where != '') {
129
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
129
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
130 130
 		}
131 131
 		$filter_query = $filter_query_join.$filter_query_where;
132 132
 		return $filter_query;
@@ -149,8 +149,8 @@  discard block
 block discarded – undo
149 149
 		if ($limit != '')
150 150
 		{
151 151
 			$limit_array = explode(',', $limit);
152
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
153
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
152
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
153
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
154 154
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
155 155
 			{
156 156
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		} else {
175 175
 			$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;
176 176
 		}
177
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
177
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
178 178
 
179 179
 		return $spotter_array;
180 180
 	}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	{
190 190
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
191 191
 		date_default_timezone_set('UTC');
192
-		$filter_query = $this->getFilter($filter,true,true);
192
+		$filter_query = $this->getFilter($filter, true, true);
193 193
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
194 194
 		if ($globalDBdriver == 'mysql') {
195 195
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		try {
213 213
 			$sth = $this->db->prepare($query);
214 214
 			$sth->execute();
215
-		} catch(PDOException $e) {
215
+		} catch (PDOException $e) {
216 216
 			echo $e->getMessage();
217 217
 			die;
218 218
 		}
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 	* @return Array the spotter information
227 227
 	*
228 228
 	*/
229
-	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false)
229
+	public function getMinLastLiveSpotterData($coord = array(), $filter = array(), $limit = false)
230 230
 	{
231 231
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
232 232
 		date_default_timezone_set('UTC');
233 233
 		$usecoord = false;
234 234
 		if (is_array($coord) && !empty($coord)) {
235
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
236
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
237
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
238
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
235
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
236
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
237
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
238
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
239 239
 			$usecoord = true;
240 240
 		}
241
-		$filter_query = $this->getFilter($filter,true,true);
241
+		$filter_query = $this->getFilter($filter, true, true);
242 242
 
243 243
 		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
244 244
 		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		try {
300 300
 			$sth = $this->db->prepare($query);
301 301
 			$sth->execute();
302
-		} catch(PDOException $e) {
302
+		} catch (PDOException $e) {
303 303
 			echo $e->getMessage();
304 304
 			die;
305 305
 		}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	public function getLiveSpotterCount($filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
319
-		$filter_query = $this->getFilter($filter,true,true);
319
+		$filter_query = $this->getFilter($filter, true, true);
320 320
 
321 321
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
322 322
 		if ($globalDBdriver == 'mysql') {
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		try {
330 330
 			$sth = $this->db->prepare($query);
331 331
 			$sth->execute();
332
-		} catch(PDOException $e) {
332
+		} catch (PDOException $e) {
333 333
 			echo $e->getMessage();
334 334
 			die;
335 335
 		}
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		$filter_query = $this->getFilter($filter);
353 353
 
354 354
 		if (is_array($coord)) {
355
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
357
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
358
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
356
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
357
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
358
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
359 359
 		} else return array();
360 360
 		if ($globalDBdriver == 'mysql') {
361 361
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -378,23 +378,23 @@  discard block
 block discarded – undo
378 378
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
379 379
 		$Spotter = new Spotter($this->db);
380 380
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
381
-		$filter_query = $this->getFilter($filter,true,true);
381
+		$filter_query = $this->getFilter($filter, true, true);
382 382
 
383 383
 		if (is_array($coord)) {
384
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
385
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
386
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
387
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
384
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
385
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
386
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
387
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
388 388
 		} else return array();
389 389
 		if ($globalDBdriver == 'mysql') {
390 390
 			if (isset($globalArchive) && $globalArchive === TRUE) {
391
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
391
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
392 392
 				FROM spotter_live 
393 393
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
394 394
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
395 395
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
396 396
 			} else {
397
-				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
397
+				$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
398 398
 				FROM spotter_live 
399 399
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
400 400
 				    FROM spotter_live l 
@@ -406,14 +406,14 @@  discard block
 block discarded – undo
406 406
 			}
407 407
 		} else {
408 408
 			if (isset($globalArchive) && $globalArchive === TRUE) {
409
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
409
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
410 410
 				FROM spotter_live 
411 411
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
412 412
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
413 413
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
414 414
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
415 415
 			} else {
416
-				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
416
+				$query = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source 
417 417
 				FROM spotter_live 
418 418
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
419 419
 				    FROM spotter_live l 
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 		try {
429 429
 			$sth = $this->db->prepare($query);
430 430
 			$sth->execute();
431
-		} catch(PDOException $e) {
431
+		} catch (PDOException $e) {
432 432
 			echo $e->getMessage();
433 433
 			die;
434 434
 		}
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 if ($interval == '1m')
478 478
                 {
479 479
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
-                } else if ($interval == '15m'){
480
+                } else if ($interval == '15m') {
481 481
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482 482
                 } 
483 483
             }
@@ -485,14 +485,14 @@  discard block
 block discarded – undo
485 485
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486 486
         }
487 487
 
488
-                $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 
488
+                $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 
489 489
                    WHERE spotter_live.latitude <> '' 
490 490
                                    AND spotter_live.longitude <> '' 
491 491
                    ".$additional_query."
492 492
                    HAVING distance < :radius  
493 493
                                    ORDER BY distance";
494 494
 
495
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
495
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
496 496
 
497 497
                 return $spotter_array;
498 498
         }
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 		date_default_timezone_set('UTC');
511 511
 
512 512
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
513
-                $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';
513
+                $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';
514 514
 
515
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
515
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
516 516
 
517 517
 		return $spotter_array;
518 518
 	}
@@ -523,16 +523,16 @@  discard block
 block discarded – undo
523 523
 	* @return Array the spotter information
524 524
 	*
525 525
 	*/
526
-	public function getDateLiveSpotterDataByIdent($ident,$date)
526
+	public function getDateLiveSpotterDataByIdent($ident, $date)
527 527
 	{
528 528
 		$Spotter = new Spotter($this->db);
529 529
 		date_default_timezone_set('UTC');
530 530
 
531 531
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
532
-                $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';
532
+                $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';
533 533
 
534
-                $date = date('c',$date);
535
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
534
+                $date = date('c', $date);
535
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 		$Spotter = new Spotter($this->db);
549 549
 		date_default_timezone_set('UTC');
550 550
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
551
-		$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';
552
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
551
+		$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';
552
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
553 553
 		return $spotter_array;
554 554
 	}
555 555
 
@@ -559,15 +559,15 @@  discard block
 block discarded – undo
559 559
 	* @return Array the spotter information
560 560
 	*
561 561
 	*/
562
-	public function getDateLiveSpotterDataById($id,$date)
562
+	public function getDateLiveSpotterDataById($id, $date)
563 563
 	{
564 564
 		$Spotter = new Spotter($this->db);
565 565
 		date_default_timezone_set('UTC');
566 566
 
567 567
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
568
-		$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';
569
-		$date = date('c',$date);
570
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
568
+		$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';
569
+		$date = date('c', $date);
570
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
571 571
 		return $spotter_array;
572 572
 	}
573 573
 
@@ -583,13 +583,13 @@  discard block
 block discarded – undo
583 583
 		date_default_timezone_set('UTC');
584 584
 
585 585
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
586
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
586
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
587 587
 
588 588
     		try {
589 589
 			
590 590
 			$sth = $this->db->prepare($query);
591 591
 			$sth->execute(array(':ident' => $ident));
592
-		} catch(PDOException $e) {
592
+		} catch (PDOException $e) {
593 593
 			echo $e->getMessage();
594 594
 			die;
595 595
 		}
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 	* @return Array the spotter information
605 605
 	*
606 606
 	*/
607
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
607
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
608 608
 	{
609 609
 		global $globalDBdriver, $globalLiveInterval;
610 610
 		date_default_timezone_set('UTC');
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
 		try {
624 624
 			$sth = $this->db->prepare($query);
625 625
 			$sth->execute(array(':id' => $id));
626
-		} catch(PDOException $e) {
626
+		} catch (PDOException $e) {
627 627
 			echo $e->getMessage();
628 628
 			die;
629 629
 		}
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
 	{
642 642
 		date_default_timezone_set('UTC');
643 643
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
644
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
644
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
645 645
     		try {
646 646
 			
647 647
 			$sth = $this->db->prepare($query);
648 648
 			$sth->execute(array(':ident' => $ident));
649
-		} catch(PDOException $e) {
649
+		} catch (PDOException $e) {
650 650
 			echo $e->getMessage();
651 651
 			die;
652 652
 		}
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			
677 677
 			$sth = $this->db->prepare($query);
678 678
 			$sth->execute();
679
-		} catch(PDOException $e) {
679
+		} catch (PDOException $e) {
680 680
 			return "error";
681 681
 		}
682 682
 
@@ -699,14 +699,14 @@  discard block
 block discarded – undo
699 699
 				
700 700
 				$sth = $this->db->prepare($query);
701 701
 				$sth->execute();
702
-			} catch(PDOException $e) {
702
+			} catch (PDOException $e) {
703 703
 				return "error";
704 704
 			}
705 705
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
706 706
                         $i = 0;
707
-                        $j =0;
707
+                        $j = 0;
708 708
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
709
-			foreach($all as $row)
709
+			foreach ($all as $row)
710 710
 			{
711 711
 				$i++;
712 712
 				$j++;
@@ -714,9 +714,9 @@  discard block
 block discarded – undo
714 714
 					if ($globalDebug) echo ".";
715 715
 				    	try {
716 716
 						
717
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
717
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
718 718
 						$sth->execute();
719
-					} catch(PDOException $e) {
719
+					} catch (PDOException $e) {
720 720
 						return "error";
721 721
 					}
722 722
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
 			if ($i > 0) {
728 728
     				try {
729 729
 					
730
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
730
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
731 731
 					$sth->execute();
732
-				} catch(PDOException $e) {
732
+				} catch (PDOException $e) {
733 733
 					return "error";
734 734
 				}
735 735
 			}
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 				
743 743
 				$sth = $this->db->prepare($query);
744 744
 				$sth->execute();
745
-			} catch(PDOException $e) {
745
+			} catch (PDOException $e) {
746 746
 				return "error";
747 747
 			}
748 748
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function deleteLiveSpotterDataByIdent($ident)
791 791
 	{
792 792
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
793
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
793
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
794 794
         
795 795
     		try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':ident' => $ident));
799
-		} catch(PDOException $e) {
799
+		} catch (PDOException $e) {
800 800
 			return "error";
801 801
 		}
802 802
 
@@ -812,13 +812,13 @@  discard block
 block discarded – undo
812 812
 	public function deleteLiveSpotterDataById($id)
813 813
 	{
814 814
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
815
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
815
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
816 816
         
817 817
     		try {
818 818
 			
819 819
 			$sth = $this->db->prepare($query);
820 820
 			$sth->execute(array(':id' => $id));
821
-		} catch(PDOException $e) {
821
+		} catch (PDOException $e) {
822 822
 			return "error";
823 823
 		}
824 824
 
@@ -836,13 +836,13 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 		global $globalDBdriver, $globalTimezone;
838 838
 		if ($globalDBdriver == 'mysql') {
839
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
839
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
840 840
 				WHERE spotter_live.ident = :ident 
841 841
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
842 842
 				AND spotter_live.date < UTC_TIMESTAMP()';
843 843
 			$query_data = array(':ident' => $ident);
844 844
 		} else {
845
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
845
+			$query = "SELECT spotter_live.ident FROM spotter_live 
846 846
 				WHERE spotter_live.ident = :ident 
847 847
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
848 848
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 		
852 852
 		$sth = $this->db->prepare($query);
853 853
 		$sth->execute($query_data);
854
-		$ident_result='';
855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
854
+		$ident_result = '';
855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
856 856
 		{
857 857
 			$ident_result = $row['ident'];
858 858
 		}
@@ -869,13 +869,13 @@  discard block
 block discarded – undo
869 869
 	{
870 870
 		global $globalDBdriver, $globalTimezone;
871 871
 		if ($globalDBdriver == 'mysql') {
872
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
872
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
873 873
 				WHERE spotter_live.ident = :ident 
874 874
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
875 875
 //				AND spotter_live.date < UTC_TIMESTAMP()";
876 876
 			$query_data = array(':ident' => $ident);
877 877
 		} else {
878
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
878
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
879 879
 				WHERE spotter_live.ident = :ident 
880 880
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
881 881
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 		
885 885
 		$sth = $this->db->prepare($query);
886 886
 		$sth->execute($query_data);
887
-		$ident_result='';
888
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
887
+		$ident_result = '';
888
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
889 889
 		{
890 890
 			$ident_result = $row['flightaware_id'];
891 891
 		}
@@ -902,13 +902,13 @@  discard block
 block discarded – undo
902 902
 	{
903 903
 		global $globalDBdriver, $globalTimezone;
904 904
 		if ($globalDBdriver == 'mysql') {
905
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
905
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
906 906
 				WHERE spotter_live.flightaware_id = :id 
907 907
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
908 908
 //				AND spotter_live.date < UTC_TIMESTAMP()";
909 909
 			$query_data = array(':id' => $id);
910 910
 		} else {
911
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
911
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
912 912
 				WHERE spotter_live.flightaware_id = :id 
913 913
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
914 914
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
 		
918 918
 		$sth = $this->db->prepare($query);
919 919
 		$sth->execute($query_data);
920
-		$ident_result='';
921
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
920
+		$ident_result = '';
921
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
922 922
 		{
923 923
 			$ident_result = $row['flightaware_id'];
924 924
 		}
@@ -935,13 +935,13 @@  discard block
 block discarded – undo
935 935
 	{
936 936
 		global $globalDBdriver, $globalTimezone;
937 937
 		if ($globalDBdriver == 'mysql') {
938
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
938
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
939 939
 				WHERE spotter_live.ModeS = :modes 
940 940
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
941 941
 //				AND spotter_live.date < UTC_TIMESTAMP()";
942 942
 			$query_data = array(':modes' => $modes);
943 943
 		} else {
944
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
944
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
945 945
 				WHERE spotter_live.ModeS = :modes 
946 946
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
947 947
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -950,8 +950,8 @@  discard block
 block discarded – undo
950 950
 		
951 951
 		$sth = $this->db->prepare($query);
952 952
 		$sth->execute($query_data);
953
-		$ident_result='';
954
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
953
+		$ident_result = '';
954
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
955 955
 		{
956 956
 			//$ident_result = $row['spotter_live_id'];
957 957
 			$ident_result = $row['flightaware_id'];
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 	* @return String success or false
971 971
 	*
972 972
 	*/
973
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
973
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
974 974
 	{
975 975
 		global $globalURL, $globalArchive, $globalDebug;
976 976
 		$Common = new Common();
@@ -1070,27 +1070,27 @@  discard block
 block discarded – undo
1070 1070
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1071 1071
 
1072 1072
         
1073
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1074
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1075
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1076
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1077
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1078
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1079
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1080
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1081
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1082
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1083
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1084
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1085
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1086
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1087
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1088
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1089
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1090
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1091
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1092
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1093
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1073
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1074
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1075
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1076
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1077
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1078
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1079
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1080
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1081
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1082
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1083
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1084
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1085
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1086
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1087
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1088
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1089
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1090
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1091
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1092
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1093
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1094 1094
 
1095 1095
 		$airline_name = '';
1096 1096
 		$airline_icao = '';
@@ -1112,10 +1112,10 @@  discard block
 block discarded – undo
1112 1112
 		$arrival_airport_country = '';
1113 1113
 		
1114 1114
             	
1115
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1116
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1117
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1118
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1115
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1116
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1117
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1118
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1119 1119
 		
1120 1120
 		$query = '';
1121 1121
 		if ($globalArchive) {
@@ -1126,19 +1126,19 @@  discard block
 block discarded – undo
1126 1126
 		$query  .= 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country, real_altitude) 
1127 1127
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country, :real_altitude)';
1128 1128
 
1129
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country,':real_altitude' => $altitude_real);
1129
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country, ':real_altitude' => $altitude_real);
1130 1130
 		try {
1131 1131
 			
1132 1132
 			$sth = $this->db->prepare($query);
1133 1133
 			$sth->execute($query_values);
1134 1134
 			$sth->closeCursor();
1135
-		} catch(PDOException $e) {
1135
+		} catch (PDOException $e) {
1136 1136
 			return "error : ".$e->getMessage();
1137 1137
 		}
1138 1138
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1139 1139
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1140 1140
 		    $SpotterArchive = new SpotterArchive($this->db);
1141
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1141
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1142 1142
 		    if ($globalDebug) echo $result.')';
1143 1143
 		} elseif ($globalDebug && $putinarchive !== true) {
1144 1144
 			echo '(Not adding to archive)';
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
 	public function getOrderBy()
1153 1153
 	{
1154
-		$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"));
1154
+		$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"));
1155 1155
 		return $orderby;
1156 1156
 	}
1157 1157
 
Please login to merge, or discard this patch.