@@ -11,7 +11,7 @@ |
||
11 | 11 | /** |
12 | 12 | * Get SQL query part for filter used |
13 | 13 | * @param Array $filter the filter |
14 | - * @return Array the SQL part |
|
14 | + * @return string the SQL part |
|
15 | 15 | */ |
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
@@ -8,47 +8,47 @@ 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; |
18 | 18 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
19 | 19 | if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
20 | 20 | $filter_query_join = ''; |
21 | 21 | $filter_query_where = ''; |
22 | 22 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
23 | - if ($filter['airlines'][0] != '') { |
|
23 | + if ($filter['airlines'][0] != '') { |
|
24 | 24 | $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
25 | - } |
|
25 | + } |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
29 | - $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 "; |
|
29 | + $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 "; |
|
30 | 30 | } |
31 | 31 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
32 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
32 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
33 | 33 | } |
34 | 34 | if (isset($filter['source']) && !empty($filter['source'])) { |
35 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
35 | + $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
36 | 36 | } |
37 | 37 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
38 | - $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
38 | + $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
|
39 | 39 | } |
40 | 40 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
41 | - if ($filter_query_where == '') { |
|
41 | + if ($filter_query_where == '') { |
|
42 | 42 | $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
43 | - } else { |
|
43 | + } else { |
|
44 | 44 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
45 | - } |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
48 | 48 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
49 | 49 | $filter_query = $filter_query_join.$filter_query_where; |
50 | 50 | return $filter_query; |
51 | - } |
|
51 | + } |
|
52 | 52 | |
53 | 53 | // Spotter_archive |
54 | 54 | 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 = '') { |
@@ -79,44 +79,44 @@ discard block |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * Gets all the spotter information based on a particular callsign |
|
84 | - * |
|
85 | - * @return Array the spotter information |
|
86 | - * |
|
87 | - */ |
|
88 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
89 | - { |
|
82 | + /** |
|
83 | + * Gets all the spotter information based on a particular callsign |
|
84 | + * |
|
85 | + * @return Array the spotter information |
|
86 | + * |
|
87 | + */ |
|
88 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
89 | + { |
|
90 | 90 | $Spotter = new Spotter($this->db); |
91 | - date_default_timezone_set('UTC'); |
|
91 | + date_default_timezone_set('UTC'); |
|
92 | 92 | |
93 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
94 | - //$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"; |
|
95 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
93 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
94 | + //$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"; |
|
95 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
96 | 96 | |
97 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
97 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
98 | 98 | |
99 | - return $spotter_array; |
|
100 | - } |
|
99 | + return $spotter_array; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Gets last the spotter information based on a particular id |
|
105 | - * |
|
106 | - * @return Array the spotter information |
|
107 | - * |
|
108 | - */ |
|
109 | - public function getLastArchiveSpotterDataById($id) |
|
110 | - { |
|
111 | - $Spotter = new Spotter($this->db); |
|
112 | - date_default_timezone_set('UTC'); |
|
113 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
114 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
115 | - //$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"; |
|
116 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
103 | + /** |
|
104 | + * Gets last the spotter information based on a particular id |
|
105 | + * |
|
106 | + * @return Array the spotter information |
|
107 | + * |
|
108 | + */ |
|
109 | + public function getLastArchiveSpotterDataById($id) |
|
110 | + { |
|
111 | + $Spotter = new Spotter($this->db); |
|
112 | + date_default_timezone_set('UTC'); |
|
113 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
114 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
115 | + //$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"; |
|
116 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
117 | 117 | |
118 | 118 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
119 | - /* |
|
119 | + /* |
|
120 | 120 | try { |
121 | 121 | $Connection = new Connection(); |
122 | 122 | $sth = Connection->$db->prepare($query); |
@@ -126,232 +126,232 @@ discard block |
||
126 | 126 | } |
127 | 127 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
128 | 128 | */ |
129 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
130 | - |
|
131 | - return $spotter_array; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Gets all the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getAllArchiveSpotterDataById($id) |
|
141 | - { |
|
142 | - date_default_timezone_set('UTC'); |
|
143 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
144 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
129 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
130 | + |
|
131 | + return $spotter_array; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Gets all the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getAllArchiveSpotterDataById($id) |
|
141 | + { |
|
142 | + date_default_timezone_set('UTC'); |
|
143 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
144 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
145 | 145 | |
146 | 146 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
147 | 147 | |
148 | - try { |
|
149 | - $sth = $this->db->prepare($query); |
|
150 | - $sth->execute(array(':id' => $id)); |
|
151 | - } catch(PDOException $e) { |
|
152 | - echo $e->getMessage(); |
|
153 | - die; |
|
154 | - } |
|
155 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
156 | - |
|
157 | - return $spotter_array; |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Gets coordinate & time spotter information based on a particular id |
|
162 | - * |
|
163 | - * @return Array the spotter information |
|
164 | - * |
|
165 | - */ |
|
166 | - public function getCoordArchiveSpotterDataById($id) |
|
167 | - { |
|
168 | - date_default_timezone_set('UTC'); |
|
169 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
170 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
148 | + try { |
|
149 | + $sth = $this->db->prepare($query); |
|
150 | + $sth->execute(array(':id' => $id)); |
|
151 | + } catch(PDOException $e) { |
|
152 | + echo $e->getMessage(); |
|
153 | + die; |
|
154 | + } |
|
155 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
156 | + |
|
157 | + return $spotter_array; |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Gets coordinate & time spotter information based on a particular id |
|
162 | + * |
|
163 | + * @return Array the spotter information |
|
164 | + * |
|
165 | + */ |
|
166 | + public function getCoordArchiveSpotterDataById($id) |
|
167 | + { |
|
168 | + date_default_timezone_set('UTC'); |
|
169 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
170 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
171 | 171 | |
172 | 172 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
173 | 173 | |
174 | - try { |
|
175 | - $sth = $this->db->prepare($query); |
|
176 | - $sth->execute(array(':id' => $id)); |
|
177 | - } catch(PDOException $e) { |
|
178 | - echo $e->getMessage(); |
|
179 | - die; |
|
180 | - } |
|
181 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
174 | + try { |
|
175 | + $sth = $this->db->prepare($query); |
|
176 | + $sth->execute(array(':id' => $id)); |
|
177 | + } catch(PDOException $e) { |
|
178 | + echo $e->getMessage(); |
|
179 | + die; |
|
180 | + } |
|
181 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | 182 | |
183 | - return $spotter_array; |
|
184 | - } |
|
183 | + return $spotter_array; |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * Gets altitude information based on a particular callsign |
|
189 | - * |
|
190 | - * @return Array the spotter information |
|
191 | - * |
|
192 | - */ |
|
193 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
194 | - { |
|
187 | + /** |
|
188 | + * Gets altitude information based on a particular callsign |
|
189 | + * |
|
190 | + * @return Array the spotter information |
|
191 | + * |
|
192 | + */ |
|
193 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
194 | + { |
|
195 | 195 | |
196 | - date_default_timezone_set('UTC'); |
|
196 | + date_default_timezone_set('UTC'); |
|
197 | 197 | |
198 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
199 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
198 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
199 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
200 | 200 | |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':ident' => $ident)); |
|
204 | - } catch(PDOException $e) { |
|
205 | - echo $e->getMessage(); |
|
206 | - die; |
|
207 | - } |
|
208 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
201 | + try { |
|
202 | + $sth = $this->db->prepare($query); |
|
203 | + $sth->execute(array(':ident' => $ident)); |
|
204 | + } catch(PDOException $e) { |
|
205 | + echo $e->getMessage(); |
|
206 | + die; |
|
207 | + } |
|
208 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
209 | 209 | |
210 | - return $spotter_array; |
|
211 | - } |
|
210 | + return $spotter_array; |
|
211 | + } |
|
212 | 212 | |
213 | - /** |
|
214 | - * Gets altitude information based on a particular id |
|
215 | - * |
|
216 | - * @return Array the spotter information |
|
217 | - * |
|
218 | - */ |
|
219 | - public function getAltitudeArchiveSpotterDataById($id) |
|
220 | - { |
|
213 | + /** |
|
214 | + * Gets altitude information based on a particular id |
|
215 | + * |
|
216 | + * @return Array the spotter information |
|
217 | + * |
|
218 | + */ |
|
219 | + public function getAltitudeArchiveSpotterDataById($id) |
|
220 | + { |
|
221 | 221 | |
222 | - date_default_timezone_set('UTC'); |
|
222 | + date_default_timezone_set('UTC'); |
|
223 | 223 | |
224 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
225 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
224 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
225 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
226 | 226 | |
227 | - try { |
|
228 | - $sth = $this->db->prepare($query); |
|
229 | - $sth->execute(array(':id' => $id)); |
|
230 | - } catch(PDOException $e) { |
|
231 | - echo $e->getMessage(); |
|
232 | - die; |
|
233 | - } |
|
234 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
227 | + try { |
|
228 | + $sth = $this->db->prepare($query); |
|
229 | + $sth->execute(array(':id' => $id)); |
|
230 | + } catch(PDOException $e) { |
|
231 | + echo $e->getMessage(); |
|
232 | + die; |
|
233 | + } |
|
234 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
235 | 235 | |
236 | - return $spotter_array; |
|
237 | - } |
|
236 | + return $spotter_array; |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * Gets altitude & speed information based on a particular id |
|
241 | - * |
|
242 | - * @return Array the spotter information |
|
243 | - * |
|
244 | - */ |
|
245 | - public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
246 | - { |
|
239 | + /** |
|
240 | + * Gets altitude & speed information based on a particular id |
|
241 | + * |
|
242 | + * @return Array the spotter information |
|
243 | + * |
|
244 | + */ |
|
245 | + public function getAltitudeSpeedArchiveSpotterDataById($id) |
|
246 | + { |
|
247 | 247 | |
248 | - date_default_timezone_set('UTC'); |
|
248 | + date_default_timezone_set('UTC'); |
|
249 | 249 | |
250 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
251 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
250 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
251 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
252 | 252 | |
253 | - try { |
|
254 | - $sth = $this->db->prepare($query); |
|
255 | - $sth->execute(array(':id' => $id)); |
|
256 | - } catch(PDOException $e) { |
|
257 | - echo $e->getMessage(); |
|
258 | - die; |
|
259 | - } |
|
260 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
253 | + try { |
|
254 | + $sth = $this->db->prepare($query); |
|
255 | + $sth->execute(array(':id' => $id)); |
|
256 | + } catch(PDOException $e) { |
|
257 | + echo $e->getMessage(); |
|
258 | + die; |
|
259 | + } |
|
260 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
261 | 261 | |
262 | - return $spotter_array; |
|
263 | - } |
|
262 | + return $spotter_array; |
|
263 | + } |
|
264 | 264 | |
265 | 265 | |
266 | - /** |
|
267 | - * Gets altitude information based on a particular callsign |
|
268 | - * |
|
269 | - * @return Array the spotter information |
|
270 | - * |
|
271 | - */ |
|
272 | - public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
273 | - { |
|
266 | + /** |
|
267 | + * Gets altitude information based on a particular callsign |
|
268 | + * |
|
269 | + * @return Array the spotter information |
|
270 | + * |
|
271 | + */ |
|
272 | + public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
|
273 | + { |
|
274 | 274 | |
275 | - date_default_timezone_set('UTC'); |
|
275 | + date_default_timezone_set('UTC'); |
|
276 | 276 | |
277 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
278 | - $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"; |
|
277 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
278 | + $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"; |
|
279 | 279 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
280 | 280 | |
281 | - try { |
|
282 | - $sth = $this->db->prepare($query); |
|
283 | - $sth->execute(array(':ident' => $ident)); |
|
284 | - } catch(PDOException $e) { |
|
285 | - echo $e->getMessage(); |
|
286 | - die; |
|
287 | - } |
|
288 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
281 | + try { |
|
282 | + $sth = $this->db->prepare($query); |
|
283 | + $sth->execute(array(':ident' => $ident)); |
|
284 | + } catch(PDOException $e) { |
|
285 | + echo $e->getMessage(); |
|
286 | + die; |
|
287 | + } |
|
288 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
289 | 289 | |
290 | - return $spotter_array; |
|
291 | - } |
|
290 | + return $spotter_array; |
|
291 | + } |
|
292 | 292 | |
293 | 293 | |
294 | 294 | |
295 | - /** |
|
296 | - * Gets all the archive spotter information |
|
297 | - * |
|
298 | - * @return Array the spotter information |
|
299 | - * |
|
300 | - */ |
|
301 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
302 | - { |
|
303 | - $Spotter = new Spotter($this->db); |
|
304 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | - $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"; |
|
295 | + /** |
|
296 | + * Gets all the archive spotter information |
|
297 | + * |
|
298 | + * @return Array the spotter information |
|
299 | + * |
|
300 | + */ |
|
301 | + public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
302 | + { |
|
303 | + $Spotter = new Spotter($this->db); |
|
304 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | + $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"; |
|
306 | 306 | |
307 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
307 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
308 | 308 | |
309 | - return $spotter_array; |
|
310 | - } |
|
309 | + return $spotter_array; |
|
310 | + } |
|
311 | 311 | |
312 | - public function deleteSpotterArchiveTrackData() |
|
313 | - { |
|
312 | + public function deleteSpotterArchiveTrackData() |
|
313 | + { |
|
314 | 314 | global $globalArchiveKeepTrackMonths; |
315 | - date_default_timezone_set('UTC'); |
|
315 | + date_default_timezone_set('UTC'); |
|
316 | 316 | $query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)'; |
317 | - try { |
|
318 | - $sth = $this->db->prepare($query); |
|
319 | - $sth->execute(); |
|
320 | - } catch(PDOException $e) { |
|
321 | - echo $e->getMessage(); |
|
322 | - die; |
|
323 | - } |
|
317 | + try { |
|
318 | + $sth = $this->db->prepare($query); |
|
319 | + $sth->execute(); |
|
320 | + } catch(PDOException $e) { |
|
321 | + echo $e->getMessage(); |
|
322 | + die; |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | - * Gets Minimal Live Spotter data |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
332 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
333 | - { |
|
334 | - global $globalDBdriver, $globalLiveInterval; |
|
335 | - date_default_timezone_set('UTC'); |
|
336 | - |
|
337 | - $filter_query = ''; |
|
338 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
339 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
340 | - } |
|
341 | - // Use spotter_output also ? |
|
342 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
343 | - $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 "; |
|
344 | - } |
|
345 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
346 | - $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 "; |
|
347 | - } |
|
348 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
349 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
350 | - } |
|
351 | - |
|
352 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
353 | - if ($globalDBdriver == 'mysql') { |
|
354 | - /* |
|
327 | + * Gets Minimal Live Spotter data |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
333 | + { |
|
334 | + global $globalDBdriver, $globalLiveInterval; |
|
335 | + date_default_timezone_set('UTC'); |
|
336 | + |
|
337 | + $filter_query = ''; |
|
338 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
339 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
340 | + } |
|
341 | + // Use spotter_output also ? |
|
342 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
343 | + $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 "; |
|
344 | + } |
|
345 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
346 | + $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 "; |
|
347 | + } |
|
348 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
349 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
350 | + } |
|
351 | + |
|
352 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
353 | + if ($globalDBdriver == 'mysql') { |
|
354 | + /* |
|
355 | 355 | $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 |
356 | 356 | FROM spotter_archive |
357 | 357 | 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'; |
@@ -370,56 +370,56 @@ discard block |
||
370 | 370 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
371 | 371 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
372 | 372 | '.$filter_query.' ORDER BY flightaware_id'; |
373 | - } else { |
|
374 | - //$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'; |
|
375 | - $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 |
|
373 | + } else { |
|
374 | + //$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'; |
|
375 | + $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 |
|
376 | 376 | FROM spotter_archive |
377 | 377 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
378 | 378 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
379 | 379 | '.$filter_query.' ORDER BY flightaware_id'; |
380 | - } |
|
381 | - //echo $query; |
|
382 | - try { |
|
383 | - $sth = $this->db->prepare($query); |
|
384 | - $sth->execute(); |
|
385 | - } catch(PDOException $e) { |
|
386 | - echo $e->getMessage(); |
|
387 | - die; |
|
388 | - } |
|
389 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
390 | - |
|
391 | - return $spotter_array; |
|
392 | - } |
|
380 | + } |
|
381 | + //echo $query; |
|
382 | + try { |
|
383 | + $sth = $this->db->prepare($query); |
|
384 | + $sth->execute(); |
|
385 | + } catch(PDOException $e) { |
|
386 | + echo $e->getMessage(); |
|
387 | + die; |
|
388 | + } |
|
389 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
390 | + |
|
391 | + return $spotter_array; |
|
392 | + } |
|
393 | 393 | |
394 | 394 | /** |
395 | - * Gets Minimal Live Spotter data |
|
396 | - * |
|
397 | - * @return Array the spotter information |
|
398 | - * |
|
399 | - */ |
|
400 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
401 | - { |
|
402 | - global $globalDBdriver, $globalLiveInterval; |
|
403 | - date_default_timezone_set('UTC'); |
|
404 | - |
|
405 | - $filter_query = ''; |
|
406 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
407 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
408 | - } |
|
409 | - // Should use spotter_output also ? |
|
410 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
411 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
412 | - } |
|
413 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
414 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
415 | - } |
|
416 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
417 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
418 | - } |
|
419 | - |
|
420 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
421 | - if ($globalDBdriver == 'mysql') { |
|
422 | - /* |
|
395 | + * Gets Minimal Live Spotter data |
|
396 | + * |
|
397 | + * @return Array the spotter information |
|
398 | + * |
|
399 | + */ |
|
400 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
401 | + { |
|
402 | + global $globalDBdriver, $globalLiveInterval; |
|
403 | + date_default_timezone_set('UTC'); |
|
404 | + |
|
405 | + $filter_query = ''; |
|
406 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
407 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
408 | + } |
|
409 | + // Should use spotter_output also ? |
|
410 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
411 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
412 | + } |
|
413 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
414 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
415 | + } |
|
416 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
417 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
418 | + } |
|
419 | + |
|
420 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
421 | + if ($globalDBdriver == 'mysql') { |
|
422 | + /* |
|
423 | 423 | $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 |
424 | 424 | FROM spotter_archive |
425 | 425 | 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'; |
@@ -430,95 +430,95 @@ discard block |
||
430 | 430 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
431 | 431 | '.$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'; |
432 | 432 | |
433 | - } else { |
|
434 | - //$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'; |
|
435 | - /* |
|
433 | + } else { |
|
434 | + //$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'; |
|
435 | + /* |
|
436 | 436 | $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 |
437 | 437 | FROM spotter_archive_output |
438 | 438 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
439 | 439 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
440 | 440 | '.$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'; |
441 | 441 | */ |
442 | - $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 |
|
442 | + $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 |
|
443 | 443 | FROM spotter_archive_output |
444 | 444 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
445 | 445 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
446 | 446 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
447 | 447 | // .' 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'; |
448 | 448 | |
449 | - } |
|
450 | - //echo $query; |
|
451 | - try { |
|
452 | - $sth = $this->db->prepare($query); |
|
453 | - $sth->execute(); |
|
454 | - } catch(PDOException $e) { |
|
455 | - echo $e->getMessage(); |
|
456 | - die; |
|
457 | - } |
|
458 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
459 | - |
|
460 | - return $spotter_array; |
|
461 | - } |
|
449 | + } |
|
450 | + //echo $query; |
|
451 | + try { |
|
452 | + $sth = $this->db->prepare($query); |
|
453 | + $sth->execute(); |
|
454 | + } catch(PDOException $e) { |
|
455 | + echo $e->getMessage(); |
|
456 | + die; |
|
457 | + } |
|
458 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
459 | + |
|
460 | + return $spotter_array; |
|
461 | + } |
|
462 | 462 | |
463 | 463 | /** |
464 | - * Gets count Live Spotter data |
|
465 | - * |
|
466 | - * @return Array the spotter information |
|
467 | - * |
|
468 | - */ |
|
469 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
470 | - { |
|
471 | - global $globalDBdriver, $globalLiveInterval; |
|
472 | - date_default_timezone_set('UTC'); |
|
473 | - |
|
474 | - $filter_query = ''; |
|
475 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
476 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
477 | - } |
|
478 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
479 | - $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 "; |
|
480 | - } |
|
481 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
482 | - $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 "; |
|
483 | - } |
|
484 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
485 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
486 | - } |
|
487 | - |
|
488 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
489 | - if ($globalDBdriver == 'mysql') { |
|
464 | + * Gets count Live Spotter data |
|
465 | + * |
|
466 | + * @return Array the spotter information |
|
467 | + * |
|
468 | + */ |
|
469 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
470 | + { |
|
471 | + global $globalDBdriver, $globalLiveInterval; |
|
472 | + date_default_timezone_set('UTC'); |
|
473 | + |
|
474 | + $filter_query = ''; |
|
475 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
476 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
477 | + } |
|
478 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
479 | + $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 "; |
|
480 | + } |
|
481 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
482 | + $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 "; |
|
483 | + } |
|
484 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
485 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
486 | + } |
|
487 | + |
|
488 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
489 | + if ($globalDBdriver == 'mysql') { |
|
490 | 490 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
491 | 491 | FROM spotter_archive l |
492 | 492 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
493 | - } else { |
|
493 | + } else { |
|
494 | 494 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
495 | - } |
|
496 | - //echo $query; |
|
497 | - try { |
|
498 | - $sth = $this->db->prepare($query); |
|
499 | - $sth->execute(); |
|
500 | - } catch(PDOException $e) { |
|
501 | - echo $e->getMessage(); |
|
502 | - die; |
|
503 | - } |
|
495 | + } |
|
496 | + //echo $query; |
|
497 | + try { |
|
498 | + $sth = $this->db->prepare($query); |
|
499 | + $sth->execute(); |
|
500 | + } catch(PDOException $e) { |
|
501 | + echo $e->getMessage(); |
|
502 | + die; |
|
503 | + } |
|
504 | 504 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
505 | 505 | $sth->closeCursor(); |
506 | - return $result['nb']; |
|
506 | + return $result['nb']; |
|
507 | 507 | |
508 | - } |
|
508 | + } |
|
509 | 509 | |
510 | 510 | |
511 | 511 | |
512 | 512 | // Spotter_Archive_output |
513 | 513 | |
514 | - /** |
|
515 | - * Gets all the spotter information |
|
516 | - * |
|
517 | - * @return Array the spotter information |
|
518 | - * |
|
519 | - */ |
|
520 | - 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()) |
|
521 | - { |
|
514 | + /** |
|
515 | + * Gets all the spotter information |
|
516 | + * |
|
517 | + * @return Array the spotter information |
|
518 | + * |
|
519 | + */ |
|
520 | + 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()) |
|
521 | + { |
|
522 | 522 | global $globalTimezone, $globalDBdriver; |
523 | 523 | require_once(dirname(__FILE__).'/class.Translation.php'); |
524 | 524 | $Translation = new Translation(); |
@@ -532,159 +532,159 @@ discard block |
||
532 | 532 | $filter_query = $this->getFilter($filters); |
533 | 533 | if ($q != "") |
534 | 534 | { |
535 | - if (!is_string($q)) |
|
536 | - { |
|
535 | + if (!is_string($q)) |
|
536 | + { |
|
537 | 537 | return false; |
538 | - } else { |
|
538 | + } else { |
|
539 | 539 | |
540 | 540 | $q_array = explode(" ", $q); |
541 | 541 | |
542 | 542 | foreach ($q_array as $q_item){ |
543 | - $additional_query .= " AND ("; |
|
544 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
545 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
546 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
547 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
548 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
549 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
550 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
551 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
552 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
553 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
554 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
555 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
556 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
557 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
558 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
559 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
560 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
561 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
562 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
563 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
564 | - $translate = $Translation->ident2icao($q_item); |
|
565 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
566 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
567 | - $additional_query .= ")"; |
|
543 | + $additional_query .= " AND ("; |
|
544 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
545 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
546 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
547 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
548 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
549 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
550 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
551 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
552 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
553 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
554 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
555 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
556 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
557 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
558 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
559 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
560 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
561 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
562 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
563 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
564 | + $translate = $Translation->ident2icao($q_item); |
|
565 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
566 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
567 | + $additional_query .= ")"; |
|
568 | + } |
|
568 | 569 | } |
569 | - } |
|
570 | 570 | } |
571 | 571 | |
572 | 572 | if ($registration != "") |
573 | 573 | { |
574 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
575 | - if (!is_string($registration)) |
|
576 | - { |
|
574 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
575 | + if (!is_string($registration)) |
|
576 | + { |
|
577 | 577 | return false; |
578 | - } else { |
|
578 | + } else { |
|
579 | 579 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
580 | - } |
|
580 | + } |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | if ($aircraft_icao != "") |
584 | 584 | { |
585 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
586 | - if (!is_string($aircraft_icao)) |
|
587 | - { |
|
585 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
586 | + if (!is_string($aircraft_icao)) |
|
587 | + { |
|
588 | 588 | return false; |
589 | - } else { |
|
589 | + } else { |
|
590 | 590 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
591 | - } |
|
591 | + } |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | if ($aircraft_manufacturer != "") |
595 | 595 | { |
596 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
597 | - if (!is_string($aircraft_manufacturer)) |
|
598 | - { |
|
596 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
597 | + if (!is_string($aircraft_manufacturer)) |
|
598 | + { |
|
599 | 599 | return false; |
600 | - } else { |
|
600 | + } else { |
|
601 | 601 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
602 | - } |
|
602 | + } |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | if ($highlights == "true") |
606 | 606 | { |
607 | - if (!is_string($highlights)) |
|
608 | - { |
|
607 | + if (!is_string($highlights)) |
|
608 | + { |
|
609 | 609 | return false; |
610 | - } else { |
|
610 | + } else { |
|
611 | 611 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
612 | - } |
|
612 | + } |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | if ($airline_icao != "") |
616 | 616 | { |
617 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
618 | - if (!is_string($airline_icao)) |
|
619 | - { |
|
617 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
618 | + if (!is_string($airline_icao)) |
|
619 | + { |
|
620 | 620 | return false; |
621 | - } else { |
|
621 | + } else { |
|
622 | 622 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
623 | - } |
|
623 | + } |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | if ($airline_country != "") |
627 | 627 | { |
628 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
629 | - if (!is_string($airline_country)) |
|
630 | - { |
|
628 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
629 | + if (!is_string($airline_country)) |
|
630 | + { |
|
631 | 631 | return false; |
632 | - } else { |
|
632 | + } else { |
|
633 | 633 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
634 | - } |
|
634 | + } |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | if ($airline_type != "") |
638 | 638 | { |
639 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
640 | - if (!is_string($airline_type)) |
|
641 | - { |
|
639 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
640 | + if (!is_string($airline_type)) |
|
641 | + { |
|
642 | 642 | return false; |
643 | - } else { |
|
643 | + } else { |
|
644 | 644 | if ($airline_type == "passenger") |
645 | 645 | { |
646 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
646 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
647 | 647 | } |
648 | 648 | if ($airline_type == "cargo") |
649 | 649 | { |
650 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
650 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
651 | 651 | } |
652 | 652 | if ($airline_type == "military") |
653 | 653 | { |
654 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
654 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
655 | + } |
|
655 | 656 | } |
656 | - } |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | if ($airport != "") |
660 | 660 | { |
661 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
662 | - if (!is_string($airport)) |
|
663 | - { |
|
661 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
662 | + if (!is_string($airport)) |
|
663 | + { |
|
664 | 664 | return false; |
665 | - } else { |
|
665 | + } else { |
|
666 | 666 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
667 | - } |
|
667 | + } |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | if ($airport_country != "") |
671 | 671 | { |
672 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
673 | - if (!is_string($airport_country)) |
|
674 | - { |
|
672 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
673 | + if (!is_string($airport_country)) |
|
674 | + { |
|
675 | 675 | return false; |
676 | - } else { |
|
676 | + } else { |
|
677 | 677 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
678 | - } |
|
678 | + } |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | if ($callsign != "") |
682 | 682 | { |
683 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
684 | - if (!is_string($callsign)) |
|
685 | - { |
|
683 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
684 | + if (!is_string($callsign)) |
|
685 | + { |
|
686 | 686 | return false; |
687 | - } else { |
|
687 | + } else { |
|
688 | 688 | $translate = $Translation->ident2icao($callsign); |
689 | 689 | if ($translate != $callsign) { |
690 | 690 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -692,99 +692,99 @@ discard block |
||
692 | 692 | } else { |
693 | 693 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
694 | 694 | } |
695 | - } |
|
695 | + } |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | if ($owner != "") |
699 | 699 | { |
700 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
701 | - if (!is_string($owner)) |
|
702 | - { |
|
700 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
701 | + if (!is_string($owner)) |
|
702 | + { |
|
703 | 703 | return false; |
704 | - } else { |
|
704 | + } else { |
|
705 | 705 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
706 | - } |
|
706 | + } |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | if ($pilot_name != "") |
710 | 710 | { |
711 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
712 | - if (!is_string($pilot_name)) |
|
713 | - { |
|
711 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
712 | + if (!is_string($pilot_name)) |
|
713 | + { |
|
714 | 714 | return false; |
715 | - } else { |
|
715 | + } else { |
|
716 | 716 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
717 | - } |
|
717 | + } |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | if ($pilot_id != "") |
721 | 721 | { |
722 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
723 | - if (!is_string($pilot_id)) |
|
724 | - { |
|
722 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
723 | + if (!is_string($pilot_id)) |
|
724 | + { |
|
725 | 725 | return false; |
726 | - } else { |
|
726 | + } else { |
|
727 | 727 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
728 | - } |
|
728 | + } |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | if ($departure_airport_route != "") |
732 | 732 | { |
733 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
734 | - if (!is_string($departure_airport_route)) |
|
735 | - { |
|
733 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
734 | + if (!is_string($departure_airport_route)) |
|
735 | + { |
|
736 | 736 | return false; |
737 | - } else { |
|
737 | + } else { |
|
738 | 738 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
739 | - } |
|
739 | + } |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | if ($arrival_airport_route != "") |
743 | 743 | { |
744 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
745 | - if (!is_string($arrival_airport_route)) |
|
746 | - { |
|
744 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
745 | + if (!is_string($arrival_airport_route)) |
|
746 | + { |
|
747 | 747 | return false; |
748 | - } else { |
|
748 | + } else { |
|
749 | 749 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
750 | - } |
|
750 | + } |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | if ($altitude != "") |
754 | 754 | { |
755 | - $altitude_array = explode(",", $altitude); |
|
755 | + $altitude_array = explode(",", $altitude); |
|
756 | 756 | |
757 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
758 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
757 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
758 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
759 | 759 | |
760 | 760 | |
761 | - if ($altitude_array[1] != "") |
|
762 | - { |
|
761 | + if ($altitude_array[1] != "") |
|
762 | + { |
|
763 | 763 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
764 | 764 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
765 | 765 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
766 | - } else { |
|
766 | + } else { |
|
767 | 767 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
768 | 768 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
769 | - } |
|
769 | + } |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($date_posted != "") |
773 | 773 | { |
774 | - $date_array = explode(",", $date_posted); |
|
774 | + $date_array = explode(",", $date_posted); |
|
775 | 775 | |
776 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
777 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
776 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
777 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
778 | 778 | |
779 | - if ($globalTimezone != '') { |
|
779 | + if ($globalTimezone != '') { |
|
780 | 780 | date_default_timezone_set($globalTimezone); |
781 | 781 | $datetime = new DateTime(); |
782 | 782 | $offset = $datetime->format('P'); |
783 | - } else $offset = '+00:00'; |
|
783 | + } else $offset = '+00:00'; |
|
784 | 784 | |
785 | 785 | |
786 | - if ($date_array[1] != "") |
|
787 | - { |
|
786 | + if ($date_array[1] != "") |
|
787 | + { |
|
788 | 788 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
789 | 789 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
790 | 790 | if ($globalDBdriver == 'mysql') { |
@@ -792,28 +792,28 @@ discard block |
||
792 | 792 | } else { |
793 | 793 | $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) "; |
794 | 794 | } |
795 | - } else { |
|
795 | + } else { |
|
796 | 796 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
797 | - if ($globalDBdriver == 'mysql') { |
|
797 | + if ($globalDBdriver == 'mysql') { |
|
798 | 798 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
799 | 799 | } else { |
800 | 800 | $additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
801 | 801 | } |
802 | - } |
|
802 | + } |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | if ($limit != "") |
806 | 806 | { |
807 | - $limit_array = explode(",", $limit); |
|
807 | + $limit_array = explode(",", $limit); |
|
808 | 808 | |
809 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
810 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
809 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
810 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
811 | 811 | |
812 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
813 | - { |
|
812 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
813 | + { |
|
814 | 814 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
815 | 815 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
816 | - } |
|
816 | + } |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | |
@@ -844,33 +844,33 @@ discard block |
||
844 | 844 | $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
845 | 845 | |
846 | 846 | return $spotter_array; |
847 | - } |
|
847 | + } |
|
848 | 848 | |
849 | - public function deleteSpotterArchiveData() |
|
850 | - { |
|
849 | + public function deleteSpotterArchiveData() |
|
850 | + { |
|
851 | 851 | global $globalArchiveKeepMonths, $globalDBdriver; |
852 | - date_default_timezone_set('UTC'); |
|
853 | - if ($globalDBdriver == 'mysql') { |
|
852 | + date_default_timezone_set('UTC'); |
|
853 | + if ($globalDBdriver == 'mysql') { |
|
854 | 854 | $query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
855 | 855 | } else { |
856 | 856 | $query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
857 | 857 | } |
858 | - try { |
|
859 | - $sth = $this->db->prepare($query); |
|
860 | - $sth->execute(); |
|
861 | - } catch(PDOException $e) { |
|
862 | - return "error"; |
|
863 | - } |
|
858 | + try { |
|
859 | + $sth = $this->db->prepare($query); |
|
860 | + $sth->execute(); |
|
861 | + } catch(PDOException $e) { |
|
862 | + return "error"; |
|
863 | + } |
|
864 | 864 | } |
865 | 865 | |
866 | - /** |
|
867 | - * Gets all the spotter information based on the callsign |
|
868 | - * |
|
869 | - * @return Array the spotter information |
|
870 | - * |
|
871 | - */ |
|
872 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
873 | - { |
|
866 | + /** |
|
867 | + * Gets all the spotter information based on the callsign |
|
868 | + * |
|
869 | + * @return Array the spotter information |
|
870 | + * |
|
871 | + */ |
|
872 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
873 | + { |
|
874 | 874 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
875 | 875 | |
876 | 876 | date_default_timezone_set('UTC'); |
@@ -882,35 +882,35 @@ discard block |
||
882 | 882 | |
883 | 883 | if ($ident != "") |
884 | 884 | { |
885 | - if (!is_string($ident)) |
|
886 | - { |
|
885 | + if (!is_string($ident)) |
|
886 | + { |
|
887 | 887 | return false; |
888 | - } else { |
|
888 | + } else { |
|
889 | 889 | $additional_query = " AND (spotter_archive_output.ident = :ident)"; |
890 | 890 | $query_values = array(':ident' => $ident); |
891 | - } |
|
891 | + } |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | if ($limit != "") |
895 | 895 | { |
896 | - $limit_array = explode(",", $limit); |
|
896 | + $limit_array = explode(",", $limit); |
|
897 | 897 | |
898 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
899 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
898 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
899 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
900 | 900 | |
901 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
902 | - { |
|
901 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
902 | + { |
|
903 | 903 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
904 | 904 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
905 | - } |
|
905 | + } |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | if ($sort != "") |
909 | 909 | { |
910 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
911 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
910 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
911 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
912 | 912 | } else { |
913 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
913 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
914 | 914 | } |
915 | 915 | |
916 | 916 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
919 | 919 | |
920 | 920 | return $spotter_array; |
921 | - } |
|
922 | - |
|
923 | - /** |
|
924 | - * Gets all number of flight over countries |
|
925 | - * |
|
926 | - * @return Array the airline country list |
|
927 | - * |
|
928 | - */ |
|
929 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
930 | - { |
|
921 | + } |
|
922 | + |
|
923 | + /** |
|
924 | + * Gets all number of flight over countries |
|
925 | + * |
|
926 | + * @return Array the airline country list |
|
927 | + * |
|
928 | + */ |
|
929 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
930 | + { |
|
931 | 931 | global $globalDBdriver; |
932 | 932 | /* |
933 | 933 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -937,14 +937,14 @@ discard block |
||
937 | 937 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
938 | 938 | FROM countries c, spotter_archive s |
939 | 939 | WHERE c.iso2 = s.over_country "; |
940 | - if ($olderthanmonths > 0) { |
|
941 | - if ($globalDBdriver == 'mysql') { |
|
940 | + if ($olderthanmonths > 0) { |
|
941 | + if ($globalDBdriver == 'mysql') { |
|
942 | 942 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
943 | 943 | } else { |
944 | 944 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
945 | 945 | } |
946 | 946 | } |
947 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
947 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
948 | 948 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
949 | 949 | if ($limit) $query .= " LIMIT 0,10"; |
950 | 950 | |
@@ -957,23 +957,23 @@ discard block |
||
957 | 957 | |
958 | 958 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
959 | 959 | { |
960 | - $temp_array['flight_count'] = $row['nb']; |
|
961 | - $temp_array['flight_country'] = $row['name']; |
|
962 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
963 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
964 | - $flight_array[] = $temp_array; |
|
960 | + $temp_array['flight_count'] = $row['nb']; |
|
961 | + $temp_array['flight_country'] = $row['name']; |
|
962 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
963 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
964 | + $flight_array[] = $temp_array; |
|
965 | 965 | } |
966 | 966 | return $flight_array; |
967 | - } |
|
968 | - |
|
969 | - /** |
|
970 | - * Gets last spotter information based on a particular callsign |
|
971 | - * |
|
972 | - * @return Array the spotter information |
|
973 | - * |
|
974 | - */ |
|
975 | - public function getDateArchiveSpotterDataById($id,$date) |
|
976 | - { |
|
967 | + } |
|
968 | + |
|
969 | + /** |
|
970 | + * Gets last spotter information based on a particular callsign |
|
971 | + * |
|
972 | + * @return Array the spotter information |
|
973 | + * |
|
974 | + */ |
|
975 | + public function getDateArchiveSpotterDataById($id,$date) |
|
976 | + { |
|
977 | 977 | $Spotter = new Spotter($this->db); |
978 | 978 | date_default_timezone_set('UTC'); |
979 | 979 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -981,16 +981,16 @@ discard block |
||
981 | 981 | $date = date('c',$date); |
982 | 982 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
983 | 983 | return $spotter_array; |
984 | - } |
|
985 | - |
|
986 | - /** |
|
987 | - * Gets all the spotter information based on a particular callsign |
|
988 | - * |
|
989 | - * @return Array the spotter information |
|
990 | - * |
|
991 | - */ |
|
992 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
993 | - { |
|
984 | + } |
|
985 | + |
|
986 | + /** |
|
987 | + * Gets all the spotter information based on a particular callsign |
|
988 | + * |
|
989 | + * @return Array the spotter information |
|
990 | + * |
|
991 | + */ |
|
992 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
993 | + { |
|
994 | 994 | $Spotter = new Spotter($this->db); |
995 | 995 | date_default_timezone_set('UTC'); |
996 | 996 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -998,16 +998,16 @@ discard block |
||
998 | 998 | $date = date('c',$date); |
999 | 999 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1000 | 1000 | return $spotter_array; |
1001 | - } |
|
1002 | - |
|
1003 | - /** |
|
1004 | - * Gets all the spotter information based on the airport |
|
1005 | - * |
|
1006 | - * @return Array the spotter information |
|
1007 | - * |
|
1008 | - */ |
|
1009 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1010 | - { |
|
1001 | + } |
|
1002 | + |
|
1003 | + /** |
|
1004 | + * Gets all the spotter information based on the airport |
|
1005 | + * |
|
1006 | + * @return Array the spotter information |
|
1007 | + * |
|
1008 | + */ |
|
1009 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1010 | + { |
|
1011 | 1011 | global $global_query; |
1012 | 1012 | $Spotter = new Spotter(); |
1013 | 1013 | date_default_timezone_set('UTC'); |
@@ -1018,35 +1018,35 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | if ($airport != "") |
1020 | 1020 | { |
1021 | - if (!is_string($airport)) |
|
1022 | - { |
|
1021 | + if (!is_string($airport)) |
|
1022 | + { |
|
1023 | 1023 | return false; |
1024 | - } else { |
|
1024 | + } else { |
|
1025 | 1025 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1026 | 1026 | $query_values = array(':airport' => $airport); |
1027 | - } |
|
1027 | + } |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | if ($limit != "") |
1031 | 1031 | { |
1032 | - $limit_array = explode(",", $limit); |
|
1032 | + $limit_array = explode(",", $limit); |
|
1033 | 1033 | |
1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1035 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1036 | 1036 | |
1037 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1038 | - { |
|
1037 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1038 | + { |
|
1039 | 1039 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1040 | 1040 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1041 | - } |
|
1041 | + } |
|
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | if ($sort != "") |
1045 | 1045 | { |
1046 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1047 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1046 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1047 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1048 | 1048 | } else { |
1049 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1049 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | $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; |
@@ -1054,6 +1054,6 @@ discard block |
||
1054 | 1054 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1055 | 1055 | |
1056 | 1056 | return $spotter_array; |
1057 | - } |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | ?> |
1060 | 1060 | \ No newline at end of file |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | * @param Array $filter the filter |
14 | 14 | * @return Array the SQL part |
15 | 15 | */ |
16 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
16 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
18 | - if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
19 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
18 | + if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName], $filter); |
|
19 | + if (is_array($globalFilter)) $filter = array_merge($globalFilter, $filter); |
|
20 | 20 | $filter_query_join = ''; |
21 | 21 | $filter_query_where = ''; |
22 | 22 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
23 | 23 | if ($filter['airlines'][0] != '') { |
24 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
24 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | |
@@ -29,19 +29,19 @@ discard block |
||
29 | 29 | $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 "; |
30 | 30 | } |
31 | 31 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
32 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
32 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id"; |
|
33 | 33 | } |
34 | 34 | if (isset($filter['source']) && !empty($filter['source'])) { |
35 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
35 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
36 | 36 | } |
37 | 37 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
38 | 38 | $filter_query_where = " WHERE ident = '".$filter['ident']."'"; |
39 | 39 | } |
40 | 40 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
41 | 41 | if ($filter_query_where == '') { |
42 | - $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
42 | + $filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
43 | 43 | } else { |
44 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
44 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
@@ -51,28 +51,28 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | // Spotter_archive |
54 | - 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 = '') { |
|
54 | + 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 = '') { |
|
55 | 55 | require_once(dirname(__FILE__).'/class.Spotter.php'); |
56 | 56 | if ($over_country == '') { |
57 | 57 | $Spotter = new Spotter($this->db); |
58 | - $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
58 | + $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
59 | 59 | if (!empty($data_country)) $country = $data_country['iso2']; |
60 | 60 | else $country = ''; |
61 | 61 | } else $country = $over_country; |
62 | - if ($airline_type === NULL) $airline_type =''; |
|
62 | + if ($airline_type === NULL) $airline_type = ''; |
|
63 | 63 | |
64 | 64 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
65 | 65 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
66 | 66 | |
67 | 67 | // Route is not added in spotter_archive |
68 | - $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
68 | + $query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name) |
|
69 | 69 | VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)"; |
70 | 70 | |
71 | - $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
71 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name); |
|
72 | 72 | try { |
73 | 73 | $sth = $this->db->prepare($query); |
74 | 74 | $sth->execute($query_values); |
75 | - } catch(PDOException $e) { |
|
75 | + } catch (PDOException $e) { |
|
76 | 76 | return "error : ".$e->getMessage(); |
77 | 77 | } |
78 | 78 | return "success"; |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
94 | 94 | //$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"; |
95 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
95 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
96 | 96 | |
97 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
97 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident)); |
|
98 | 98 | |
99 | 99 | return $spotter_array; |
100 | 100 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
114 | 114 | //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
115 | 115 | //$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"; |
116 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
116 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
117 | 117 | |
118 | 118 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
119 | 119 | /* |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | } |
127 | 127 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
128 | 128 | */ |
129 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
129 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id)); |
|
130 | 130 | |
131 | 131 | return $spotter_array; |
132 | 132 | } |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | { |
142 | 142 | date_default_timezone_set('UTC'); |
143 | 143 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
144 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
144 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
145 | 145 | |
146 | 146 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
147 | 147 | |
148 | 148 | try { |
149 | 149 | $sth = $this->db->prepare($query); |
150 | 150 | $sth->execute(array(':id' => $id)); |
151 | - } catch(PDOException $e) { |
|
151 | + } catch (PDOException $e) { |
|
152 | 152 | echo $e->getMessage(); |
153 | 153 | die; |
154 | 154 | } |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | { |
168 | 168 | date_default_timezone_set('UTC'); |
169 | 169 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
170 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
170 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id"; |
|
171 | 171 | |
172 | 172 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
173 | 173 | |
174 | 174 | try { |
175 | 175 | $sth = $this->db->prepare($query); |
176 | 176 | $sth->execute(array(':id' => $id)); |
177 | - } catch(PDOException $e) { |
|
177 | + } catch (PDOException $e) { |
|
178 | 178 | echo $e->getMessage(); |
179 | 179 | die; |
180 | 180 | } |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | date_default_timezone_set('UTC'); |
197 | 197 | |
198 | 198 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
199 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
199 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
|
200 | 200 | |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | 203 | $sth->execute(array(':ident' => $ident)); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo $e->getMessage(); |
206 | 206 | die; |
207 | 207 | } |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | date_default_timezone_set('UTC'); |
223 | 223 | |
224 | 224 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
225 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
225 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
226 | 226 | |
227 | 227 | try { |
228 | 228 | $sth = $this->db->prepare($query); |
229 | 229 | $sth->execute(array(':id' => $id)); |
230 | - } catch(PDOException $e) { |
|
230 | + } catch (PDOException $e) { |
|
231 | 231 | echo $e->getMessage(); |
232 | 232 | die; |
233 | 233 | } |
@@ -248,12 +248,12 @@ discard block |
||
248 | 248 | date_default_timezone_set('UTC'); |
249 | 249 | |
250 | 250 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
251 | - $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
251 | + $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
252 | 252 | |
253 | 253 | try { |
254 | 254 | $sth = $this->db->prepare($query); |
255 | 255 | $sth->execute(array(':id' => $id)); |
256 | - } catch(PDOException $e) { |
|
256 | + } catch (PDOException $e) { |
|
257 | 257 | echo $e->getMessage(); |
258 | 258 | die; |
259 | 259 | } |
@@ -275,13 +275,13 @@ discard block |
||
275 | 275 | date_default_timezone_set('UTC'); |
276 | 276 | |
277 | 277 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
278 | - $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"; |
|
278 | + $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"; |
|
279 | 279 | // $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident"; |
280 | 280 | |
281 | 281 | try { |
282 | 282 | $sth = $this->db->prepare($query); |
283 | 283 | $sth->execute(array(':ident' => $ident)); |
284 | - } catch(PDOException $e) { |
|
284 | + } catch (PDOException $e) { |
|
285 | 285 | echo $e->getMessage(); |
286 | 286 | die; |
287 | 287 | } |
@@ -298,13 +298,13 @@ discard block |
||
298 | 298 | * @return Array the spotter information |
299 | 299 | * |
300 | 300 | */ |
301 | - public function getSpotterArchiveData($ident,$flightaware_id,$date) |
|
301 | + public function getSpotterArchiveData($ident, $flightaware_id, $date) |
|
302 | 302 | { |
303 | 303 | $Spotter = new Spotter($this->db); |
304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
305 | - $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"; |
|
305 | + $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"; |
|
306 | 306 | |
307 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%')); |
|
307 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%')); |
|
308 | 308 | |
309 | 309 | return $spotter_array; |
310 | 310 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | try { |
318 | 318 | $sth = $this->db->prepare($query); |
319 | 319 | $sth->execute(); |
320 | - } catch(PDOException $e) { |
|
320 | + } catch (PDOException $e) { |
|
321 | 321 | echo $e->getMessage(); |
322 | 322 | die; |
323 | 323 | } |
@@ -329,24 +329,24 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
332 | + public function getMinLiveSpotterData($begindate, $enddate, $filter = array()) |
|
333 | 333 | { |
334 | 334 | global $globalDBdriver, $globalLiveInterval; |
335 | 335 | date_default_timezone_set('UTC'); |
336 | 336 | |
337 | 337 | $filter_query = ''; |
338 | 338 | if (isset($filter['source']) && !empty($filter['source'])) { |
339 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
339 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
340 | 340 | } |
341 | 341 | // Use spotter_output also ? |
342 | 342 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
343 | - $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 "; |
|
343 | + $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 "; |
|
344 | 344 | } |
345 | 345 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
346 | 346 | $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 "; |
347 | 347 | } |
348 | 348 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
349 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
349 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id |
366 | 366 | AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
367 | 367 | */ |
368 | - $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 |
|
368 | + $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 |
|
369 | 369 | FROM spotter_archive |
370 | 370 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
371 | 371 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
372 | 372 | '.$filter_query.' ORDER BY flightaware_id'; |
373 | 373 | } else { |
374 | 374 | //$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'; |
375 | - $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 |
|
375 | + $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 |
|
376 | 376 | FROM spotter_archive |
377 | 377 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
378 | 378 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | try { |
383 | 383 | $sth = $this->db->prepare($query); |
384 | 384 | $sth->execute(); |
385 | - } catch(PDOException $e) { |
|
385 | + } catch (PDOException $e) { |
|
386 | 386 | echo $e->getMessage(); |
387 | 387 | die; |
388 | 388 | } |
@@ -397,24 +397,24 @@ discard block |
||
397 | 397 | * @return Array the spotter information |
398 | 398 | * |
399 | 399 | */ |
400 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
400 | + public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array()) |
|
401 | 401 | { |
402 | 402 | global $globalDBdriver, $globalLiveInterval; |
403 | 403 | date_default_timezone_set('UTC'); |
404 | 404 | |
405 | 405 | $filter_query = ''; |
406 | 406 | if (isset($filter['source']) && !empty($filter['source'])) { |
407 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
407 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
408 | 408 | } |
409 | 409 | // Should use spotter_output also ? |
410 | 410 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
411 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
411 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
412 | 412 | } |
413 | 413 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
414 | 414 | $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
415 | 415 | } |
416 | 416 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
417 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
417 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | FROM spotter_archive |
425 | 425 | 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'; |
426 | 426 | */ |
427 | - $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
427 | + $query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk |
|
428 | 428 | FROM spotter_archive_output |
429 | 429 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao |
430 | 430 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
440 | 440 | '.$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'; |
441 | 441 | */ |
442 | - $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 |
|
442 | + $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 |
|
443 | 443 | FROM spotter_archive_output |
444 | 444 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
445 | 445 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | try { |
452 | 452 | $sth = $this->db->prepare($query); |
453 | 453 | $sth->execute(); |
454 | - } catch(PDOException $e) { |
|
454 | + } catch (PDOException $e) { |
|
455 | 455 | echo $e->getMessage(); |
456 | 456 | die; |
457 | 457 | } |
@@ -466,23 +466,23 @@ discard block |
||
466 | 466 | * @return Array the spotter information |
467 | 467 | * |
468 | 468 | */ |
469 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
469 | + public function getLiveSpotterCount($begindate, $enddate, $filter = array()) |
|
470 | 470 | { |
471 | 471 | global $globalDBdriver, $globalLiveInterval; |
472 | 472 | date_default_timezone_set('UTC'); |
473 | 473 | |
474 | 474 | $filter_query = ''; |
475 | 475 | if (isset($filter['source']) && !empty($filter['source'])) { |
476 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
476 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
477 | 477 | } |
478 | 478 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
479 | - $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 "; |
|
479 | + $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 "; |
|
480 | 480 | } |
481 | 481 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
482 | 482 | $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 "; |
483 | 483 | } |
484 | 484 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
485 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
485 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | try { |
498 | 498 | $sth = $this->db->prepare($query); |
499 | 499 | $sth->execute(); |
500 | - } catch(PDOException $e) { |
|
500 | + } catch (PDOException $e) { |
|
501 | 501 | echo $e->getMessage(); |
502 | 502 | die; |
503 | 503 | } |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @return Array the spotter information |
518 | 518 | * |
519 | 519 | */ |
520 | - 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()) |
|
520 | + 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()) |
|
521 | 521 | { |
522 | 522 | global $globalTimezone, $globalDBdriver; |
523 | 523 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | $q_array = explode(" ", $q); |
541 | 541 | |
542 | - foreach ($q_array as $q_item){ |
|
542 | + foreach ($q_array as $q_item) { |
|
543 | 543 | $additional_query .= " AND ("; |
544 | 544 | $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
545 | 545 | $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | |
572 | 572 | if ($registration != "") |
573 | 573 | { |
574 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
574 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
575 | 575 | if (!is_string($registration)) |
576 | 576 | { |
577 | 577 | return false; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | |
583 | 583 | if ($aircraft_icao != "") |
584 | 584 | { |
585 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
585 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
586 | 586 | if (!is_string($aircraft_icao)) |
587 | 587 | { |
588 | 588 | return false; |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | |
594 | 594 | if ($aircraft_manufacturer != "") |
595 | 595 | { |
596 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
596 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
597 | 597 | if (!is_string($aircraft_manufacturer)) |
598 | 598 | { |
599 | 599 | return false; |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | |
615 | 615 | if ($airline_icao != "") |
616 | 616 | { |
617 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
617 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
618 | 618 | if (!is_string($airline_icao)) |
619 | 619 | { |
620 | 620 | return false; |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | |
626 | 626 | if ($airline_country != "") |
627 | 627 | { |
628 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
628 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
629 | 629 | if (!is_string($airline_country)) |
630 | 630 | { |
631 | 631 | return false; |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | |
637 | 637 | if ($airline_type != "") |
638 | 638 | { |
639 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
639 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
640 | 640 | if (!is_string($airline_type)) |
641 | 641 | { |
642 | 642 | return false; |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | |
659 | 659 | if ($airport != "") |
660 | 660 | { |
661 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
661 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
662 | 662 | if (!is_string($airport)) |
663 | 663 | { |
664 | 664 | return false; |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | |
670 | 670 | if ($airport_country != "") |
671 | 671 | { |
672 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
672 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
673 | 673 | if (!is_string($airport_country)) |
674 | 674 | { |
675 | 675 | return false; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | |
681 | 681 | if ($callsign != "") |
682 | 682 | { |
683 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
683 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
684 | 684 | if (!is_string($callsign)) |
685 | 685 | { |
686 | 686 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | $translate = $Translation->ident2icao($callsign); |
689 | 689 | if ($translate != $callsign) { |
690 | 690 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
691 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
691 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
692 | 692 | } else { |
693 | 693 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
694 | 694 | } |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | |
698 | 698 | if ($owner != "") |
699 | 699 | { |
700 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
700 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
701 | 701 | if (!is_string($owner)) |
702 | 702 | { |
703 | 703 | return false; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | if ($pilot_name != "") |
710 | 710 | { |
711 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
711 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
712 | 712 | if (!is_string($pilot_name)) |
713 | 713 | { |
714 | 714 | return false; |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | if ($pilot_id != "") |
721 | 721 | { |
722 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
722 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
723 | 723 | if (!is_string($pilot_id)) |
724 | 724 | { |
725 | 725 | return false; |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | if ($departure_airport_route != "") |
732 | 732 | { |
733 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
733 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
734 | 734 | if (!is_string($departure_airport_route)) |
735 | 735 | { |
736 | 736 | return false; |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | |
742 | 742 | if ($arrival_airport_route != "") |
743 | 743 | { |
744 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
744 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
745 | 745 | if (!is_string($arrival_airport_route)) |
746 | 746 | { |
747 | 747 | return false; |
@@ -754,8 +754,8 @@ discard block |
||
754 | 754 | { |
755 | 755 | $altitude_array = explode(",", $altitude); |
756 | 756 | |
757 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
758 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
757 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
758 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
759 | 759 | |
760 | 760 | |
761 | 761 | if ($altitude_array[1] != "") |
@@ -773,8 +773,8 @@ discard block |
||
773 | 773 | { |
774 | 774 | $date_array = explode(",", $date_posted); |
775 | 775 | |
776 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
777 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
776 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
777 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
778 | 778 | |
779 | 779 | if ($globalTimezone != '') { |
780 | 780 | date_default_timezone_set($globalTimezone); |
@@ -806,8 +806,8 @@ discard block |
||
806 | 806 | { |
807 | 807 | $limit_array = explode(",", $limit); |
808 | 808 | |
809 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
810 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
809 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
810 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
811 | 811 | |
812 | 812 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
813 | 813 | { |
@@ -818,8 +818,8 @@ discard block |
||
818 | 818 | |
819 | 819 | |
820 | 820 | if ($origLat != "" && $origLon != "" && $dist != "") { |
821 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
822 | - $query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
821 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
822 | + $query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
823 | 823 | FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
824 | 824 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
825 | 825 | } else { |
@@ -836,12 +836,12 @@ discard block |
||
836 | 836 | $additional_query .= " AND (spotter_archive_output.waypoints <> '')"; |
837 | 837 | } |
838 | 838 | |
839 | - $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
839 | + $query = "SELECT spotter_archive_output.* FROM spotter_archive_output |
|
840 | 840 | WHERE spotter_archive_output.ident <> '' |
841 | 841 | ".$additional_query." |
842 | 842 | ".$filter_query.$orderby_query; |
843 | 843 | } |
844 | - $spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query); |
|
844 | + $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
|
845 | 845 | |
846 | 846 | return $spotter_array; |
847 | 847 | } |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | try { |
859 | 859 | $sth = $this->db->prepare($query); |
860 | 860 | $sth->execute(); |
861 | - } catch(PDOException $e) { |
|
861 | + } catch (PDOException $e) { |
|
862 | 862 | return "error"; |
863 | 863 | } |
864 | 864 | } |
@@ -895,8 +895,8 @@ discard block |
||
895 | 895 | { |
896 | 896 | $limit_array = explode(",", $limit); |
897 | 897 | |
898 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
899 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
898 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
899 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
900 | 900 | |
901 | 901 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
902 | 902 | { |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | * @return Array the airline country list |
927 | 927 | * |
928 | 928 | */ |
929 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
929 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
930 | 930 | { |
931 | 931 | global $globalDBdriver; |
932 | 932 | /* |
@@ -955,7 +955,7 @@ discard block |
||
955 | 955 | $flight_array = array(); |
956 | 956 | $temp_array = array(); |
957 | 957 | |
958 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
958 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
959 | 959 | { |
960 | 960 | $temp_array['flight_count'] = $row['nb']; |
961 | 961 | $temp_array['flight_country'] = $row['name']; |
@@ -972,14 +972,14 @@ discard block |
||
972 | 972 | * @return Array the spotter information |
973 | 973 | * |
974 | 974 | */ |
975 | - public function getDateArchiveSpotterDataById($id,$date) |
|
975 | + public function getDateArchiveSpotterDataById($id, $date) |
|
976 | 976 | { |
977 | 977 | $Spotter = new Spotter($this->db); |
978 | 978 | date_default_timezone_set('UTC'); |
979 | 979 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
980 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
981 | - $date = date('c',$date); |
|
982 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
980 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
981 | + $date = date('c', $date); |
|
982 | + $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
983 | 983 | return $spotter_array; |
984 | 984 | } |
985 | 985 | |
@@ -989,14 +989,14 @@ discard block |
||
989 | 989 | * @return Array the spotter information |
990 | 990 | * |
991 | 991 | */ |
992 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
992 | + public function getDateArchiveSpotterDataByIdent($ident, $date) |
|
993 | 993 | { |
994 | 994 | $Spotter = new Spotter($this->db); |
995 | 995 | date_default_timezone_set('UTC'); |
996 | 996 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
997 | - $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
998 | - $date = date('c',$date); |
|
999 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
997 | + $query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC'; |
|
998 | + $date = date('c', $date); |
|
999 | + $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1000 | 1000 | return $spotter_array; |
1001 | 1001 | } |
1002 | 1002 | |
@@ -1006,7 +1006,7 @@ discard block |
||
1006 | 1006 | * @return Array the spotter information |
1007 | 1007 | * |
1008 | 1008 | */ |
1009 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1009 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1010 | 1010 | { |
1011 | 1011 | global $global_query; |
1012 | 1012 | $Spotter = new Spotter(); |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $query_values = array(); |
1015 | 1015 | $limit_query = ''; |
1016 | 1016 | $additional_query = ''; |
1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
1018 | 1018 | |
1019 | 1019 | if ($airport != "") |
1020 | 1020 | { |
@@ -1031,8 +1031,8 @@ discard block |
||
1031 | 1031 | { |
1032 | 1032 | $limit_array = explode(",", $limit); |
1033 | 1033 | |
1034 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1035 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1034 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1035 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1036 | 1036 | |
1037 | 1037 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1038 | 1038 | { |
@@ -15,8 +15,12 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function getFilter($filter = array(),$where = false,$and = false) { |
17 | 17 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
18 | - if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
19 | - if (is_array($globalFilter)) $filter = array_merge($globalFilter,$filter); |
|
18 | + if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
|
19 | + $filter = array_merge($globalStatsFilters[$globalFilterName],$filter); |
|
20 | + } |
|
21 | + if (is_array($globalFilter)) { |
|
22 | + $filter = array_merge($globalFilter,$filter); |
|
23 | + } |
|
20 | 24 | $filter_query_join = ''; |
21 | 25 | $filter_query_where = ''; |
22 | 26 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
@@ -44,8 +48,11 @@ discard block |
||
44 | 48 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
45 | 49 | } |
46 | 50 | } |
47 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
48 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
51 | + if ($filter_query_where == '' && $where) { |
|
52 | + $filter_query_where = ' WHERE'; |
|
53 | + } elseif ($filter_query_where != '' && $and) { |
|
54 | + $filter_query_where .= ' AND'; |
|
55 | + } |
|
49 | 56 | $filter_query = $filter_query_join.$filter_query_where; |
50 | 57 | return $filter_query; |
51 | 58 | } |
@@ -56,10 +63,17 @@ discard block |
||
56 | 63 | if ($over_country == '') { |
57 | 64 | $Spotter = new Spotter($this->db); |
58 | 65 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
59 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
60 | - else $country = ''; |
|
61 | - } else $country = $over_country; |
|
62 | - if ($airline_type === NULL) $airline_type =''; |
|
66 | + if (!empty($data_country)) { |
|
67 | + $country = $data_country['iso2']; |
|
68 | + } else { |
|
69 | + $country = ''; |
|
70 | + } |
|
71 | + } else { |
|
72 | + $country = $over_country; |
|
73 | + } |
|
74 | + if ($airline_type === NULL) { |
|
75 | + $airline_type =''; |
|
76 | + } |
|
63 | 77 | |
64 | 78 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
65 | 79 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -562,7 +576,9 @@ discard block |
||
562 | 576 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
563 | 577 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
564 | 578 | $translate = $Translation->ident2icao($q_item); |
565 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
579 | + if ($translate != $q_item) { |
|
580 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
581 | + } |
|
566 | 582 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
567 | 583 | $additional_query .= ")"; |
568 | 584 | } |
@@ -780,7 +796,9 @@ discard block |
||
780 | 796 | date_default_timezone_set($globalTimezone); |
781 | 797 | $datetime = new DateTime(); |
782 | 798 | $offset = $datetime->format('P'); |
783 | - } else $offset = '+00:00'; |
|
799 | + } else { |
|
800 | + $offset = '+00:00'; |
|
801 | + } |
|
784 | 802 | |
785 | 803 | |
786 | 804 | if ($date_array[1] != "") |
@@ -944,9 +962,13 @@ discard block |
||
944 | 962 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
945 | 963 | } |
946 | 964 | } |
947 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
965 | + if ($sincedate != '') { |
|
966 | + $query .= "AND date > '".$sincedate."' "; |
|
967 | + } |
|
948 | 968 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
949 | - if ($limit) $query .= " LIMIT 0,10"; |
|
969 | + if ($limit) { |
|
970 | + $query .= " LIMIT 0,10"; |
|
971 | + } |
|
950 | 972 | |
951 | 973 | |
952 | 974 | $sth = $this->db->prepare($query); |
@@ -15,67 +15,67 @@ discard block |
||
15 | 15 | if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
16 | 16 | $Connection = new Connection($dbc); |
17 | 17 | $this->db = $Connection->db(); |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | 20 | public function addLastStatsUpdate($type,$stats_date) { |
21 | - $query = "DELETE FROM config WHERE name = :type; |
|
21 | + $query = "DELETE FROM config WHERE name = :type; |
|
22 | 22 | INSERT INTO config (name,value) VALUES (:type,:stats_date);"; |
23 | - $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | - try { |
|
25 | - $sth = $this->db->prepare($query); |
|
26 | - $sth->execute($query_values); |
|
27 | - } catch(PDOException $e) { |
|
28 | - return "error : ".$e->getMessage(); |
|
29 | - } |
|
30 | - } |
|
23 | + $query_values = array('type' => $type,':stats_date' => $stats_date); |
|
24 | + try { |
|
25 | + $sth = $this->db->prepare($query); |
|
26 | + $sth->execute($query_values); |
|
27 | + } catch(PDOException $e) { |
|
28 | + return "error : ".$e->getMessage(); |
|
29 | + } |
|
30 | + } |
|
31 | 31 | |
32 | 32 | public function getLastStatsUpdate($type = 'last_update_stats') { |
33 | - $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | - try { |
|
35 | - $sth = $this->db->prepare($query); |
|
36 | - $sth->execute(array(':type' => $type)); |
|
37 | - } catch(PDOException $e) { |
|
38 | - echo "error : ".$e->getMessage(); |
|
39 | - } |
|
40 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | - return $all; |
|
42 | - } |
|
33 | + $query = "SELECT value FROM config WHERE name = :type"; |
|
34 | + try { |
|
35 | + $sth = $this->db->prepare($query); |
|
36 | + $sth->execute(array(':type' => $type)); |
|
37 | + } catch(PDOException $e) { |
|
38 | + echo "error : ".$e->getMessage(); |
|
39 | + } |
|
40 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
41 | + return $all; |
|
42 | + } |
|
43 | 43 | public function getAllAirlineNames($filter_name = '') { |
44 | 44 | if ($filter_name == '') $filter_name = $this->filter_name; |
45 | - $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | - try { |
|
47 | - $sth = $this->db->prepare($query); |
|
48 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | - } catch(PDOException $e) { |
|
50 | - echo "error : ".$e->getMessage(); |
|
51 | - } |
|
52 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | - return $all; |
|
54 | - } |
|
45 | + $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
|
46 | + try { |
|
47 | + $sth = $this->db->prepare($query); |
|
48 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
49 | + } catch(PDOException $e) { |
|
50 | + echo "error : ".$e->getMessage(); |
|
51 | + } |
|
52 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
53 | + return $all; |
|
54 | + } |
|
55 | 55 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
56 | 56 | if ($filter_name == '') $filter_name = $this->filter_name; |
57 | - $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | - try { |
|
59 | - $sth = $this->db->prepare($query); |
|
60 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | - } catch(PDOException $e) { |
|
62 | - echo "error : ".$e->getMessage(); |
|
63 | - } |
|
64 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | - return $all; |
|
66 | - } |
|
57 | + $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
|
58 | + try { |
|
59 | + $sth = $this->db->prepare($query); |
|
60 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
61 | + } catch(PDOException $e) { |
|
62 | + echo "error : ".$e->getMessage(); |
|
63 | + } |
|
64 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
65 | + return $all; |
|
66 | + } |
|
67 | 67 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
68 | 68 | if ($filter_name == '') $filter_name = $this->filter_name; |
69 | - $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
70 | - try { |
|
71 | - $sth = $this->db->prepare($query); |
|
72 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | - } catch(PDOException $e) { |
|
74 | - echo "error : ".$e->getMessage(); |
|
75 | - } |
|
76 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | - return $all; |
|
78 | - } |
|
69 | + $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
|
70 | + try { |
|
71 | + $sth = $this->db->prepare($query); |
|
72 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
73 | + } catch(PDOException $e) { |
|
74 | + echo "error : ".$e->getMessage(); |
|
75 | + } |
|
76 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
77 | + return $all; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -83,66 +83,66 @@ discard block |
||
83 | 83 | if ($filter_name == '') $filter_name = $this->filter_name; |
84 | 84 | if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
85 | 85 | else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
86 | - try { |
|
87 | - $sth = $this->db->prepare($query); |
|
88 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | - } catch(PDOException $e) { |
|
90 | - echo "error : ".$e->getMessage(); |
|
91 | - } |
|
92 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | - if (empty($all)) { |
|
94 | - $filters = array('airlines' => array($stats_airline)); |
|
95 | - if ($filter_name != '') { |
|
96 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | - } |
|
98 | - $Spotter = new Spotter($this->db); |
|
99 | - $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | - } |
|
101 | - return $all; |
|
86 | + try { |
|
87 | + $sth = $this->db->prepare($query); |
|
88 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
89 | + } catch(PDOException $e) { |
|
90 | + echo "error : ".$e->getMessage(); |
|
91 | + } |
|
92 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
93 | + if (empty($all)) { |
|
94 | + $filters = array('airlines' => array($stats_airline)); |
|
95 | + if ($filter_name != '') { |
|
96 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
97 | + } |
|
98 | + $Spotter = new Spotter($this->db); |
|
99 | + $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters); |
|
100 | + } |
|
101 | + return $all; |
|
102 | 102 | } |
103 | 103 | public function countAllAirlineCountries($limit = true,$filter_name = '') { |
104 | 104 | global $globalStatsFilters; |
105 | 105 | if ($filter_name == '') $filter_name = $this->filter_name; |
106 | 106 | if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
107 | 107 | else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
108 | - try { |
|
109 | - $sth = $this->db->prepare($query); |
|
110 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | - } catch(PDOException $e) { |
|
112 | - echo "error : ".$e->getMessage(); |
|
113 | - } |
|
114 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | - if (empty($all)) { |
|
116 | - $Spotter = new Spotter($this->db); |
|
117 | - $filters = array(); |
|
118 | - if ($filter_name != '') { |
|
119 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | - } |
|
121 | - $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | - } |
|
123 | - return $all; |
|
108 | + try { |
|
109 | + $sth = $this->db->prepare($query); |
|
110 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
111 | + } catch(PDOException $e) { |
|
112 | + echo "error : ".$e->getMessage(); |
|
113 | + } |
|
114 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
115 | + if (empty($all)) { |
|
116 | + $Spotter = new Spotter($this->db); |
|
117 | + $filters = array(); |
|
118 | + if ($filter_name != '') { |
|
119 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
120 | + } |
|
121 | + $all = $Spotter->countAllAirlineCountries($limit,$filters); |
|
122 | + } |
|
123 | + return $all; |
|
124 | 124 | } |
125 | 125 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '') { |
126 | 126 | global $globalStatsFilters; |
127 | 127 | if ($filter_name == '') $filter_name = $this->filter_name; |
128 | 128 | if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
129 | 129 | else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
130 | - try { |
|
131 | - $sth = $this->db->prepare($query); |
|
132 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | - } catch(PDOException $e) { |
|
134 | - echo "error : ".$e->getMessage(); |
|
135 | - } |
|
136 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | - if (empty($all)) { |
|
138 | - $filters = array('airlines' => array($stats_airline)); |
|
139 | - if ($filter_name != '') { |
|
140 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
130 | + try { |
|
131 | + $sth = $this->db->prepare($query); |
|
132 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
133 | + } catch(PDOException $e) { |
|
134 | + echo "error : ".$e->getMessage(); |
|
135 | + } |
|
136 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
137 | + if (empty($all)) { |
|
138 | + $filters = array('airlines' => array($stats_airline)); |
|
139 | + if ($filter_name != '') { |
|
140 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
141 | 141 | } |
142 | - $Spotter = new Spotter($this->db); |
|
142 | + $Spotter = new Spotter($this->db); |
|
143 | 143 | $all = $Spotter->countAllAircraftManufacturers($filters); |
144 | - } |
|
145 | - return $all; |
|
144 | + } |
|
145 | + return $all; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '') { |
@@ -150,44 +150,44 @@ discard block |
||
150 | 150 | if ($filter_name == '') $filter_name = $this->filter_name; |
151 | 151 | if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
152 | 152 | else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
153 | - try { |
|
154 | - $sth = $this->db->prepare($query); |
|
155 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | - } catch(PDOException $e) { |
|
157 | - echo "error : ".$e->getMessage(); |
|
158 | - } |
|
159 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | - if (empty($all)) { |
|
153 | + try { |
|
154 | + $sth = $this->db->prepare($query); |
|
155 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
156 | + } catch(PDOException $e) { |
|
157 | + echo "error : ".$e->getMessage(); |
|
158 | + } |
|
159 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
160 | + if (empty($all)) { |
|
161 | 161 | $filters = array('airlines' => array($stats_airline)); |
162 | 162 | if ($filter_name != '') { |
163 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
163 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
164 | 164 | } |
165 | 165 | $Spotter = new Spotter($this->db); |
166 | 166 | $all = $Spotter->countAllArrivalCountries($limit,$filters); |
167 | - } |
|
168 | - return $all; |
|
167 | + } |
|
168 | + return $all; |
|
169 | 169 | } |
170 | 170 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '') { |
171 | 171 | global $globalStatsFilters; |
172 | 172 | if ($filter_name == '') $filter_name = $this->filter_name; |
173 | 173 | if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
174 | 174 | else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo "error : ".$e->getMessage(); |
|
180 | - } |
|
181 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | - if (empty($all)) { |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo "error : ".$e->getMessage(); |
|
180 | + } |
|
181 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
182 | + if (empty($all)) { |
|
183 | 183 | $filters = array('airlines' => array($stats_airline)); |
184 | 184 | if ($filter_name != '') { |
185 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
185 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
186 | 186 | } |
187 | 187 | $Spotter = new Spotter($this->db); |
188 | 188 | $all = $Spotter->countAllDepartureCountries($filters); |
189 | - } |
|
190 | - return $all; |
|
189 | + } |
|
190 | + return $all; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | public function countAllAirlines($limit = true,$filter_name = '') { |
@@ -195,45 +195,45 @@ discard block |
||
195 | 195 | if ($filter_name == '') $filter_name = $this->filter_name; |
196 | 196 | if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
197 | 197 | else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name ORDER BY airline_count DESC"; |
198 | - try { |
|
199 | - $sth = $this->db->prepare($query); |
|
200 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | - } catch(PDOException $e) { |
|
202 | - echo "error : ".$e->getMessage(); |
|
203 | - } |
|
204 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | - if (empty($all)) { |
|
206 | - $Spotter = new Spotter($this->db); |
|
207 | - $filters = array(); |
|
208 | - if ($filter_name != '') { |
|
209 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
198 | + try { |
|
199 | + $sth = $this->db->prepare($query); |
|
200 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
201 | + } catch(PDOException $e) { |
|
202 | + echo "error : ".$e->getMessage(); |
|
203 | + } |
|
204 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + if (empty($all)) { |
|
206 | + $Spotter = new Spotter($this->db); |
|
207 | + $filters = array(); |
|
208 | + if ($filter_name != '') { |
|
209 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
210 | 210 | } |
211 | 211 | |
212 | - $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | - } |
|
214 | - return $all; |
|
212 | + $all = $Spotter->countAllAirlines($limit,0,'',$filters); |
|
213 | + } |
|
214 | + return $all; |
|
215 | 215 | } |
216 | 216 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '') { |
217 | 217 | global $globalStatsFilters; |
218 | 218 | if ($filter_name == '') $filter_name = $this->filter_name; |
219 | 219 | if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
220 | 220 | else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
221 | - try { |
|
222 | - $sth = $this->db->prepare($query); |
|
223 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | - } catch(PDOException $e) { |
|
225 | - echo "error : ".$e->getMessage(); |
|
226 | - } |
|
227 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | - if (empty($all)) { |
|
221 | + try { |
|
222 | + $sth = $this->db->prepare($query); |
|
223 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
224 | + } catch(PDOException $e) { |
|
225 | + echo "error : ".$e->getMessage(); |
|
226 | + } |
|
227 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + if (empty($all)) { |
|
229 | 229 | $filters = array('airlines' => array($stats_airline)); |
230 | 230 | if ($filter_name != '') { |
231 | 231 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
232 | 232 | } |
233 | - $Spotter = new Spotter($this->db); |
|
234 | - $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | - } |
|
236 | - return $all; |
|
233 | + $Spotter = new Spotter($this->db); |
|
234 | + $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters); |
|
235 | + } |
|
236 | + return $all; |
|
237 | 237 | } |
238 | 238 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '') { |
239 | 239 | global $globalStatsFilters; |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | echo "error : ".$e->getMessage(); |
271 | 271 | } |
272 | 272 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
273 | - /* |
|
273 | + /* |
|
274 | 274 | if (empty($all)) { |
275 | 275 | $Spotter = new Spotter($this->db); |
276 | 276 | $all = $Spotter->countAllFlightOverCountries($limit); |
@@ -286,84 +286,84 @@ discard block |
||
286 | 286 | if ($filter_name == '') $filter_name = $this->filter_name; |
287 | 287 | if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
288 | 288 | else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
289 | - try { |
|
290 | - $sth = $this->db->prepare($query); |
|
291 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | - } catch(PDOException $e) { |
|
293 | - echo "error : ".$e->getMessage(); |
|
294 | - } |
|
295 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | - if (empty($all)) { |
|
289 | + try { |
|
290 | + $sth = $this->db->prepare($query); |
|
291 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
292 | + } catch(PDOException $e) { |
|
293 | + echo "error : ".$e->getMessage(); |
|
294 | + } |
|
295 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | + if (empty($all)) { |
|
297 | 297 | $filters = array('airlines' => array($stats_airline)); |
298 | 298 | if ($filter_name != '') { |
299 | 299 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
300 | 300 | } |
301 | - $Spotter = new Spotter($this->db); |
|
302 | - $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | - } |
|
304 | - return $all; |
|
301 | + $Spotter = new Spotter($this->db); |
|
302 | + $all = $Spotter->countAllPilots($limit,0,'',$filters); |
|
303 | + } |
|
304 | + return $all; |
|
305 | 305 | } |
306 | 306 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '') { |
307 | 307 | global $globalStatsFilters; |
308 | 308 | if ($filter_name == '') $filter_name = $this->filter_name; |
309 | 309 | if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
310 | 310 | else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
311 | - try { |
|
312 | - $sth = $this->db->prepare($query); |
|
313 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | - } catch(PDOException $e) { |
|
315 | - echo "error : ".$e->getMessage(); |
|
316 | - } |
|
317 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | - if (empty($all)) { |
|
311 | + try { |
|
312 | + $sth = $this->db->prepare($query); |
|
313 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
314 | + } catch(PDOException $e) { |
|
315 | + echo "error : ".$e->getMessage(); |
|
316 | + } |
|
317 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
318 | + if (empty($all)) { |
|
319 | 319 | $filters = array('airlines' => array($stats_airline)); |
320 | 320 | if ($filter_name != '') { |
321 | 321 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
322 | 322 | } |
323 | - $Spotter = new Spotter($this->db); |
|
324 | - $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | - } |
|
326 | - return $all; |
|
323 | + $Spotter = new Spotter($this->db); |
|
324 | + $all = $Spotter->countAllOwners($limit,0,'',$filters); |
|
325 | + } |
|
326 | + return $all; |
|
327 | 327 | } |
328 | 328 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '') { |
329 | 329 | global $globalStatsFilters; |
330 | 330 | if ($filter_name == '') $filter_name = $this->filter_name; |
331 | 331 | if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
332 | 332 | else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
333 | - try { |
|
334 | - $sth = $this->db->prepare($query); |
|
335 | - $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | - } catch(PDOException $e) { |
|
337 | - echo "error : ".$e->getMessage(); |
|
338 | - } |
|
339 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | - if (empty($all)) { |
|
333 | + try { |
|
334 | + $sth = $this->db->prepare($query); |
|
335 | + $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
|
336 | + } catch(PDOException $e) { |
|
337 | + echo "error : ".$e->getMessage(); |
|
338 | + } |
|
339 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
340 | + if (empty($all)) { |
|
341 | 341 | $filters = array('airlines' => array($stats_airline)); |
342 | - if ($filter_name != '') { |
|
343 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | - } |
|
345 | - $Spotter = new Spotter($this->db); |
|
346 | - $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | - $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | - $all = array(); |
|
349 | - foreach ($pall as $value) { |
|
350 | - $icao = $value['airport_departure_icao']; |
|
351 | - $all[$icao] = $value; |
|
352 | - } |
|
342 | + if ($filter_name != '') { |
|
343 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
344 | + } |
|
345 | + $Spotter = new Spotter($this->db); |
|
346 | + $pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters); |
|
347 | + $dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters); |
|
348 | + $all = array(); |
|
349 | + foreach ($pall as $value) { |
|
350 | + $icao = $value['airport_departure_icao']; |
|
351 | + $all[$icao] = $value; |
|
352 | + } |
|
353 | 353 | |
354 | - foreach ($dall as $value) { |
|
355 | - $icao = $value['airport_departure_icao']; |
|
356 | - if (isset($all[$icao])) { |
|
357 | - $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | - } else $all[$icao] = $value; |
|
359 | - } |
|
360 | - $count = array(); |
|
361 | - foreach ($all as $key => $row) { |
|
362 | - $count[$key] = $row['airport_departure_icao_count']; |
|
363 | - } |
|
364 | - array_multisort($count,SORT_DESC,$all); |
|
365 | - } |
|
366 | - return $all; |
|
354 | + foreach ($dall as $value) { |
|
355 | + $icao = $value['airport_departure_icao']; |
|
356 | + if (isset($all[$icao])) { |
|
357 | + $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
358 | + } else $all[$icao] = $value; |
|
359 | + } |
|
360 | + $count = array(); |
|
361 | + foreach ($all as $key => $row) { |
|
362 | + $count[$key] = $row['airport_departure_icao_count']; |
|
363 | + } |
|
364 | + array_multisort($count,SORT_DESC,$all); |
|
365 | + } |
|
366 | + return $all; |
|
367 | 367 | } |
368 | 368 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '') { |
369 | 369 | global $globalStatsFilters; |
@@ -385,26 +385,26 @@ discard block |
||
385 | 385 | $Spotter = new Spotter($this->db); |
386 | 386 | $pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters); |
387 | 387 | $dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters); |
388 | - $all = array(); |
|
389 | - foreach ($pall as $value) { |
|
390 | - $icao = $value['airport_arrival_icao']; |
|
391 | - $all[$icao] = $value; |
|
392 | - } |
|
388 | + $all = array(); |
|
389 | + foreach ($pall as $value) { |
|
390 | + $icao = $value['airport_arrival_icao']; |
|
391 | + $all[$icao] = $value; |
|
392 | + } |
|
393 | 393 | |
394 | - foreach ($dall as $value) { |
|
395 | - $icao = $value['airport_arrival_icao']; |
|
396 | - if (isset($all[$icao])) { |
|
397 | - $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | - } else $all[$icao] = $value; |
|
399 | - } |
|
400 | - $count = array(); |
|
401 | - foreach ($all as $key => $row) { |
|
402 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | - } |
|
404 | - array_multisort($count,SORT_DESC,$all); |
|
405 | - } |
|
394 | + foreach ($dall as $value) { |
|
395 | + $icao = $value['airport_arrival_icao']; |
|
396 | + if (isset($all[$icao])) { |
|
397 | + $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
398 | + } else $all[$icao] = $value; |
|
399 | + } |
|
400 | + $count = array(); |
|
401 | + foreach ($all as $key => $row) { |
|
402 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
403 | + } |
|
404 | + array_multisort($count,SORT_DESC,$all); |
|
405 | + } |
|
406 | 406 | |
407 | - return $all; |
|
407 | + return $all; |
|
408 | 408 | } |
409 | 409 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
410 | 410 | global $globalDBdriver, $globalStatsFilters; |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
418 | 418 | } |
419 | 419 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
420 | - try { |
|
421 | - $sth = $this->db->prepare($query); |
|
422 | - $sth->execute($query_data); |
|
423 | - } catch(PDOException $e) { |
|
424 | - echo "error : ".$e->getMessage(); |
|
425 | - } |
|
426 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | - if (empty($all)) { |
|
420 | + try { |
|
421 | + $sth = $this->db->prepare($query); |
|
422 | + $sth->execute($query_data); |
|
423 | + } catch(PDOException $e) { |
|
424 | + echo "error : ".$e->getMessage(); |
|
425 | + } |
|
426 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
427 | + if (empty($all)) { |
|
428 | 428 | $filters = array('airlines' => array($stats_airline)); |
429 | 429 | if ($filter_name != '') { |
430 | 430 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
431 | 431 | } |
432 | - $Spotter = new Spotter($this->db); |
|
433 | - $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | - } |
|
432 | + $Spotter = new Spotter($this->db); |
|
433 | + $all = $Spotter->countAllMonthsLastYear($filters); |
|
434 | + } |
|
435 | 435 | |
436 | - return $all; |
|
436 | + return $all; |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | if ($filter_name == '') $filter_name = $this->filter_name; |
442 | 442 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
443 | 443 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
444 | - try { |
|
445 | - $sth = $this->db->prepare($query); |
|
446 | - $sth->execute($query_data); |
|
447 | - } catch(PDOException $e) { |
|
448 | - echo "error : ".$e->getMessage(); |
|
449 | - } |
|
450 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | - if (empty($all)) { |
|
444 | + try { |
|
445 | + $sth = $this->db->prepare($query); |
|
446 | + $sth->execute($query_data); |
|
447 | + } catch(PDOException $e) { |
|
448 | + echo "error : ".$e->getMessage(); |
|
449 | + } |
|
450 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
451 | + if (empty($all)) { |
|
452 | 452 | $filters = array('airlines' => array($stats_airline)); |
453 | 453 | if ($filter_name != '') { |
454 | 454 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
455 | 455 | } |
456 | - $Spotter = new Spotter($this->db); |
|
457 | - $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | - } |
|
459 | - return $all; |
|
456 | + $Spotter = new Spotter($this->db); |
|
457 | + $all = $Spotter->countAllDatesLastMonth($filters); |
|
458 | + } |
|
459 | + return $all; |
|
460 | 460 | } |
461 | 461 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
462 | 462 | global $globalDBdriver, $globalStatsFilters; |
@@ -467,108 +467,108 @@ discard block |
||
467 | 467 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
468 | 468 | } |
469 | 469 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
470 | - try { |
|
471 | - $sth = $this->db->prepare($query); |
|
472 | - $sth->execute($query_data); |
|
473 | - } catch(PDOException $e) { |
|
474 | - echo "error : ".$e->getMessage(); |
|
475 | - } |
|
476 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | - if (empty($all)) { |
|
470 | + try { |
|
471 | + $sth = $this->db->prepare($query); |
|
472 | + $sth->execute($query_data); |
|
473 | + } catch(PDOException $e) { |
|
474 | + echo "error : ".$e->getMessage(); |
|
475 | + } |
|
476 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
477 | + if (empty($all)) { |
|
478 | 478 | $filters = array('airlines' => array($stats_airline)); |
479 | 479 | if ($filter_name != '') { |
480 | 480 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
481 | 481 | } |
482 | - $Spotter = new Spotter($this->db); |
|
483 | - $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | - } |
|
485 | - return $all; |
|
482 | + $Spotter = new Spotter($this->db); |
|
483 | + $all = $Spotter->countAllDatesLast7Days($filters); |
|
484 | + } |
|
485 | + return $all; |
|
486 | 486 | } |
487 | 487 | public function countAllDates($stats_airline = '',$filter_name = '') { |
488 | 488 | global $globalStatsFilters; |
489 | 489 | if ($filter_name == '') $filter_name = $this->filter_name; |
490 | 490 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
491 | 491 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
492 | - try { |
|
493 | - $sth = $this->db->prepare($query); |
|
494 | - $sth->execute($query_data); |
|
495 | - } catch(PDOException $e) { |
|
496 | - echo "error : ".$e->getMessage(); |
|
497 | - } |
|
498 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | - if (empty($all)) { |
|
492 | + try { |
|
493 | + $sth = $this->db->prepare($query); |
|
494 | + $sth->execute($query_data); |
|
495 | + } catch(PDOException $e) { |
|
496 | + echo "error : ".$e->getMessage(); |
|
497 | + } |
|
498 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
499 | + if (empty($all)) { |
|
500 | 500 | $filters = array('airlines' => array($stats_airline)); |
501 | 501 | if ($filter_name != '') { |
502 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
502 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
503 | 503 | } |
504 | - $Spotter = new Spotter($this->db); |
|
505 | - $all = $Spotter->countAllDates($filters); |
|
506 | - } |
|
507 | - return $all; |
|
504 | + $Spotter = new Spotter($this->db); |
|
505 | + $all = $Spotter->countAllDates($filters); |
|
506 | + } |
|
507 | + return $all; |
|
508 | 508 | } |
509 | 509 | public function countAllDatesByAirlines($filter_name = '') { |
510 | 510 | global $globalStatsFilters; |
511 | 511 | if ($filter_name == '') $filter_name = $this->filter_name; |
512 | 512 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
513 | 513 | $query_data = array('filter_name' => $filter_name); |
514 | - try { |
|
515 | - $sth = $this->db->prepare($query); |
|
516 | - $sth->execute($query_data); |
|
517 | - } catch(PDOException $e) { |
|
518 | - echo "error : ".$e->getMessage(); |
|
519 | - } |
|
520 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | - if (empty($all)) { |
|
522 | - $filters = array(); |
|
523 | - if ($filter_name != '') { |
|
524 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | - } |
|
526 | - $Spotter = new Spotter($this->db); |
|
527 | - $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | - } |
|
529 | - return $all; |
|
514 | + try { |
|
515 | + $sth = $this->db->prepare($query); |
|
516 | + $sth->execute($query_data); |
|
517 | + } catch(PDOException $e) { |
|
518 | + echo "error : ".$e->getMessage(); |
|
519 | + } |
|
520 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
521 | + if (empty($all)) { |
|
522 | + $filters = array(); |
|
523 | + if ($filter_name != '') { |
|
524 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
525 | + } |
|
526 | + $Spotter = new Spotter($this->db); |
|
527 | + $all = $Spotter->countAllDatesByAirlines($filters); |
|
528 | + } |
|
529 | + return $all; |
|
530 | 530 | } |
531 | 531 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
532 | 532 | global $globalStatsFilters; |
533 | 533 | if ($filter_name == '') $filter_name = $this->filter_name; |
534 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
535 | - try { |
|
536 | - $sth = $this->db->prepare($query); |
|
537 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | - } catch(PDOException $e) { |
|
539 | - echo "error : ".$e->getMessage(); |
|
540 | - } |
|
541 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | - if (empty($all)) { |
|
534 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
535 | + try { |
|
536 | + $sth = $this->db->prepare($query); |
|
537 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
538 | + } catch(PDOException $e) { |
|
539 | + echo "error : ".$e->getMessage(); |
|
540 | + } |
|
541 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
542 | + if (empty($all)) { |
|
543 | 543 | $filters = array('airlines' => array($stats_airline)); |
544 | 544 | if ($filter_name != '') { |
545 | 545 | $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
546 | 546 | } |
547 | - $Spotter = new Spotter($this->db); |
|
548 | - $all = $Spotter->countAllMonths($filters); |
|
549 | - } |
|
550 | - return $all; |
|
547 | + $Spotter = new Spotter($this->db); |
|
548 | + $all = $Spotter->countAllMonths($filters); |
|
549 | + } |
|
550 | + return $all; |
|
551 | 551 | } |
552 | 552 | public function countAllMilitaryMonths($filter_name = '') { |
553 | 553 | global $globalStatsFilters; |
554 | 554 | if ($filter_name == '') $filter_name = $this->filter_name; |
555 | - $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
556 | - try { |
|
557 | - $sth = $this->db->prepare($query); |
|
558 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | - } catch(PDOException $e) { |
|
560 | - echo "error : ".$e->getMessage(); |
|
561 | - } |
|
562 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | - if (empty($all)) { |
|
564 | - $filters = array(); |
|
565 | - if ($filter_name != '') { |
|
566 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | - } |
|
568 | - $Spotter = new Spotter($this->db); |
|
569 | - $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | - } |
|
571 | - return $all; |
|
555 | + $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
|
556 | + try { |
|
557 | + $sth = $this->db->prepare($query); |
|
558 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
559 | + } catch(PDOException $e) { |
|
560 | + echo "error : ".$e->getMessage(); |
|
561 | + } |
|
562 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
563 | + if (empty($all)) { |
|
564 | + $filters = array(); |
|
565 | + if ($filter_name != '') { |
|
566 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
567 | + } |
|
568 | + $Spotter = new Spotter($this->db); |
|
569 | + $all = $Spotter->countAllMilitaryMonths($filters); |
|
570 | + } |
|
571 | + return $all; |
|
572 | 572 | } |
573 | 573 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
574 | 574 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
@@ -584,22 +584,22 @@ discard block |
||
584 | 584 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
585 | 585 | } |
586 | 586 | if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
587 | - try { |
|
588 | - $sth = $this->db->prepare($query); |
|
589 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | - } catch(PDOException $e) { |
|
591 | - echo "error : ".$e->getMessage(); |
|
592 | - } |
|
593 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | - if (empty($all)) { |
|
587 | + try { |
|
588 | + $sth = $this->db->prepare($query); |
|
589 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
590 | + } catch(PDOException $e) { |
|
591 | + echo "error : ".$e->getMessage(); |
|
592 | + } |
|
593 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
594 | + if (empty($all)) { |
|
595 | 595 | $filters = array('airlines' => array($stats_airline)); |
596 | 596 | if ($filter_name != '') { |
597 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
597 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
598 | 598 | } |
599 | - $Spotter = new Spotter($this->db); |
|
600 | - $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | - } |
|
602 | - return $all; |
|
599 | + $Spotter = new Spotter($this->db); |
|
600 | + $all = $Spotter->countAllHours($orderby,$filters); |
|
601 | + } |
|
602 | + return $all; |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | public function countOverallFlights($stats_airline = '', $filter_name = '') { |
@@ -621,9 +621,9 @@ discard block |
||
621 | 621 | if ($filter_name == '') $filter_name = $this->filter_name; |
622 | 622 | $all = $this->getSumStats('military_flights_bymonth',date('Y'),'',$filter_name); |
623 | 623 | if (empty($all)) { |
624 | - $filters = array(); |
|
625 | - if ($filter_name != '') { |
|
626 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
624 | + $filters = array(); |
|
625 | + if ($filter_name != '') { |
|
626 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
627 | 627 | } |
628 | 628 | $Spotter = new Spotter($this->db); |
629 | 629 | $all = $Spotter->countOverallMilitaryFlights($filters); |
@@ -662,19 +662,19 @@ discard block |
||
662 | 662 | global $globalStatsFilters; |
663 | 663 | if ($filter_name == '') $filter_name = $this->filter_name; |
664 | 664 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
665 | - try { |
|
666 | - $sth = $this->db->prepare($query); |
|
667 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | - } catch(PDOException $e) { |
|
669 | - echo "error : ".$e->getMessage(); |
|
670 | - } |
|
671 | - $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | - $all = $result[0]['nb_airline']; |
|
665 | + try { |
|
666 | + $sth = $this->db->prepare($query); |
|
667 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
668 | + } catch(PDOException $e) { |
|
669 | + echo "error : ".$e->getMessage(); |
|
670 | + } |
|
671 | + $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
672 | + $all = $result[0]['nb_airline']; |
|
673 | 673 | //$all = $this->getSumStats('airlines_bymonth',date('Y')); |
674 | 674 | if (empty($all)) { |
675 | - $filters = array(); |
|
676 | - if ($filter_name != '') { |
|
677 | - $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
675 | + $filters = array(); |
|
676 | + if ($filter_name != '') { |
|
677 | + $filters = array_merge($filters,$globalStatsFilters[$filter_name]); |
|
678 | 678 | } |
679 | 679 | $Spotter = new Spotter($this->db); |
680 | 680 | $all = $Spotter->countOverallAirlines($filters); |
@@ -725,166 +725,166 @@ discard block |
||
725 | 725 | if ($filter_name == '') $filter_name = $this->filter_name; |
726 | 726 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
727 | 727 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
728 | - try { |
|
729 | - $sth = $this->db->prepare($query); |
|
730 | - $sth->execute($query_values); |
|
731 | - } catch(PDOException $e) { |
|
732 | - echo "error : ".$e->getMessage(); |
|
733 | - } |
|
734 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | - return $all; |
|
728 | + try { |
|
729 | + $sth = $this->db->prepare($query); |
|
730 | + $sth->execute($query_values); |
|
731 | + } catch(PDOException $e) { |
|
732 | + echo "error : ".$e->getMessage(); |
|
733 | + } |
|
734 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
735 | + return $all; |
|
736 | 736 | } |
737 | 737 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
738 | 738 | if ($filter_name == '') $filter_name = $this->filter_name; |
739 | - $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | - $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | - try { |
|
742 | - $sth = $this->db->prepare($query); |
|
743 | - $sth->execute($query_values); |
|
744 | - } catch(PDOException $e) { |
|
745 | - echo "error : ".$e->getMessage(); |
|
746 | - } |
|
747 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | - return $all; |
|
749 | - } |
|
739 | + $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
|
740 | + $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
741 | + try { |
|
742 | + $sth = $this->db->prepare($query); |
|
743 | + $sth->execute($query_values); |
|
744 | + } catch(PDOException $e) { |
|
745 | + echo "error : ".$e->getMessage(); |
|
746 | + } |
|
747 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
748 | + return $all; |
|
749 | + } |
|
750 | 750 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '') { |
751 | 751 | if ($filter_name == '') $filter_name = $this->filter_name; |
752 | - global $globalArchiveMonths, $globalDBdriver; |
|
753 | - if ($globalDBdriver == 'mysql') { |
|
754 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
755 | - } else { |
|
756 | - $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
757 | - } |
|
758 | - $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | - try { |
|
760 | - $sth = $this->db->prepare($query); |
|
761 | - $sth->execute($query_values); |
|
762 | - } catch(PDOException $e) { |
|
763 | - echo "error : ".$e->getMessage(); |
|
764 | - } |
|
765 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | - return $all[0]['total']; |
|
767 | - } |
|
752 | + global $globalArchiveMonths, $globalDBdriver; |
|
753 | + if ($globalDBdriver == 'mysql') { |
|
754 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
755 | + } else { |
|
756 | + $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
757 | + } |
|
758 | + $query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
759 | + try { |
|
760 | + $sth = $this->db->prepare($query); |
|
761 | + $sth->execute($query_values); |
|
762 | + } catch(PDOException $e) { |
|
763 | + echo "error : ".$e->getMessage(); |
|
764 | + } |
|
765 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
766 | + return $all[0]['total']; |
|
767 | + } |
|
768 | 768 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
769 | - global $globalArchiveMonths, $globalDBdriver; |
|
769 | + global $globalArchiveMonths, $globalDBdriver; |
|
770 | 770 | if ($filter_name == '') $filter_name = $this->filter_name; |
771 | - if ($globalDBdriver == 'mysql') { |
|
771 | + if ($globalDBdriver == 'mysql') { |
|
772 | 772 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
773 | 773 | } else { |
774 | 774 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
775 | - } |
|
776 | - $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | - try { |
|
778 | - $sth = $this->db->prepare($query); |
|
779 | - $sth->execute($query_values); |
|
780 | - } catch(PDOException $e) { |
|
781 | - echo "error : ".$e->getMessage(); |
|
782 | - } |
|
783 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | - return $all[0]['total']; |
|
785 | - } |
|
775 | + } |
|
776 | + $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
|
777 | + try { |
|
778 | + $sth = $this->db->prepare($query); |
|
779 | + $sth->execute($query_values); |
|
780 | + } catch(PDOException $e) { |
|
781 | + echo "error : ".$e->getMessage(); |
|
782 | + } |
|
783 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
784 | + return $all[0]['total']; |
|
785 | + } |
|
786 | 786 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
787 | - global $globalArchiveMonths, $globalDBdriver; |
|
787 | + global $globalArchiveMonths, $globalDBdriver; |
|
788 | 788 | if ($filter_name == '') $filter_name = $this->filter_name; |
789 | - if ($globalDBdriver == 'mysql') { |
|
789 | + if ($globalDBdriver == 'mysql') { |
|
790 | 790 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
791 | - } else { |
|
791 | + } else { |
|
792 | 792 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
793 | - } |
|
794 | - try { |
|
795 | - $sth = $this->db->prepare($query); |
|
796 | - $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | - } catch(PDOException $e) { |
|
798 | - echo "error : ".$e->getMessage(); |
|
799 | - } |
|
800 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | - return $all[0]['total']; |
|
802 | - } |
|
793 | + } |
|
794 | + try { |
|
795 | + $sth = $this->db->prepare($query); |
|
796 | + $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
|
797 | + } catch(PDOException $e) { |
|
798 | + echo "error : ".$e->getMessage(); |
|
799 | + } |
|
800 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
801 | + return $all[0]['total']; |
|
802 | + } |
|
803 | 803 | public function getStatsAirlineTotal($filter_name = '') { |
804 | - global $globalArchiveMonths, $globalDBdriver; |
|
804 | + global $globalArchiveMonths, $globalDBdriver; |
|
805 | 805 | if ($filter_name == '') $filter_name = $this->filter_name; |
806 | - if ($globalDBdriver == 'mysql') { |
|
806 | + if ($globalDBdriver == 'mysql') { |
|
807 | 807 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
808 | - } else { |
|
808 | + } else { |
|
809 | 809 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
810 | - } |
|
811 | - try { |
|
812 | - $sth = $this->db->prepare($query); |
|
813 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | - } catch(PDOException $e) { |
|
815 | - echo "error : ".$e->getMessage(); |
|
816 | - } |
|
817 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | - return $all[0]['total']; |
|
819 | - } |
|
810 | + } |
|
811 | + try { |
|
812 | + $sth = $this->db->prepare($query); |
|
813 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
814 | + } catch(PDOException $e) { |
|
815 | + echo "error : ".$e->getMessage(); |
|
816 | + } |
|
817 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
818 | + return $all[0]['total']; |
|
819 | + } |
|
820 | 820 | public function getStatsOwnerTotal($filter_name = '') { |
821 | - global $globalArchiveMonths, $globalDBdriver; |
|
821 | + global $globalArchiveMonths, $globalDBdriver; |
|
822 | 822 | if ($filter_name == '') $filter_name = $this->filter_name; |
823 | - if ($globalDBdriver == 'mysql') { |
|
823 | + if ($globalDBdriver == 'mysql') { |
|
824 | 824 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
825 | 825 | } else { |
826 | 826 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
827 | - } |
|
828 | - try { |
|
829 | - $sth = $this->db->prepare($query); |
|
830 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | - } catch(PDOException $e) { |
|
832 | - echo "error : ".$e->getMessage(); |
|
833 | - } |
|
834 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | - return $all[0]['total']; |
|
836 | - } |
|
827 | + } |
|
828 | + try { |
|
829 | + $sth = $this->db->prepare($query); |
|
830 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
831 | + } catch(PDOException $e) { |
|
832 | + echo "error : ".$e->getMessage(); |
|
833 | + } |
|
834 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
835 | + return $all[0]['total']; |
|
836 | + } |
|
837 | 837 | public function getStatsPilotTotal($filter_name = '') { |
838 | - global $globalArchiveMonths, $globalDBdriver; |
|
838 | + global $globalArchiveMonths, $globalDBdriver; |
|
839 | 839 | if ($filter_name == '') $filter_name = $this->filter_name; |
840 | - if ($globalDBdriver == 'mysql') { |
|
841 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | - } else { |
|
843 | - $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | - } |
|
845 | - try { |
|
846 | - $sth = $this->db->prepare($query); |
|
847 | - $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | - } catch(PDOException $e) { |
|
849 | - echo "error : ".$e->getMessage(); |
|
850 | - } |
|
851 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | - return $all[0]['total']; |
|
853 | - } |
|
840 | + if ($globalDBdriver == 'mysql') { |
|
841 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
842 | + } else { |
|
843 | + $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
|
844 | + } |
|
845 | + try { |
|
846 | + $sth = $this->db->prepare($query); |
|
847 | + $sth->execute(array(':filter_name' => $filter_name)); |
|
848 | + } catch(PDOException $e) { |
|
849 | + echo "error : ".$e->getMessage(); |
|
850 | + } |
|
851 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
852 | + return $all[0]['total']; |
|
853 | + } |
|
854 | 854 | |
855 | 855 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
856 | 856 | global $globalDBdriver; |
857 | 857 | if ($filter_name == '') $filter_name = $this->filter_name; |
858 | 858 | if ($globalDBdriver == 'mysql') { |
859 | 859 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
860 | - } else { |
|
860 | + } else { |
|
861 | 861 | $query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
862 | 862 | } |
863 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | - try { |
|
865 | - $sth = $this->db->prepare($query); |
|
866 | - $sth->execute($query_values); |
|
867 | - } catch(PDOException $e) { |
|
868 | - return "error : ".$e->getMessage(); |
|
869 | - } |
|
870 | - } |
|
863 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
864 | + try { |
|
865 | + $sth = $this->db->prepare($query); |
|
866 | + $sth->execute($query_values); |
|
867 | + } catch(PDOException $e) { |
|
868 | + return "error : ".$e->getMessage(); |
|
869 | + } |
|
870 | + } |
|
871 | 871 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
872 | 872 | global $globalDBdriver; |
873 | 873 | if ($filter_name == '') $filter_name = $this->filter_name; |
874 | 874 | if ($globalDBdriver == 'mysql') { |
875 | 875 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
876 | 876 | } else { |
877 | - //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
877 | + //$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
|
878 | 878 | $query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
879 | - } |
|
880 | - $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | - try { |
|
882 | - $sth = $this->db->prepare($query); |
|
883 | - $sth->execute($query_values); |
|
884 | - } catch(PDOException $e) { |
|
885 | - return "error : ".$e->getMessage(); |
|
886 | - } |
|
887 | - } |
|
879 | + } |
|
880 | + $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
881 | + try { |
|
882 | + $sth = $this->db->prepare($query); |
|
883 | + $sth->execute($query_values); |
|
884 | + } catch(PDOException $e) { |
|
885 | + return "error : ".$e->getMessage(); |
|
886 | + } |
|
887 | + } |
|
888 | 888 | public function getStatsSource($date,$stats_type = '') { |
889 | 889 | if ($stats_type == '') { |
890 | 890 | $query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name"; |
@@ -893,15 +893,15 @@ discard block |
||
893 | 893 | $query = "SELECT * FROM stats_source WHERE stats_date = :date AND stats_type = :stats_type ORDER BY source_name"; |
894 | 894 | $query_values = array(':date' => $date,':stats_type' => $stats_type); |
895 | 895 | } |
896 | - try { |
|
897 | - $sth = $this->db->prepare($query); |
|
898 | - $sth->execute($query_values); |
|
899 | - } catch(PDOException $e) { |
|
900 | - echo "error : ".$e->getMessage(); |
|
901 | - } |
|
902 | - $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | - return $all; |
|
904 | - } |
|
896 | + try { |
|
897 | + $sth = $this->db->prepare($query); |
|
898 | + $sth->execute($query_values); |
|
899 | + } catch(PDOException $e) { |
|
900 | + echo "error : ".$e->getMessage(); |
|
901 | + } |
|
902 | + $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
903 | + return $all; |
|
904 | + } |
|
905 | 905 | |
906 | 906 | public function addStatSource($data,$source_name,$stats_type,$date) { |
907 | 907 | global $globalDBdriver; |
@@ -909,25 +909,25 @@ discard block |
||
909 | 909 | $query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data"; |
910 | 910 | } else { |
911 | 911 | $query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; |
912 | - } |
|
913 | - $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | - try { |
|
915 | - $sth = $this->db->prepare($query); |
|
916 | - $sth->execute($query_values); |
|
917 | - } catch(PDOException $e) { |
|
918 | - return "error : ".$e->getMessage(); |
|
919 | - } |
|
920 | - } |
|
912 | + } |
|
913 | + $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type); |
|
914 | + try { |
|
915 | + $sth = $this->db->prepare($query); |
|
916 | + $sth->execute($query_values); |
|
917 | + } catch(PDOException $e) { |
|
918 | + return "error : ".$e->getMessage(); |
|
919 | + } |
|
920 | + } |
|
921 | 921 | public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') { |
922 | - $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | - $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | - try { |
|
925 | - $sth = $this->db->prepare($query); |
|
926 | - $sth->execute($query_values); |
|
927 | - } catch(PDOException $e) { |
|
928 | - return "error : ".$e->getMessage(); |
|
929 | - } |
|
930 | - } |
|
922 | + $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)"; |
|
923 | + $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
924 | + try { |
|
925 | + $sth = $this->db->prepare($query); |
|
926 | + $sth->execute($query_values); |
|
927 | + } catch(PDOException $e) { |
|
928 | + return "error : ".$e->getMessage(); |
|
929 | + } |
|
930 | + } |
|
931 | 931 | public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '') { |
932 | 932 | global $globalDBdriver; |
933 | 933 | if ($globalDBdriver == 'mysql') { |
@@ -935,14 +935,14 @@ discard block |
||
935 | 935 | } else { |
936 | 936 | $query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
937 | 937 | } |
938 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | - try { |
|
940 | - $sth = $this->db->prepare($query); |
|
941 | - $sth->execute($query_values); |
|
942 | - } catch(PDOException $e) { |
|
943 | - return "error : ".$e->getMessage(); |
|
944 | - } |
|
945 | - } |
|
938 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
939 | + try { |
|
940 | + $sth = $this->db->prepare($query); |
|
941 | + $sth->execute($query_values); |
|
942 | + } catch(PDOException $e) { |
|
943 | + return "error : ".$e->getMessage(); |
|
944 | + } |
|
945 | + } |
|
946 | 946 | public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '') { |
947 | 947 | global $globalDBdriver; |
948 | 948 | if ($globalDBdriver == 'mysql') { |
@@ -950,14 +950,14 @@ discard block |
||
950 | 950 | } else { |
951 | 951 | $query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; |
952 | 952 | } |
953 | - $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | - try { |
|
955 | - $sth = $this->db->prepare($query); |
|
956 | - $sth->execute($query_values); |
|
957 | - } catch(PDOException $e) { |
|
958 | - return "error : ".$e->getMessage(); |
|
959 | - } |
|
960 | - } |
|
953 | + $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name); |
|
954 | + try { |
|
955 | + $sth = $this->db->prepare($query); |
|
956 | + $sth->execute($query_values); |
|
957 | + } catch(PDOException $e) { |
|
958 | + return "error : ".$e->getMessage(); |
|
959 | + } |
|
960 | + } |
|
961 | 961 | public function addStatCountry($iso2,$iso3,$name,$cnt,$filter_name = '') { |
962 | 962 | global $globalDBdriver; |
963 | 963 | if ($globalDBdriver == 'mysql') { |
@@ -965,14 +965,14 @@ discard block |
||
965 | 965 | } else { |
966 | 966 | $query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name; INSERT INTO stats_country (iso2,iso3,name,cnt,filter_name) SELECT :iso2,:iso3,:name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name);"; |
967 | 967 | } |
968 | - $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | - try { |
|
970 | - $sth = $this->db->prepare($query); |
|
971 | - $sth->execute($query_values); |
|
972 | - } catch(PDOException $e) { |
|
973 | - return "error : ".$e->getMessage(); |
|
974 | - } |
|
975 | - } |
|
968 | + $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
969 | + try { |
|
970 | + $sth = $this->db->prepare($query); |
|
971 | + $sth->execute($query_values); |
|
972 | + } catch(PDOException $e) { |
|
973 | + return "error : ".$e->getMessage(); |
|
974 | + } |
|
975 | + } |
|
976 | 976 | public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '') { |
977 | 977 | global $globalDBdriver; |
978 | 978 | if ($globalDBdriver == 'mysql') { |
@@ -980,14 +980,14 @@ discard block |
||
980 | 980 | } else { |
981 | 981 | $query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
982 | 982 | } |
983 | - $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
984 | - try { |
|
985 | - $sth = $this->db->prepare($query); |
|
986 | - $sth->execute($query_values); |
|
987 | - } catch(PDOException $e) { |
|
988 | - return "error : ".$e->getMessage(); |
|
989 | - } |
|
990 | - } |
|
983 | + $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name); |
|
984 | + try { |
|
985 | + $sth = $this->db->prepare($query); |
|
986 | + $sth->execute($query_values); |
|
987 | + } catch(PDOException $e) { |
|
988 | + return "error : ".$e->getMessage(); |
|
989 | + } |
|
990 | + } |
|
991 | 991 | public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '') { |
992 | 992 | global $globalDBdriver; |
993 | 993 | if ($globalDBdriver == 'mysql') { |
@@ -995,14 +995,14 @@ discard block |
||
995 | 995 | } else { |
996 | 996 | $query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; |
997 | 997 | } |
998 | - $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | - try { |
|
1000 | - $sth = $this->db->prepare($query); |
|
1001 | - $sth->execute($query_values); |
|
1002 | - } catch(PDOException $e) { |
|
1003 | - return "error : ".$e->getMessage(); |
|
1004 | - } |
|
1005 | - } |
|
998 | + $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name); |
|
999 | + try { |
|
1000 | + $sth = $this->db->prepare($query); |
|
1001 | + $sth->execute($query_values); |
|
1002 | + } catch(PDOException $e) { |
|
1003 | + return "error : ".$e->getMessage(); |
|
1004 | + } |
|
1005 | + } |
|
1006 | 1006 | public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '') { |
1007 | 1007 | global $globalDBdriver; |
1008 | 1008 | if ($globalDBdriver == 'mysql') { |
@@ -1010,14 +1010,14 @@ discard block |
||
1010 | 1010 | } else { |
1011 | 1011 | $query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1012 | 1012 | } |
1013 | - $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | - try { |
|
1015 | - $sth = $this->db->prepare($query); |
|
1016 | - $sth->execute($query_values); |
|
1017 | - } catch(PDOException $e) { |
|
1018 | - return "error : ".$e->getMessage(); |
|
1019 | - } |
|
1020 | - } |
|
1013 | + $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1014 | + try { |
|
1015 | + $sth = $this->db->prepare($query); |
|
1016 | + $sth->execute($query_values); |
|
1017 | + } catch(PDOException $e) { |
|
1018 | + return "error : ".$e->getMessage(); |
|
1019 | + } |
|
1020 | + } |
|
1021 | 1021 | public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '') { |
1022 | 1022 | global $globalDBdriver; |
1023 | 1023 | if ($globalDBdriver == 'mysql') { |
@@ -1025,14 +1025,14 @@ discard block |
||
1025 | 1025 | } else { |
1026 | 1026 | $query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1027 | 1027 | } |
1028 | - $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | - try { |
|
1030 | - $sth = $this->db->prepare($query); |
|
1031 | - $sth->execute($query_values); |
|
1032 | - } catch(PDOException $e) { |
|
1033 | - return "error : ".$e->getMessage(); |
|
1034 | - } |
|
1035 | - } |
|
1028 | + $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
|
1029 | + try { |
|
1030 | + $sth = $this->db->prepare($query); |
|
1031 | + $sth->execute($query_values); |
|
1032 | + } catch(PDOException $e) { |
|
1033 | + return "error : ".$e->getMessage(); |
|
1034 | + } |
|
1035 | + } |
|
1036 | 1036 | public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1037 | 1037 | global $globalDBdriver; |
1038 | 1038 | if ($globalDBdriver == 'mysql') { |
@@ -1040,14 +1040,14 @@ discard block |
||
1040 | 1040 | } else { |
1041 | 1041 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1042 | 1042 | } |
1043 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1044 | - try { |
|
1045 | - $sth = $this->db->prepare($query); |
|
1046 | - $sth->execute($query_values); |
|
1047 | - } catch(PDOException $e) { |
|
1048 | - return "error : ".$e->getMessage(); |
|
1049 | - } |
|
1050 | - } |
|
1043 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => date('Y').'-01-01 00:00:00', ':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1044 | + try { |
|
1045 | + $sth = $this->db->prepare($query); |
|
1046 | + $sth->execute($query_values); |
|
1047 | + } catch(PDOException $e) { |
|
1048 | + return "error : ".$e->getMessage(); |
|
1049 | + } |
|
1050 | + } |
|
1051 | 1051 | public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') { |
1052 | 1052 | global $globalDBdriver; |
1053 | 1053 | if ($globalDBdriver == 'mysql') { |
@@ -1055,14 +1055,14 @@ discard block |
||
1055 | 1055 | } else { |
1056 | 1056 | $query = "UPDATE stats_airport SET departure = departure+:departure WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,departure,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:departure,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1057 | 1057 | } |
1058 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1059 | - try { |
|
1060 | - $sth = $this->db->prepare($query); |
|
1061 | - $sth->execute($query_values); |
|
1062 | - } catch(PDOException $e) { |
|
1063 | - return "error : ".$e->getMessage(); |
|
1064 | - } |
|
1065 | - } |
|
1058 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':departure' => $departure,':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1059 | + try { |
|
1060 | + $sth = $this->db->prepare($query); |
|
1061 | + $sth->execute($query_values); |
|
1062 | + } catch(PDOException $e) { |
|
1063 | + return "error : ".$e->getMessage(); |
|
1064 | + } |
|
1065 | + } |
|
1066 | 1066 | public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1067 | 1067 | global $globalDBdriver; |
1068 | 1068 | if ($globalDBdriver == 'mysql') { |
@@ -1070,14 +1070,14 @@ discard block |
||
1070 | 1070 | } else { |
1071 | 1071 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; |
1072 | 1072 | } |
1073 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1074 | - try { |
|
1075 | - $sth = $this->db->prepare($query); |
|
1076 | - $sth->execute($query_values); |
|
1077 | - } catch(PDOException $e) { |
|
1078 | - return "error : ".$e->getMessage(); |
|
1079 | - } |
|
1080 | - } |
|
1073 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1074 | + try { |
|
1075 | + $sth = $this->db->prepare($query); |
|
1076 | + $sth->execute($query_values); |
|
1077 | + } catch(PDOException $e) { |
|
1078 | + return "error : ".$e->getMessage(); |
|
1079 | + } |
|
1080 | + } |
|
1081 | 1081 | public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') { |
1082 | 1082 | global $globalDBdriver; |
1083 | 1083 | if ($globalDBdriver == 'mysql') { |
@@ -1085,52 +1085,52 @@ discard block |
||
1085 | 1085 | } else { |
1086 | 1086 | $query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'daily',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'daily' AND date = :date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; |
1087 | 1087 | } |
1088 | - $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1089 | - try { |
|
1090 | - $sth = $this->db->prepare($query); |
|
1091 | - $sth->execute($query_values); |
|
1092 | - } catch(PDOException $e) { |
|
1093 | - return "error : ".$e->getMessage(); |
|
1094 | - } |
|
1095 | - } |
|
1088 | + $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival, ':date' => $date,':stats_airline' => $airline_icao,':filter_name' => $filter_name); |
|
1089 | + try { |
|
1090 | + $sth = $this->db->prepare($query); |
|
1091 | + $sth->execute($query_values); |
|
1092 | + } catch(PDOException $e) { |
|
1093 | + return "error : ".$e->getMessage(); |
|
1094 | + } |
|
1095 | + } |
|
1096 | 1096 | |
1097 | 1097 | public function deleteStat($id) { |
1098 | - $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | - $query_values = array(':id' => $id); |
|
1100 | - try { |
|
1101 | - $sth = $this->db->prepare($query); |
|
1102 | - $sth->execute($query_values); |
|
1103 | - } catch(PDOException $e) { |
|
1104 | - return "error : ".$e->getMessage(); |
|
1105 | - } |
|
1106 | - } |
|
1098 | + $query = "DELETE FROM stats WHERE stats_id = :id"; |
|
1099 | + $query_values = array(':id' => $id); |
|
1100 | + try { |
|
1101 | + $sth = $this->db->prepare($query); |
|
1102 | + $sth->execute($query_values); |
|
1103 | + } catch(PDOException $e) { |
|
1104 | + return "error : ".$e->getMessage(); |
|
1105 | + } |
|
1106 | + } |
|
1107 | 1107 | public function deleteStatFlight($type) { |
1108 | - $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | - $query_values = array(':type' => $type); |
|
1110 | - try { |
|
1111 | - $sth = $this->db->prepare($query); |
|
1112 | - $sth->execute($query_values); |
|
1113 | - } catch(PDOException $e) { |
|
1114 | - return "error : ".$e->getMessage(); |
|
1115 | - } |
|
1116 | - } |
|
1108 | + $query = "DELETE FROM stats_flight WHERE stats_type = :type"; |
|
1109 | + $query_values = array(':type' => $type); |
|
1110 | + try { |
|
1111 | + $sth = $this->db->prepare($query); |
|
1112 | + $sth->execute($query_values); |
|
1113 | + } catch(PDOException $e) { |
|
1114 | + return "error : ".$e->getMessage(); |
|
1115 | + } |
|
1116 | + } |
|
1117 | 1117 | public function deleteStatAirport($type) { |
1118 | - $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | - $query_values = array(':type' => $type); |
|
1120 | - try { |
|
1121 | - $sth = $this->db->prepare($query); |
|
1122 | - $sth->execute($query_values); |
|
1123 | - } catch(PDOException $e) { |
|
1124 | - return "error : ".$e->getMessage(); |
|
1125 | - } |
|
1126 | - } |
|
1118 | + $query = "DELETE FROM stats_airport WHERE stats_type = :type"; |
|
1119 | + $query_values = array(':type' => $type); |
|
1120 | + try { |
|
1121 | + $sth = $this->db->prepare($query); |
|
1122 | + $sth->execute($query_values); |
|
1123 | + } catch(PDOException $e) { |
|
1124 | + return "error : ".$e->getMessage(); |
|
1125 | + } |
|
1126 | + } |
|
1127 | 1127 | |
1128 | - public function addOldStats() { |
|
1129 | - global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | - $Common = new Common(); |
|
1131 | - $Connection = new Connection(); |
|
1132 | - date_default_timezone_set('UTC'); |
|
1133 | - $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1128 | + public function addOldStats() { |
|
1129 | + global $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters; |
|
1130 | + $Common = new Common(); |
|
1131 | + $Connection = new Connection(); |
|
1132 | + date_default_timezone_set('UTC'); |
|
1133 | + $last_update = $this->getLastStatsUpdate('last_update_stats'); |
|
1134 | 1134 | //print_r($last_update); |
1135 | 1135 | /* |
1136 | 1136 | $flightsbymonth = $this->getStats('flights_by_month'); |
@@ -1384,46 +1384,46 @@ discard block |
||
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
1387 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1388 | - $alldata = array(); |
|
1387 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
|
1388 | + $alldata = array(); |
|
1389 | 1389 | |
1390 | - foreach ($pall as $value) { |
|
1391 | - $icao = $value['airport_departure_icao']; |
|
1392 | - $alldata[$icao] = $value; |
|
1393 | - } |
|
1394 | - foreach ($dall as $value) { |
|
1395 | - $icao = $value['airport_departure_icao']; |
|
1396 | - if (isset($alldata[$icao])) { |
|
1397 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1398 | - } else $alldata[$icao] = $value; |
|
1399 | - } |
|
1400 | - $count = array(); |
|
1401 | - foreach ($alldata as $key => $row) { |
|
1402 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1403 | - } |
|
1390 | + foreach ($pall as $value) { |
|
1391 | + $icao = $value['airport_departure_icao']; |
|
1392 | + $alldata[$icao] = $value; |
|
1393 | + } |
|
1394 | + foreach ($dall as $value) { |
|
1395 | + $icao = $value['airport_departure_icao']; |
|
1396 | + if (isset($alldata[$icao])) { |
|
1397 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1398 | + } else $alldata[$icao] = $value; |
|
1399 | + } |
|
1400 | + $count = array(); |
|
1401 | + foreach ($alldata as $key => $row) { |
|
1402 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1403 | + } |
|
1404 | 1404 | array_multisort($count,SORT_DESC,$alldata); |
1405 | 1405 | foreach ($alldata as $number) { |
1406 | 1406 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count']); |
1407 | 1407 | } |
1408 | 1408 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
1409 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1410 | - $alldata = array(); |
|
1411 | - foreach ($pall as $value) { |
|
1412 | - $icao = $value['airport_arrival_icao']; |
|
1413 | - $alldata[$icao] = $value; |
|
1414 | - } |
|
1415 | - foreach ($dall as $value) { |
|
1416 | - $icao = $value['airport_arrival_icao']; |
|
1417 | - if (isset($alldata[$icao])) { |
|
1418 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1419 | - } else $alldata[$icao] = $value; |
|
1420 | - } |
|
1421 | - $count = array(); |
|
1422 | - foreach ($alldata as $key => $row) { |
|
1423 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1424 | - } |
|
1425 | - array_multisort($count,SORT_DESC,$alldata); |
|
1426 | - foreach ($alldata as $number) { |
|
1409 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
|
1410 | + $alldata = array(); |
|
1411 | + foreach ($pall as $value) { |
|
1412 | + $icao = $value['airport_arrival_icao']; |
|
1413 | + $alldata[$icao] = $value; |
|
1414 | + } |
|
1415 | + foreach ($dall as $value) { |
|
1416 | + $icao = $value['airport_arrival_icao']; |
|
1417 | + if (isset($alldata[$icao])) { |
|
1418 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1419 | + } else $alldata[$icao] = $value; |
|
1420 | + } |
|
1421 | + $count = array(); |
|
1422 | + foreach ($alldata as $key => $row) { |
|
1423 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1424 | + } |
|
1425 | + array_multisort($count,SORT_DESC,$alldata); |
|
1426 | + foreach ($alldata as $number) { |
|
1427 | 1427 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count']); |
1428 | 1428 | } |
1429 | 1429 | if ($Connection->tableExists('countries')) { |
@@ -1475,8 +1475,8 @@ discard block |
||
1475 | 1475 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1476 | 1476 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
1477 | 1477 | $pall = $Spotter->getLast7DaysAirportsDeparture(); |
1478 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1479 | - /* |
|
1478 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
|
1479 | + /* |
|
1480 | 1480 | $alldata = array(); |
1481 | 1481 | foreach ($pall as $value) { |
1482 | 1482 | $icao = $value['departure_airport_icao']; |
@@ -1495,29 +1495,29 @@ discard block |
||
1495 | 1495 | } |
1496 | 1496 | array_multisort($count,SORT_DESC,$alldata); |
1497 | 1497 | */ |
1498 | - foreach ($dall as $value) { |
|
1499 | - $icao = $value['departure_airport_icao']; |
|
1500 | - $ddate = $value['date']; |
|
1501 | - $find = false; |
|
1502 | - foreach ($pall as $pvalue) { |
|
1503 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1504 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1505 | - $find = true; |
|
1506 | - break; |
|
1507 | - } |
|
1508 | - } |
|
1509 | - if ($find === false) { |
|
1510 | - $pall[] = $value; |
|
1511 | - } |
|
1512 | - } |
|
1513 | - $alldata = $pall; |
|
1498 | + foreach ($dall as $value) { |
|
1499 | + $icao = $value['departure_airport_icao']; |
|
1500 | + $ddate = $value['date']; |
|
1501 | + $find = false; |
|
1502 | + foreach ($pall as $pvalue) { |
|
1503 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1504 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1505 | + $find = true; |
|
1506 | + break; |
|
1507 | + } |
|
1508 | + } |
|
1509 | + if ($find === false) { |
|
1510 | + $pall[] = $value; |
|
1511 | + } |
|
1512 | + } |
|
1513 | + $alldata = $pall; |
|
1514 | 1514 | foreach ($alldata as $number) { |
1515 | 1515 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']); |
1516 | 1516 | } |
1517 | 1517 | echo '...Arrival'."\n"; |
1518 | 1518 | $pall = $Spotter->getLast7DaysAirportsArrival(); |
1519 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1520 | - /* |
|
1519 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival(); |
|
1520 | + /* |
|
1521 | 1521 | $alldata = array(); |
1522 | 1522 | foreach ($pall as $value) { |
1523 | 1523 | $icao = $value['arrival_airport_icao']; |
@@ -1537,22 +1537,22 @@ discard block |
||
1537 | 1537 | */ |
1538 | 1538 | |
1539 | 1539 | |
1540 | - foreach ($dall as $value) { |
|
1541 | - $icao = $value['arrival_airport_icao']; |
|
1542 | - $ddate = $value['date']; |
|
1543 | - $find = false; |
|
1544 | - foreach ($pall as $pvalue) { |
|
1545 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1546 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1547 | - $find = true; |
|
1548 | - break; |
|
1549 | - } |
|
1550 | - } |
|
1551 | - if ($find === false) { |
|
1552 | - $pall[] = $value; |
|
1553 | - } |
|
1554 | - } |
|
1555 | - $alldata = $pall; |
|
1540 | + foreach ($dall as $value) { |
|
1541 | + $icao = $value['arrival_airport_icao']; |
|
1542 | + $ddate = $value['date']; |
|
1543 | + $find = false; |
|
1544 | + foreach ($pall as $pvalue) { |
|
1545 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1546 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1547 | + $find = true; |
|
1548 | + break; |
|
1549 | + } |
|
1550 | + } |
|
1551 | + if ($find === false) { |
|
1552 | + $pall[] = $value; |
|
1553 | + } |
|
1554 | + } |
|
1555 | + $alldata = $pall; |
|
1556 | 1556 | foreach ($alldata as $number) { |
1557 | 1557 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']); |
1558 | 1558 | } |
@@ -1613,47 +1613,47 @@ discard block |
||
1613 | 1613 | } |
1614 | 1614 | |
1615 | 1615 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
1616 | - $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1617 | - //$alldata = array(); |
|
1618 | - foreach ($dall as $value) { |
|
1619 | - $icao = $value['airport_departure_icao']; |
|
1620 | - $dicao = $value['airline_icao']; |
|
1621 | - $find = false; |
|
1622 | - foreach ($pall as $pvalue) { |
|
1623 | - if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1624 | - $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1625 | - $find = true; |
|
1626 | - break; |
|
1627 | - } |
|
1628 | - } |
|
1629 | - if ($find === false) { |
|
1630 | - $pall[] = $value; |
|
1631 | - } |
|
1632 | - } |
|
1633 | - $alldata = $pall; |
|
1616 | + $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
|
1617 | + //$alldata = array(); |
|
1618 | + foreach ($dall as $value) { |
|
1619 | + $icao = $value['airport_departure_icao']; |
|
1620 | + $dicao = $value['airline_icao']; |
|
1621 | + $find = false; |
|
1622 | + foreach ($pall as $pvalue) { |
|
1623 | + if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1624 | + $pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1625 | + $find = true; |
|
1626 | + break; |
|
1627 | + } |
|
1628 | + } |
|
1629 | + if ($find === false) { |
|
1630 | + $pall[] = $value; |
|
1631 | + } |
|
1632 | + } |
|
1633 | + $alldata = $pall; |
|
1634 | 1634 | foreach ($alldata as $number) { |
1635 | 1635 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao']); |
1636 | 1636 | } |
1637 | 1637 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
1638 | - $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1639 | - //$alldata = array(); |
|
1640 | - foreach ($dall as $value) { |
|
1641 | - $icao = $value['airport_arrival_icao']; |
|
1642 | - $dicao = $value['airline_icao']; |
|
1643 | - $find = false; |
|
1644 | - foreach ($pall as $pvalue) { |
|
1645 | - if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1646 | - $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1647 | - $find = true; |
|
1648 | - break; |
|
1649 | - } |
|
1650 | - } |
|
1651 | - if ($find === false) { |
|
1652 | - $pall[] = $value; |
|
1653 | - } |
|
1654 | - } |
|
1655 | - $alldata = $pall; |
|
1656 | - foreach ($alldata as $number) { |
|
1638 | + $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
|
1639 | + //$alldata = array(); |
|
1640 | + foreach ($dall as $value) { |
|
1641 | + $icao = $value['airport_arrival_icao']; |
|
1642 | + $dicao = $value['airline_icao']; |
|
1643 | + $find = false; |
|
1644 | + foreach ($pall as $pvalue) { |
|
1645 | + if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) { |
|
1646 | + $pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1647 | + $find = true; |
|
1648 | + break; |
|
1649 | + } |
|
1650 | + } |
|
1651 | + if ($find === false) { |
|
1652 | + $pall[] = $value; |
|
1653 | + } |
|
1654 | + } |
|
1655 | + $alldata = $pall; |
|
1656 | + foreach ($alldata as $number) { |
|
1657 | 1657 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao']); |
1658 | 1658 | } |
1659 | 1659 | $Spotter = new Spotter($this->db); |
@@ -1681,47 +1681,47 @@ discard block |
||
1681 | 1681 | } |
1682 | 1682 | echo '...Departure'."\n"; |
1683 | 1683 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
1684 | - $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1685 | - foreach ($dall as $value) { |
|
1686 | - $icao = $value['departure_airport_icao']; |
|
1687 | - $airline = $value['airline_icao']; |
|
1688 | - $ddate = $value['date']; |
|
1689 | - $find = false; |
|
1690 | - foreach ($pall as $pvalue) { |
|
1691 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1692 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1693 | - $find = true; |
|
1694 | - break; |
|
1695 | - } |
|
1696 | - } |
|
1697 | - if ($find === false) { |
|
1698 | - $pall[] = $value; |
|
1699 | - } |
|
1700 | - } |
|
1701 | - $alldata = $pall; |
|
1684 | + $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
|
1685 | + foreach ($dall as $value) { |
|
1686 | + $icao = $value['departure_airport_icao']; |
|
1687 | + $airline = $value['airline_icao']; |
|
1688 | + $ddate = $value['date']; |
|
1689 | + $find = false; |
|
1690 | + foreach ($pall as $pvalue) { |
|
1691 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) { |
|
1692 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1693 | + $find = true; |
|
1694 | + break; |
|
1695 | + } |
|
1696 | + } |
|
1697 | + if ($find === false) { |
|
1698 | + $pall[] = $value; |
|
1699 | + } |
|
1700 | + } |
|
1701 | + $alldata = $pall; |
|
1702 | 1702 | foreach ($alldata as $number) { |
1703 | 1703 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
1704 | 1704 | } |
1705 | 1705 | echo '...Arrival'."\n"; |
1706 | 1706 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
1707 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1708 | - foreach ($dall as $value) { |
|
1709 | - $icao = $value['arrival_airport_icao']; |
|
1710 | - $airline = $value['airline_icao']; |
|
1711 | - $ddate = $value['date']; |
|
1712 | - $find = false; |
|
1713 | - foreach ($pall as $pvalue) { |
|
1714 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1715 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1716 | - $find = true; |
|
1717 | - break; |
|
1718 | - } |
|
1719 | - } |
|
1720 | - if ($find === false) { |
|
1721 | - $pall[] = $value; |
|
1722 | - } |
|
1723 | - } |
|
1724 | - $alldata = $pall; |
|
1707 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
|
1708 | + foreach ($dall as $value) { |
|
1709 | + $icao = $value['arrival_airport_icao']; |
|
1710 | + $airline = $value['airline_icao']; |
|
1711 | + $ddate = $value['date']; |
|
1712 | + $find = false; |
|
1713 | + foreach ($pall as $pvalue) { |
|
1714 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) { |
|
1715 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1716 | + $find = true; |
|
1717 | + break; |
|
1718 | + } |
|
1719 | + } |
|
1720 | + if ($find === false) { |
|
1721 | + $pall[] = $value; |
|
1722 | + } |
|
1723 | + } |
|
1724 | + $alldata = $pall; |
|
1725 | 1725 | foreach ($alldata as $number) { |
1726 | 1726 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
1727 | 1727 | } |
@@ -1785,44 +1785,44 @@ discard block |
||
1785 | 1785 | } |
1786 | 1786 | |
1787 | 1787 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter); |
1788 | - $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1789 | - $alldata = array(); |
|
1790 | - foreach ($pall as $value) { |
|
1791 | - $icao = $value['airport_departure_icao']; |
|
1792 | - $alldata[$icao] = $value; |
|
1793 | - } |
|
1794 | - foreach ($dall as $value) { |
|
1795 | - $icao = $value['airport_departure_icao']; |
|
1796 | - if (isset($alldata[$icao])) { |
|
1797 | - $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1798 | - } else $alldata[$icao] = $value; |
|
1799 | - } |
|
1800 | - $count = array(); |
|
1801 | - foreach ($alldata as $key => $row) { |
|
1802 | - $count[$key] = $row['airport_departure_icao_count']; |
|
1803 | - } |
|
1788 | + $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter); |
|
1789 | + $alldata = array(); |
|
1790 | + foreach ($pall as $value) { |
|
1791 | + $icao = $value['airport_departure_icao']; |
|
1792 | + $alldata[$icao] = $value; |
|
1793 | + } |
|
1794 | + foreach ($dall as $value) { |
|
1795 | + $icao = $value['airport_departure_icao']; |
|
1796 | + if (isset($alldata[$icao])) { |
|
1797 | + $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
|
1798 | + } else $alldata[$icao] = $value; |
|
1799 | + } |
|
1800 | + $count = array(); |
|
1801 | + foreach ($alldata as $key => $row) { |
|
1802 | + $count[$key] = $row['airport_departure_icao_count']; |
|
1803 | + } |
|
1804 | 1804 | array_multisort($count,SORT_DESC,$alldata); |
1805 | 1805 | foreach ($alldata as $number) { |
1806 | - echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1806 | + echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name); |
|
1807 | 1807 | } |
1808 | 1808 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,$filter); |
1809 | - $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1809 | + $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,$filter); |
|
1810 | 1810 | $alldata = array(); |
1811 | - foreach ($pall as $value) { |
|
1812 | - $icao = $value['airport_arrival_icao']; |
|
1813 | - $alldata[$icao] = $value; |
|
1814 | - } |
|
1815 | - foreach ($dall as $value) { |
|
1816 | - $icao = $value['airport_arrival_icao']; |
|
1817 | - if (isset($alldata[$icao])) { |
|
1818 | - $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1819 | - } else $alldata[$icao] = $value; |
|
1820 | - } |
|
1821 | - $count = array(); |
|
1822 | - foreach ($alldata as $key => $row) { |
|
1823 | - $count[$key] = $row['airport_arrival_icao_count']; |
|
1824 | - } |
|
1825 | - array_multisort($count,SORT_DESC,$alldata); |
|
1811 | + foreach ($pall as $value) { |
|
1812 | + $icao = $value['airport_arrival_icao']; |
|
1813 | + $alldata[$icao] = $value; |
|
1814 | + } |
|
1815 | + foreach ($dall as $value) { |
|
1816 | + $icao = $value['airport_arrival_icao']; |
|
1817 | + if (isset($alldata[$icao])) { |
|
1818 | + $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
|
1819 | + } else $alldata[$icao] = $value; |
|
1820 | + } |
|
1821 | + $count = array(); |
|
1822 | + foreach ($alldata as $key => $row) { |
|
1823 | + $count[$key] = $row['airport_arrival_icao_count']; |
|
1824 | + } |
|
1825 | + array_multisort($count,SORT_DESC,$alldata); |
|
1826 | 1826 | foreach ($alldata as $number) { |
1827 | 1827 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name); |
1828 | 1828 | } |
@@ -1851,45 +1851,45 @@ discard block |
||
1851 | 1851 | } |
1852 | 1852 | echo '...Departure'."\n"; |
1853 | 1853 | $pall = $Spotter->getLast7DaysAirportsDeparture('',$filter); |
1854 | - $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1854 | + $dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter); |
|
1855 | 1855 | foreach ($dall as $value) { |
1856 | - $icao = $value['departure_airport_icao']; |
|
1857 | - $ddate = $value['date']; |
|
1858 | - $find = false; |
|
1859 | - foreach ($pall as $pvalue) { |
|
1860 | - if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1861 | - $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1862 | - $find = true; |
|
1863 | - break; |
|
1864 | - } |
|
1865 | - } |
|
1866 | - if ($find === false) { |
|
1867 | - $pall[] = $value; |
|
1868 | - } |
|
1869 | - } |
|
1870 | - $alldata = $pall; |
|
1856 | + $icao = $value['departure_airport_icao']; |
|
1857 | + $ddate = $value['date']; |
|
1858 | + $find = false; |
|
1859 | + foreach ($pall as $pvalue) { |
|
1860 | + if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1861 | + $pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count']; |
|
1862 | + $find = true; |
|
1863 | + break; |
|
1864 | + } |
|
1865 | + } |
|
1866 | + if ($find === false) { |
|
1867 | + $pall[] = $value; |
|
1868 | + } |
|
1869 | + } |
|
1870 | + $alldata = $pall; |
|
1871 | 1871 | foreach ($alldata as $number) { |
1872 | 1872 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name); |
1873 | 1873 | } |
1874 | 1874 | echo '...Arrival'."\n"; |
1875 | 1875 | $pall = $Spotter->getLast7DaysAirportsArrival('',$filter); |
1876 | - $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1876 | + $dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter); |
|
1877 | 1877 | foreach ($dall as $value) { |
1878 | 1878 | $icao = $value['arrival_airport_icao']; |
1879 | 1879 | $ddate = $value['date']; |
1880 | - $find = false; |
|
1880 | + $find = false; |
|
1881 | 1881 | foreach ($pall as $pvalue) { |
1882 | - if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1883 | - $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1884 | - $find = true; |
|
1885 | - break; |
|
1886 | - } |
|
1887 | - } |
|
1888 | - if ($find === false) { |
|
1889 | - $pall[] = $value; |
|
1890 | - } |
|
1891 | - } |
|
1892 | - $alldata = $pall; |
|
1882 | + if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) { |
|
1883 | + $pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count']; |
|
1884 | + $find = true; |
|
1885 | + break; |
|
1886 | + } |
|
1887 | + } |
|
1888 | + if ($find === false) { |
|
1889 | + $pall[] = $value; |
|
1890 | + } |
|
1891 | + } |
|
1892 | + $alldata = $pall; |
|
1893 | 1893 | foreach ($alldata as $number) { |
1894 | 1894 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name); |
1895 | 1895 | } |