@@ -16,64 +16,64 @@ discard block |
||
16 | 16 | * @param Array $filter the filter |
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
19 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
21 | 21 | $filters = array(); |
22 | 22 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
23 | 23 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
24 | 24 | $filters = $globalStatsFilters[$globalFilterName]; |
25 | 25 | } else { |
26 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
26 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
27 | 27 | } |
28 | 28 | } |
29 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
29 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
30 | 30 | $filter_query_join = ''; |
31 | 31 | $filter_query_where = ''; |
32 | - foreach($filters as $flt) { |
|
32 | + foreach ($filters as $flt) { |
|
33 | 33 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
34 | 34 | if ($flt['airlines'][0] != '') { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
43 | 43 | if (isset($flt['source'])) { |
44 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
44 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
45 | 45 | } else { |
46 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
46 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
50 | 50 | if (isset($flt['source'])) { |
51 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
51 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | } |
55 | 55 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
56 | 56 | if ($filter['airlines'][0] != '') { |
57 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
57 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
61 | 61 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id "; |
62 | 62 | } |
63 | 63 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
64 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
64 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_live.flightaware_id"; |
|
65 | 65 | } |
66 | 66 | if (isset($filter['source']) && !empty($filter['source'])) { |
67 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
67 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
68 | 68 | } |
69 | 69 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
70 | 70 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
71 | 71 | } |
72 | 72 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
73 | 73 | if ($filter_query_where == '') { |
74 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } else { |
76 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
76 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | if ($limit != '') |
100 | 100 | { |
101 | 101 | $limit_array = explode(',', $limit); |
102 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
103 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
102 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
103 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
104 | 104 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
105 | 105 | { |
106 | 106 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } else { |
121 | 121 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query.$orderby_query; |
122 | 122 | } |
123 | - $spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true); |
|
123 | + $spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true); |
|
124 | 124 | |
125 | 125 | return $spotter_array; |
126 | 126 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | global $globalDBdriver, $globalLiveInterval; |
137 | 137 | date_default_timezone_set('UTC'); |
138 | 138 | |
139 | - $filter_query = $this->getFilter($filter,true,true); |
|
139 | + $filter_query = $this->getFilter($filter, true, true); |
|
140 | 140 | |
141 | 141 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
142 | 142 | if ($globalDBdriver == 'mysql') { |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $query = 'SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
148 | 148 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
149 | 149 | */ |
150 | - $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 |
|
150 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
151 | 151 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0"; |
152 | 152 | |
153 | 153 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $query = "SELECT a.aircraft_shadow, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
162 | 162 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
163 | 163 | */ |
164 | - $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 |
|
164 | + $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 |
|
165 | 165 | FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'"; |
166 | 166 | |
167 | 167 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | try { |
172 | 172 | $sth = $this->db->prepare($query); |
173 | 173 | $sth->execute(); |
174 | - } catch(PDOException $e) { |
|
174 | + } catch (PDOException $e) { |
|
175 | 175 | echo $e->getMessage(); |
176 | 176 | die; |
177 | 177 | } |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | global $globalDBdriver, $globalLiveInterval; |
192 | 192 | date_default_timezone_set('UTC'); |
193 | 193 | |
194 | - $filter_query = $this->getFilter($filter,true,true); |
|
194 | + $filter_query = $this->getFilter($filter, true, true); |
|
195 | 195 | |
196 | 196 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
197 | 197 | if ($globalDBdriver == 'mysql') { |
198 | 198 | |
199 | - $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
199 | + $query = 'SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
200 | 200 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
201 | 201 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
202 | 202 | } else { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | FROM spotter_live WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date |
206 | 206 | ".$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao ORDER BY spotter_live.flightaware_id, spotter_live.date'; |
207 | 207 | */ |
208 | - $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
208 | + $query = "SELECT a.aircraft_shadow, a.engine_type, a.engine_count, a.wake_category, spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source |
|
209 | 209 | FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' |
210 | 210 | ORDER BY spotter_live.flightaware_id, spotter_live.date"; |
211 | 211 | // echo $query; |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | try { |
215 | 215 | $sth = $this->db->prepare($query); |
216 | 216 | $sth->execute(); |
217 | - } catch(PDOException $e) { |
|
217 | + } catch (PDOException $e) { |
|
218 | 218 | echo $e->getMessage(); |
219 | 219 | die; |
220 | 220 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public function getLiveSpotterCount($filter = array()) |
232 | 232 | { |
233 | 233 | global $globalDBdriver, $globalLiveInterval; |
234 | - $filter_query = $this->getFilter($filter,true,true); |
|
234 | + $filter_query = $this->getFilter($filter, true, true); |
|
235 | 235 | |
236 | 236 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
237 | 237 | if ($globalDBdriver == 'mysql') { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | try { |
245 | 245 | $sth = $this->db->prepare($query); |
246 | 246 | $sth->execute(); |
247 | - } catch(PDOException $e) { |
|
247 | + } catch (PDOException $e) { |
|
248 | 248 | echo $e->getMessage(); |
249 | 249 | die; |
250 | 250 | } |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | $filter_query = $this->getFilter($filter); |
268 | 268 | |
269 | 269 | if (is_array($coord)) { |
270 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
271 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
272 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
273 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
270 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
271 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
272 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
273 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
274 | 274 | } else return array(); |
275 | 275 | if ($globalDBdriver == 'mysql') { |
276 | 276 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | if ($interval == '1m') |
324 | 324 | { |
325 | 325 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
326 | - } else if ($interval == '15m'){ |
|
326 | + } else if ($interval == '15m') { |
|
327 | 327 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date '; |
328 | 328 | } |
329 | 329 | } |
@@ -331,14 +331,14 @@ discard block |
||
331 | 331 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date '; |
332 | 332 | } |
333 | 333 | |
334 | - $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 |
|
334 | + $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 |
|
335 | 335 | WHERE spotter_live.latitude <> '' |
336 | 336 | AND spotter_live.longitude <> '' |
337 | 337 | ".$additional_query." |
338 | 338 | HAVING distance < :radius |
339 | 339 | ORDER BY distance"; |
340 | 340 | |
341 | - $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
341 | + $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
342 | 342 | |
343 | 343 | return $spotter_array; |
344 | 344 | } |
@@ -356,9 +356,9 @@ discard block |
||
356 | 356 | date_default_timezone_set('UTC'); |
357 | 357 | |
358 | 358 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
359 | - $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'; |
|
359 | + $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'; |
|
360 | 360 | |
361 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
361 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
362 | 362 | |
363 | 363 | return $spotter_array; |
364 | 364 | } |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | * @return Array the spotter information |
370 | 370 | * |
371 | 371 | */ |
372 | - public function getDateLiveSpotterDataByIdent($ident,$date) |
|
372 | + public function getDateLiveSpotterDataByIdent($ident, $date) |
|
373 | 373 | { |
374 | 374 | $Spotter = new Spotter($this->db); |
375 | 375 | date_default_timezone_set('UTC'); |
376 | 376 | |
377 | 377 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
378 | - $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.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'; |
|
378 | + $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.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'; |
|
379 | 379 | |
380 | - $date = date('c',$date); |
|
381 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
380 | + $date = date('c', $date); |
|
381 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
382 | 382 | |
383 | 383 | return $spotter_array; |
384 | 384 | } |
@@ -395,9 +395,9 @@ discard block |
||
395 | 395 | date_default_timezone_set('UTC'); |
396 | 396 | |
397 | 397 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
398 | - $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'; |
|
398 | + $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'; |
|
399 | 399 | |
400 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true); |
|
400 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true); |
|
401 | 401 | |
402 | 402 | return $spotter_array; |
403 | 403 | } |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | * @return Array the spotter information |
409 | 409 | * |
410 | 410 | */ |
411 | - public function getDateLiveSpotterDataById($id,$date) |
|
411 | + public function getDateLiveSpotterDataById($id, $date) |
|
412 | 412 | { |
413 | 413 | $Spotter = new Spotter($this->db); |
414 | 414 | date_default_timezone_set('UTC'); |
415 | 415 | |
416 | 416 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
417 | - $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'; |
|
418 | - $date = date('c',$date); |
|
419 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
417 | + $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'; |
|
418 | + $date = date('c', $date); |
|
419 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
420 | 420 | |
421 | 421 | return $spotter_array; |
422 | 422 | } |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
436 | - $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
436 | + $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident'; |
|
437 | 437 | |
438 | 438 | try { |
439 | 439 | |
440 | 440 | $sth = $this->db->prepare($query); |
441 | 441 | $sth->execute(array(':ident' => $ident)); |
442 | - } catch(PDOException $e) { |
|
442 | + } catch (PDOException $e) { |
|
443 | 443 | echo $e->getMessage(); |
444 | 444 | die; |
445 | 445 | } |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * @return Array the spotter information |
455 | 455 | * |
456 | 456 | */ |
457 | - public function getAllLiveSpotterDataById($id,$liveinterval = false) |
|
457 | + public function getAllLiveSpotterDataById($id, $liveinterval = false) |
|
458 | 458 | { |
459 | 459 | global $globalDBdriver, $globalLiveInterval; |
460 | 460 | date_default_timezone_set('UTC'); |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | try { |
474 | 474 | $sth = $this->db->prepare($query); |
475 | 475 | $sth->execute(array(':id' => $id)); |
476 | - } catch(PDOException $e) { |
|
476 | + } catch (PDOException $e) { |
|
477 | 477 | echo $e->getMessage(); |
478 | 478 | die; |
479 | 479 | } |
@@ -491,12 +491,12 @@ discard block |
||
491 | 491 | { |
492 | 492 | date_default_timezone_set('UTC'); |
493 | 493 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
494 | - $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
494 | + $query = self::$global_query.' WHERE spotter_live.ident = :ident'; |
|
495 | 495 | try { |
496 | 496 | |
497 | 497 | $sth = $this->db->prepare($query); |
498 | 498 | $sth->execute(array(':ident' => $ident)); |
499 | - } catch(PDOException $e) { |
|
499 | + } catch (PDOException $e) { |
|
500 | 500 | echo $e->getMessage(); |
501 | 501 | die; |
502 | 502 | } |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | |
527 | 527 | $sth = $this->db->prepare($query); |
528 | 528 | $sth->execute(); |
529 | - } catch(PDOException $e) { |
|
529 | + } catch (PDOException $e) { |
|
530 | 530 | return "error"; |
531 | 531 | } |
532 | 532 | |
@@ -549,14 +549,14 @@ discard block |
||
549 | 549 | |
550 | 550 | $sth = $this->db->prepare($query); |
551 | 551 | $sth->execute(); |
552 | - } catch(PDOException $e) { |
|
552 | + } catch (PDOException $e) { |
|
553 | 553 | return "error"; |
554 | 554 | } |
555 | 555 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
556 | 556 | $i = 0; |
557 | - $j =0; |
|
557 | + $j = 0; |
|
558 | 558 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
559 | - foreach($all as $row) |
|
559 | + foreach ($all as $row) |
|
560 | 560 | { |
561 | 561 | $i++; |
562 | 562 | $j++; |
@@ -564,9 +564,9 @@ discard block |
||
564 | 564 | if ($globalDebug) echo "."; |
565 | 565 | try { |
566 | 566 | |
567 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
567 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
568 | 568 | $sth->execute(); |
569 | - } catch(PDOException $e) { |
|
569 | + } catch (PDOException $e) { |
|
570 | 570 | return "error"; |
571 | 571 | } |
572 | 572 | $query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN ('; |
@@ -577,9 +577,9 @@ discard block |
||
577 | 577 | if ($i > 0) { |
578 | 578 | try { |
579 | 579 | |
580 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
580 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
581 | 581 | $sth->execute(); |
582 | - } catch(PDOException $e) { |
|
582 | + } catch (PDOException $e) { |
|
583 | 583 | return "error"; |
584 | 584 | } |
585 | 585 | } |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | |
593 | 593 | $sth = $this->db->prepare($query); |
594 | 594 | $sth->execute(); |
595 | - } catch(PDOException $e) { |
|
595 | + } catch (PDOException $e) { |
|
596 | 596 | return "error"; |
597 | 597 | } |
598 | 598 | /* $query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN ("; |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | public function deleteLiveSpotterDataByIdent($ident) |
641 | 641 | { |
642 | 642 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
643 | - $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
643 | + $query = 'DELETE FROM spotter_live WHERE ident = :ident'; |
|
644 | 644 | |
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 | return "error"; |
651 | 651 | } |
652 | 652 | |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | public function deleteLiveSpotterDataById($id) |
663 | 663 | { |
664 | 664 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
665 | - $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
665 | + $query = 'DELETE FROM spotter_live WHERE flightaware_id = :id'; |
|
666 | 666 | |
667 | 667 | try { |
668 | 668 | |
669 | 669 | $sth = $this->db->prepare($query); |
670 | 670 | $sth->execute(array(':id' => $id)); |
671 | - } catch(PDOException $e) { |
|
671 | + } catch (PDOException $e) { |
|
672 | 672 | return "error"; |
673 | 673 | } |
674 | 674 | |
@@ -686,13 +686,13 @@ discard block |
||
686 | 686 | { |
687 | 687 | global $globalDBdriver, $globalTimezone; |
688 | 688 | if ($globalDBdriver == 'mysql') { |
689 | - $query = 'SELECT spotter_live.ident FROM spotter_live |
|
689 | + $query = 'SELECT spotter_live.ident FROM spotter_live |
|
690 | 690 | WHERE spotter_live.ident = :ident |
691 | 691 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
692 | 692 | AND spotter_live.date < UTC_TIMESTAMP()'; |
693 | 693 | $query_data = array(':ident' => $ident); |
694 | 694 | } else { |
695 | - $query = "SELECT spotter_live.ident FROM spotter_live |
|
695 | + $query = "SELECT spotter_live.ident FROM spotter_live |
|
696 | 696 | WHERE spotter_live.ident = :ident |
697 | 697 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
698 | 698 | AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | |
702 | 702 | $sth = $this->db->prepare($query); |
703 | 703 | $sth->execute($query_data); |
704 | - $ident_result=''; |
|
705 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
704 | + $ident_result = ''; |
|
705 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
706 | 706 | { |
707 | 707 | $ident_result = $row['ident']; |
708 | 708 | } |
@@ -719,13 +719,13 @@ discard block |
||
719 | 719 | { |
720 | 720 | global $globalDBdriver, $globalTimezone; |
721 | 721 | if ($globalDBdriver == 'mysql') { |
722 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
722 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
723 | 723 | WHERE spotter_live.ident = :ident |
724 | 724 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
725 | 725 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
726 | 726 | $query_data = array(':ident' => $ident); |
727 | 727 | } else { |
728 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
728 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
729 | 729 | WHERE spotter_live.ident = :ident |
730 | 730 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
731 | 731 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -734,8 +734,8 @@ discard block |
||
734 | 734 | |
735 | 735 | $sth = $this->db->prepare($query); |
736 | 736 | $sth->execute($query_data); |
737 | - $ident_result=''; |
|
738 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
737 | + $ident_result = ''; |
|
738 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
739 | 739 | { |
740 | 740 | $ident_result = $row['flightaware_id']; |
741 | 741 | } |
@@ -752,13 +752,13 @@ discard block |
||
752 | 752 | { |
753 | 753 | global $globalDBdriver, $globalTimezone; |
754 | 754 | if ($globalDBdriver == 'mysql') { |
755 | - $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
755 | + $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
756 | 756 | WHERE spotter_live.flightaware_id = :id |
757 | 757 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
758 | 758 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
759 | 759 | $query_data = array(':id' => $id); |
760 | 760 | } else { |
761 | - $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
761 | + $query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live |
|
762 | 762 | WHERE spotter_live.flightaware_id = :id |
763 | 763 | AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
764 | 764 | // AND spotter_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -767,8 +767,8 @@ discard block |
||
767 | 767 | |
768 | 768 | $sth = $this->db->prepare($query); |
769 | 769 | $sth->execute($query_data); |
770 | - $ident_result=''; |
|
771 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
770 | + $ident_result = ''; |
|
771 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
772 | 772 | { |
773 | 773 | $ident_result = $row['flightaware_id']; |
774 | 774 | } |
@@ -785,13 +785,13 @@ discard block |
||
785 | 785 | { |
786 | 786 | global $globalDBdriver, $globalTimezone; |
787 | 787 | if ($globalDBdriver == 'mysql') { |
788 | - $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
788 | + $query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
789 | 789 | WHERE spotter_live.ModeS = :modes |
790 | 790 | AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
791 | 791 | // AND spotter_live.date < UTC_TIMESTAMP()"; |
792 | 792 | $query_data = array(':modes' => $modes); |
793 | 793 | } else { |
794 | - $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
794 | + $query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live |
|
795 | 795 | WHERE spotter_live.ModeS = :modes |
796 | 796 | AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'"; |
797 | 797 | // // AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
@@ -800,8 +800,8 @@ discard block |
||
800 | 800 | |
801 | 801 | $sth = $this->db->prepare($query); |
802 | 802 | $sth->execute($query_data); |
803 | - $ident_result=''; |
|
804 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
803 | + $ident_result = ''; |
|
804 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
805 | 805 | { |
806 | 806 | //$ident_result = $row['spotter_live_id']; |
807 | 807 | $ident_result = $row['flightaware_id']; |
@@ -820,7 +820,7 @@ discard block |
||
820 | 820 | * @return String success or false |
821 | 821 | * |
822 | 822 | */ |
823 | - public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '') |
|
823 | + public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '') |
|
824 | 824 | { |
825 | 825 | global $globalURL, $globalArchive, $globalDebug; |
826 | 826 | $Common = new Common(); |
@@ -913,26 +913,26 @@ discard block |
||
913 | 913 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
914 | 914 | |
915 | 915 | |
916 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
917 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
918 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
919 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
920 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
921 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
922 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
923 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
924 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
925 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
926 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
927 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
928 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
929 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
930 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
931 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
932 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
933 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
934 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
935 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
916 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
917 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
918 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
919 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
920 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
921 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
922 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
923 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
924 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
925 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
926 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
927 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
929 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
930 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
931 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
932 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
933 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
934 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
935 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | 937 | $airline_name = ''; |
938 | 938 | $airline_icao = ''; |
@@ -954,26 +954,26 @@ discard block |
||
954 | 954 | $arrival_airport_country = ''; |
955 | 955 | |
956 | 956 | |
957 | - if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL; |
|
958 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL; |
|
959 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
960 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
957 | + if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL; |
|
958 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL; |
|
959 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
960 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
961 | 961 | |
962 | - $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) |
|
962 | + $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) |
|
963 | 963 | 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)'; |
964 | 964 | |
965 | - $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); |
|
965 | + $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); |
|
966 | 966 | try { |
967 | 967 | |
968 | 968 | $sth = $this->db->prepare($query); |
969 | 969 | $sth->execute($query_values); |
970 | - } catch(PDOException $e) { |
|
970 | + } catch (PDOException $e) { |
|
971 | 971 | return "error : ".$e->getMessage(); |
972 | 972 | } |
973 | 973 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
974 | 974 | if ($globalDebug) echo '(Add to SBS archive : '; |
975 | 975 | $SpotterArchive = new SpotterArchive($this->db); |
976 | - $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
|
976 | + $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country); |
|
977 | 977 | if ($globalDebug) echo $result.')'; |
978 | 978 | } |
979 | 979 | return "success"; |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | |
983 | 983 | public function getOrderBy() |
984 | 984 | { |
985 | - $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")); |
|
985 | + $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")); |
|
986 | 986 | return $orderby; |
987 | 987 | } |
988 | 988 |