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