@@ -11,7 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * Get SQL query part for filter used |
13 | 13 | * @param Array $filter the filter |
14 | - * @return Array the SQL part |
|
14 | + * @return string the SQL part |
|
15 | 15 | */ |
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -8,12 +8,12 @@ discard block |
||
8 | 8 | $this->db = $Connection->db; |
9 | 9 | } |
10 | 10 | |
11 | - /** |
|
12 | - * Get SQL query part for filter used |
|
13 | - * @param Array $filter the filter |
|
14 | - * @return Array the SQL part |
|
15 | - */ |
|
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
11 | + /** |
|
12 | + * Get SQL query part for filter used |
|
13 | + * @param Array $filter the filter |
|
14 | + * @return Array the SQL part |
|
15 | + */ |
|
16 | + public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
@@ -27,74 +27,74 @@ discard block |
||
27 | 27 | $filter_query_join = ''; |
28 | 28 | $filter_query_where = ''; |
29 | 29 | foreach($filters as $flt) { |
30 | - if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
30 | + if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
|
31 | 31 | if ($flt['airlines'][0] != '') { |
32 | - if (isset($flt['source'])) { |
|
32 | + if (isset($flt['source'])) { |
|
33 | 33 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
34 | - } else { |
|
34 | + } else { |
|
35 | 35 | $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"; |
36 | - } |
|
36 | + } |
|
37 | + } |
|
37 | 38 | } |
38 | - } |
|
39 | - if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
39 | + if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
|
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | 44 | } |
45 | - } |
|
46 | - if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
45 | + } |
|
46 | + if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
|
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
48 | + $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"; |
|
49 | + } |
|
49 | 50 | } |
50 | - } |
|
51 | 51 | } |
52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
53 | - if ($filter['airlines'][0] != '') { |
|
53 | + if ($filter['airlines'][0] != '') { |
|
54 | 54 | $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"; |
55 | - } |
|
55 | + } |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
59 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
59 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
|
60 | 60 | } |
61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
63 | 63 | } |
64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
65 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
65 | + $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
66 | 66 | } |
67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
68 | - $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
68 | + $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
|
69 | 69 | } |
70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
71 | 71 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
72 | 72 | } |
73 | 73 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
74 | - $filter_query_date = ''; |
|
74 | + $filter_query_date = ''; |
|
75 | 75 | |
76 | - if (isset($filter['year']) && $filter['year'] != '') { |
|
76 | + if (isset($filter['year']) && $filter['year'] != '') { |
|
77 | 77 | if ($globalDBdriver == 'mysql') { |
78 | - $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
78 | + $filter_query_date .= " AND YEAR(spotter_archive_output.date) = '".$filter['year']."'"; |
|
79 | 79 | } else { |
80 | - $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
80 | + $filter_query_date .= " AND EXTRACT(YEAR FROM spotter_archive_output.date) = '".$filter['year']."'"; |
|
81 | 81 | } |
82 | - } |
|
83 | - if (isset($filter['month']) && $filter['month'] != '') { |
|
82 | + } |
|
83 | + if (isset($filter['month']) && $filter['month'] != '') { |
|
84 | 84 | if ($globalDBdriver == 'mysql') { |
85 | - $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
85 | + $filter_query_date .= " AND MONTH(spotter_archive_output.date) = '".$filter['month']."'"; |
|
86 | 86 | } else { |
87 | - $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
87 | + $filter_query_date .= " AND EXTRACT(MONTH FROM spotter_archive_output.date) = '".$filter['month']."'"; |
|
88 | + } |
|
88 | 89 | } |
89 | - } |
|
90 | - if (isset($filter['day']) && $filter['day'] != '') { |
|
90 | + if (isset($filter['day']) && $filter['day'] != '') { |
|
91 | 91 | if ($globalDBdriver == 'mysql') { |
92 | - $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
92 | + $filter_query_date .= " AND DAY(spotter_archive_output.date) = '".$filter['day']."'"; |
|
93 | 93 | } else { |
94 | - $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
94 | + $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
|
95 | + } |
|
95 | 96 | } |
96 | - } |
|
97 | - $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"; |
|
97 | + $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"; |
|
98 | 98 | } |
99 | 99 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
100 | 100 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | $filter_query = $filter_query_join.$filter_query_where; |
105 | 105 | return $filter_query; |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | 108 | // Spotter_archive |
109 | 109 | public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
@@ -134,44 +134,44 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | - /** |
|
138 | - * Gets all the spotter information based on a particular callsign |
|
139 | - * |
|
140 | - * @return Array the spotter information |
|
141 | - * |
|
142 | - */ |
|
143 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
144 | - { |
|
137 | + /** |
|
138 | + * Gets all the spotter information based on a particular callsign |
|
139 | + * |
|
140 | + * @return Array the spotter information |
|
141 | + * |
|
142 | + */ |
|
143 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
144 | + { |
|
145 | 145 | $Spotter = new Spotter($this->db); |
146 | - date_default_timezone_set('UTC'); |
|
146 | + date_default_timezone_set('UTC'); |
|
147 | 147 | |
148 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
149 | - //$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"; |
|
150 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
148 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
149 | + //$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"; |
|
150 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
151 | 151 | |
152 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
152 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
153 | 153 | |
154 | - return $spotter_array; |
|
155 | - } |
|
154 | + return $spotter_array; |
|
155 | + } |
|
156 | 156 | |
157 | 157 | |
158 | - /** |
|
159 | - * Gets last the spotter information based on a particular id |
|
160 | - * |
|
161 | - * @return Array the spotter information |
|
162 | - * |
|
163 | - */ |
|
164 | - public function getLastArchiveSpotterDataById($id) |
|
165 | - { |
|
166 | - $Spotter = new Spotter($this->db); |
|
167 | - date_default_timezone_set('UTC'); |
|
168 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
169 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
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.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"; |
|
171 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
158 | + /** |
|
159 | + * Gets last the spotter information based on a particular id |
|
160 | + * |
|
161 | + * @return Array the spotter information |
|
162 | + * |
|
163 | + */ |
|
164 | + public function getLastArchiveSpotterDataById($id) |
|
165 | + { |
|
166 | + $Spotter = new Spotter($this->db); |
|
167 | + date_default_timezone_set('UTC'); |
|
168 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
169 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
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.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"; |
|
171 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
174 | - /* |
|
174 | + /* |
|
175 | 175 | try { |
176 | 176 | $Connection = new Connection(); |
177 | 177 | $sth = Connection->$db->prepare($query); |
@@ -181,232 +181,232 @@ discard block |
||
181 | 181 | } |
182 | 182 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
183 | 183 | */ |
184 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
185 | - |
|
186 | - return $spotter_array; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Gets all the spotter information based on a particular id |
|
191 | - * |
|
192 | - * @return Array the spotter information |
|
193 | - * |
|
194 | - */ |
|
195 | - public function getAllArchiveSpotterDataById($id) |
|
196 | - { |
|
197 | - date_default_timezone_set('UTC'); |
|
198 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
199 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
184 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
185 | + |
|
186 | + return $spotter_array; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Gets all the spotter information based on a particular id |
|
191 | + * |
|
192 | + * @return Array the spotter information |
|
193 | + * |
|
194 | + */ |
|
195 | + public function getAllArchiveSpotterDataById($id) |
|
196 | + { |
|
197 | + date_default_timezone_set('UTC'); |
|
198 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
199 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
200 | 200 | |
201 | 201 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
202 | 202 | |
203 | - try { |
|
204 | - $sth = $this->db->prepare($query); |
|
205 | - $sth->execute(array(':id' => $id)); |
|
206 | - } catch(PDOException $e) { |
|
207 | - echo $e->getMessage(); |
|
208 | - die; |
|
209 | - } |
|
210 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
211 | - |
|
212 | - return $spotter_array; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Gets coordinate & time spotter information based on a particular id |
|
217 | - * |
|
218 | - * @return Array the spotter information |
|
219 | - * |
|
220 | - */ |
|
221 | - public function getCoordArchiveSpotterDataById($id) |
|
222 | - { |
|
223 | - date_default_timezone_set('UTC'); |
|
224 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
225 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
203 | + try { |
|
204 | + $sth = $this->db->prepare($query); |
|
205 | + $sth->execute(array(':id' => $id)); |
|
206 | + } catch(PDOException $e) { |
|
207 | + echo $e->getMessage(); |
|
208 | + die; |
|
209 | + } |
|
210 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
211 | + |
|
212 | + return $spotter_array; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Gets coordinate & time spotter information based on a particular id |
|
217 | + * |
|
218 | + * @return Array the spotter information |
|
219 | + * |
|
220 | + */ |
|
221 | + public function getCoordArchiveSpotterDataById($id) |
|
222 | + { |
|
223 | + date_default_timezone_set('UTC'); |
|
224 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
225 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
226 | 226 | |
227 | 227 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
228 | 228 | |
229 | - try { |
|
230 | - $sth = $this->db->prepare($query); |
|
231 | - $sth->execute(array(':id' => $id)); |
|
232 | - } catch(PDOException $e) { |
|
233 | - echo $e->getMessage(); |
|
234 | - die; |
|
235 | - } |
|
236 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
229 | + try { |
|
230 | + $sth = $this->db->prepare($query); |
|
231 | + $sth->execute(array(':id' => $id)); |
|
232 | + } catch(PDOException $e) { |
|
233 | + echo $e->getMessage(); |
|
234 | + die; |
|
235 | + } |
|
236 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
237 | 237 | |
238 | - return $spotter_array; |
|
239 | - } |
|
238 | + return $spotter_array; |
|
239 | + } |
|
240 | 240 | |
241 | 241 | |
242 | - /** |
|
243 | - * Gets altitude information based on a particular callsign |
|
244 | - * |
|
245 | - * @return Array the spotter information |
|
246 | - * |
|
247 | - */ |
|
248 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
249 | - { |
|
242 | + /** |
|
243 | + * Gets altitude information based on a particular callsign |
|
244 | + * |
|
245 | + * @return Array the spotter information |
|
246 | + * |
|
247 | + */ |
|
248 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
249 | + { |
|
250 | 250 | |
251 | - date_default_timezone_set('UTC'); |
|
251 | + date_default_timezone_set('UTC'); |
|
252 | 252 | |
253 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
254 | - $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"; |
|
253 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
254 | + $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"; |
|
255 | 255 | |
256 | - try { |
|
257 | - $sth = $this->db->prepare($query); |
|
258 | - $sth->execute(array(':ident' => $ident)); |
|
259 | - } catch(PDOException $e) { |
|
260 | - echo $e->getMessage(); |
|
261 | - die; |
|
262 | - } |
|
263 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
256 | + try { |
|
257 | + $sth = $this->db->prepare($query); |
|
258 | + $sth->execute(array(':ident' => $ident)); |
|
259 | + } catch(PDOException $e) { |
|
260 | + echo $e->getMessage(); |
|
261 | + die; |
|
262 | + } |
|
263 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
264 | 264 | |
265 | - return $spotter_array; |
|
266 | - } |
|
265 | + return $spotter_array; |
|
266 | + } |
|
267 | 267 | |
268 | - /** |
|
269 | - * Gets altitude information based on a particular id |
|
270 | - * |
|
271 | - * @return Array the spotter information |
|
272 | - * |
|
273 | - */ |
|
274 | - public function getAltitudeArchiveSpotterDataById($id) |
|
275 | - { |
|
268 | + /** |
|
269 | + * Gets altitude information based on a particular id |
|
270 | + * |
|
271 | + * @return Array the spotter information |
|
272 | + * |
|
273 | + */ |
|
274 | + public function getAltitudeArchiveSpotterDataById($id) |
|
275 | + { |
|
276 | 276 | |
277 | - date_default_timezone_set('UTC'); |
|
277 | + date_default_timezone_set('UTC'); |
|
278 | 278 | |
279 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
280 | - $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"; |
|
279 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
280 | + $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"; |
|
281 | 281 | |
282 | - try { |
|
283 | - $sth = $this->db->prepare($query); |
|
284 | - $sth->execute(array(':id' => $id)); |
|
285 | - } catch(PDOException $e) { |
|
286 | - echo $e->getMessage(); |
|
287 | - die; |
|
288 | - } |
|
289 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
282 | + try { |
|
283 | + $sth = $this->db->prepare($query); |
|
284 | + $sth->execute(array(':id' => $id)); |
|
285 | + } catch(PDOException $e) { |
|
286 | + echo $e->getMessage(); |
|
287 | + die; |
|
288 | + } |
|
289 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
290 | 290 | |
291 | - return $spotter_array; |
|
292 | - } |
|
291 | + return $spotter_array; |
|
292 | + } |
|
293 | 293 | |
294 | - /** |
|
295 | - * Gets altitude & speed information based on a particular id |
|
296 | - * |
|
297 | - * @return Array the spotter information |
|
298 | - * |
|
299 | - */ |
|
300 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
301 | - { |
|
294 | + /** |
|
295 | + * Gets altitude & speed information based on a particular id |
|
296 | + * |
|
297 | + * @return Array the spotter information |
|
298 | + * |
|
299 | + */ |
|
300 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
301 | + { |
|
302 | 302 | |
303 | - date_default_timezone_set('UTC'); |
|
303 | + date_default_timezone_set('UTC'); |
|
304 | 304 | |
305 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
306 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
305 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
306 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
307 | 307 | |
308 | - try { |
|
309 | - $sth = $this->db->prepare($query); |
|
310 | - $sth->execute(array(':id' => $id)); |
|
311 | - } catch(PDOException $e) { |
|
312 | - echo $e->getMessage(); |
|
313 | - die; |
|
314 | - } |
|
315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | + try { |
|
309 | + $sth = $this->db->prepare($query); |
|
310 | + $sth->execute(array(':id' => $id)); |
|
311 | + } catch(PDOException $e) { |
|
312 | + echo $e->getMessage(); |
|
313 | + die; |
|
314 | + } |
|
315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
316 | 316 | |
317 | - return $spotter_array; |
|
318 | - } |
|
317 | + return $spotter_array; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | - /** |
|
322 | - * Gets altitude information based on a particular callsign |
|
323 | - * |
|
324 | - * @return Array the spotter information |
|
325 | - * |
|
326 | - */ |
|
327 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
328 | - { |
|
321 | + /** |
|
322 | + * Gets altitude information based on a particular callsign |
|
323 | + * |
|
324 | + * @return Array the spotter information |
|
325 | + * |
|
326 | + */ |
|
327 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
328 | + { |
|
329 | 329 | |
330 | - date_default_timezone_set('UTC'); |
|
330 | + date_default_timezone_set('UTC'); |
|
331 | 331 | |
332 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
333 | - $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"; |
|
332 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
333 | + $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"; |
|
334 | 334 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
335 | 335 | |
336 | - try { |
|
337 | - $sth = $this->db->prepare($query); |
|
338 | - $sth->execute(array(':ident' => $ident)); |
|
339 | - } catch(PDOException $e) { |
|
340 | - echo $e->getMessage(); |
|
341 | - die; |
|
342 | - } |
|
343 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
336 | + try { |
|
337 | + $sth = $this->db->prepare($query); |
|
338 | + $sth->execute(array(':ident' => $ident)); |
|
339 | + } catch(PDOException $e) { |
|
340 | + echo $e->getMessage(); |
|
341 | + die; |
|
342 | + } |
|
343 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
344 | 344 | |
345 | - return $spotter_array; |
|
346 | - } |
|
345 | + return $spotter_array; |
|
346 | + } |
|
347 | 347 | |
348 | 348 | |
349 | 349 | |
350 | - /** |
|
351 | - * Gets all the archive spotter information |
|
352 | - * |
|
353 | - * @return Array the spotter information |
|
354 | - * |
|
355 | - */ |
|
356 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
357 | - { |
|
358 | - $Spotter = new Spotter($this->db); |
|
359 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
360 | - $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"; |
|
350 | + /** |
|
351 | + * Gets all the archive spotter information |
|
352 | + * |
|
353 | + * @return Array the spotter information |
|
354 | + * |
|
355 | + */ |
|
356 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
357 | + { |
|
358 | + $Spotter = new Spotter($this->db); |
|
359 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
360 | + $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"; |
|
361 | 361 | |
362 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
362 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
363 | 363 | |
364 | - return $spotter_array; |
|
365 | - } |
|
364 | + return $spotter_array; |
|
365 | + } |
|
366 | 366 | |
367 | - public function deleteSpotterArchiveTrackData() |
|
368 | - { |
|
367 | + public function deleteSpotterArchiveTrackData() |
|
368 | + { |
|
369 | 369 | global $globalArchiveKeepTrackMonths; |
370 | - date_default_timezone_set('UTC'); |
|
370 | + date_default_timezone_set('UTC'); |
|
371 | 371 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
372 | - try { |
|
373 | - $sth = $this->db->prepare($query); |
|
374 | - $sth->execute(); |
|
375 | - } catch(PDOException $e) { |
|
376 | - echo $e->getMessage(); |
|
377 | - die; |
|
378 | - } |
|
372 | + try { |
|
373 | + $sth = $this->db->prepare($query); |
|
374 | + $sth->execute(); |
|
375 | + } catch(PDOException $e) { |
|
376 | + echo $e->getMessage(); |
|
377 | + die; |
|
378 | + } |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | /** |
382 | - * Gets Minimal Live Spotter data |
|
383 | - * |
|
384 | - * @return Array the spotter information |
|
385 | - * |
|
386 | - */ |
|
387 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
388 | - { |
|
389 | - global $globalDBdriver, $globalLiveInterval; |
|
390 | - date_default_timezone_set('UTC'); |
|
391 | - |
|
392 | - $filter_query = ''; |
|
393 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
394 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
395 | - } |
|
396 | - // Use spotter_output also ? |
|
397 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
398 | - $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 "; |
|
399 | - } |
|
400 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
401 | - $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 "; |
|
402 | - } |
|
403 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
404 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
405 | - } |
|
406 | - |
|
407 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
408 | - if ($globalDBdriver == 'mysql') { |
|
409 | - /* |
|
382 | + * Gets Minimal Live Spotter data |
|
383 | + * |
|
384 | + * @return Array the spotter information |
|
385 | + * |
|
386 | + */ |
|
387 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
388 | + { |
|
389 | + global $globalDBdriver, $globalLiveInterval; |
|
390 | + date_default_timezone_set('UTC'); |
|
391 | + |
|
392 | + $filter_query = ''; |
|
393 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
394 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
395 | + } |
|
396 | + // Use spotter_output also ? |
|
397 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
398 | + $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 "; |
|
399 | + } |
|
400 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
401 | + $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 "; |
|
402 | + } |
|
403 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
404 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
405 | + } |
|
406 | + |
|
407 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
408 | + if ($globalDBdriver == 'mysql') { |
|
409 | + /* |
|
410 | 410 | $query = 'SELECT a.aircraft_shadow, 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 |
411 | 411 | FROM spotter_archive |
412 | 412 | 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'; |
@@ -425,56 +425,56 @@ discard block |
||
425 | 425 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
426 | 426 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
427 | 427 | '.$filter_query.' ORDER BY flightaware_id'; |
428 | - } else { |
|
429 | - //$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'; |
|
430 | - $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 |
|
428 | + } else { |
|
429 | + //$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'; |
|
430 | + $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 |
|
431 | 431 | FROM spotter_archive |
432 | 432 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
433 | 433 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
434 | 434 | '.$filter_query.' ORDER BY flightaware_id'; |
435 | - } |
|
436 | - //echo $query; |
|
437 | - try { |
|
438 | - $sth = $this->db->prepare($query); |
|
439 | - $sth->execute(); |
|
440 | - } catch(PDOException $e) { |
|
441 | - echo $e->getMessage(); |
|
442 | - die; |
|
443 | - } |
|
444 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
445 | - |
|
446 | - return $spotter_array; |
|
447 | - } |
|
435 | + } |
|
436 | + //echo $query; |
|
437 | + try { |
|
438 | + $sth = $this->db->prepare($query); |
|
439 | + $sth->execute(); |
|
440 | + } catch(PDOException $e) { |
|
441 | + echo $e->getMessage(); |
|
442 | + die; |
|
443 | + } |
|
444 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
445 | + |
|
446 | + return $spotter_array; |
|
447 | + } |
|
448 | 448 | |
449 | 449 | /** |
450 | - * Gets Minimal Live Spotter data |
|
451 | - * |
|
452 | - * @return Array the spotter information |
|
453 | - * |
|
454 | - */ |
|
455 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
456 | - { |
|
457 | - global $globalDBdriver, $globalLiveInterval; |
|
458 | - date_default_timezone_set('UTC'); |
|
459 | - |
|
460 | - $filter_query = ''; |
|
461 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
462 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
463 | - } |
|
464 | - // Should use spotter_output also ? |
|
465 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
466 | - $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 "; |
|
467 | - } |
|
468 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
469 | - $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 "; |
|
470 | - } |
|
471 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
472 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
473 | - } |
|
474 | - |
|
475 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
476 | - if ($globalDBdriver == 'mysql') { |
|
477 | - /* |
|
450 | + * Gets Minimal Live Spotter data |
|
451 | + * |
|
452 | + * @return Array the spotter information |
|
453 | + * |
|
454 | + */ |
|
455 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
456 | + { |
|
457 | + global $globalDBdriver, $globalLiveInterval; |
|
458 | + date_default_timezone_set('UTC'); |
|
459 | + |
|
460 | + $filter_query = ''; |
|
461 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
462 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
463 | + } |
|
464 | + // Should use spotter_output also ? |
|
465 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
466 | + $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 "; |
|
467 | + } |
|
468 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
469 | + $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 "; |
|
470 | + } |
|
471 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
472 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
473 | + } |
|
474 | + |
|
475 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
476 | + if ($globalDBdriver == 'mysql') { |
|
477 | + /* |
|
478 | 478 | $query = 'SELECT a.aircraft_shadow, 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 |
479 | 479 | FROM spotter_archive |
480 | 480 | 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'; |
@@ -485,95 +485,95 @@ discard block |
||
485 | 485 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
486 | 486 | '.$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'; |
487 | 487 | |
488 | - } else { |
|
489 | - //$query = 'SELECT 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, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
490 | - /* |
|
488 | + } else { |
|
489 | + //$query = 'SELECT 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, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
490 | + /* |
|
491 | 491 | $query = 'SELECT 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, a.aircraft_shadow |
492 | 492 | FROM spotter_archive_output |
493 | 493 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
494 | 494 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
495 | 495 | '.$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'; |
496 | 496 | */ |
497 | - $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 |
|
497 | + $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 |
|
498 | 498 | FROM spotter_archive_output |
499 | 499 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
500 | 500 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
501 | 501 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
502 | 502 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
503 | 503 | |
504 | - } |
|
505 | - //echo $query; |
|
506 | - try { |
|
507 | - $sth = $this->db->prepare($query); |
|
508 | - $sth->execute(); |
|
509 | - } catch(PDOException $e) { |
|
510 | - echo $e->getMessage(); |
|
511 | - die; |
|
512 | - } |
|
513 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
514 | - |
|
515 | - return $spotter_array; |
|
516 | - } |
|
504 | + } |
|
505 | + //echo $query; |
|
506 | + try { |
|
507 | + $sth = $this->db->prepare($query); |
|
508 | + $sth->execute(); |
|
509 | + } catch(PDOException $e) { |
|
510 | + echo $e->getMessage(); |
|
511 | + die; |
|
512 | + } |
|
513 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
514 | + |
|
515 | + return $spotter_array; |
|
516 | + } |
|
517 | 517 | |
518 | 518 | /** |
519 | - * Gets count Live Spotter data |
|
520 | - * |
|
521 | - * @return Array the spotter information |
|
522 | - * |
|
523 | - */ |
|
524 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
525 | - { |
|
526 | - global $globalDBdriver, $globalLiveInterval; |
|
527 | - date_default_timezone_set('UTC'); |
|
528 | - |
|
529 | - $filter_query = ''; |
|
530 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
531 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
532 | - } |
|
533 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
534 | - $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 "; |
|
535 | - } |
|
536 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
537 | - $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 "; |
|
538 | - } |
|
539 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
540 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
541 | - } |
|
542 | - |
|
543 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
544 | - if ($globalDBdriver == 'mysql') { |
|
519 | + * Gets count Live Spotter data |
|
520 | + * |
|
521 | + * @return Array the spotter information |
|
522 | + * |
|
523 | + */ |
|
524 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
525 | + { |
|
526 | + global $globalDBdriver, $globalLiveInterval; |
|
527 | + date_default_timezone_set('UTC'); |
|
528 | + |
|
529 | + $filter_query = ''; |
|
530 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
531 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
532 | + } |
|
533 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
534 | + $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 "; |
|
535 | + } |
|
536 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
537 | + $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 "; |
|
538 | + } |
|
539 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
540 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
541 | + } |
|
542 | + |
|
543 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
544 | + if ($globalDBdriver == 'mysql') { |
|
545 | 545 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
546 | 546 | FROM spotter_archive l |
547 | 547 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
548 | - } else { |
|
548 | + } else { |
|
549 | 549 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
550 | - } |
|
551 | - //echo $query; |
|
552 | - try { |
|
553 | - $sth = $this->db->prepare($query); |
|
554 | - $sth->execute(); |
|
555 | - } catch(PDOException $e) { |
|
556 | - echo $e->getMessage(); |
|
557 | - die; |
|
558 | - } |
|
550 | + } |
|
551 | + //echo $query; |
|
552 | + try { |
|
553 | + $sth = $this->db->prepare($query); |
|
554 | + $sth->execute(); |
|
555 | + } catch(PDOException $e) { |
|
556 | + echo $e->getMessage(); |
|
557 | + die; |
|
558 | + } |
|
559 | 559 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
560 | 560 | $sth->closeCursor(); |
561 | - return $result['nb']; |
|
561 | + return $result['nb']; |
|
562 | 562 | |
563 | - } |
|
563 | + } |
|
564 | 564 | |
565 | 565 | |
566 | 566 | |
567 | 567 | // Spotter_Archive_output |
568 | 568 | |
569 | - /** |
|
570 | - * Gets all the spotter information |
|
571 | - * |
|
572 | - * @return Array the spotter information |
|
573 | - * |
|
574 | - */ |
|
575 | - 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()) |
|
576 | - { |
|
569 | + /** |
|
570 | + * Gets all the spotter information |
|
571 | + * |
|
572 | + * @return Array the spotter information |
|
573 | + * |
|
574 | + */ |
|
575 | + 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()) |
|
576 | + { |
|
577 | 577 | global $globalTimezone, $globalDBdriver; |
578 | 578 | require_once(dirname(__FILE__).'/class.Translation.php'); |
579 | 579 | $Translation = new Translation(); |
@@ -587,159 +587,159 @@ discard block |
||
587 | 587 | $filter_query = $this->getFilter($filters); |
588 | 588 | if ($q != "") |
589 | 589 | { |
590 | - if (!is_string($q)) |
|
591 | - { |
|
590 | + if (!is_string($q)) |
|
591 | + { |
|
592 | 592 | return false; |
593 | - } else { |
|
593 | + } else { |
|
594 | 594 | |
595 | 595 | $q_array = explode(" ", $q); |
596 | 596 | |
597 | 597 | foreach ($q_array as $q_item){ |
598 | - $additional_query .= " AND ("; |
|
599 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
600 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
601 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
602 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
603 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
604 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
605 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
606 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
607 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
608 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
609 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
610 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
611 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
612 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
613 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
614 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
615 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
616 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
617 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
619 | - $translate = $Translation->ident2icao($q_item); |
|
620 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
622 | - $additional_query .= ")"; |
|
623 | - } |
|
624 | - } |
|
598 | + $additional_query .= " AND ("; |
|
599 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
600 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
601 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
602 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
603 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
604 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
605 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
606 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
607 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
608 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
609 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
610 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
611 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
612 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
613 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
614 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
615 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
616 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
617 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
619 | + $translate = $Translation->ident2icao($q_item); |
|
620 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
622 | + $additional_query .= ")"; |
|
623 | + } |
|
624 | + } |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | if ($registration != "") |
628 | 628 | { |
629 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
630 | - if (!is_string($registration)) |
|
631 | - { |
|
629 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
630 | + if (!is_string($registration)) |
|
631 | + { |
|
632 | 632 | return false; |
633 | - } else { |
|
633 | + } else { |
|
634 | 634 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
635 | - } |
|
635 | + } |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | if ($aircraft_icao != "") |
639 | 639 | { |
640 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
641 | - if (!is_string($aircraft_icao)) |
|
642 | - { |
|
640 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
641 | + if (!is_string($aircraft_icao)) |
|
642 | + { |
|
643 | 643 | return false; |
644 | - } else { |
|
644 | + } else { |
|
645 | 645 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
646 | - } |
|
646 | + } |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | if ($aircraft_manufacturer != "") |
650 | 650 | { |
651 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
652 | - if (!is_string($aircraft_manufacturer)) |
|
653 | - { |
|
651 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
652 | + if (!is_string($aircraft_manufacturer)) |
|
653 | + { |
|
654 | 654 | return false; |
655 | - } else { |
|
655 | + } else { |
|
656 | 656 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
657 | - } |
|
657 | + } |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | if ($highlights == "true") |
661 | 661 | { |
662 | - if (!is_string($highlights)) |
|
663 | - { |
|
662 | + if (!is_string($highlights)) |
|
663 | + { |
|
664 | 664 | return false; |
665 | - } else { |
|
665 | + } else { |
|
666 | 666 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
667 | - } |
|
667 | + } |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | if ($airline_icao != "") |
671 | 671 | { |
672 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
673 | - if (!is_string($airline_icao)) |
|
674 | - { |
|
672 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
673 | + if (!is_string($airline_icao)) |
|
674 | + { |
|
675 | 675 | return false; |
676 | - } else { |
|
676 | + } else { |
|
677 | 677 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
678 | - } |
|
678 | + } |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | if ($airline_country != "") |
682 | 682 | { |
683 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
684 | - if (!is_string($airline_country)) |
|
685 | - { |
|
683 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
684 | + if (!is_string($airline_country)) |
|
685 | + { |
|
686 | 686 | return false; |
687 | - } else { |
|
687 | + } else { |
|
688 | 688 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
689 | - } |
|
689 | + } |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | if ($airline_type != "") |
693 | 693 | { |
694 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
695 | - if (!is_string($airline_type)) |
|
696 | - { |
|
694 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
695 | + if (!is_string($airline_type)) |
|
696 | + { |
|
697 | 697 | return false; |
698 | - } else { |
|
698 | + } else { |
|
699 | 699 | if ($airline_type == "passenger") |
700 | 700 | { |
701 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
701 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
702 | 702 | } |
703 | 703 | if ($airline_type == "cargo") |
704 | 704 | { |
705 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
705 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
706 | 706 | } |
707 | 707 | if ($airline_type == "military") |
708 | 708 | { |
709 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
709 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
710 | + } |
|
710 | 711 | } |
711 | - } |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | if ($airport != "") |
715 | 715 | { |
716 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
717 | - if (!is_string($airport)) |
|
718 | - { |
|
716 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
717 | + if (!is_string($airport)) |
|
718 | + { |
|
719 | 719 | return false; |
720 | - } else { |
|
720 | + } else { |
|
721 | 721 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
722 | - } |
|
722 | + } |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | if ($airport_country != "") |
726 | 726 | { |
727 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
728 | - if (!is_string($airport_country)) |
|
729 | - { |
|
727 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
728 | + if (!is_string($airport_country)) |
|
729 | + { |
|
730 | 730 | return false; |
731 | - } else { |
|
731 | + } else { |
|
732 | 732 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
733 | - } |
|
733 | + } |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | if ($callsign != "") |
737 | 737 | { |
738 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
739 | - if (!is_string($callsign)) |
|
740 | - { |
|
738 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
739 | + if (!is_string($callsign)) |
|
740 | + { |
|
741 | 741 | return false; |
742 | - } else { |
|
742 | + } else { |
|
743 | 743 | $translate = $Translation->ident2icao($callsign); |
744 | 744 | if ($translate != $callsign) { |
745 | 745 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -747,99 +747,99 @@ discard block |
||
747 | 747 | } else { |
748 | 748 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
749 | 749 | } |
750 | - } |
|
750 | + } |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | if ($owner != "") |
754 | 754 | { |
755 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
756 | - if (!is_string($owner)) |
|
757 | - { |
|
755 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
756 | + if (!is_string($owner)) |
|
757 | + { |
|
758 | 758 | return false; |
759 | - } else { |
|
759 | + } else { |
|
760 | 760 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
761 | - } |
|
761 | + } |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | if ($pilot_name != "") |
765 | 765 | { |
766 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
767 | - if (!is_string($pilot_name)) |
|
768 | - { |
|
766 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
767 | + if (!is_string($pilot_name)) |
|
768 | + { |
|
769 | 769 | return false; |
770 | - } else { |
|
770 | + } else { |
|
771 | 771 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
772 | - } |
|
772 | + } |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | if ($pilot_id != "") |
776 | 776 | { |
777 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
778 | - if (!is_string($pilot_id)) |
|
779 | - { |
|
777 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
778 | + if (!is_string($pilot_id)) |
|
779 | + { |
|
780 | 780 | return false; |
781 | - } else { |
|
781 | + } else { |
|
782 | 782 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
783 | - } |
|
783 | + } |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | if ($departure_airport_route != "") |
787 | 787 | { |
788 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
789 | - if (!is_string($departure_airport_route)) |
|
790 | - { |
|
788 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
789 | + if (!is_string($departure_airport_route)) |
|
790 | + { |
|
791 | 791 | return false; |
792 | - } else { |
|
792 | + } else { |
|
793 | 793 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
794 | - } |
|
794 | + } |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | if ($arrival_airport_route != "") |
798 | 798 | { |
799 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
800 | - if (!is_string($arrival_airport_route)) |
|
801 | - { |
|
799 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
800 | + if (!is_string($arrival_airport_route)) |
|
801 | + { |
|
802 | 802 | return false; |
803 | - } else { |
|
803 | + } else { |
|
804 | 804 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
805 | - } |
|
805 | + } |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | if ($altitude != "") |
809 | 809 | { |
810 | - $altitude_array = explode(",", $altitude); |
|
810 | + $altitude_array = explode(",", $altitude); |
|
811 | 811 | |
812 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
813 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
812 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
813 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
814 | 814 | |
815 | 815 | |
816 | - if ($altitude_array[1] != "") |
|
817 | - { |
|
816 | + if ($altitude_array[1] != "") |
|
817 | + { |
|
818 | 818 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
819 | 819 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
820 | 820 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
821 | - } else { |
|
821 | + } else { |
|
822 | 822 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
823 | 823 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
824 | - } |
|
824 | + } |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | if ($date_posted != "") |
828 | 828 | { |
829 | - $date_array = explode(",", $date_posted); |
|
829 | + $date_array = explode(",", $date_posted); |
|
830 | 830 | |
831 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
832 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
831 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
832 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
833 | 833 | |
834 | - if ($globalTimezone != '') { |
|
834 | + if ($globalTimezone != '') { |
|
835 | 835 | date_default_timezone_set($globalTimezone); |
836 | 836 | $datetime = new DateTime(); |
837 | 837 | $offset = $datetime->format('P'); |
838 | - } else $offset = '+00:00'; |
|
838 | + } else $offset = '+00:00'; |
|
839 | 839 | |
840 | 840 | |
841 | - if ($date_array[1] != "") |
|
842 | - { |
|
841 | + if ($date_array[1] != "") |
|
842 | + { |
|
843 | 843 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
844 | 844 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
845 | 845 | if ($globalDBdriver == 'mysql') { |
@@ -847,28 +847,28 @@ discard block |
||
847 | 847 | } else { |
848 | 848 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
849 | 849 | } |
850 | - } else { |
|
850 | + } else { |
|
851 | 851 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
852 | - if ($globalDBdriver == 'mysql') { |
|
852 | + if ($globalDBdriver == 'mysql') { |
|
853 | 853 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
854 | 854 | } else { |
855 | 855 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
856 | 856 | } |
857 | - } |
|
857 | + } |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | if ($limit != "") |
861 | 861 | { |
862 | - $limit_array = explode(",", $limit); |
|
862 | + $limit_array = explode(",", $limit); |
|
863 | 863 | |
864 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
865 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
864 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
865 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
866 | 866 | |
867 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
868 | - { |
|
867 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
868 | + { |
|
869 | 869 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
870 | 870 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
871 | - } |
|
871 | + } |
|
872 | 872 | } |
873 | 873 | |
874 | 874 | |
@@ -899,33 +899,33 @@ discard block |
||
899 | 899 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
900 | 900 | |
901 | 901 | return $spotter_array; |
902 | - } |
|
902 | + } |
|
903 | 903 | |
904 | - public function deleteSpotterArchiveData() |
|
905 | - { |
|
904 | + public function deleteSpotterArchiveData() |
|
905 | + { |
|
906 | 906 | global $globalArchiveKeepMonths, $globalDBdriver; |
907 | - date_default_timezone_set('UTC'); |
|
908 | - if ($globalDBdriver == 'mysql') { |
|
907 | + date_default_timezone_set('UTC'); |
|
908 | + if ($globalDBdriver == 'mysql') { |
|
909 | 909 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
910 | 910 | } else { |
911 | 911 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
912 | 912 | } |
913 | - try { |
|
914 | - $sth = $this->db->prepare($query); |
|
915 | - $sth->execute(); |
|
916 | - } catch(PDOException $e) { |
|
917 | - return "error"; |
|
918 | - } |
|
913 | + try { |
|
914 | + $sth = $this->db->prepare($query); |
|
915 | + $sth->execute(); |
|
916 | + } catch(PDOException $e) { |
|
917 | + return "error"; |
|
918 | + } |
|
919 | 919 | } |
920 | 920 | |
921 | - /** |
|
922 | - * Gets all the spotter information based on the callsign |
|
923 | - * |
|
924 | - * @return Array the spotter information |
|
925 | - * |
|
926 | - */ |
|
927 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
928 | - { |
|
921 | + /** |
|
922 | + * Gets all the spotter information based on the callsign |
|
923 | + * |
|
924 | + * @return Array the spotter information |
|
925 | + * |
|
926 | + */ |
|
927 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
928 | + { |
|
929 | 929 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
930 | 930 | |
931 | 931 | date_default_timezone_set('UTC'); |
@@ -937,35 +937,35 @@ discard block |
||
937 | 937 | |
938 | 938 | if ($ident != "") |
939 | 939 | { |
940 | - if (!is_string($ident)) |
|
941 | - { |
|
940 | + if (!is_string($ident)) |
|
941 | + { |
|
942 | 942 | return false; |
943 | - } else { |
|
943 | + } else { |
|
944 | 944 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
945 | 945 | $query_values = array(':ident' => $ident); |
946 | - } |
|
946 | + } |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | if ($limit != "") |
950 | 950 | { |
951 | - $limit_array = explode(",", $limit); |
|
951 | + $limit_array = explode(",", $limit); |
|
952 | 952 | |
953 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
953 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
955 | 955 | |
956 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
957 | - { |
|
956 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
957 | + { |
|
958 | 958 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
959 | 959 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
960 | - } |
|
960 | + } |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | if ($sort != "") |
964 | 964 | { |
965 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
966 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
965 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
966 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
967 | 967 | } else { |
968 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
968 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -973,17 +973,17 @@ discard block |
||
973 | 973 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
974 | 974 | |
975 | 975 | return $spotter_array; |
976 | - } |
|
976 | + } |
|
977 | 977 | |
978 | 978 | |
979 | - /** |
|
980 | - * Gets all the spotter information based on the owner |
|
981 | - * |
|
982 | - * @return Array the spotter information |
|
983 | - * |
|
984 | - */ |
|
985 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
986 | - { |
|
979 | + /** |
|
980 | + * Gets all the spotter information based on the owner |
|
981 | + * |
|
982 | + * @return Array the spotter information |
|
983 | + * |
|
984 | + */ |
|
985 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
986 | + { |
|
987 | 987 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
988 | 988 | |
989 | 989 | date_default_timezone_set('UTC'); |
@@ -996,35 +996,35 @@ discard block |
||
996 | 996 | |
997 | 997 | if ($owner != "") |
998 | 998 | { |
999 | - if (!is_string($owner)) |
|
1000 | - { |
|
999 | + if (!is_string($owner)) |
|
1000 | + { |
|
1001 | 1001 | return false; |
1002 | - } else { |
|
1002 | + } else { |
|
1003 | 1003 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1004 | 1004 | $query_values = array(':owner' => $owner); |
1005 | - } |
|
1005 | + } |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | if ($limit != "") |
1009 | 1009 | { |
1010 | - $limit_array = explode(",", $limit); |
|
1010 | + $limit_array = explode(",", $limit); |
|
1011 | 1011 | |
1012 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1012 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1014 | 1014 | |
1015 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1016 | - { |
|
1015 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1016 | + { |
|
1017 | 1017 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1018 | 1018 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1019 | - } |
|
1019 | + } |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | if ($sort != "") |
1023 | 1023 | { |
1024 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1025 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1024 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1025 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1026 | 1026 | } else { |
1027 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1027 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1032,16 +1032,16 @@ discard block |
||
1032 | 1032 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1033 | 1033 | |
1034 | 1034 | return $spotter_array; |
1035 | - } |
|
1036 | - |
|
1037 | - /** |
|
1038 | - * Gets all the spotter information based on the pilot |
|
1039 | - * |
|
1040 | - * @return Array the spotter information |
|
1041 | - * |
|
1042 | - */ |
|
1043 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1044 | - { |
|
1035 | + } |
|
1036 | + |
|
1037 | + /** |
|
1038 | + * Gets all the spotter information based on the pilot |
|
1039 | + * |
|
1040 | + * @return Array the spotter information |
|
1041 | + * |
|
1042 | + */ |
|
1043 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1044 | + { |
|
1045 | 1045 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1046 | 1046 | |
1047 | 1047 | date_default_timezone_set('UTC'); |
@@ -1060,24 +1060,24 @@ discard block |
||
1060 | 1060 | |
1061 | 1061 | if ($limit != "") |
1062 | 1062 | { |
1063 | - $limit_array = explode(",", $limit); |
|
1063 | + $limit_array = explode(",", $limit); |
|
1064 | 1064 | |
1065 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1065 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1067 | 1067 | |
1068 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1069 | - { |
|
1068 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1069 | + { |
|
1070 | 1070 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1071 | 1071 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | if ($sort != "") |
1076 | 1076 | { |
1077 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1078 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1077 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1078 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1079 | 1079 | } else { |
1080 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1080 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1085,16 +1085,16 @@ discard block |
||
1085 | 1085 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1086 | 1086 | |
1087 | 1087 | return $spotter_array; |
1088 | - } |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * Gets all number of flight over countries |
|
1092 | - * |
|
1093 | - * @return Array the airline country list |
|
1094 | - * |
|
1095 | - */ |
|
1096 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1097 | - { |
|
1088 | + } |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * Gets all number of flight over countries |
|
1092 | + * |
|
1093 | + * @return Array the airline country list |
|
1094 | + * |
|
1095 | + */ |
|
1096 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1097 | + { |
|
1098 | 1098 | global $globalDBdriver; |
1099 | 1099 | /* |
1100 | 1100 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1104,14 +1104,14 @@ discard block |
||
1104 | 1104 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1105 | 1105 | FROM countries c, spotter_archive s |
1106 | 1106 | WHERE c.iso2 = s.over_country "; |
1107 | - if ($olderthanmonths > 0) { |
|
1108 | - if ($globalDBdriver == 'mysql') { |
|
1107 | + if ($olderthanmonths > 0) { |
|
1108 | + if ($globalDBdriver == 'mysql') { |
|
1109 | 1109 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1110 | 1110 | } else { |
1111 | 1111 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1112 | 1112 | } |
1113 | 1113 | } |
1114 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1114 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1115 | 1115 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1116 | 1116 | if ($limit) $query .= " LIMIT 0,10"; |
1117 | 1117 | |
@@ -1124,23 +1124,23 @@ discard block |
||
1124 | 1124 | |
1125 | 1125 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1126 | 1126 | { |
1127 | - $temp_array['flight_count'] = $row['nb']; |
|
1128 | - $temp_array['flight_country'] = $row['name']; |
|
1129 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1130 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1131 | - $flight_array[] = $temp_array; |
|
1127 | + $temp_array['flight_count'] = $row['nb']; |
|
1128 | + $temp_array['flight_country'] = $row['name']; |
|
1129 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1130 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1131 | + $flight_array[] = $temp_array; |
|
1132 | 1132 | } |
1133 | 1133 | return $flight_array; |
1134 | - } |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * Gets all number of flight over countries |
|
1138 | - * |
|
1139 | - * @return Array the airline country list |
|
1140 | - * |
|
1141 | - */ |
|
1142 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1143 | - { |
|
1134 | + } |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * Gets all number of flight over countries |
|
1138 | + * |
|
1139 | + * @return Array the airline country list |
|
1140 | + * |
|
1141 | + */ |
|
1142 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1143 | + { |
|
1144 | 1144 | global $globalDBdriver; |
1145 | 1145 | /* |
1146 | 1146 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1150,14 +1150,14 @@ discard block |
||
1150 | 1150 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1151 | 1151 | FROM countries c, spotter_archive s, spotter_output o |
1152 | 1152 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1153 | - if ($olderthanmonths > 0) { |
|
1154 | - if ($globalDBdriver == 'mysql') { |
|
1153 | + if ($olderthanmonths > 0) { |
|
1154 | + if ($globalDBdriver == 'mysql') { |
|
1155 | 1155 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1156 | 1156 | } else { |
1157 | 1157 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1158 | 1158 | } |
1159 | 1159 | } |
1160 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1160 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1161 | 1161 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1162 | 1162 | if ($limit) $query .= " LIMIT 0,10"; |
1163 | 1163 | |
@@ -1170,24 +1170,24 @@ discard block |
||
1170 | 1170 | |
1171 | 1171 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1172 | 1172 | { |
1173 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1174 | - $temp_array['flight_count'] = $row['nb']; |
|
1175 | - $temp_array['flight_country'] = $row['name']; |
|
1176 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1177 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1178 | - $flight_array[] = $temp_array; |
|
1173 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1174 | + $temp_array['flight_count'] = $row['nb']; |
|
1175 | + $temp_array['flight_country'] = $row['name']; |
|
1176 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1177 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1178 | + $flight_array[] = $temp_array; |
|
1179 | 1179 | } |
1180 | 1180 | return $flight_array; |
1181 | - } |
|
1182 | - |
|
1183 | - /** |
|
1184 | - * Gets last spotter information based on a particular callsign |
|
1185 | - * |
|
1186 | - * @return Array the spotter information |
|
1187 | - * |
|
1188 | - */ |
|
1189 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1190 | - { |
|
1181 | + } |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * Gets last spotter information based on a particular callsign |
|
1185 | + * |
|
1186 | + * @return Array the spotter information |
|
1187 | + * |
|
1188 | + */ |
|
1189 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1190 | + { |
|
1191 | 1191 | $Spotter = new Spotter($this->db); |
1192 | 1192 | date_default_timezone_set('UTC'); |
1193 | 1193 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1195,16 +1195,16 @@ discard block |
||
1195 | 1195 | $date = date('c',$date); |
1196 | 1196 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1197 | 1197 | return $spotter_array; |
1198 | - } |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Gets all the spotter information based on a particular callsign |
|
1202 | - * |
|
1203 | - * @return Array the spotter information |
|
1204 | - * |
|
1205 | - */ |
|
1206 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1207 | - { |
|
1198 | + } |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Gets all the spotter information based on a particular callsign |
|
1202 | + * |
|
1203 | + * @return Array the spotter information |
|
1204 | + * |
|
1205 | + */ |
|
1206 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1207 | + { |
|
1208 | 1208 | $Spotter = new Spotter($this->db); |
1209 | 1209 | date_default_timezone_set('UTC'); |
1210 | 1210 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1212,16 +1212,16 @@ discard block |
||
1212 | 1212 | $date = date('c',$date); |
1213 | 1213 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1214 | 1214 | return $spotter_array; |
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * Gets all the spotter information based on the airport |
|
1219 | - * |
|
1220 | - * @return Array the spotter information |
|
1221 | - * |
|
1222 | - */ |
|
1223 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1224 | - { |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * Gets all the spotter information based on the airport |
|
1219 | + * |
|
1220 | + * @return Array the spotter information |
|
1221 | + * |
|
1222 | + */ |
|
1223 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1224 | + { |
|
1225 | 1225 | global $global_query; |
1226 | 1226 | $Spotter = new Spotter(); |
1227 | 1227 | date_default_timezone_set('UTC'); |
@@ -1232,35 +1232,35 @@ discard block |
||
1232 | 1232 | |
1233 | 1233 | if ($airport != "") |
1234 | 1234 | { |
1235 | - if (!is_string($airport)) |
|
1236 | - { |
|
1235 | + if (!is_string($airport)) |
|
1236 | + { |
|
1237 | 1237 | return false; |
1238 | - } else { |
|
1238 | + } else { |
|
1239 | 1239 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1240 | 1240 | $query_values = array(':airport' => $airport); |
1241 | - } |
|
1241 | + } |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | if ($limit != "") |
1245 | 1245 | { |
1246 | - $limit_array = explode(",", $limit); |
|
1246 | + $limit_array = explode(",", $limit); |
|
1247 | 1247 | |
1248 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1248 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1250 | 1250 | |
1251 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1252 | - { |
|
1251 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1252 | + { |
|
1253 | 1253 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1254 | 1254 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1255 | - } |
|
1255 | + } |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | if ($sort != "") |
1259 | 1259 | { |
1260 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1261 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1260 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1261 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1262 | 1262 | } else { |
1263 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1263 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1268,6 +1268,6 @@ discard block |
||
1268 | 1268 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1269 | 1269 | |
1270 | 1270 | return $spotter_array; |
1271 | - } |
|
1271 | + } |
|
1272 | 1272 | } |
1273 | 1273 | ?> |
1274 | 1274 | \ No newline at end of file |
@@ -13,45 +13,45 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
18 | 18 | $filters = array(); |
19 | 19 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
20 | 20 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
21 | 21 | $filters = $globalStatsFilters[$globalFilterName]; |
22 | 22 | } else { |
23 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
23 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
24 | 24 | } |
25 | 25 | } |
26 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
26 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
27 | 27 | $filter_query_join = ''; |
28 | 28 | $filter_query_where = ''; |
29 | - foreach($filters as $flt) { |
|
29 | + foreach ($filters as $flt) { |
|
30 | 30 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
31 | 31 | if ($flt['airlines'][0] != '') { |
32 | 32 | if (isset($flt['source'])) { |
33 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
33 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
34 | 34 | } else { |
35 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
35 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id"; |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | } |
39 | 39 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
40 | 40 | if (isset($flt['source'])) { |
41 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
42 | 42 | } else { |
43 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
43 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
47 | 47 | if (isset($flt['source'])) { |
48 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id"; |
|
48 | + $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"; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | } |
52 | 52 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
53 | 53 | if ($filter['airlines'][0] != '') { |
54 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
54 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id"; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id "; |
60 | 60 | } |
61 | 61 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
62 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
62 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id"; |
|
63 | 63 | } |
64 | 64 | if (isset($filter['source']) && !empty($filter['source'])) { |
65 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
65 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
66 | 66 | } |
67 | 67 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
68 | 68 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
69 | 69 | } |
70 | 70 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
71 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
71 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
72 | 72 | } |
73 | 73 | if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) { |
74 | 74 | $filter_query_date = ''; |
@@ -94,40 +94,40 @@ discard block |
||
94 | 94 | $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'"; |
95 | 95 | } |
96 | 96 | } |
97 | - $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"; |
|
97 | + $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"; |
|
98 | 98 | } |
99 | 99 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
100 | 100 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
101 | 101 | if ($filter_query_where != '') { |
102 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
102 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
103 | 103 | } |
104 | 104 | $filter_query = $filter_query_join.$filter_query_where; |
105 | 105 | return $filter_query; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // Spotter_archive |
109 | - public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') { |
|
109 | + public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') { |
|
110 | 110 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
111 | 111 | if ($over_country == '') { |
112 | 112 | $Spotter = new Spotter($this->db); |
113 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
113 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
114 | 114 | if (!empty($data_country)) $country = $data_country['iso2']; |
115 | 115 | else $country = ''; |
116 | 116 | } else $country = $over_country; |
117 | - if ($airline_type === NULL) $airline_type =''; |
|
117 | + if ($airline_type === NULL) $airline_type = ''; |
|
118 | 118 | |
119 | 119 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
120 | 120 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
121 | 121 | |
122 | 122 | // Route is not added in spotter_archive |
123 | - $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) |
|
123 | + $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) |
|
124 | 124 | 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)"; |
125 | 125 | |
126 | - $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); |
|
126 | + $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); |
|
127 | 127 | try { |
128 | 128 | $sth = $this->db->prepare($query); |
129 | 129 | $sth->execute($query_values); |
130 | - } catch(PDOException $e) { |
|
130 | + } catch (PDOException $e) { |
|
131 | 131 | return "error : ".$e->getMessage(); |
132 | 132 | } |
133 | 133 | return "success"; |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | |
148 | 148 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
149 | 149 | //$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"; |
150 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
150 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
151 | 151 | |
152 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
152 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
153 | 153 | |
154 | 154 | return $spotter_array; |
155 | 155 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
169 | 169 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
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.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"; |
171 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
171 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | /* |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | } |
182 | 182 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
183 | 183 | */ |
184 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
184 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
185 | 185 | |
186 | 186 | return $spotter_array; |
187 | 187 | } |
@@ -196,14 +196,14 @@ discard block |
||
196 | 196 | { |
197 | 197 | date_default_timezone_set('UTC'); |
198 | 198 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
199 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
199 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
200 | 200 | |
201 | 201 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
202 | 202 | |
203 | 203 | try { |
204 | 204 | $sth = $this->db->prepare($query); |
205 | 205 | $sth->execute(array(':id' => $id)); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | echo $e->getMessage(); |
208 | 208 | die; |
209 | 209 | } |
@@ -222,14 +222,14 @@ discard block |
||
222 | 222 | { |
223 | 223 | date_default_timezone_set('UTC'); |
224 | 224 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
225 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
225 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
226 | 226 | |
227 | 227 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
228 | 228 | |
229 | 229 | try { |
230 | 230 | $sth = $this->db->prepare($query); |
231 | 231 | $sth->execute(array(':id' => $id)); |
232 | - } catch(PDOException $e) { |
|
232 | + } catch (PDOException $e) { |
|
233 | 233 | echo $e->getMessage(); |
234 | 234 | die; |
235 | 235 | } |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | date_default_timezone_set('UTC'); |
252 | 252 | |
253 | 253 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
254 | - $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"; |
|
254 | + $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"; |
|
255 | 255 | |
256 | 256 | try { |
257 | 257 | $sth = $this->db->prepare($query); |
258 | 258 | $sth->execute(array(':ident' => $ident)); |
259 | - } catch(PDOException $e) { |
|
259 | + } catch (PDOException $e) { |
|
260 | 260 | echo $e->getMessage(); |
261 | 261 | die; |
262 | 262 | } |
@@ -277,12 +277,12 @@ discard block |
||
277 | 277 | date_default_timezone_set('UTC'); |
278 | 278 | |
279 | 279 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
280 | - $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"; |
|
280 | + $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"; |
|
281 | 281 | |
282 | 282 | try { |
283 | 283 | $sth = $this->db->prepare($query); |
284 | 284 | $sth->execute(array(':id' => $id)); |
285 | - } catch(PDOException $e) { |
|
285 | + } catch (PDOException $e) { |
|
286 | 286 | echo $e->getMessage(); |
287 | 287 | die; |
288 | 288 | } |
@@ -303,12 +303,12 @@ discard block |
||
303 | 303 | date_default_timezone_set('UTC'); |
304 | 304 | |
305 | 305 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
306 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
306 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
307 | 307 | |
308 | 308 | try { |
309 | 309 | $sth = $this->db->prepare($query); |
310 | 310 | $sth->execute(array(':id' => $id)); |
311 | - } catch(PDOException $e) { |
|
311 | + } catch (PDOException $e) { |
|
312 | 312 | echo $e->getMessage(); |
313 | 313 | die; |
314 | 314 | } |
@@ -330,13 +330,13 @@ discard block |
||
330 | 330 | date_default_timezone_set('UTC'); |
331 | 331 | |
332 | 332 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
333 | - $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"; |
|
333 | + $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"; |
|
334 | 334 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
335 | 335 | |
336 | 336 | try { |
337 | 337 | $sth = $this->db->prepare($query); |
338 | 338 | $sth->execute(array(':ident' => $ident)); |
339 | - } catch(PDOException $e) { |
|
339 | + } catch (PDOException $e) { |
|
340 | 340 | echo $e->getMessage(); |
341 | 341 | die; |
342 | 342 | } |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | * @return Array the spotter information |
354 | 354 | * |
355 | 355 | */ |
356 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
356 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
357 | 357 | { |
358 | 358 | $Spotter = new Spotter($this->db); |
359 | 359 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
360 | - $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"; |
|
360 | + $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"; |
|
361 | 361 | |
362 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
362 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
363 | 363 | |
364 | 364 | return $spotter_array; |
365 | 365 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | try { |
373 | 373 | $sth = $this->db->prepare($query); |
374 | 374 | $sth->execute(); |
375 | - } catch(PDOException $e) { |
|
375 | + } catch (PDOException $e) { |
|
376 | 376 | echo $e->getMessage(); |
377 | 377 | die; |
378 | 378 | } |
@@ -384,24 +384,24 @@ discard block |
||
384 | 384 | * @return Array the spotter information |
385 | 385 | * |
386 | 386 | */ |
387 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
387 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
388 | 388 | { |
389 | 389 | global $globalDBdriver, $globalLiveInterval; |
390 | 390 | date_default_timezone_set('UTC'); |
391 | 391 | |
392 | 392 | $filter_query = ''; |
393 | 393 | if (isset($filter['source']) && !empty($filter['source'])) { |
394 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
394 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
395 | 395 | } |
396 | 396 | // Use spotter_output also ? |
397 | 397 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
398 | - $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 "; |
|
398 | + $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 "; |
|
399 | 399 | } |
400 | 400 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
401 | 401 | $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 "; |
402 | 402 | } |
403 | 403 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
404 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
404 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
421 | 421 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
422 | 422 | */ |
423 | - $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 |
|
423 | + $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 |
|
424 | 424 | FROM spotter_archive |
425 | 425 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
426 | 426 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
427 | 427 | '.$filter_query.' ORDER BY flightaware_id'; |
428 | 428 | } else { |
429 | 429 | //$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'; |
430 | - $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 |
|
430 | + $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 |
|
431 | 431 | FROM spotter_archive |
432 | 432 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
433 | 433 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | try { |
438 | 438 | $sth = $this->db->prepare($query); |
439 | 439 | $sth->execute(); |
440 | - } catch(PDOException $e) { |
|
440 | + } catch (PDOException $e) { |
|
441 | 441 | echo $e->getMessage(); |
442 | 442 | die; |
443 | 443 | } |
@@ -452,24 +452,24 @@ discard block |
||
452 | 452 | * @return Array the spotter information |
453 | 453 | * |
454 | 454 | */ |
455 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
455 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
456 | 456 | { |
457 | 457 | global $globalDBdriver, $globalLiveInterval; |
458 | 458 | date_default_timezone_set('UTC'); |
459 | 459 | |
460 | 460 | $filter_query = ''; |
461 | 461 | if (isset($filter['source']) && !empty($filter['source'])) { |
462 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
462 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
463 | 463 | } |
464 | 464 | // Should use spotter_output also ? |
465 | 465 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
466 | - $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 "; |
|
466 | + $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 "; |
|
467 | 467 | } |
468 | 468 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
469 | 469 | $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 "; |
470 | 470 | } |
471 | 471 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
472 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
472 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | FROM spotter_archive |
480 | 480 | 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'; |
481 | 481 | */ |
482 | - $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 |
|
482 | + $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 |
|
483 | 483 | FROM spotter_archive_output |
484 | 484 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
485 | 485 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
495 | 495 | '.$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'; |
496 | 496 | */ |
497 | - $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 |
|
497 | + $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 |
|
498 | 498 | FROM spotter_archive_output |
499 | 499 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
500 | 500 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | try { |
507 | 507 | $sth = $this->db->prepare($query); |
508 | 508 | $sth->execute(); |
509 | - } catch(PDOException $e) { |
|
509 | + } catch (PDOException $e) { |
|
510 | 510 | echo $e->getMessage(); |
511 | 511 | die; |
512 | 512 | } |
@@ -521,23 +521,23 @@ discard block |
||
521 | 521 | * @return Array the spotter information |
522 | 522 | * |
523 | 523 | */ |
524 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
524 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
525 | 525 | { |
526 | 526 | global $globalDBdriver, $globalLiveInterval; |
527 | 527 | date_default_timezone_set('UTC'); |
528 | 528 | |
529 | 529 | $filter_query = ''; |
530 | 530 | if (isset($filter['source']) && !empty($filter['source'])) { |
531 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
531 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
532 | 532 | } |
533 | 533 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
534 | - $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 "; |
|
534 | + $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 "; |
|
535 | 535 | } |
536 | 536 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
537 | 537 | $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 "; |
538 | 538 | } |
539 | 539 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
540 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
540 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
541 | 541 | } |
542 | 542 | |
543 | 543 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | try { |
553 | 553 | $sth = $this->db->prepare($query); |
554 | 554 | $sth->execute(); |
555 | - } catch(PDOException $e) { |
|
555 | + } catch (PDOException $e) { |
|
556 | 556 | echo $e->getMessage(); |
557 | 557 | die; |
558 | 558 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @return Array the spotter information |
573 | 573 | * |
574 | 574 | */ |
575 | - 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()) |
|
575 | + 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()) |
|
576 | 576 | { |
577 | 577 | global $globalTimezone, $globalDBdriver; |
578 | 578 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | |
595 | 595 | $q_array = explode(" ", $q); |
596 | 596 | |
597 | - foreach ($q_array as $q_item){ |
|
597 | + foreach ($q_array as $q_item) { |
|
598 | 598 | $additional_query .= " AND ("; |
599 | 599 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
600 | 600 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | |
627 | 627 | if ($registration != "") |
628 | 628 | { |
629 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
629 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
630 | 630 | if (!is_string($registration)) |
631 | 631 | { |
632 | 632 | return false; |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | |
638 | 638 | if ($aircraft_icao != "") |
639 | 639 | { |
640 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
640 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
641 | 641 | if (!is_string($aircraft_icao)) |
642 | 642 | { |
643 | 643 | return false; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | |
649 | 649 | if ($aircraft_manufacturer != "") |
650 | 650 | { |
651 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
651 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
652 | 652 | if (!is_string($aircraft_manufacturer)) |
653 | 653 | { |
654 | 654 | return false; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | |
670 | 670 | if ($airline_icao != "") |
671 | 671 | { |
672 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
672 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
673 | 673 | if (!is_string($airline_icao)) |
674 | 674 | { |
675 | 675 | return false; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | |
681 | 681 | if ($airline_country != "") |
682 | 682 | { |
683 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
683 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
684 | 684 | if (!is_string($airline_country)) |
685 | 685 | { |
686 | 686 | return false; |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | |
692 | 692 | if ($airline_type != "") |
693 | 693 | { |
694 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
694 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
695 | 695 | if (!is_string($airline_type)) |
696 | 696 | { |
697 | 697 | return false; |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | |
714 | 714 | if ($airport != "") |
715 | 715 | { |
716 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
716 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
717 | 717 | if (!is_string($airport)) |
718 | 718 | { |
719 | 719 | return false; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | if ($airport_country != "") |
726 | 726 | { |
727 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
727 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
728 | 728 | if (!is_string($airport_country)) |
729 | 729 | { |
730 | 730 | return false; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | |
736 | 736 | if ($callsign != "") |
737 | 737 | { |
738 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
738 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
739 | 739 | if (!is_string($callsign)) |
740 | 740 | { |
741 | 741 | return false; |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | $translate = $Translation->ident2icao($callsign); |
744 | 744 | if ($translate != $callsign) { |
745 | 745 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
746 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
746 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
747 | 747 | } else { |
748 | 748 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
749 | 749 | } |
@@ -752,7 +752,7 @@ discard block |
||
752 | 752 | |
753 | 753 | if ($owner != "") |
754 | 754 | { |
755 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
755 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
756 | 756 | if (!is_string($owner)) |
757 | 757 | { |
758 | 758 | return false; |
@@ -763,7 +763,7 @@ discard block |
||
763 | 763 | |
764 | 764 | if ($pilot_name != "") |
765 | 765 | { |
766 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
766 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
767 | 767 | if (!is_string($pilot_name)) |
768 | 768 | { |
769 | 769 | return false; |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | |
775 | 775 | if ($pilot_id != "") |
776 | 776 | { |
777 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
777 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
778 | 778 | if (!is_string($pilot_id)) |
779 | 779 | { |
780 | 780 | return false; |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | |
786 | 786 | if ($departure_airport_route != "") |
787 | 787 | { |
788 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
788 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
789 | 789 | if (!is_string($departure_airport_route)) |
790 | 790 | { |
791 | 791 | return false; |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | |
797 | 797 | if ($arrival_airport_route != "") |
798 | 798 | { |
799 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
799 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
800 | 800 | if (!is_string($arrival_airport_route)) |
801 | 801 | { |
802 | 802 | return false; |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | $altitude_array = explode(",", $altitude); |
811 | 811 | |
812 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
813 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
812 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
813 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
814 | 814 | |
815 | 815 | |
816 | 816 | if ($altitude_array[1] != "") |
@@ -828,8 +828,8 @@ discard block |
||
828 | 828 | { |
829 | 829 | $date_array = explode(",", $date_posted); |
830 | 830 | |
831 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
832 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
831 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
832 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
833 | 833 | |
834 | 834 | if ($globalTimezone != '') { |
835 | 835 | date_default_timezone_set($globalTimezone); |
@@ -861,8 +861,8 @@ discard block |
||
861 | 861 | { |
862 | 862 | $limit_array = explode(",", $limit); |
863 | 863 | |
864 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
865 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
864 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
865 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
866 | 866 | |
867 | 867 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
868 | 868 | { |
@@ -873,8 +873,8 @@ discard block |
||
873 | 873 | |
874 | 874 | |
875 | 875 | if ($origLat != "" && $origLon != "" && $dist != "") { |
876 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
877 | - $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 |
|
876 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
877 | + $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 |
|
878 | 878 | 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)) |
879 | 879 | 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"; |
880 | 880 | } else { |
@@ -891,12 +891,12 @@ discard block |
||
891 | 891 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
892 | 892 | } |
893 | 893 | |
894 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
894 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
895 | 895 | WHERE spotter_archive_output.ident <> '' |
896 | 896 | ".$additional_query." |
897 | 897 | ".$filter_query.$orderby_query; |
898 | 898 | } |
899 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
899 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
900 | 900 | |
901 | 901 | return $spotter_array; |
902 | 902 | } |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | try { |
914 | 914 | $sth = $this->db->prepare($query); |
915 | 915 | $sth->execute(); |
916 | - } catch(PDOException $e) { |
|
916 | + } catch (PDOException $e) { |
|
917 | 917 | return "error"; |
918 | 918 | } |
919 | 919 | } |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | { |
951 | 951 | $limit_array = explode(",", $limit); |
952 | 952 | |
953 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
953 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
954 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
955 | 955 | |
956 | 956 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
957 | 957 | { |
@@ -992,7 +992,7 @@ discard block |
||
992 | 992 | $query_values = array(); |
993 | 993 | $limit_query = ''; |
994 | 994 | $additional_query = ''; |
995 | - $filter_query = $this->getFilter($filter,true,true); |
|
995 | + $filter_query = $this->getFilter($filter, true, true); |
|
996 | 996 | |
997 | 997 | if ($owner != "") |
998 | 998 | { |
@@ -1009,8 +1009,8 @@ discard block |
||
1009 | 1009 | { |
1010 | 1010 | $limit_array = explode(",", $limit); |
1011 | 1011 | |
1012 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1012 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1013 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1014 | 1014 | |
1015 | 1015 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1016 | 1016 | { |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | $query_values = array(); |
1051 | 1051 | $limit_query = ''; |
1052 | 1052 | $additional_query = ''; |
1053 | - $filter_query = $this->getFilter($filter,true,true); |
|
1053 | + $filter_query = $this->getFilter($filter, true, true); |
|
1054 | 1054 | |
1055 | 1055 | if ($pilot != "") |
1056 | 1056 | { |
@@ -1062,8 +1062,8 @@ discard block |
||
1062 | 1062 | { |
1063 | 1063 | $limit_array = explode(",", $limit); |
1064 | 1064 | |
1065 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1065 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1066 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1067 | 1067 | |
1068 | 1068 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1069 | 1069 | { |
@@ -1093,7 +1093,7 @@ discard block |
||
1093 | 1093 | * @return Array the airline country list |
1094 | 1094 | * |
1095 | 1095 | */ |
1096 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1096 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1097 | 1097 | { |
1098 | 1098 | global $globalDBdriver; |
1099 | 1099 | /* |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | $flight_array = array(); |
1123 | 1123 | $temp_array = array(); |
1124 | 1124 | |
1125 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1125 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1126 | 1126 | { |
1127 | 1127 | $temp_array['flight_count'] = $row['nb']; |
1128 | 1128 | $temp_array['flight_country'] = $row['name']; |
@@ -1139,7 +1139,7 @@ discard block |
||
1139 | 1139 | * @return Array the airline country list |
1140 | 1140 | * |
1141 | 1141 | */ |
1142 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1142 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1143 | 1143 | { |
1144 | 1144 | global $globalDBdriver; |
1145 | 1145 | /* |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | $flight_array = array(); |
1169 | 1169 | $temp_array = array(); |
1170 | 1170 | |
1171 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1171 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1172 | 1172 | { |
1173 | 1173 | $temp_array['airline_icao'] = $row['airline_icao']; |
1174 | 1174 | $temp_array['flight_count'] = $row['nb']; |
@@ -1186,14 +1186,14 @@ discard block |
||
1186 | 1186 | * @return Array the spotter information |
1187 | 1187 | * |
1188 | 1188 | */ |
1189 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1189 | + public function getDateArchiveSpotterDataById($id, $date) |
|
1190 | 1190 | { |
1191 | 1191 | $Spotter = new Spotter($this->db); |
1192 | 1192 | date_default_timezone_set('UTC'); |
1193 | 1193 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1194 | - $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'; |
|
1195 | - $date = date('c',$date); |
|
1196 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1194 | + $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'; |
|
1195 | + $date = date('c', $date); |
|
1196 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1197 | 1197 | return $spotter_array; |
1198 | 1198 | } |
1199 | 1199 | |
@@ -1203,14 +1203,14 @@ discard block |
||
1203 | 1203 | * @return Array the spotter information |
1204 | 1204 | * |
1205 | 1205 | */ |
1206 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1206 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
1207 | 1207 | { |
1208 | 1208 | $Spotter = new Spotter($this->db); |
1209 | 1209 | date_default_timezone_set('UTC'); |
1210 | 1210 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1211 | - $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'; |
|
1212 | - $date = date('c',$date); |
|
1213 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1211 | + $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'; |
|
1212 | + $date = date('c', $date); |
|
1213 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1214 | 1214 | return $spotter_array; |
1215 | 1215 | } |
1216 | 1216 | |
@@ -1220,7 +1220,7 @@ discard block |
||
1220 | 1220 | * @return Array the spotter information |
1221 | 1221 | * |
1222 | 1222 | */ |
1223 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1223 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1224 | 1224 | { |
1225 | 1225 | global $global_query; |
1226 | 1226 | $Spotter = new Spotter(); |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | $query_values = array(); |
1229 | 1229 | $limit_query = ''; |
1230 | 1230 | $additional_query = ''; |
1231 | - $filter_query = $this->getFilter($filters,true,true); |
|
1231 | + $filter_query = $this->getFilter($filters, true, true); |
|
1232 | 1232 | |
1233 | 1233 | if ($airport != "") |
1234 | 1234 | { |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | { |
1246 | 1246 | $limit_array = explode(",", $limit); |
1247 | 1247 | |
1248 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1248 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1249 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1250 | 1250 | |
1251 | 1251 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1252 | 1252 | { |