@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | |
113 | - /** |
|
114 | - * Gets all the spotter information based on a particular callsign |
|
115 | - * |
|
116 | - * @return Array the spotter information |
|
117 | - * |
|
118 | - */ |
|
119 | - public function getLastArchiveMarineDataByIdent($ident) |
|
120 | - { |
|
113 | + /** |
|
114 | + * Gets all the spotter information based on a particular callsign |
|
115 | + * |
|
116 | + * @return Array the spotter information |
|
117 | + * |
|
118 | + */ |
|
119 | + public function getLastArchiveMarineDataByIdent($ident) |
|
120 | + { |
|
121 | 121 | $Marine = new Marine($this->db); |
122 | - date_default_timezone_set('UTC'); |
|
122 | + date_default_timezone_set('UTC'); |
|
123 | 123 | |
124 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
124 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
125 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
129 | 129 | |
130 | - return $spotter_array; |
|
131 | - } |
|
130 | + return $spotter_array; |
|
131 | + } |
|
132 | 132 | |
133 | 133 | |
134 | - /** |
|
135 | - * Gets last the spotter information based on a particular id |
|
136 | - * |
|
137 | - * @return Array the spotter information |
|
138 | - * |
|
139 | - */ |
|
140 | - public function getLastArchiveMarineDataById($id) |
|
141 | - { |
|
142 | - $Marine = new Marine($this->db); |
|
143 | - date_default_timezone_set('UTC'); |
|
144 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | - //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | - //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
134 | + /** |
|
135 | + * Gets last the spotter information based on a particular id |
|
136 | + * |
|
137 | + * @return Array the spotter information |
|
138 | + * |
|
139 | + */ |
|
140 | + public function getLastArchiveMarineDataById($id) |
|
141 | + { |
|
142 | + $Marine = new Marine($this->db); |
|
143 | + date_default_timezone_set('UTC'); |
|
144 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
145 | + //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
|
146 | + //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | - /* |
|
150 | + /* |
|
151 | 151 | try { |
152 | 152 | $Connection = new Connection(); |
153 | 153 | $sth = Connection->$db->prepare($query); |
@@ -157,178 +157,178 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | - |
|
162 | - return $spotter_array; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Gets all the spotter information based on a particular id |
|
167 | - * |
|
168 | - * @return Array the spotter information |
|
169 | - * |
|
170 | - */ |
|
171 | - public function getAllArchiveMarineDataById($id) |
|
160 | + $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
161 | + |
|
162 | + return $spotter_array; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Gets all the spotter information based on a particular id |
|
167 | + * |
|
168 | + * @return Array the spotter information |
|
169 | + * |
|
170 | + */ |
|
171 | + public function getAllArchiveMarineDataById($id) |
|
172 | 172 | { |
173 | - date_default_timezone_set('UTC'); |
|
174 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
173 | + date_default_timezone_set('UTC'); |
|
174 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | - try { |
|
180 | - $sth = $this->db->prepare($query); |
|
181 | - $sth->execute(array(':id' => $id)); |
|
182 | - } catch(PDOException $e) { |
|
183 | - echo $e->getMessage(); |
|
184 | - die; |
|
185 | - } |
|
186 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | - |
|
188 | - return $spotter_array; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Gets coordinate & time spotter information based on a particular id |
|
193 | - * |
|
194 | - * @return Array the spotter information |
|
195 | - * |
|
196 | - */ |
|
197 | - public function getCoordArchiveMarineDataById($id) |
|
198 | - { |
|
199 | - date_default_timezone_set('UTC'); |
|
200 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
179 | + try { |
|
180 | + $sth = $this->db->prepare($query); |
|
181 | + $sth->execute(array(':id' => $id)); |
|
182 | + } catch(PDOException $e) { |
|
183 | + echo $e->getMessage(); |
|
184 | + die; |
|
185 | + } |
|
186 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
187 | + |
|
188 | + return $spotter_array; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Gets coordinate & time spotter information based on a particular id |
|
193 | + * |
|
194 | + * @return Array the spotter information |
|
195 | + * |
|
196 | + */ |
|
197 | + public function getCoordArchiveMarineDataById($id) |
|
198 | + { |
|
199 | + date_default_timezone_set('UTC'); |
|
200 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | - try { |
|
206 | - $sth = $this->db->prepare($query); |
|
207 | - $sth->execute(array(':id' => $id)); |
|
208 | - } catch(PDOException $e) { |
|
209 | - echo $e->getMessage(); |
|
210 | - die; |
|
211 | - } |
|
212 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
205 | + try { |
|
206 | + $sth = $this->db->prepare($query); |
|
207 | + $sth->execute(array(':id' => $id)); |
|
208 | + } catch(PDOException $e) { |
|
209 | + echo $e->getMessage(); |
|
210 | + die; |
|
211 | + } |
|
212 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
213 | 213 | |
214 | - return $spotter_array; |
|
215 | - } |
|
214 | + return $spotter_array; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * Gets altitude information based on a particular callsign |
|
220 | - * |
|
221 | - * @return Array the spotter information |
|
222 | - * |
|
223 | - */ |
|
224 | - public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | - { |
|
218 | + /** |
|
219 | + * Gets altitude information based on a particular callsign |
|
220 | + * |
|
221 | + * @return Array the spotter information |
|
222 | + * |
|
223 | + */ |
|
224 | + public function getAltitudeArchiveMarineDataByIdent($ident) |
|
225 | + { |
|
226 | 226 | |
227 | - date_default_timezone_set('UTC'); |
|
227 | + date_default_timezone_set('UTC'); |
|
228 | 228 | |
229 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
229 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | - try { |
|
233 | - $sth = $this->db->prepare($query); |
|
234 | - $sth->execute(array(':ident' => $ident)); |
|
235 | - } catch(PDOException $e) { |
|
236 | - echo $e->getMessage(); |
|
237 | - die; |
|
238 | - } |
|
239 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
232 | + try { |
|
233 | + $sth = $this->db->prepare($query); |
|
234 | + $sth->execute(array(':ident' => $ident)); |
|
235 | + } catch(PDOException $e) { |
|
236 | + echo $e->getMessage(); |
|
237 | + die; |
|
238 | + } |
|
239 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
240 | 240 | |
241 | - return $spotter_array; |
|
242 | - } |
|
241 | + return $spotter_array; |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Gets altitude information based on a particular id |
|
246 | - * |
|
247 | - * @return Array the spotter information |
|
248 | - * |
|
249 | - */ |
|
250 | - public function getAltitudeArchiveMarineDataById($id) |
|
251 | - { |
|
244 | + /** |
|
245 | + * Gets altitude information based on a particular id |
|
246 | + * |
|
247 | + * @return Array the spotter information |
|
248 | + * |
|
249 | + */ |
|
250 | + public function getAltitudeArchiveMarineDataById($id) |
|
251 | + { |
|
252 | 252 | |
253 | - date_default_timezone_set('UTC'); |
|
253 | + date_default_timezone_set('UTC'); |
|
254 | 254 | |
255 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
255 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | - try { |
|
259 | - $sth = $this->db->prepare($query); |
|
260 | - $sth->execute(array(':id' => $id)); |
|
261 | - } catch(PDOException $e) { |
|
262 | - echo $e->getMessage(); |
|
263 | - die; |
|
264 | - } |
|
265 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + try { |
|
259 | + $sth = $this->db->prepare($query); |
|
260 | + $sth->execute(array(':id' => $id)); |
|
261 | + } catch(PDOException $e) { |
|
262 | + echo $e->getMessage(); |
|
263 | + die; |
|
264 | + } |
|
265 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
266 | 266 | |
267 | - return $spotter_array; |
|
268 | - } |
|
267 | + return $spotter_array; |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Gets altitude & speed information based on a particular id |
|
272 | - * |
|
273 | - * @return Array the spotter information |
|
274 | - * |
|
275 | - */ |
|
276 | - public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | - { |
|
270 | + /** |
|
271 | + * Gets altitude & speed information based on a particular id |
|
272 | + * |
|
273 | + * @return Array the spotter information |
|
274 | + * |
|
275 | + */ |
|
276 | + public function getAltitudeSpeedArchiveMarineDataById($id) |
|
277 | + { |
|
278 | 278 | |
279 | - date_default_timezone_set('UTC'); |
|
279 | + date_default_timezone_set('UTC'); |
|
280 | 280 | |
281 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
281 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | - try { |
|
285 | - $sth = $this->db->prepare($query); |
|
286 | - $sth->execute(array(':id' => $id)); |
|
287 | - } catch(PDOException $e) { |
|
288 | - echo $e->getMessage(); |
|
289 | - die; |
|
290 | - } |
|
291 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
284 | + try { |
|
285 | + $sth = $this->db->prepare($query); |
|
286 | + $sth->execute(array(':id' => $id)); |
|
287 | + } catch(PDOException $e) { |
|
288 | + echo $e->getMessage(); |
|
289 | + die; |
|
290 | + } |
|
291 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
292 | 292 | |
293 | - return $spotter_array; |
|
294 | - } |
|
293 | + return $spotter_array; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | - /** |
|
298 | - * Gets altitude information based on a particular callsign |
|
299 | - * |
|
300 | - * @return Array the spotter information |
|
301 | - * |
|
302 | - */ |
|
303 | - public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | - { |
|
297 | + /** |
|
298 | + * Gets altitude information based on a particular callsign |
|
299 | + * |
|
300 | + * @return Array the spotter information |
|
301 | + * |
|
302 | + */ |
|
303 | + public function getLastAltitudeArchiveMarineDataByIdent($ident) |
|
304 | + { |
|
305 | 305 | |
306 | - date_default_timezone_set('UTC'); |
|
306 | + date_default_timezone_set('UTC'); |
|
307 | 307 | |
308 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
308 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | - try { |
|
313 | - $sth = $this->db->prepare($query); |
|
314 | - $sth->execute(array(':ident' => $ident)); |
|
315 | - } catch(PDOException $e) { |
|
316 | - echo $e->getMessage(); |
|
317 | - die; |
|
318 | - } |
|
319 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
312 | + try { |
|
313 | + $sth = $this->db->prepare($query); |
|
314 | + $sth->execute(array(':ident' => $ident)); |
|
315 | + } catch(PDOException $e) { |
|
316 | + echo $e->getMessage(); |
|
317 | + die; |
|
318 | + } |
|
319 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
320 | 320 | |
321 | - return $spotter_array; |
|
322 | - } |
|
321 | + return $spotter_array; |
|
322 | + } |
|
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | - /** |
|
327 | - * Gets all the archive spotter information |
|
328 | - * |
|
329 | - * @return Array the spotter information |
|
330 | - * |
|
331 | - */ |
|
326 | + /** |
|
327 | + * Gets all the archive spotter information |
|
328 | + * |
|
329 | + * @return Array the spotter information |
|
330 | + * |
|
331 | + */ |
|
332 | 332 | public function getMarineArchiveData($ident,$fammarine_id,$date) |
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
341 | - /** |
|
342 | - * Delete all tracking data |
|
343 | - * |
|
344 | - */ |
|
341 | + /** |
|
342 | + * Delete all tracking data |
|
343 | + * |
|
344 | + */ |
|
345 | 345 | public function deleteMarineArchiveTrackData() |
346 | 346 | { |
347 | 347 | global $globalArchiveKeepTrackMonths, $globalDBdriver; |
@@ -360,34 +360,34 @@ discard block |
||
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
363 | - * Gets Minimal Live Marine data |
|
364 | - * |
|
365 | - * @return Array the spotter information |
|
366 | - * |
|
367 | - */ |
|
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | - { |
|
370 | - global $globalDBdriver, $globalLiveInterval; |
|
371 | - date_default_timezone_set('UTC'); |
|
372 | - |
|
373 | - $filter_query = ''; |
|
374 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | - } |
|
377 | - // Use spotter_output also ? |
|
378 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | - } |
|
381 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | - } |
|
384 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | - } |
|
363 | + * Gets Minimal Live Marine data |
|
364 | + * |
|
365 | + * @return Array the spotter information |
|
366 | + * |
|
367 | + */ |
|
368 | + public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
369 | + { |
|
370 | + global $globalDBdriver, $globalLiveInterval; |
|
371 | + date_default_timezone_set('UTC'); |
|
387 | 372 | |
388 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | - if ($globalDBdriver == 'mysql') { |
|
390 | - /* |
|
373 | + $filter_query = ''; |
|
374 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
376 | + } |
|
377 | + // Use spotter_output also ? |
|
378 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | + } |
|
381 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
382 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
383 | + } |
|
384 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
386 | + } |
|
387 | + |
|
388 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
389 | + if ($globalDBdriver == 'mysql') { |
|
390 | + /* |
|
391 | 391 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
392 | 392 | FROM marine_archive |
393 | 393 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -406,56 +406,56 @@ discard block |
||
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | - } else { |
|
410 | - //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
409 | + } else { |
|
410 | + //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
415 | 415 | '.$filter_query.' ORDER BY fammarine_id'; |
416 | - } |
|
417 | - //echo $query; |
|
418 | - try { |
|
419 | - $sth = $this->db->prepare($query); |
|
420 | - $sth->execute(); |
|
421 | - } catch(PDOException $e) { |
|
422 | - echo $e->getMessage(); |
|
423 | - die; |
|
424 | - } |
|
425 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
416 | + } |
|
417 | + //echo $query; |
|
418 | + try { |
|
419 | + $sth = $this->db->prepare($query); |
|
420 | + $sth->execute(); |
|
421 | + } catch(PDOException $e) { |
|
422 | + echo $e->getMessage(); |
|
423 | + die; |
|
424 | + } |
|
425 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
426 | 426 | |
427 | - return $spotter_array; |
|
428 | - } |
|
427 | + return $spotter_array; |
|
428 | + } |
|
429 | 429 | |
430 | 430 | /** |
431 | - * Gets Minimal Live Marine data |
|
432 | - * |
|
433 | - * @return Array the spotter information |
|
434 | - * |
|
435 | - */ |
|
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | - { |
|
438 | - global $globalDBdriver, $globalLiveInterval; |
|
439 | - date_default_timezone_set('UTC'); |
|
440 | - |
|
441 | - $filter_query = ''; |
|
442 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | - } |
|
445 | - // Should use spotter_output also ? |
|
446 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | - } |
|
449 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | - } |
|
452 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | - } |
|
431 | + * Gets Minimal Live Marine data |
|
432 | + * |
|
433 | + * @return Array the spotter information |
|
434 | + * |
|
435 | + */ |
|
436 | + public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
437 | + { |
|
438 | + global $globalDBdriver, $globalLiveInterval; |
|
439 | + date_default_timezone_set('UTC'); |
|
455 | 440 | |
456 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | - if ($globalDBdriver == 'mysql') { |
|
458 | - /* |
|
441 | + $filter_query = ''; |
|
442 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
444 | + } |
|
445 | + // Should use spotter_output also ? |
|
446 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | + } |
|
449 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
450 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
451 | + } |
|
452 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
454 | + } |
|
455 | + |
|
456 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
457 | + if ($globalDBdriver == 'mysql') { |
|
458 | + /* |
|
459 | 459 | $query = 'SELECT a.aircraft_shadow, marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk |
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
@@ -466,95 +466,95 @@ discard block |
||
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
467 | 467 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
468 | 468 | |
469 | - } else { |
|
470 | - //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | - /* |
|
469 | + } else { |
|
470 | + //$query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow FROM marine_archive_output INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive_output.fammarine_id = s.fammarine_id AND marine_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao'; |
|
471 | + /* |
|
472 | 472 | $query = 'SELECT marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
473 | 473 | FROM marine_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
482 | 482 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
483 | 483 | // .' GROUP BY spotter_output.fammarine_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'; |
484 | 484 | |
485 | - } |
|
486 | - //echo $query; |
|
487 | - try { |
|
488 | - $sth = $this->db->prepare($query); |
|
489 | - $sth->execute(); |
|
490 | - } catch(PDOException $e) { |
|
491 | - echo $e->getMessage(); |
|
492 | - die; |
|
493 | - } |
|
494 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
485 | + } |
|
486 | + //echo $query; |
|
487 | + try { |
|
488 | + $sth = $this->db->prepare($query); |
|
489 | + $sth->execute(); |
|
490 | + } catch(PDOException $e) { |
|
491 | + echo $e->getMessage(); |
|
492 | + die; |
|
493 | + } |
|
494 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
495 | 495 | |
496 | - return $spotter_array; |
|
497 | - } |
|
496 | + return $spotter_array; |
|
497 | + } |
|
498 | 498 | |
499 | 499 | /** |
500 | - * Gets count Live Marine data |
|
501 | - * |
|
502 | - * @return Array the spotter information |
|
503 | - * |
|
504 | - */ |
|
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | - { |
|
507 | - global $globalDBdriver, $globalLiveInterval; |
|
508 | - date_default_timezone_set('UTC'); |
|
509 | - |
|
510 | - $filter_query = ''; |
|
511 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | - } |
|
514 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | - } |
|
517 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | - } |
|
520 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | - } |
|
500 | + * Gets count Live Marine data |
|
501 | + * |
|
502 | + * @return Array the spotter information |
|
503 | + * |
|
504 | + */ |
|
505 | + public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
506 | + { |
|
507 | + global $globalDBdriver, $globalLiveInterval; |
|
508 | + date_default_timezone_set('UTC'); |
|
523 | 509 | |
524 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | - if ($globalDBdriver == 'mysql') { |
|
510 | + $filter_query = ''; |
|
511 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
513 | + } |
|
514 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | + } |
|
517 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
518 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
|
519 | + } |
|
520 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
522 | + } |
|
523 | + |
|
524 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
525 | + if ($globalDBdriver == 'mysql') { |
|
526 | 526 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb |
527 | 527 | FROM marine_archive l |
528 | 528 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
529 | - } else { |
|
529 | + } else { |
|
530 | 530 | $query = 'SELECT COUNT(DISTINCT fammarine_id) as nb FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
531 | - } |
|
532 | - //echo $query; |
|
533 | - try { |
|
534 | - $sth = $this->db->prepare($query); |
|
535 | - $sth->execute(); |
|
536 | - } catch(PDOException $e) { |
|
537 | - echo $e->getMessage(); |
|
538 | - die; |
|
539 | - } |
|
531 | + } |
|
532 | + //echo $query; |
|
533 | + try { |
|
534 | + $sth = $this->db->prepare($query); |
|
535 | + $sth->execute(); |
|
536 | + } catch(PDOException $e) { |
|
537 | + echo $e->getMessage(); |
|
538 | + die; |
|
539 | + } |
|
540 | 540 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
541 | 541 | $sth->closeCursor(); |
542 | - return $result['nb']; |
|
542 | + return $result['nb']; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | 546 | |
547 | 547 | |
548 | 548 | // marine_archive_output |
549 | 549 | |
550 | - /** |
|
551 | - * Gets all the spotter information |
|
552 | - * |
|
553 | - * @return Array the spotter information |
|
554 | - * |
|
555 | - */ |
|
556 | - public function searchMarineData($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()) |
|
557 | - { |
|
550 | + /** |
|
551 | + * Gets all the spotter information |
|
552 | + * |
|
553 | + * @return Array the spotter information |
|
554 | + * |
|
555 | + */ |
|
556 | + public function searchMarineData($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()) |
|
557 | + { |
|
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
560 | 560 | $Translation = new Translation($this->db); |
@@ -568,159 +568,159 @@ discard block |
||
568 | 568 | $filter_query = $this->getFilter($filters); |
569 | 569 | if ($q != "") |
570 | 570 | { |
571 | - if (!is_string($q)) |
|
572 | - { |
|
571 | + if (!is_string($q)) |
|
572 | + { |
|
573 | 573 | return false; |
574 | - } else { |
|
574 | + } else { |
|
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | 578 | foreach ($q_array as $q_item){ |
579 | - $additional_query .= " AND ("; |
|
580 | - $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | - $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | - $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | - $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | - $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | - $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | - $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | - $translate = $Translation->ident2icao($q_item); |
|
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | - $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | - $additional_query .= ")"; |
|
579 | + $additional_query .= " AND ("; |
|
580 | + $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(marine_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(marine_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(marine_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(marine_archive_output.airline_name like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(marine_archive_output.airline_country like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(marine_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(marine_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(marine_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(marine_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(marine_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(marine_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(marine_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
594 | + $additional_query .= "(marine_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
595 | + $additional_query .= "(marine_archive_output.registration like '%".$q_item."%') OR "; |
|
596 | + $additional_query .= "(marine_archive_output.owner_name like '%".$q_item."%') OR "; |
|
597 | + $additional_query .= "(marine_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
598 | + $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
599 | + $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
|
600 | + $translate = $Translation->ident2icao($q_item); |
|
601 | + if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
602 | + $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
|
603 | + $additional_query .= ")"; |
|
604 | + } |
|
604 | 605 | } |
605 | - } |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | - if (!is_string($registration)) |
|
612 | - { |
|
610 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
611 | + if (!is_string($registration)) |
|
612 | + { |
|
613 | 613 | return false; |
614 | - } else { |
|
614 | + } else { |
|
615 | 615 | $additional_query .= " AND (marine_archive_output.registration = '".$registration."')"; |
616 | - } |
|
616 | + } |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | - if (!is_string($aircraft_icao)) |
|
623 | - { |
|
621 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
622 | + if (!is_string($aircraft_icao)) |
|
623 | + { |
|
624 | 624 | return false; |
625 | - } else { |
|
625 | + } else { |
|
626 | 626 | $additional_query .= " AND (marine_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | - if (!is_string($aircraft_manufacturer)) |
|
634 | - { |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
633 | + if (!is_string($aircraft_manufacturer)) |
|
634 | + { |
|
635 | 635 | return false; |
636 | - } else { |
|
636 | + } else { |
|
637 | 637 | $additional_query .= " AND (marine_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
638 | - } |
|
638 | + } |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if ($highlights == "true") |
642 | 642 | { |
643 | - if (!is_string($highlights)) |
|
644 | - { |
|
643 | + if (!is_string($highlights)) |
|
644 | + { |
|
645 | 645 | return false; |
646 | - } else { |
|
646 | + } else { |
|
647 | 647 | $additional_query .= " AND (marine_archive_output.highlight <> '')"; |
648 | - } |
|
648 | + } |
|
649 | 649 | } |
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | - if (!is_string($airline_icao)) |
|
655 | - { |
|
653 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
654 | + if (!is_string($airline_icao)) |
|
655 | + { |
|
656 | 656 | return false; |
657 | - } else { |
|
657 | + } else { |
|
658 | 658 | $additional_query .= " AND (marine_archive_output.airline_icao = '".$airline_icao."')"; |
659 | - } |
|
659 | + } |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | - if (!is_string($airline_country)) |
|
666 | - { |
|
664 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
665 | + if (!is_string($airline_country)) |
|
666 | + { |
|
667 | 667 | return false; |
668 | - } else { |
|
668 | + } else { |
|
669 | 669 | $additional_query .= " AND (marine_archive_output.airline_country = '".$airline_country."')"; |
670 | - } |
|
670 | + } |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | - if (!is_string($airline_type)) |
|
677 | - { |
|
675 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
676 | + if (!is_string($airline_type)) |
|
677 | + { |
|
678 | 678 | return false; |
679 | - } else { |
|
679 | + } else { |
|
680 | 680 | if ($airline_type == "passenger") |
681 | 681 | { |
682 | - $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
682 | + $additional_query .= " AND (marine_archive_output.airline_type = 'passenger')"; |
|
683 | 683 | } |
684 | 684 | if ($airline_type == "cargo") |
685 | 685 | { |
686 | - $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
686 | + $additional_query .= " AND (marine_archive_output.airline_type = 'cargo')"; |
|
687 | 687 | } |
688 | 688 | if ($airline_type == "military") |
689 | 689 | { |
690 | - $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
690 | + $additional_query .= " AND (marine_archive_output.airline_type = 'military')"; |
|
691 | + } |
|
691 | 692 | } |
692 | - } |
|
693 | 693 | } |
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | - if (!is_string($airport)) |
|
699 | - { |
|
697 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
698 | + if (!is_string($airport)) |
|
699 | + { |
|
700 | 700 | return false; |
701 | - } else { |
|
701 | + } else { |
|
702 | 702 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = '".$airport."') OR (marine_archive_output.arrival_airport_icao = '".$airport."'))"; |
703 | - } |
|
703 | + } |
|
704 | 704 | } |
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | - if (!is_string($airport_country)) |
|
710 | - { |
|
708 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
709 | + if (!is_string($airport_country)) |
|
710 | + { |
|
711 | 711 | return false; |
712 | - } else { |
|
712 | + } else { |
|
713 | 713 | $additional_query .= " AND ((marine_archive_output.departure_airport_country = '".$airport_country."') OR (marine_archive_output.arrival_airport_country = '".$airport_country."'))"; |
714 | - } |
|
714 | + } |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | - if (!is_string($callsign)) |
|
721 | - { |
|
719 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
720 | + if (!is_string($callsign)) |
|
721 | + { |
|
722 | 722 | return false; |
723 | - } else { |
|
723 | + } else { |
|
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
@@ -728,99 +728,99 @@ discard block |
||
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
731 | - } |
|
731 | + } |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | - if (!is_string($owner)) |
|
738 | - { |
|
736 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
737 | + if (!is_string($owner)) |
|
738 | + { |
|
739 | 739 | return false; |
740 | - } else { |
|
740 | + } else { |
|
741 | 741 | $additional_query .= " AND (marine_archive_output.owner_name = '".$owner."')"; |
742 | - } |
|
742 | + } |
|
743 | 743 | } |
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | - if (!is_string($pilot_name)) |
|
749 | - { |
|
747 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
748 | + if (!is_string($pilot_name)) |
|
749 | + { |
|
750 | 750 | return false; |
751 | - } else { |
|
751 | + } else { |
|
752 | 752 | $additional_query .= " AND (marine_archive_output.pilot_name = '".$pilot_name."')"; |
753 | - } |
|
753 | + } |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | - if (!is_string($pilot_id)) |
|
760 | - { |
|
758 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
759 | + if (!is_string($pilot_id)) |
|
760 | + { |
|
761 | 761 | return false; |
762 | - } else { |
|
762 | + } else { |
|
763 | 763 | $additional_query .= " AND (marine_archive_output.pilot_id = '".$pilot_id."')"; |
764 | - } |
|
764 | + } |
|
765 | 765 | } |
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | - if (!is_string($departure_airport_route)) |
|
771 | - { |
|
769 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
770 | + if (!is_string($departure_airport_route)) |
|
771 | + { |
|
772 | 772 | return false; |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | $additional_query .= " AND (marine_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
775 | - } |
|
775 | + } |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | - if (!is_string($arrival_airport_route)) |
|
782 | - { |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
781 | + if (!is_string($arrival_airport_route)) |
|
782 | + { |
|
783 | 783 | return false; |
784 | - } else { |
|
784 | + } else { |
|
785 | 785 | $additional_query .= " AND (marine_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
786 | - } |
|
786 | + } |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | if ($altitude != "") |
790 | 790 | { |
791 | - $altitude_array = explode(",", $altitude); |
|
791 | + $altitude_array = explode(",", $altitude); |
|
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | - if ($altitude_array[1] != "") |
|
798 | - { |
|
797 | + if ($altitude_array[1] != "") |
|
798 | + { |
|
799 | 799 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
800 | 800 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
801 | 801 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
802 | - } else { |
|
802 | + } else { |
|
803 | 803 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
804 | 804 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
805 | - } |
|
805 | + } |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | if ($date_posted != "") |
809 | 809 | { |
810 | - $date_array = explode(",", $date_posted); |
|
810 | + $date_array = explode(",", $date_posted); |
|
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | - if ($globalTimezone != '') { |
|
815 | + if ($globalTimezone != '') { |
|
816 | 816 | date_default_timezone_set($globalTimezone); |
817 | 817 | $datetime = new DateTime(); |
818 | 818 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
819 | + } else $offset = '+00:00'; |
|
820 | 820 | |
821 | 821 | |
822 | - if ($date_array[1] != "") |
|
823 | - { |
|
822 | + if ($date_array[1] != "") |
|
823 | + { |
|
824 | 824 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
825 | 825 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
826 | 826 | if ($globalDBdriver == 'mysql') { |
@@ -828,28 +828,28 @@ discard block |
||
828 | 828 | } else { |
829 | 829 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
830 | 830 | } |
831 | - } else { |
|
831 | + } else { |
|
832 | 832 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
833 | - if ($globalDBdriver == 'mysql') { |
|
833 | + if ($globalDBdriver == 'mysql') { |
|
834 | 834 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(marine_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
835 | 835 | } else { |
836 | 836 | $additional_query .= " AND marine_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
837 | 837 | } |
838 | - } |
|
838 | + } |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | if ($limit != "") |
842 | 842 | { |
843 | - $limit_array = explode(",", $limit); |
|
843 | + $limit_array = explode(",", $limit); |
|
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | - { |
|
848 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
849 | + { |
|
850 | 850 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
851 | 851 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
852 | - } |
|
852 | + } |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | |
@@ -880,33 +880,33 @@ discard block |
||
880 | 880 | $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | - } |
|
883 | + } |
|
884 | 884 | |
885 | - public function deleteMarineArchiveData() |
|
886 | - { |
|
885 | + public function deleteMarineArchiveData() |
|
886 | + { |
|
887 | 887 | global $globalArchiveKeepMonths, $globalDBdriver; |
888 | - date_default_timezone_set('UTC'); |
|
889 | - if ($globalDBdriver == 'mysql') { |
|
888 | + date_default_timezone_set('UTC'); |
|
889 | + if ($globalDBdriver == 'mysql') { |
|
890 | 890 | $query = 'DELETE FROM marine_archive_output WHERE marine_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
891 | 891 | } else { |
892 | 892 | $query = "DELETE FROM marine_archive_output WHERE marine_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
893 | 893 | } |
894 | - try { |
|
895 | - $sth = $this->db->prepare($query); |
|
896 | - $sth->execute(); |
|
897 | - } catch(PDOException $e) { |
|
898 | - return "error"; |
|
899 | - } |
|
894 | + try { |
|
895 | + $sth = $this->db->prepare($query); |
|
896 | + $sth->execute(); |
|
897 | + } catch(PDOException $e) { |
|
898 | + return "error"; |
|
899 | + } |
|
900 | 900 | } |
901 | 901 | |
902 | - /** |
|
903 | - * Gets all the spotter information based on the callsign |
|
904 | - * |
|
905 | - * @return Array the spotter information |
|
906 | - * |
|
907 | - */ |
|
908 | - public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | - { |
|
902 | + /** |
|
903 | + * Gets all the spotter information based on the callsign |
|
904 | + * |
|
905 | + * @return Array the spotter information |
|
906 | + * |
|
907 | + */ |
|
908 | + public function getMarineDataByIdent($ident = '', $limit = '', $sort = '') |
|
909 | + { |
|
910 | 910 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
911 | 911 | |
912 | 912 | date_default_timezone_set('UTC'); |
@@ -918,35 +918,35 @@ discard block |
||
918 | 918 | |
919 | 919 | if ($ident != "") |
920 | 920 | { |
921 | - if (!is_string($ident)) |
|
922 | - { |
|
921 | + if (!is_string($ident)) |
|
922 | + { |
|
923 | 923 | return false; |
924 | - } else { |
|
924 | + } else { |
|
925 | 925 | $additional_query = " AND (marine_archive_output.ident = :ident)"; |
926 | 926 | $query_values = array(':ident' => $ident); |
927 | - } |
|
927 | + } |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | if ($limit != "") |
931 | 931 | { |
932 | - $limit_array = explode(",", $limit); |
|
932 | + $limit_array = explode(",", $limit); |
|
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | - { |
|
937 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
938 | + { |
|
939 | 939 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
940 | 940 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
941 | - } |
|
941 | + } |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | if ($sort != "") |
945 | 945 | { |
946 | - $search_orderby_array = $Marine->getOrderBy(); |
|
947 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
946 | + $search_orderby_array = $Marine->getOrderBy(); |
|
947 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
948 | 948 | } else { |
949 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
949 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | $query = $global_query." WHERE marine_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -954,17 +954,17 @@ discard block |
||
954 | 954 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
955 | 955 | |
956 | 956 | return $spotter_array; |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | |
960 | - /** |
|
961 | - * Gets all the spotter information based on the owner |
|
962 | - * |
|
963 | - * @return Array the spotter information |
|
964 | - * |
|
965 | - */ |
|
966 | - public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | - { |
|
960 | + /** |
|
961 | + * Gets all the spotter information based on the owner |
|
962 | + * |
|
963 | + * @return Array the spotter information |
|
964 | + * |
|
965 | + */ |
|
966 | + public function getMarineDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
967 | + { |
|
968 | 968 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
969 | 969 | |
970 | 970 | date_default_timezone_set('UTC'); |
@@ -977,35 +977,35 @@ discard block |
||
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
980 | - if (!is_string($owner)) |
|
981 | - { |
|
980 | + if (!is_string($owner)) |
|
981 | + { |
|
982 | 982 | return false; |
983 | - } else { |
|
983 | + } else { |
|
984 | 984 | $additional_query = " AND (marine_archive_output.owner_name = :owner)"; |
985 | 985 | $query_values = array(':owner' => $owner); |
986 | - } |
|
986 | + } |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | if ($limit != "") |
990 | 990 | { |
991 | - $limit_array = explode(",", $limit); |
|
991 | + $limit_array = explode(",", $limit); |
|
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | - { |
|
996 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
997 | + { |
|
998 | 998 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
999 | 999 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1000 | - } |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if ($sort != "") |
1004 | 1004 | { |
1005 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1005 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1006 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1007 | 1007 | } else { |
1008 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1008 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | $query = $global_query.$filter_query." marine_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1013,16 +1013,16 @@ discard block |
||
1013 | 1013 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1014 | 1014 | |
1015 | 1015 | return $spotter_array; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * Gets all the spotter information based on the pilot |
|
1020 | - * |
|
1021 | - * @return Array the spotter information |
|
1022 | - * |
|
1023 | - */ |
|
1024 | - public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | - { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * Gets all the spotter information based on the pilot |
|
1020 | + * |
|
1021 | + * @return Array the spotter information |
|
1022 | + * |
|
1023 | + */ |
|
1024 | + public function getMarineDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1025 | + { |
|
1026 | 1026 | $global_query = "SELECT marine_archive_output.* FROM marine_archive_output"; |
1027 | 1027 | |
1028 | 1028 | date_default_timezone_set('UTC'); |
@@ -1041,24 +1041,24 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | if ($limit != "") |
1043 | 1043 | { |
1044 | - $limit_array = explode(",", $limit); |
|
1044 | + $limit_array = explode(",", $limit); |
|
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | - { |
|
1049 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1050 | + { |
|
1051 | 1051 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1052 | 1052 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1053 | - } |
|
1053 | + } |
|
1054 | 1054 | } |
1055 | 1055 | |
1056 | 1056 | if ($sort != "") |
1057 | 1057 | { |
1058 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1058 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1059 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1060 | 1060 | } else { |
1061 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1061 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | $query = $global_query.$filter_query." marine_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1066,16 +1066,16 @@ discard block |
||
1066 | 1066 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1067 | 1067 | |
1068 | 1068 | return $spotter_array; |
1069 | - } |
|
1070 | - |
|
1071 | - /** |
|
1072 | - * Gets all number of flight over countries |
|
1073 | - * |
|
1074 | - * @return Array the airline country list |
|
1075 | - * |
|
1076 | - */ |
|
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | - { |
|
1069 | + } |
|
1070 | + |
|
1071 | + /** |
|
1072 | + * Gets all number of flight over countries |
|
1073 | + * |
|
1074 | + * @return Array the airline country list |
|
1075 | + * |
|
1076 | + */ |
|
1077 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1078 | + { |
|
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
1081 | 1081 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1085,14 +1085,14 @@ discard block |
||
1085 | 1085 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1086 | 1086 | FROM countries c, marine_archive s |
1087 | 1087 | WHERE c.iso2 = s.over_country "; |
1088 | - if ($olderthanmonths > 0) { |
|
1089 | - if ($globalDBdriver == 'mysql') { |
|
1088 | + if ($olderthanmonths > 0) { |
|
1089 | + if ($globalDBdriver == 'mysql') { |
|
1090 | 1090 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1091 | 1091 | } else { |
1092 | 1092 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1093 | } |
1094 | 1094 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1095 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1096 | 1096 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | 1097 | if ($limit) $query .= " LIMIT 0,10"; |
1098 | 1098 | |
@@ -1105,23 +1105,23 @@ discard block |
||
1105 | 1105 | |
1106 | 1106 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1107 | 1107 | { |
1108 | - $temp_array['flight_count'] = $row['nb']; |
|
1109 | - $temp_array['flight_country'] = $row['name']; |
|
1110 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | - $flight_array[] = $temp_array; |
|
1108 | + $temp_array['flight_count'] = $row['nb']; |
|
1109 | + $temp_array['flight_country'] = $row['name']; |
|
1110 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1111 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1112 | + $flight_array[] = $temp_array; |
|
1113 | 1113 | } |
1114 | 1114 | return $flight_array; |
1115 | - } |
|
1116 | - |
|
1117 | - /** |
|
1118 | - * Gets all number of flight over countries |
|
1119 | - * |
|
1120 | - * @return Array the airline country list |
|
1121 | - * |
|
1122 | - */ |
|
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | - { |
|
1115 | + } |
|
1116 | + |
|
1117 | + /** |
|
1118 | + * Gets all number of flight over countries |
|
1119 | + * |
|
1120 | + * @return Array the airline country list |
|
1121 | + * |
|
1122 | + */ |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1124 | + { |
|
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
1127 | 1127 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1131,14 +1131,14 @@ discard block |
||
1131 | 1131 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1132 | 1132 | FROM countries c, marine_archive s, spotter_output o |
1133 | 1133 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.fammarine_id = s.fammarine_id "; |
1134 | - if ($olderthanmonths > 0) { |
|
1135 | - if ($globalDBdriver == 'mysql') { |
|
1134 | + if ($olderthanmonths > 0) { |
|
1135 | + if ($globalDBdriver == 'mysql') { |
|
1136 | 1136 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1137 | 1137 | } else { |
1138 | 1138 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1139 | } |
1140 | 1140 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1141 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1142 | 1142 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | 1143 | if ($limit) $query .= " LIMIT 0,10"; |
1144 | 1144 | |
@@ -1151,24 +1151,24 @@ discard block |
||
1151 | 1151 | |
1152 | 1152 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1153 | 1153 | { |
1154 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | - $temp_array['flight_count'] = $row['nb']; |
|
1156 | - $temp_array['flight_country'] = $row['name']; |
|
1157 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | - $flight_array[] = $temp_array; |
|
1154 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1155 | + $temp_array['flight_count'] = $row['nb']; |
|
1156 | + $temp_array['flight_country'] = $row['name']; |
|
1157 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1158 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1159 | + $flight_array[] = $temp_array; |
|
1160 | 1160 | } |
1161 | 1161 | return $flight_array; |
1162 | - } |
|
1163 | - |
|
1164 | - /** |
|
1165 | - * Gets last spotter information based on a particular callsign |
|
1166 | - * |
|
1167 | - * @return Array the spotter information |
|
1168 | - * |
|
1169 | - */ |
|
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1171 | - { |
|
1162 | + } |
|
1163 | + |
|
1164 | + /** |
|
1165 | + * Gets last spotter information based on a particular callsign |
|
1166 | + * |
|
1167 | + * @return Array the spotter information |
|
1168 | + * |
|
1169 | + */ |
|
1170 | + public function getDateArchiveMarineDataById($id,$date) |
|
1171 | + { |
|
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1176,16 +1176,16 @@ discard block |
||
1176 | 1176 | $date = date('c',$date); |
1177 | 1177 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1178 | 1178 | return $spotter_array; |
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * Gets all the spotter information based on a particular callsign |
|
1183 | - * |
|
1184 | - * @return Array the spotter information |
|
1185 | - * |
|
1186 | - */ |
|
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | - { |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * Gets all the spotter information based on a particular callsign |
|
1183 | + * |
|
1184 | + * @return Array the spotter information |
|
1185 | + * |
|
1186 | + */ |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1188 | + { |
|
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1193,16 +1193,16 @@ discard block |
||
1193 | 1193 | $date = date('c',$date); |
1194 | 1194 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1195 | 1195 | return $spotter_array; |
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * Gets all the spotter information based on the airport |
|
1200 | - * |
|
1201 | - * @return Array the spotter information |
|
1202 | - * |
|
1203 | - */ |
|
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | - { |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * Gets all the spotter information based on the airport |
|
1200 | + * |
|
1201 | + * @return Array the spotter information |
|
1202 | + * |
|
1203 | + */ |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1205 | + { |
|
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
1208 | 1208 | date_default_timezone_set('UTC'); |
@@ -1213,35 +1213,35 @@ discard block |
||
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
1216 | - if (!is_string($airport)) |
|
1217 | - { |
|
1216 | + if (!is_string($airport)) |
|
1217 | + { |
|
1218 | 1218 | return false; |
1219 | - } else { |
|
1219 | + } else { |
|
1220 | 1220 | $additional_query .= " AND ((marine_archive_output.departure_airport_icao = :airport) OR (marine_archive_output.arrival_airport_icao = :airport))"; |
1221 | 1221 | $query_values = array(':airport' => $airport); |
1222 | - } |
|
1222 | + } |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | if ($limit != "") |
1226 | 1226 | { |
1227 | - $limit_array = explode(",", $limit); |
|
1227 | + $limit_array = explode(",", $limit); |
|
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | - { |
|
1232 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1233 | + { |
|
1234 | 1234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1235 | 1235 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1236 | - } |
|
1236 | + } |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | if ($sort != "") |
1240 | 1240 | { |
1241 | - $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1241 | + $search_orderby_array = $Marine->getOrderBy(); |
|
1242 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1243 | 1243 | } else { |
1244 | - $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1244 | + $orderby_query = " ORDER BY marine_archive_output.date DESC"; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | $query = $global_query.$filter_query." marine_archive_output.ident <> '' ".$additional_query." AND ((marine_archive_output.departure_airport_icao <> 'NA') AND (marine_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1249,6 +1249,6 @@ discard block |
||
1249 | 1249 | $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
1250 | 1250 | |
1251 | 1251 | return $spotter_array; |
1252 | - } |
|
1252 | + } |
|
1253 | 1253 | } |
1254 | 1254 | ?> |
1255 | 1255 | \ No newline at end of file |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_archive.fammarine_id"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,42 +68,42 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_archive.fammarine_id"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // marine_archive |
86 | - public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addMarineArchiveData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Marine.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Marine = new Marine($this->db); |
90 | - $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Marine->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | |
95 | 95 | //$country = $over_country; |
96 | 96 | // Route is not added in marine_archive |
97 | - $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
97 | + $query = 'INSERT INTO marine_archive (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
|
98 | 98 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
99 | 99 | |
100 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
100 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
101 | 101 | |
102 | 102 | try { |
103 | 103 | $sth = $this->db->prepare($query); |
104 | 104 | $sth->execute($query_values); |
105 | 105 | $sth->closeCursor(); |
106 | - } catch(PDOException $e) { |
|
106 | + } catch (PDOException $e) { |
|
107 | 107 | return "error : ".$e->getMessage(); |
108 | 108 | } |
109 | 109 | return "success"; |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | |
124 | 124 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
125 | 125 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
126 | - $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
126 | + $query = "SELECT marine_archive.* FROM marine_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
127 | 127 | |
128 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident)); |
|
128 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident)); |
|
129 | 129 | |
130 | 130 | return $spotter_array; |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
145 | 145 | //$query = MarineArchive->$global_query." WHERE marine_archive.fammarine_id = :id"; |
146 | 146 | //$query = "SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
147 | - $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
147 | + $query = "SELECT * FROM marine_archive WHERE fammarine_id = :id ORDER BY date DESC LIMIT 1"; |
|
148 | 148 | |
149 | 149 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
150 | 150 | /* |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | } |
158 | 158 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
159 | 159 | */ |
160 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id)); |
|
160 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id)); |
|
161 | 161 | |
162 | 162 | return $spotter_array; |
163 | 163 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | { |
173 | 173 | date_default_timezone_set('UTC'); |
174 | 174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
175 | - $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
175 | + $query = $this->global_query." WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
176 | 176 | |
177 | 177 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
178 | 178 | |
179 | 179 | try { |
180 | 180 | $sth = $this->db->prepare($query); |
181 | 181 | $sth->execute(array(':id' => $id)); |
182 | - } catch(PDOException $e) { |
|
182 | + } catch (PDOException $e) { |
|
183 | 183 | echo $e->getMessage(); |
184 | 184 | die; |
185 | 185 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | { |
199 | 199 | date_default_timezone_set('UTC'); |
200 | 200 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
201 | - $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
201 | + $query = "SELECT marine_archive.latitude, marine_archive.longitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id"; |
|
202 | 202 | |
203 | 203 | // $spotter_array = Marine->getDataFromDB($query,array(':id' => $id)); |
204 | 204 | |
205 | 205 | try { |
206 | 206 | $sth = $this->db->prepare($query); |
207 | 207 | $sth->execute(array(':id' => $id)); |
208 | - } catch(PDOException $e) { |
|
208 | + } catch (PDOException $e) { |
|
209 | 209 | echo $e->getMessage(); |
210 | 210 | die; |
211 | 211 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | date_default_timezone_set('UTC'); |
228 | 228 | |
229 | 229 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
230 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
230 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
231 | 231 | |
232 | 232 | try { |
233 | 233 | $sth = $this->db->prepare($query); |
234 | 234 | $sth->execute(array(':ident' => $ident)); |
235 | - } catch(PDOException $e) { |
|
235 | + } catch (PDOException $e) { |
|
236 | 236 | echo $e->getMessage(); |
237 | 237 | die; |
238 | 238 | } |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | date_default_timezone_set('UTC'); |
254 | 254 | |
255 | 255 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
256 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
256 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id AND marine_archive.latitude <> 0 AND marine_archive.longitude <> 0 ORDER BY date"; |
|
257 | 257 | |
258 | 258 | try { |
259 | 259 | $sth = $this->db->prepare($query); |
260 | 260 | $sth->execute(array(':id' => $id)); |
261 | - } catch(PDOException $e) { |
|
261 | + } catch (PDOException $e) { |
|
262 | 262 | echo $e->getMessage(); |
263 | 263 | die; |
264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
279 | 279 | date_default_timezone_set('UTC'); |
280 | 280 | |
281 | 281 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
282 | - $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
282 | + $query = "SELECT marine_archive.altitude, marine_archive.ground_speed, marine_archive.date FROM marine_archive WHERE marine_archive.fammarine_id = :id ORDER BY date"; |
|
283 | 283 | |
284 | 284 | try { |
285 | 285 | $sth = $this->db->prepare($query); |
286 | 286 | $sth->execute(array(':id' => $id)); |
287 | - } catch(PDOException $e) { |
|
287 | + } catch (PDOException $e) { |
|
288 | 288 | echo $e->getMessage(); |
289 | 289 | die; |
290 | 290 | } |
@@ -306,13 +306,13 @@ discard block |
||
306 | 306 | date_default_timezone_set('UTC'); |
307 | 307 | |
308 | 308 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
309 | - $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
309 | + $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate LIMIT 1"; |
|
310 | 310 | // $query = "SELECT marine_archive.altitude, marine_archive.date FROM marine_archive WHERE marine_archive.ident = :ident"; |
311 | 311 | |
312 | 312 | try { |
313 | 313 | $sth = $this->db->prepare($query); |
314 | 314 | $sth->execute(array(':ident' => $ident)); |
315 | - } catch(PDOException $e) { |
|
315 | + } catch (PDOException $e) { |
|
316 | 316 | echo $e->getMessage(); |
317 | 317 | die; |
318 | 318 | } |
@@ -329,12 +329,12 @@ discard block |
||
329 | 329 | * @return Array the spotter information |
330 | 330 | * |
331 | 331 | */ |
332 | - public function getMarineArchiveData($ident,$fammarine_id,$date) |
|
332 | + public function getMarineArchiveData($ident, $fammarine_id, $date) |
|
333 | 333 | { |
334 | 334 | $Marine = new Marine($this->db); |
335 | 335 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
336 | 336 | $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.fammarine_id = :fammarine_id AND l.date LIKE :date GROUP BY l.fammarine_id) s on spotter_live.fammarine_id = s.fammarine_id AND spotter_live.date = s.maxdate"; |
337 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':fammarine_id' => $fammarine_id,':date' => $date.'%')); |
|
337 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':fammarine_id' => $fammarine_id, ':date' => $date.'%')); |
|
338 | 338 | return $spotter_array; |
339 | 339 | } |
340 | 340 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | try { |
354 | 354 | $sth = $this->db->prepare($query); |
355 | 355 | $sth->execute(); |
356 | - } catch(PDOException $e) { |
|
356 | + } catch (PDOException $e) { |
|
357 | 357 | echo $e->getMessage(); |
358 | 358 | die; |
359 | 359 | } |
@@ -365,24 +365,24 @@ discard block |
||
365 | 365 | * @return Array the spotter information |
366 | 366 | * |
367 | 367 | */ |
368 | - public function getMinLiveMarineData($begindate,$enddate,$filter = array()) |
|
368 | + public function getMinLiveMarineData($begindate, $enddate, $filter = array()) |
|
369 | 369 | { |
370 | 370 | global $globalDBdriver, $globalLiveInterval; |
371 | 371 | date_default_timezone_set('UTC'); |
372 | 372 | |
373 | 373 | $filter_query = ''; |
374 | 374 | if (isset($filter['source']) && !empty($filter['source'])) { |
375 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
375 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
376 | 376 | } |
377 | 377 | // Use spotter_output also ? |
378 | 378 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
379 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
379 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
380 | 380 | } |
381 | 381 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
382 | 382 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
383 | 383 | } |
384 | 384 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
385 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
385 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id |
402 | 402 | AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
403 | 403 | */ |
404 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
404 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | 405 | FROM marine_archive |
406 | 406 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
407 | 407 | WHERE marine_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
408 | 408 | '.$filter_query.' ORDER BY fammarine_id'; |
409 | 409 | } else { |
410 | 410 | //$query = 'SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao'; |
411 | - $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
411 | + $query = 'SELECT marine_archive.date,marine_archive.fammarine_id, marine_archive.ident, marine_archive.aircraft_icao, marine_archive.departure_airport_icao as departure_airport, marine_archive.arrival_airport_icao as arrival_airport, marine_archive.latitude, marine_archive.longitude, marine_archive.altitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
412 | 412 | FROM marine_archive |
413 | 413 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive.aircraft_icao = a.icao |
414 | 414 | WHERE marine_archive.date >= '."'".$begindate."'".' AND marine_archive.date <= '."'".$enddate."'".' |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | try { |
419 | 419 | $sth = $this->db->prepare($query); |
420 | 420 | $sth->execute(); |
421 | - } catch(PDOException $e) { |
|
421 | + } catch (PDOException $e) { |
|
422 | 422 | echo $e->getMessage(); |
423 | 423 | die; |
424 | 424 | } |
@@ -433,24 +433,24 @@ discard block |
||
433 | 433 | * @return Array the spotter information |
434 | 434 | * |
435 | 435 | */ |
436 | - public function getMinLiveMarineDataPlayback($begindate,$enddate,$filter = array()) |
|
436 | + public function getMinLiveMarineDataPlayback($begindate, $enddate, $filter = array()) |
|
437 | 437 | { |
438 | 438 | global $globalDBdriver, $globalLiveInterval; |
439 | 439 | date_default_timezone_set('UTC'); |
440 | 440 | |
441 | 441 | $filter_query = ''; |
442 | 442 | if (isset($filter['source']) && !empty($filter['source'])) { |
443 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
443 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
444 | 444 | } |
445 | 445 | // Should use spotter_output also ? |
446 | 446 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
447 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
447 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
448 | 448 | } |
449 | 449 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
450 | 450 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM marine_archive_output WHERE marine_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
451 | 451 | } |
452 | 452 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
453 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
453 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | FROM marine_archive |
461 | 461 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive.aircraft_icao = a.icao'; |
462 | 462 | */ |
463 | - $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
463 | + $query = 'SELECT a.aircraft_shadow, marine_archive_output.ident, marine_archive_output.fammarine_id, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk |
|
464 | 464 | FROM marine_archive_output |
465 | 465 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON marine_archive_output.aircraft_icao = a.icao |
466 | 466 | WHERE (marine_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' GROUP BY marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao, marine_archive_output.arrival_airport_icao, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow'; |
477 | 477 | */ |
478 | - $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
478 | + $query = 'SELECT DISTINCT marine_archive_output.fammarine_id, marine_archive_output.ident, marine_archive_output.aircraft_icao, marine_archive_output.departure_airport_icao as departure_airport, marine_archive_output.arrival_airport_icao as arrival_airport, marine_archive_output.latitude, marine_archive_output.longitude, marine_archive_output.altitude, marine_archive_output.heading, marine_archive_output.ground_speed, marine_archive_output.squawk, a.aircraft_shadow |
|
479 | 479 | FROM marine_archive_output |
480 | 480 | INNER JOIN (SELECT * FROM aircraft) a on marine_archive_output.aircraft_icao = a.icao |
481 | 481 | WHERE marine_archive_output.date >= '."'".$begindate."'".' AND marine_archive_output.date <= '."'".$enddate."'".' |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | try { |
488 | 488 | $sth = $this->db->prepare($query); |
489 | 489 | $sth->execute(); |
490 | - } catch(PDOException $e) { |
|
490 | + } catch (PDOException $e) { |
|
491 | 491 | echo $e->getMessage(); |
492 | 492 | die; |
493 | 493 | } |
@@ -502,23 +502,23 @@ discard block |
||
502 | 502 | * @return Array the spotter information |
503 | 503 | * |
504 | 504 | */ |
505 | - public function getLiveMarineCount($begindate,$enddate,$filter = array()) |
|
505 | + public function getLiveMarineCount($begindate, $enddate, $filter = array()) |
|
506 | 506 | { |
507 | 507 | global $globalDBdriver, $globalLiveInterval; |
508 | 508 | date_default_timezone_set('UTC'); |
509 | 509 | |
510 | 510 | $filter_query = ''; |
511 | 511 | if (isset($filter['source']) && !empty($filter['source'])) { |
512 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
512 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
513 | 513 | } |
514 | 514 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
515 | - $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
515 | + $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.fammarine_id = marine_archive.fammarine_id "; |
|
516 | 516 | } |
517 | 517 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
518 | 518 | $filter_query .= " INNER JOIN (SELECT fammarine_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.fammarine_id = marine_archive.fammarine_id "; |
519 | 519 | } |
520 | 520 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
521 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
521 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | try { |
534 | 534 | $sth = $this->db->prepare($query); |
535 | 535 | $sth->execute(); |
536 | - } catch(PDOException $e) { |
|
536 | + } catch (PDOException $e) { |
|
537 | 537 | echo $e->getMessage(); |
538 | 538 | die; |
539 | 539 | } |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | * @return Array the spotter information |
554 | 554 | * |
555 | 555 | */ |
556 | - public function searchMarineData($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()) |
|
556 | + public function searchMarineData($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()) |
|
557 | 557 | { |
558 | 558 | global $globalTimezone, $globalDBdriver; |
559 | 559 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | |
576 | 576 | $q_array = explode(" ", $q); |
577 | 577 | |
578 | - foreach ($q_array as $q_item){ |
|
578 | + foreach ($q_array as $q_item) { |
|
579 | 579 | $additional_query .= " AND ("; |
580 | 580 | $additional_query .= "(marine_archive_output.spotter_id like '%".$q_item."%') OR "; |
581 | 581 | $additional_query .= "(marine_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | |
608 | 608 | if ($registration != "") |
609 | 609 | { |
610 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
610 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
611 | 611 | if (!is_string($registration)) |
612 | 612 | { |
613 | 613 | return false; |
@@ -618,7 +618,7 @@ discard block |
||
618 | 618 | |
619 | 619 | if ($aircraft_icao != "") |
620 | 620 | { |
621 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
621 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
622 | 622 | if (!is_string($aircraft_icao)) |
623 | 623 | { |
624 | 624 | return false; |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | |
630 | 630 | if ($aircraft_manufacturer != "") |
631 | 631 | { |
632 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
632 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
633 | 633 | if (!is_string($aircraft_manufacturer)) |
634 | 634 | { |
635 | 635 | return false; |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | |
651 | 651 | if ($airline_icao != "") |
652 | 652 | { |
653 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
653 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
654 | 654 | if (!is_string($airline_icao)) |
655 | 655 | { |
656 | 656 | return false; |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | |
662 | 662 | if ($airline_country != "") |
663 | 663 | { |
664 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
664 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
665 | 665 | if (!is_string($airline_country)) |
666 | 666 | { |
667 | 667 | return false; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | |
673 | 673 | if ($airline_type != "") |
674 | 674 | { |
675 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
675 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
676 | 676 | if (!is_string($airline_type)) |
677 | 677 | { |
678 | 678 | return false; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | |
695 | 695 | if ($airport != "") |
696 | 696 | { |
697 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
697 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
698 | 698 | if (!is_string($airport)) |
699 | 699 | { |
700 | 700 | return false; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | if ($airport_country != "") |
707 | 707 | { |
708 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
708 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
709 | 709 | if (!is_string($airport_country)) |
710 | 710 | { |
711 | 711 | return false; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | |
717 | 717 | if ($callsign != "") |
718 | 718 | { |
719 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
719 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
720 | 720 | if (!is_string($callsign)) |
721 | 721 | { |
722 | 722 | return false; |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | $translate = $Translation->ident2icao($callsign); |
725 | 725 | if ($translate != $callsign) { |
726 | 726 | $additional_query .= " AND (marine_archive_output.ident = :callsign OR marine_archive_output.ident = :translate)"; |
727 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
727 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
728 | 728 | } else { |
729 | 729 | $additional_query .= " AND (marine_archive_output.ident = '".$callsign."')"; |
730 | 730 | } |
@@ -733,7 +733,7 @@ discard block |
||
733 | 733 | |
734 | 734 | if ($owner != "") |
735 | 735 | { |
736 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
736 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
737 | 737 | if (!is_string($owner)) |
738 | 738 | { |
739 | 739 | return false; |
@@ -744,7 +744,7 @@ discard block |
||
744 | 744 | |
745 | 745 | if ($pilot_name != "") |
746 | 746 | { |
747 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
747 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
748 | 748 | if (!is_string($pilot_name)) |
749 | 749 | { |
750 | 750 | return false; |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | |
756 | 756 | if ($pilot_id != "") |
757 | 757 | { |
758 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
758 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
759 | 759 | if (!is_string($pilot_id)) |
760 | 760 | { |
761 | 761 | return false; |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | if ($departure_airport_route != "") |
768 | 768 | { |
769 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
769 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
770 | 770 | if (!is_string($departure_airport_route)) |
771 | 771 | { |
772 | 772 | return false; |
@@ -777,7 +777,7 @@ discard block |
||
777 | 777 | |
778 | 778 | if ($arrival_airport_route != "") |
779 | 779 | { |
780 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
780 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
781 | 781 | if (!is_string($arrival_airport_route)) |
782 | 782 | { |
783 | 783 | return false; |
@@ -790,8 +790,8 @@ discard block |
||
790 | 790 | { |
791 | 791 | $altitude_array = explode(",", $altitude); |
792 | 792 | |
793 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
794 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
793 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
794 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
795 | 795 | |
796 | 796 | |
797 | 797 | if ($altitude_array[1] != "") |
@@ -809,8 +809,8 @@ discard block |
||
809 | 809 | { |
810 | 810 | $date_array = explode(",", $date_posted); |
811 | 811 | |
812 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
813 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
812 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
813 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
814 | 814 | |
815 | 815 | if ($globalTimezone != '') { |
816 | 816 | date_default_timezone_set($globalTimezone); |
@@ -842,8 +842,8 @@ discard block |
||
842 | 842 | { |
843 | 843 | $limit_array = explode(",", $limit); |
844 | 844 | |
845 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
846 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
845 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
846 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
847 | 847 | |
848 | 848 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
849 | 849 | { |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | |
855 | 855 | |
856 | 856 | if ($origLat != "" && $origLon != "" && $dist != "") { |
857 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
858 | - $query="SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
857 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
858 | + $query = "SELECT marine_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
859 | 859 | FROM marine_archive_output, marine_archive WHERE spotter_output_archive.fammarine_id = marine_archive.fammarine_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
860 | 860 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(marine_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(marine_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
861 | 861 | } else { |
@@ -872,12 +872,12 @@ discard block |
||
872 | 872 | $additional_query .= " AND (marine_archive_output.waypoints <> '')"; |
873 | 873 | } |
874 | 874 | |
875 | - $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
875 | + $query = "SELECT marine_archive_output.* FROM marine_archive_output |
|
876 | 876 | WHERE marine_archive_output.ident <> '' |
877 | 877 | ".$additional_query." |
878 | 878 | ".$filter_query.$orderby_query; |
879 | 879 | } |
880 | - $spotter_array = $Marine->getDataFromDB($query, $query_values,$limit_query); |
|
880 | + $spotter_array = $Marine->getDataFromDB($query, $query_values, $limit_query); |
|
881 | 881 | |
882 | 882 | return $spotter_array; |
883 | 883 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | try { |
895 | 895 | $sth = $this->db->prepare($query); |
896 | 896 | $sth->execute(); |
897 | - } catch(PDOException $e) { |
|
897 | + } catch (PDOException $e) { |
|
898 | 898 | return "error"; |
899 | 899 | } |
900 | 900 | } |
@@ -931,8 +931,8 @@ discard block |
||
931 | 931 | { |
932 | 932 | $limit_array = explode(",", $limit); |
933 | 933 | |
934 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
935 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
934 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
935 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
936 | 936 | |
937 | 937 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
938 | 938 | { |
@@ -973,7 +973,7 @@ discard block |
||
973 | 973 | $query_values = array(); |
974 | 974 | $limit_query = ''; |
975 | 975 | $additional_query = ''; |
976 | - $filter_query = $this->getFilter($filter,true,true); |
|
976 | + $filter_query = $this->getFilter($filter, true, true); |
|
977 | 977 | |
978 | 978 | if ($owner != "") |
979 | 979 | { |
@@ -990,8 +990,8 @@ discard block |
||
990 | 990 | { |
991 | 991 | $limit_array = explode(",", $limit); |
992 | 992 | |
993 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
994 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
993 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
994 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
995 | 995 | |
996 | 996 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
997 | 997 | { |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | $query_values = array(); |
1032 | 1032 | $limit_query = ''; |
1033 | 1033 | $additional_query = ''; |
1034 | - $filter_query = $this->getFilter($filter,true,true); |
|
1034 | + $filter_query = $this->getFilter($filter, true, true); |
|
1035 | 1035 | |
1036 | 1036 | if ($pilot != "") |
1037 | 1037 | { |
@@ -1043,8 +1043,8 @@ discard block |
||
1043 | 1043 | { |
1044 | 1044 | $limit_array = explode(",", $limit); |
1045 | 1045 | |
1046 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1047 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1046 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1047 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1048 | 1048 | |
1049 | 1049 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1050 | 1050 | { |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | * @return Array the airline country list |
1075 | 1075 | * |
1076 | 1076 | */ |
1077 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1077 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1078 | 1078 | { |
1079 | 1079 | global $globalDBdriver; |
1080 | 1080 | /* |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | $flight_array = array(); |
1104 | 1104 | $temp_array = array(); |
1105 | 1105 | |
1106 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1106 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1107 | 1107 | { |
1108 | 1108 | $temp_array['flight_count'] = $row['nb']; |
1109 | 1109 | $temp_array['flight_country'] = $row['name']; |
@@ -1120,7 +1120,7 @@ discard block |
||
1120 | 1120 | * @return Array the airline country list |
1121 | 1121 | * |
1122 | 1122 | */ |
1123 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1123 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1124 | 1124 | { |
1125 | 1125 | global $globalDBdriver; |
1126 | 1126 | /* |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | $flight_array = array(); |
1150 | 1150 | $temp_array = array(); |
1151 | 1151 | |
1152 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1152 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1153 | 1153 | { |
1154 | 1154 | $temp_array['airline_icao'] = $row['airline_icao']; |
1155 | 1155 | $temp_array['flight_count'] = $row['nb']; |
@@ -1167,14 +1167,14 @@ discard block |
||
1167 | 1167 | * @return Array the spotter information |
1168 | 1168 | * |
1169 | 1169 | */ |
1170 | - public function getDateArchiveMarineDataById($id,$date) |
|
1170 | + public function getDateArchiveMarineDataById($id, $date) |
|
1171 | 1171 | { |
1172 | 1172 | $Marine = new Marine($this->db); |
1173 | 1173 | date_default_timezone_set('UTC'); |
1174 | 1174 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1175 | 1175 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1176 | - $date = date('c',$date); |
|
1177 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1176 | + $date = date('c', $date); |
|
1177 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1178 | 1178 | return $spotter_array; |
1179 | 1179 | } |
1180 | 1180 | |
@@ -1184,14 +1184,14 @@ discard block |
||
1184 | 1184 | * @return Array the spotter information |
1185 | 1185 | * |
1186 | 1186 | */ |
1187 | - public function getDateArchiveMarineDataByIdent($ident,$date) |
|
1187 | + public function getDateArchiveMarineDataByIdent($ident, $date) |
|
1188 | 1188 | { |
1189 | 1189 | $Marine = new Marine($this->db); |
1190 | 1190 | date_default_timezone_set('UTC'); |
1191 | 1191 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1192 | 1192 | $query = 'SELECT marine_archive.* FROM marine_archive INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_archive.fammarine_id = s.fammarine_id AND marine_archive.date = s.maxdate ORDER BY marine_archive.date DESC'; |
1193 | - $date = date('c',$date); |
|
1194 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1193 | + $date = date('c', $date); |
|
1194 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1195 | 1195 | return $spotter_array; |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1201,7 +1201,7 @@ discard block |
||
1201 | 1201 | * @return Array the spotter information |
1202 | 1202 | * |
1203 | 1203 | */ |
1204 | - public function getMarineDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1204 | + public function getMarineDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1205 | 1205 | { |
1206 | 1206 | global $global_query; |
1207 | 1207 | $Marine = new Marine($this->db); |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | $query_values = array(); |
1210 | 1210 | $limit_query = ''; |
1211 | 1211 | $additional_query = ''; |
1212 | - $filter_query = $this->getFilter($filters,true,true); |
|
1212 | + $filter_query = $this->getFilter($filters, true, true); |
|
1213 | 1213 | |
1214 | 1214 | if ($airport != "") |
1215 | 1215 | { |
@@ -1226,8 +1226,8 @@ discard block |
||
1226 | 1226 | { |
1227 | 1227 | $limit_array = explode(",", $limit); |
1228 | 1228 | |
1229 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1230 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1229 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1230 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1231 | 1231 | |
1232 | 1232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1233 | 1233 | { |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (MarineArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (MarineArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Marine = new Marine($this->db); |
90 | 97 | $data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | |
95 | 107 | //$country = $over_country; |
96 | 108 | // Route is not added in marine_archive |
@@ -598,7 +610,9 @@ discard block |
||
598 | 610 | $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR "; |
599 | 611 | $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR "; |
600 | 612 | $translate = $Translation->ident2icao($q_item); |
601 | - if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
613 | + if ($translate != $q_item) { |
|
614 | + $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR "; |
|
615 | + } |
|
602 | 616 | $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')"; |
603 | 617 | $additional_query .= ")"; |
604 | 618 | } |
@@ -816,7 +830,9 @@ discard block |
||
816 | 830 | date_default_timezone_set($globalTimezone); |
817 | 831 | $datetime = new DateTime(); |
818 | 832 | $offset = $datetime->format('P'); |
819 | - } else $offset = '+00:00'; |
|
833 | + } else { |
|
834 | + $offset = '+00:00'; |
|
835 | + } |
|
820 | 836 | |
821 | 837 | |
822 | 838 | if ($date_array[1] != "") |
@@ -1092,9 +1108,13 @@ discard block |
||
1092 | 1108 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1093 | 1109 | } |
1094 | 1110 | } |
1095 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1111 | + if ($sincedate != '') { |
|
1112 | + $query .= "AND date > '".$sincedate."' "; |
|
1113 | + } |
|
1096 | 1114 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1097 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1115 | + if ($limit) { |
|
1116 | + $query .= " LIMIT 0,10"; |
|
1117 | + } |
|
1098 | 1118 | |
1099 | 1119 | |
1100 | 1120 | $sth = $this->db->prepare($query); |
@@ -1138,9 +1158,13 @@ discard block |
||
1138 | 1158 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1139 | 1159 | } |
1140 | 1160 | } |
1141 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1161 | + if ($sincedate != '') { |
|
1162 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1163 | + } |
|
1142 | 1164 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1143 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1165 | + if ($limit) { |
|
1166 | + $query .= " LIMIT 0,10"; |
|
1167 | + } |
|
1144 | 1168 | |
1145 | 1169 | |
1146 | 1170 | $sth = $this->db->prepare($query); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * Get SQL query part for filter used |
15 | 15 | * @param Array $filter the filter |
16 | - * @return Array the SQL part |
|
16 | + * @return string the SQL part |
|
17 | 17 | */ |
18 | 18 | |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
@@ -566,25 +566,6 @@ discard block |
||
566 | 566 | * |
567 | 567 | * @param String $fammarine_id the ID |
568 | 568 | * @param String $ident the marine ident |
569 | - * @param String $departure_airport_icao the departure airport |
|
570 | - * @param String $arrival_airport_icao the arrival airport |
|
571 | - * @param String $latitude latitude of flight |
|
572 | - * @param String $longitude latitude of flight |
|
573 | - * @param String $waypoints waypoints of flight |
|
574 | - * @param String $heading heading of flight |
|
575 | - * @param String $groundspeed speed of flight |
|
576 | - * @param String $date date of flight |
|
577 | - * @param String $departure_airport_time departure time of flight |
|
578 | - * @param String $arrival_airport_time arrival time of flight |
|
579 | - * @param String $squawk squawk code of flight |
|
580 | - * @param String $route_stop route stop of flight |
|
581 | - * @param String $highlight highlight or not |
|
582 | - * @param String $ModeS ModesS code of flight |
|
583 | - * @param String $registration registration code of flight |
|
584 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
585 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
586 | - * @param String $verticalrate vertival rate of flight |
|
587 | - * @return String success or false |
|
588 | 569 | */ |
589 | 570 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
590 | 571 | { |
@@ -1467,7 +1448,7 @@ discard block |
||
1467 | 1448 | /** |
1468 | 1449 | * Parses the direction degrees to working |
1469 | 1450 | * |
1470 | - * @param Float $direction the direction in degrees |
|
1451 | + * @param integer $direction the direction in degrees |
|
1471 | 1452 | * @return Array the direction information |
1472 | 1453 | * |
1473 | 1454 | */ |
@@ -11,10 +11,10 @@ discard block |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | - * Get SQL query part for filter used |
|
15 | - * @param Array $filter the filter |
|
16 | - * @return Array the SQL part |
|
17 | - */ |
|
14 | + * Get SQL query part for filter used |
|
15 | + * @param Array $filter the filter |
|
16 | + * @return Array the SQL part |
|
17 | + */ |
|
18 | 18 | |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | - * Executes the SQL statements to get the spotter information |
|
82 | - * |
|
83 | - * @param String $query the SQL query |
|
84 | - * @param Array $params parameter of the query |
|
85 | - * @param String $limitQuery the limit query |
|
86 | - * @return Array the spotter information |
|
87 | - * |
|
88 | - */ |
|
81 | + * Executes the SQL statements to get the spotter information |
|
82 | + * |
|
83 | + * @param String $query the SQL query |
|
84 | + * @param Array $params parameter of the query |
|
85 | + * @param String $limitQuery the limit query |
|
86 | + * @return Array the spotter information |
|
87 | + * |
|
88 | + */ |
|
89 | 89 | public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
90 | 90 | { |
91 | 91 | date_default_timezone_set('UTC'); |
@@ -213,11 +213,11 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | /** |
216 | - * Gets all the spotter information based on the latest data entry |
|
217 | - * |
|
218 | - * @return Array the spotter information |
|
219 | - * |
|
220 | - */ |
|
216 | + * Gets all the spotter information based on the latest data entry |
|
217 | + * |
|
218 | + * @return Array the spotter information |
|
219 | + * |
|
220 | + */ |
|
221 | 221 | public function getLatestMarineData($limit = '', $sort = '', $filter = array()) |
222 | 222 | { |
223 | 223 | global $global_query; |
@@ -266,11 +266,11 @@ discard block |
||
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | - * Gets all the spotter information based on the callsign |
|
270 | - * |
|
271 | - * @return Array the spotter information |
|
272 | - * |
|
273 | - */ |
|
269 | + * Gets all the spotter information based on the callsign |
|
270 | + * |
|
271 | + * @return Array the spotter information |
|
272 | + * |
|
273 | + */ |
|
274 | 274 | public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array()) |
275 | 275 | { |
276 | 276 | global $global_query; |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | |
383 | 383 | /** |
384 | - * Gets all source name |
|
385 | - * |
|
386 | - * @param String type format of source |
|
387 | - * @return Array list of source name |
|
388 | - * |
|
389 | - */ |
|
384 | + * Gets all source name |
|
385 | + * |
|
386 | + * @param String type format of source |
|
387 | + * @return Array list of source name |
|
388 | + * |
|
389 | + */ |
|
390 | 390 | public function getAllSourceName($type = '',$filters = array()) |
391 | 391 | { |
392 | 392 | $filter_query = $this->getFilter($filters,true,true); |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | |
417 | 417 | |
418 | 418 | /** |
419 | - * Gets a list of all idents/callsigns |
|
420 | - * |
|
421 | - * @return Array list of ident/callsign names |
|
422 | - * |
|
423 | - */ |
|
419 | + * Gets a list of all idents/callsigns |
|
420 | + * |
|
421 | + * @return Array list of ident/callsign names |
|
422 | + * |
|
423 | + */ |
|
424 | 424 | public function getAllIdents($filters = array()) |
425 | 425 | { |
426 | 426 | $filter_query = $this->getFilter($filters,true,true); |
@@ -444,11 +444,11 @@ discard block |
||
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
447 | - * Gets all info from a mmsi |
|
448 | - * |
|
449 | - * @return Array list of mmsi info |
|
450 | - * |
|
451 | - */ |
|
447 | + * Gets all info from a mmsi |
|
448 | + * |
|
449 | + * @return Array list of mmsi info |
|
450 | + * |
|
451 | + */ |
|
452 | 452 | public function getIdentity($mmsi) |
453 | 453 | { |
454 | 454 | $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
@@ -505,18 +505,18 @@ discard block |
||
505 | 505 | |
506 | 506 | |
507 | 507 | /** |
508 | - * Update ident tracker data |
|
509 | - * |
|
510 | - * @param String $fammarine_id the ID |
|
511 | - * @param String $ident the marine ident |
|
512 | - * @return String success or false |
|
513 | - * |
|
514 | - */ |
|
508 | + * Update ident tracker data |
|
509 | + * |
|
510 | + * @param String $fammarine_id the ID |
|
511 | + * @param String $ident the marine ident |
|
512 | + * @return String success or false |
|
513 | + * |
|
514 | + */ |
|
515 | 515 | public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
516 | 516 | { |
517 | 517 | |
518 | 518 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
519 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
519 | + $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
520 | 520 | |
521 | 521 | try { |
522 | 522 | $sth = $this->db->prepare($query); |
@@ -530,19 +530,19 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
533 | - * Update Status data |
|
534 | - * |
|
535 | - * @param String $fammarine_id the ID |
|
536 | - * @param String $status_id the marine status id |
|
537 | - * @param String $status the marine status |
|
538 | - * @return String success or false |
|
539 | - * |
|
540 | - */ |
|
533 | + * Update Status data |
|
534 | + * |
|
535 | + * @param String $fammarine_id the ID |
|
536 | + * @param String $status_id the marine status id |
|
537 | + * @param String $status the marine status |
|
538 | + * @return String success or false |
|
539 | + * |
|
540 | + */ |
|
541 | 541 | public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
542 | 542 | { |
543 | 543 | |
544 | 544 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
545 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
545 | + $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
546 | 546 | |
547 | 547 | try { |
548 | 548 | $sth = $this->db->prepare($query); |
@@ -555,17 +555,17 @@ discard block |
||
555 | 555 | |
556 | 556 | } |
557 | 557 | /** |
558 | - * Update latest marine data |
|
559 | - * |
|
560 | - * @param String $fammarine_id the ID |
|
561 | - * @param String $ident the marine ident |
|
562 | - * @return String success or false |
|
563 | - * |
|
564 | - */ |
|
558 | + * Update latest marine data |
|
559 | + * |
|
560 | + * @param String $fammarine_id the ID |
|
561 | + * @param String $ident the marine ident |
|
562 | + * @return String success or false |
|
563 | + * |
|
564 | + */ |
|
565 | 565 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
566 | 566 | { |
567 | 567 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
568 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
568 | + $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
569 | 569 | |
570 | 570 | try { |
571 | 571 | $sth = $this->db->prepare($query); |
@@ -579,30 +579,30 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | /** |
582 | - * Adds a new spotter data |
|
583 | - * |
|
584 | - * @param String $fammarine_id the ID |
|
585 | - * @param String $ident the marine ident |
|
586 | - * @param String $departure_airport_icao the departure airport |
|
587 | - * @param String $arrival_airport_icao the arrival airport |
|
588 | - * @param String $latitude latitude of flight |
|
589 | - * @param String $longitude latitude of flight |
|
590 | - * @param String $waypoints waypoints of flight |
|
591 | - * @param String $heading heading of flight |
|
592 | - * @param String $groundspeed speed of flight |
|
593 | - * @param String $date date of flight |
|
594 | - * @param String $departure_airport_time departure time of flight |
|
595 | - * @param String $arrival_airport_time arrival time of flight |
|
596 | - * @param String $squawk squawk code of flight |
|
597 | - * @param String $route_stop route stop of flight |
|
598 | - * @param String $highlight highlight or not |
|
599 | - * @param String $ModeS ModesS code of flight |
|
600 | - * @param String $registration registration code of flight |
|
601 | - * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
602 | - * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
603 | - * @param String $verticalrate vertival rate of flight |
|
604 | - * @return String success or false |
|
605 | - */ |
|
582 | + * Adds a new spotter data |
|
583 | + * |
|
584 | + * @param String $fammarine_id the ID |
|
585 | + * @param String $ident the marine ident |
|
586 | + * @param String $departure_airport_icao the departure airport |
|
587 | + * @param String $arrival_airport_icao the arrival airport |
|
588 | + * @param String $latitude latitude of flight |
|
589 | + * @param String $longitude latitude of flight |
|
590 | + * @param String $waypoints waypoints of flight |
|
591 | + * @param String $heading heading of flight |
|
592 | + * @param String $groundspeed speed of flight |
|
593 | + * @param String $date date of flight |
|
594 | + * @param String $departure_airport_time departure time of flight |
|
595 | + * @param String $arrival_airport_time arrival time of flight |
|
596 | + * @param String $squawk squawk code of flight |
|
597 | + * @param String $route_stop route stop of flight |
|
598 | + * @param String $highlight highlight or not |
|
599 | + * @param String $ModeS ModesS code of flight |
|
600 | + * @param String $registration registration code of flight |
|
601 | + * @param String $pilot_id pilot id of flight (for virtual airlines) |
|
602 | + * @param String $pilot_name pilot name of flight (for virtual airlines) |
|
603 | + * @param String $verticalrate vertival rate of flight |
|
604 | + * @return String success or false |
|
605 | + */ |
|
606 | 606 | public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
607 | 607 | { |
608 | 608 | global $globalURL, $globalMarineImageFetch; |
@@ -699,13 +699,13 @@ discard block |
||
699 | 699 | unset($Image); |
700 | 700 | } |
701 | 701 | |
702 | - if ($latitude == '' && $longitude == '') { |
|
703 | - $latitude = 0; |
|
704 | - $longitude = 0; |
|
705 | - } |
|
706 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
707 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
708 | - if ($arrival_date == '') $arrival_date = NULL; |
|
702 | + if ($latitude == '' && $longitude == '') { |
|
703 | + $latitude = 0; |
|
704 | + $longitude = 0; |
|
705 | + } |
|
706 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
707 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
708 | + if ($arrival_date == '') $arrival_date = NULL; |
|
709 | 709 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
710 | 710 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
711 | 711 | |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | $sth->execute($query_values); |
717 | 717 | $this->db = null; |
718 | 718 | } catch (PDOException $e) { |
719 | - return "error : ".$e->getMessage(); |
|
719 | + return "error : ".$e->getMessage(); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | return "success"; |
@@ -725,11 +725,11 @@ discard block |
||
725 | 725 | |
726 | 726 | |
727 | 727 | /** |
728 | - * Gets the aircraft ident within the last hour |
|
729 | - * |
|
730 | - * @return String the ident |
|
731 | - * |
|
732 | - */ |
|
728 | + * Gets the aircraft ident within the last hour |
|
729 | + * |
|
730 | + * @return String the ident |
|
731 | + * |
|
732 | + */ |
|
733 | 733 | public function getIdentFromLastHour($ident) |
734 | 734 | { |
735 | 735 | global $globalDBdriver, $globalTimezone; |
@@ -745,11 +745,11 @@ discard block |
||
745 | 745 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
746 | 746 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
747 | 747 | $query_data = array(':ident' => $ident); |
748 | - } |
|
748 | + } |
|
749 | 749 | |
750 | 750 | $sth = $this->db->prepare($query); |
751 | 751 | $sth->execute($query_data); |
752 | - $ident_result=''; |
|
752 | + $ident_result=''; |
|
753 | 753 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
754 | 754 | { |
755 | 755 | $ident_result = $row['ident']; |
@@ -760,11 +760,11 @@ discard block |
||
760 | 760 | |
761 | 761 | |
762 | 762 | /** |
763 | - * Gets the aircraft data from the last 20 seconds |
|
764 | - * |
|
765 | - * @return Array the spotter data |
|
766 | - * |
|
767 | - */ |
|
763 | + * Gets the aircraft data from the last 20 seconds |
|
764 | + * |
|
765 | + * @return Array the spotter data |
|
766 | + * |
|
767 | + */ |
|
768 | 768 | public function getRealTimeData($q = '') |
769 | 769 | { |
770 | 770 | global $globalDBdriver; |
@@ -802,11 +802,11 @@ discard block |
||
802 | 802 | |
803 | 803 | |
804 | 804 | /** |
805 | - * Gets all number of flight over countries |
|
806 | - * |
|
807 | - * @return Array the airline country list |
|
808 | - * |
|
809 | - */ |
|
805 | + * Gets all number of flight over countries |
|
806 | + * |
|
807 | + * @return Array the airline country list |
|
808 | + * |
|
809 | + */ |
|
810 | 810 | |
811 | 811 | public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
812 | 812 | { |
@@ -879,11 +879,11 @@ discard block |
||
879 | 879 | |
880 | 880 | |
881 | 881 | /** |
882 | - * Gets all callsigns that have flown over |
|
883 | - * |
|
884 | - * @return Array the callsign list |
|
885 | - * |
|
886 | - */ |
|
882 | + * Gets all callsigns that have flown over |
|
883 | + * |
|
884 | + * @return Array the callsign list |
|
885 | + * |
|
886 | + */ |
|
887 | 887 | public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
888 | 888 | { |
889 | 889 | global $globalDBdriver; |
@@ -950,11 +950,11 @@ discard block |
||
950 | 950 | |
951 | 951 | |
952 | 952 | /** |
953 | - * Counts all dates |
|
954 | - * |
|
955 | - * @return Array the date list |
|
956 | - * |
|
957 | - */ |
|
953 | + * Counts all dates |
|
954 | + * |
|
955 | + * @return Array the date list |
|
956 | + * |
|
957 | + */ |
|
958 | 958 | public function countAllDates($filters = array()) |
959 | 959 | { |
960 | 960 | global $globalTimezone, $globalDBdriver; |
@@ -1000,11 +1000,11 @@ discard block |
||
1000 | 1000 | |
1001 | 1001 | |
1002 | 1002 | /** |
1003 | - * Counts all dates during the last 7 days |
|
1004 | - * |
|
1005 | - * @return Array the date list |
|
1006 | - * |
|
1007 | - */ |
|
1003 | + * Counts all dates during the last 7 days |
|
1004 | + * |
|
1005 | + * @return Array the date list |
|
1006 | + * |
|
1007 | + */ |
|
1008 | 1008 | public function countAllDatesLast7Days($filters = array()) |
1009 | 1009 | { |
1010 | 1010 | global $globalTimezone, $globalDBdriver; |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | $query .= " GROUP BY date_name |
1027 | 1027 | ORDER BY date_name ASC"; |
1028 | 1028 | $query_data = array(':offset' => $offset); |
1029 | - } |
|
1029 | + } |
|
1030 | 1030 | |
1031 | 1031 | $sth = $this->db->prepare($query); |
1032 | 1032 | $sth->execute($query_data); |
@@ -1046,11 +1046,11 @@ discard block |
||
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /** |
1049 | - * Counts all dates during the last month |
|
1050 | - * |
|
1051 | - * @return Array the date list |
|
1052 | - * |
|
1053 | - */ |
|
1049 | + * Counts all dates during the last month |
|
1050 | + * |
|
1051 | + * @return Array the date list |
|
1052 | + * |
|
1053 | + */ |
|
1054 | 1054 | public function countAllDatesLastMonth($filters = array()) |
1055 | 1055 | { |
1056 | 1056 | global $globalTimezone, $globalDBdriver; |
@@ -1072,7 +1072,7 @@ discard block |
||
1072 | 1072 | $query .= " GROUP BY date_name |
1073 | 1073 | ORDER BY date_name ASC"; |
1074 | 1074 | $query_data = array(':offset' => $offset); |
1075 | - } |
|
1075 | + } |
|
1076 | 1076 | |
1077 | 1077 | $sth = $this->db->prepare($query); |
1078 | 1078 | $sth->execute($query_data); |
@@ -1094,11 +1094,11 @@ discard block |
||
1094 | 1094 | |
1095 | 1095 | |
1096 | 1096 | /** |
1097 | - * Counts all month |
|
1098 | - * |
|
1099 | - * @return Array the month list |
|
1100 | - * |
|
1101 | - */ |
|
1097 | + * Counts all month |
|
1098 | + * |
|
1099 | + * @return Array the month list |
|
1100 | + * |
|
1101 | + */ |
|
1102 | 1102 | public function countAllMonths($filters = array()) |
1103 | 1103 | { |
1104 | 1104 | global $globalTimezone, $globalDBdriver; |
@@ -1143,11 +1143,11 @@ discard block |
||
1143 | 1143 | |
1144 | 1144 | |
1145 | 1145 | /** |
1146 | - * Counts all dates during the last year |
|
1147 | - * |
|
1148 | - * @return Array the date list |
|
1149 | - * |
|
1150 | - */ |
|
1146 | + * Counts all dates during the last year |
|
1147 | + * |
|
1148 | + * @return Array the date list |
|
1149 | + * |
|
1150 | + */ |
|
1151 | 1151 | public function countAllMonthsLastYear($filters) |
1152 | 1152 | { |
1153 | 1153 | global $globalTimezone, $globalDBdriver; |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | $query .= " GROUP BY year_name, month_name |
1170 | 1170 | ORDER BY year_name, month_name ASC"; |
1171 | 1171 | $query_data = array(':offset' => $offset); |
1172 | - } |
|
1172 | + } |
|
1173 | 1173 | |
1174 | 1174 | $sth = $this->db->prepare($query); |
1175 | 1175 | $sth->execute($query_data); |
@@ -1192,11 +1192,11 @@ discard block |
||
1192 | 1192 | |
1193 | 1193 | |
1194 | 1194 | /** |
1195 | - * Counts all hours |
|
1196 | - * |
|
1197 | - * @return Array the hour list |
|
1198 | - * |
|
1199 | - */ |
|
1195 | + * Counts all hours |
|
1196 | + * |
|
1197 | + * @return Array the hour list |
|
1198 | + * |
|
1199 | + */ |
|
1200 | 1200 | public function countAllHours($orderby,$filters = array()) |
1201 | 1201 | { |
1202 | 1202 | global $globalTimezone, $globalDBdriver; |
@@ -1259,11 +1259,11 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | |
1261 | 1261 | /** |
1262 | - * Counts all hours by date |
|
1263 | - * |
|
1264 | - * @return Array the hour list |
|
1265 | - * |
|
1266 | - */ |
|
1262 | + * Counts all hours by date |
|
1263 | + * |
|
1264 | + * @return Array the hour list |
|
1265 | + * |
|
1266 | + */ |
|
1267 | 1267 | public function countAllHoursByDate($date, $filters = array()) |
1268 | 1268 | { |
1269 | 1269 | global $globalTimezone, $globalDBdriver; |
@@ -1307,11 +1307,11 @@ discard block |
||
1307 | 1307 | |
1308 | 1308 | |
1309 | 1309 | /** |
1310 | - * Counts all hours by a ident/callsign |
|
1311 | - * |
|
1312 | - * @return Array the hour list |
|
1313 | - * |
|
1314 | - */ |
|
1310 | + * Counts all hours by a ident/callsign |
|
1311 | + * |
|
1312 | + * @return Array the hour list |
|
1313 | + * |
|
1314 | + */ |
|
1315 | 1315 | public function countAllHoursByIdent($ident, $filters = array()) |
1316 | 1316 | { |
1317 | 1317 | global $globalTimezone, $globalDBdriver; |
@@ -1356,11 +1356,11 @@ discard block |
||
1356 | 1356 | |
1357 | 1357 | |
1358 | 1358 | /** |
1359 | - * Counts all vessels |
|
1360 | - * |
|
1361 | - * @return Integer the number of vessels |
|
1362 | - * |
|
1363 | - */ |
|
1359 | + * Counts all vessels |
|
1360 | + * |
|
1361 | + * @return Integer the number of vessels |
|
1362 | + * |
|
1363 | + */ |
|
1364 | 1364 | public function countOverallMarine($filters = array(),$year = '',$month = '') |
1365 | 1365 | { |
1366 | 1366 | global $globalDBdriver; |
@@ -1395,11 +1395,11 @@ discard block |
||
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | /** |
1398 | - * Counts all vessel type |
|
1399 | - * |
|
1400 | - * @return Integer the number of vessels |
|
1401 | - * |
|
1402 | - */ |
|
1398 | + * Counts all vessel type |
|
1399 | + * |
|
1400 | + * @return Integer the number of vessels |
|
1401 | + * |
|
1402 | + */ |
|
1403 | 1403 | public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
1404 | 1404 | { |
1405 | 1405 | global $globalDBdriver; |
@@ -1434,11 +1434,11 @@ discard block |
||
1434 | 1434 | |
1435 | 1435 | |
1436 | 1436 | /** |
1437 | - * Counts all hours of today |
|
1438 | - * |
|
1439 | - * @return Array the hour list |
|
1440 | - * |
|
1441 | - */ |
|
1437 | + * Counts all hours of today |
|
1438 | + * |
|
1439 | + * @return Array the hour list |
|
1440 | + * |
|
1441 | + */ |
|
1442 | 1442 | public function countAllHoursFromToday($filters = array()) |
1443 | 1443 | { |
1444 | 1444 | global $globalTimezone, $globalDBdriver; |
@@ -1478,12 +1478,12 @@ discard block |
||
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | |
1481 | - /** |
|
1482 | - * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1483 | - * |
|
1484 | - * @return Integer the Barrie Spotter ID |
|
1481 | + /** |
|
1482 | + * Gets the Barrie Spotter ID based on the FlightAware ID |
|
1483 | + * |
|
1484 | + * @return Integer the Barrie Spotter ID |
|
1485 | 1485 | q * |
1486 | - */ |
|
1486 | + */ |
|
1487 | 1487 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1488 | 1488 | { |
1489 | 1489 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -1504,13 +1504,13 @@ discard block |
||
1504 | 1504 | |
1505 | 1505 | |
1506 | 1506 | /** |
1507 | - * Parses a date string |
|
1508 | - * |
|
1509 | - * @param String $dateString the date string |
|
1510 | - * @param String $timezone the timezone of a user |
|
1511 | - * @return Array the time information |
|
1512 | - * |
|
1513 | - */ |
|
1507 | + * Parses a date string |
|
1508 | + * |
|
1509 | + * @param String $dateString the date string |
|
1510 | + * @param String $timezone the timezone of a user |
|
1511 | + * @return Array the time information |
|
1512 | + * |
|
1513 | + */ |
|
1514 | 1514 | public function parseDateString($dateString, $timezone = '') |
1515 | 1515 | { |
1516 | 1516 | $time_array = array(); |
@@ -1543,12 +1543,12 @@ discard block |
||
1543 | 1543 | } |
1544 | 1544 | |
1545 | 1545 | /** |
1546 | - * Parses the direction degrees to working |
|
1547 | - * |
|
1548 | - * @param Float $direction the direction in degrees |
|
1549 | - * @return Array the direction information |
|
1550 | - * |
|
1551 | - */ |
|
1546 | + * Parses the direction degrees to working |
|
1547 | + * |
|
1548 | + * @param Float $direction the direction in degrees |
|
1549 | + * @return Array the direction information |
|
1550 | + * |
|
1551 | + */ |
|
1552 | 1552 | public function parseDirection($direction = 0) |
1553 | 1553 | { |
1554 | 1554 | if ($direction == '') $direction = 0; |
@@ -1627,12 +1627,12 @@ discard block |
||
1627 | 1627 | |
1628 | 1628 | |
1629 | 1629 | /** |
1630 | - * Gets Country from latitude/longitude |
|
1631 | - * |
|
1632 | - * @param Float $latitude latitute of the flight |
|
1633 | - * @param Float $longitude longitute of the flight |
|
1634 | - * @return String the countrie |
|
1635 | - */ |
|
1630 | + * Gets Country from latitude/longitude |
|
1631 | + * |
|
1632 | + * @param Float $latitude latitute of the flight |
|
1633 | + * @param Float $longitude longitute of the flight |
|
1634 | + * @return String the countrie |
|
1635 | + */ |
|
1636 | 1636 | public function getCountryFromLatitudeLongitude($latitude,$longitude) |
1637 | 1637 | { |
1638 | 1638 | global $globalDBdriver, $globalDebug; |
@@ -1669,11 +1669,11 @@ discard block |
||
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | /** |
1672 | - * Gets Country from iso2 |
|
1673 | - * |
|
1674 | - * @param String $iso2 ISO2 country code |
|
1675 | - * @return String the countrie |
|
1676 | - */ |
|
1672 | + * Gets Country from iso2 |
|
1673 | + * |
|
1674 | + * @param String $iso2 ISO2 country code |
|
1675 | + * @return String the countrie |
|
1676 | + */ |
|
1677 | 1677 | public function getCountryFromISO2($iso2) |
1678 | 1678 | { |
1679 | 1679 | global $globalDBdriver, $globalDebug; |
@@ -1702,12 +1702,12 @@ discard block |
||
1702 | 1702 | |
1703 | 1703 | |
1704 | 1704 | /** |
1705 | - * Gets the short url from bit.ly |
|
1706 | - * |
|
1707 | - * @param String $url the full url |
|
1708 | - * @return String the bit.ly url |
|
1709 | - * |
|
1710 | - */ |
|
1705 | + * Gets the short url from bit.ly |
|
1706 | + * |
|
1707 | + * @param String $url the full url |
|
1708 | + * @return String the bit.ly url |
|
1709 | + * |
|
1710 | + */ |
|
1711 | 1711 | public function getBitlyURL($url) |
1712 | 1712 | { |
1713 | 1713 | global $globalBitlyAccessToken; |
@@ -1734,11 +1734,11 @@ discard block |
||
1734 | 1734 | |
1735 | 1735 | |
1736 | 1736 | /** |
1737 | - * Gets all vessels types that have flown over |
|
1738 | - * |
|
1739 | - * @return Array the vessel type list |
|
1740 | - * |
|
1741 | - */ |
|
1737 | + * Gets all vessels types that have flown over |
|
1738 | + * |
|
1739 | + * @return Array the vessel type list |
|
1740 | + * |
|
1741 | + */ |
|
1742 | 1742 | public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
1743 | 1743 | { |
1744 | 1744 | global $globalDBdriver; |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once(dirname(__FILE__).'/class.Image.php'); |
3 | 3 | $global_query = "SELECT marine_output.* FROM marine_output"; |
4 | 4 | |
5 | -class Marine{ |
|
5 | +class Marine { |
|
6 | 6 | public $db; |
7 | 7 | |
8 | 8 | public function __construct($dbc = null) { |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @return Array the SQL part |
18 | 18 | */ |
19 | 19 | |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
73 | 73 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
74 | 74 | if ($filter_query_where != '') { |
75 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
75 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
76 | 76 | } |
77 | 77 | $filter_query = $filter_query_join.$filter_query_where; |
78 | 78 | return $filter_query; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return Array the spotter information |
88 | 88 | * |
89 | 89 | */ |
90 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
90 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
91 | 91 | { |
92 | 92 | date_default_timezone_set('UTC'); |
93 | 93 | if (!is_string($query)) |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | $sth = $this->db->prepare($query.$limitQuery); |
108 | 108 | $sth->execute($params); |
109 | 109 | } catch (PDOException $e) { |
110 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
110 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
111 | 111 | exit(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | $num_rows = 0; |
115 | 115 | $spotter_array = array(); |
116 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
116 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
117 | 117 | { |
118 | 118 | $num_rows++; |
119 | 119 | $temp_array = array(); |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | } |
146 | 146 | if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
147 | 147 | |
148 | - if($temp_array['mmsi'] != "") |
|
148 | + if ($temp_array['mmsi'] != "") |
|
149 | 149 | { |
150 | 150 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
151 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']); |
|
152 | 152 | else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
153 | 153 | unset($Image); |
154 | 154 | if (count($image_array) > 0) { |
@@ -184,17 +184,17 @@ discard block |
||
184 | 184 | { |
185 | 185 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
186 | 186 | } else { |
187 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
187 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
188 | 188 | } |
189 | 189 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
190 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
191 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
190 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
191 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
192 | 192 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
193 | 193 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
194 | 194 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
195 | 195 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
196 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
197 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
196 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
197 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
198 | 198 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
199 | 199 | } |
200 | 200 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | if ($limit != "") |
228 | 228 | { |
229 | 229 | $limit_array = explode(",", $limit); |
230 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
231 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
230 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
231 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
232 | 232 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
233 | 233 | { |
234 | 234 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | } else { |
243 | 243 | $orderby_query = " ORDER BY marine_output.date DESC"; |
244 | 244 | } |
245 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
245 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
246 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
247 | 247 | return $spotter_array; |
248 | 248 | } |
249 | 249 | |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | if ($id == '') return array(); |
262 | 262 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 263 | $query_values = array(':id' => $id); |
264 | - $query = $global_query." WHERE ".$additional_query." "; |
|
265 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
264 | + $query = $global_query." WHERE ".$additional_query." "; |
|
265 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
266 | 266 | return $spotter_array; |
267 | 267 | } |
268 | 268 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $query_values = array(); |
282 | 282 | $limit_query = ''; |
283 | 283 | $additional_query = ''; |
284 | - $filter_query = $this->getFilter($filter,true,true); |
|
284 | + $filter_query = $this->getFilter($filter, true, true); |
|
285 | 285 | if ($ident != "") |
286 | 286 | { |
287 | 287 | if (!is_string($ident)) |
@@ -297,8 +297,8 @@ discard block |
||
297 | 297 | { |
298 | 298 | $limit_array = explode(",", $limit); |
299 | 299 | |
300 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
301 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
300 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
301 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
302 | 302 | |
303 | 303 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
304 | 304 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | return $spotter_array; |
323 | 323 | } |
324 | 324 | |
325 | - public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
325 | + public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
326 | 326 | { |
327 | 327 | global $global_query, $globalTimezone, $globalDBdriver; |
328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | $limit_query = ''; |
331 | 331 | $additional_query = ''; |
332 | 332 | |
333 | - $filter_query = $this->getFilter($filter,true,true); |
|
333 | + $filter_query = $this->getFilter($filter, true, true); |
|
334 | 334 | |
335 | 335 | if ($date != "") |
336 | 336 | { |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | { |
357 | 357 | $limit_array = explode(",", $limit); |
358 | 358 | |
359 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
360 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
359 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
360 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
361 | 361 | |
362 | 362 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
363 | 363 | { |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | * @return Array list of source name |
389 | 389 | * |
390 | 390 | */ |
391 | - public function getAllSourceName($type = '',$filters = array()) |
|
391 | + public function getAllSourceName($type = '', $filters = array()) |
|
392 | 392 | { |
393 | - $filter_query = $this->getFilter($filters,true,true); |
|
393 | + $filter_query = $this->getFilter($filters, true, true); |
|
394 | 394 | $query_values = array(); |
395 | - $query = "SELECT DISTINCT marine_output.source_name |
|
395 | + $query = "SELECT DISTINCT marine_output.source_name |
|
396 | 396 | FROM marine_output".$filter_query." marine_output.source_name <> ''"; |
397 | 397 | if ($type != '') { |
398 | 398 | $query_values = array(':type' => $type); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $source_array = array(); |
408 | 408 | $temp_array = array(); |
409 | 409 | |
410 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
410 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
411 | 411 | { |
412 | 412 | $temp_array['source_name'] = $row['source_name']; |
413 | 413 | $source_array[] = $temp_array; |
@@ -424,8 +424,8 @@ discard block |
||
424 | 424 | */ |
425 | 425 | public function getAllIdents($filters = array()) |
426 | 426 | { |
427 | - $filter_query = $this->getFilter($filters,true,true); |
|
428 | - $query = "SELECT DISTINCT marine_output.ident |
|
427 | + $filter_query = $this->getFilter($filters, true, true); |
|
428 | + $query = "SELECT DISTINCT marine_output.ident |
|
429 | 429 | FROM marine_output".$filter_query." marine_output.ident <> '' |
430 | 430 | ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0"; |
431 | 431 | |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $ident_array = array(); |
436 | 436 | $temp_array = array(); |
437 | 437 | |
438 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
438 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
439 | 439 | { |
440 | 440 | $temp_array['ident'] = $row['ident']; |
441 | 441 | $ident_array[] = $temp_array; |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | public function getIdentity($mmsi) |
454 | 454 | { |
455 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
455 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
456 | 456 | $query = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1"; |
457 | 457 | $sth = $this->db->prepare($query); |
458 | 458 | $sth->execute(array(':mmsi' => $mmsi)); |
@@ -477,12 +477,12 @@ discard block |
||
477 | 477 | } else $offset = '+00:00'; |
478 | 478 | |
479 | 479 | if ($globalDBdriver == 'mysql') { |
480 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
480 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
|
481 | 481 | FROM marine_output |
482 | 482 | WHERE marine_output.date <> '' |
483 | 483 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
484 | 484 | } else { |
485 | - $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
485 | + $query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
486 | 486 | FROM marine_output |
487 | 487 | WHERE marine_output.date <> '' |
488 | 488 | ORDER BY marine_output.date ASC LIMIT 0,200"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $date_array = array(); |
495 | 495 | $temp_array = array(); |
496 | 496 | |
497 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
497 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
498 | 498 | { |
499 | 499 | $temp_array['date'] = $row['date']; |
500 | 500 | |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @return String success or false |
514 | 514 | * |
515 | 515 | */ |
516 | - public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL) |
|
516 | + public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL) |
|
517 | 517 | { |
518 | 518 | |
519 | 519 | $query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id'; |
520 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident); |
|
520 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident); |
|
521 | 521 | |
522 | 522 | try { |
523 | 523 | $sth = $this->db->prepare($query); |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | * @return String success or false |
540 | 540 | * |
541 | 541 | */ |
542 | - public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '') |
|
542 | + public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '') |
|
543 | 543 | { |
544 | 544 | |
545 | 545 | $query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id'; |
546 | - $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id); |
|
546 | + $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id); |
|
547 | 547 | |
548 | 548 | try { |
549 | 549 | $sth = $this->db->prepare($query); |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '') |
567 | 567 | { |
568 | 568 | $query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id'; |
569 | - $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident); |
|
569 | + $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident); |
|
570 | 570 | |
571 | 571 | try { |
572 | 572 | $sth = $this->db->prepare($query); |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | * @param String $verticalrate vertival rate of flight |
605 | 605 | * @return String success or false |
606 | 606 | */ |
607 | - public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '') |
|
607 | + public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '') |
|
608 | 608 | { |
609 | 609 | global $globalURL, $globalMarineImageFetch; |
610 | 610 | |
@@ -671,31 +671,31 @@ discard block |
||
671 | 671 | } |
672 | 672 | |
673 | 673 | |
674 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
674 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
675 | 675 | { |
676 | 676 | $date = date("Y-m-d H:i:s", time()); |
677 | 677 | } |
678 | 678 | |
679 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
680 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
681 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
682 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
683 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
684 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
685 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
686 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
687 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
688 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
689 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
690 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
691 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
692 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
679 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
680 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
681 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
682 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
683 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
684 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
685 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
686 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
687 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
688 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
689 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
690 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
691 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
692 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
693 | 693 | |
694 | 694 | if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) { |
695 | 695 | $Image = new Image($this->db); |
696 | - $image_array = $Image->getMarineImage($mmsi,$imo,$ident); |
|
696 | + $image_array = $Image->getMarineImage($mmsi, $imo, $ident); |
|
697 | 697 | if (!isset($image_array[0]['mmsi'])) { |
698 | - $Image->addMarineImage($mmsi,$imo,$ident); |
|
698 | + $Image->addMarineImage($mmsi, $imo, $ident); |
|
699 | 699 | } |
700 | 700 | unset($Image); |
701 | 701 | } |
@@ -707,10 +707,10 @@ discard block |
||
707 | 707 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
708 | 708 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
709 | 709 | if ($arrival_date == '') $arrival_date = NULL; |
710 | - $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
710 | + $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
|
711 | 711 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 712 | |
713 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
713 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
714 | 714 | try { |
715 | 715 | |
716 | 716 | $sth = $this->db->prepare($query); |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | { |
736 | 736 | global $globalDBdriver, $globalTimezone; |
737 | 737 | if ($globalDBdriver == 'mysql') { |
738 | - $query = "SELECT marine_output.ident FROM marine_output |
|
738 | + $query = "SELECT marine_output.ident FROM marine_output |
|
739 | 739 | WHERE marine_output.ident = :ident |
740 | 740 | AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
741 | 741 | AND marine_output.date < UTC_TIMESTAMP()"; |
742 | 742 | $query_data = array(':ident' => $ident); |
743 | 743 | } else { |
744 | - $query = "SELECT marine_output.ident FROM marine_output |
|
744 | + $query = "SELECT marine_output.ident FROM marine_output |
|
745 | 745 | WHERE marine_output.ident = :ident |
746 | 746 | AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
747 | 747 | AND marine_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -750,8 +750,8 @@ discard block |
||
750 | 750 | |
751 | 751 | $sth = $this->db->prepare($query); |
752 | 752 | $sth->execute($query_data); |
753 | - $ident_result=''; |
|
754 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
753 | + $ident_result = ''; |
|
754 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
755 | 755 | { |
756 | 756 | $ident_result = $row['ident']; |
757 | 757 | } |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | return false; |
778 | 778 | } else { |
779 | 779 | $q_array = explode(" ", $q); |
780 | - foreach ($q_array as $q_item){ |
|
781 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
780 | + foreach ($q_array as $q_item) { |
|
781 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
782 | 782 | $additional_query .= " AND ("; |
783 | 783 | $additional_query .= "(marine_output.ident like '%".$q_item."%')"; |
784 | 784 | $additional_query .= ")"; |
@@ -786,11 +786,11 @@ discard block |
||
786 | 786 | } |
787 | 787 | } |
788 | 788 | if ($globalDBdriver == 'mysql') { |
789 | - $query = "SELECT marine_output.* FROM marine_output |
|
789 | + $query = "SELECT marine_output.* FROM marine_output |
|
790 | 790 | WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
791 | 791 | AND marine_output.date < UTC_TIMESTAMP()"; |
792 | 792 | } else { |
793 | - $query = "SELECT marine_output.* FROM marine_output |
|
793 | + $query = "SELECT marine_output.* FROM marine_output |
|
794 | 794 | WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
795 | 795 | AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
796 | 796 | } |
@@ -809,16 +809,16 @@ discard block |
||
809 | 809 | * |
810 | 810 | */ |
811 | 811 | |
812 | - public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
812 | + public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
813 | 813 | { |
814 | 814 | global $globalDBdriver, $globalArchive; |
815 | 815 | //$filter_query = $this->getFilter($filters,true,true); |
816 | - $Connection= new Connection($this->db); |
|
816 | + $Connection = new Connection($this->db); |
|
817 | 817 | if (!$Connection->tableExists('countries')) return array(); |
818 | 818 | require_once('class.SpotterLive.php'); |
819 | 819 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 820 | $MarineLive = new MarineLive($this->db); |
821 | - $filter_query = $MarineLive->getFilter($filters,true,true); |
|
821 | + $filter_query = $MarineLive->getFilter($filters, true, true); |
|
822 | 822 | $filter_query .= " over_country IS NOT NULL AND over_country <> ''"; |
823 | 823 | if ($olderthanmonths > 0) { |
824 | 824 | if ($globalDBdriver == 'mysql') { |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } else { |
839 | 839 | require_once(dirname(__FILE__)."/class.MarineArchive.php"); |
840 | 840 | $MarineArchive = new MarineArchive($this->db); |
841 | - $filter_query = $MarineArchive->getFilter($filters,true,true); |
|
841 | + $filter_query = $MarineArchive->getFilter($filters, true, true); |
|
842 | 842 | $filter_query .= " over_country <> ''"; |
843 | 843 | if ($olderthanmonths > 0) { |
844 | 844 | if ($globalDBdriver == 'mysql') { |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | $flight_array = array(); |
867 | 867 | $temp_array = array(); |
868 | 868 | |
869 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
870 | 870 | { |
871 | 871 | $temp_array['marine_count'] = $row['nb']; |
872 | 872 | $temp_array['marine_country'] = $row['name']; |
@@ -885,11 +885,11 @@ discard block |
||
885 | 885 | * @return Array the callsign list |
886 | 886 | * |
887 | 887 | */ |
888 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
888 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
889 | 889 | { |
890 | 890 | global $globalDBdriver; |
891 | - $filter_query = $this->getFilter($filters,true,true); |
|
892 | - $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
891 | + $filter_query = $this->getFilter($filters, true, true); |
|
892 | + $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
|
893 | 893 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 894 | if ($olderthanmonths > 0) { |
895 | 895 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -903,28 +903,28 @@ discard block |
||
903 | 903 | if ($year != '') { |
904 | 904 | if ($globalDBdriver == 'mysql') { |
905 | 905 | $query .= " AND YEAR(marine_output.date) = :year"; |
906 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
906 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
907 | 907 | } else { |
908 | 908 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
909 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
909 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | if ($month != '') { |
913 | 913 | if ($globalDBdriver == 'mysql') { |
914 | 914 | $query .= " AND MONTH(marine_output.date) = :month"; |
915 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
915 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
916 | 916 | } else { |
917 | 917 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
918 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
918 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
919 | 919 | } |
920 | 920 | } |
921 | 921 | if ($day != '') { |
922 | 922 | if ($globalDBdriver == 'mysql') { |
923 | 923 | $query .= " AND DAY(marine_output.date) = :day"; |
924 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
924 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
925 | 925 | } else { |
926 | 926 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
927 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
927 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
928 | 928 | } |
929 | 929 | } |
930 | 930 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | $callsign_array = array(); |
937 | 937 | $temp_array = array(); |
938 | 938 | |
939 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
939 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
940 | 940 | { |
941 | 941 | $temp_array['callsign_icao'] = $row['ident']; |
942 | 942 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | $date_array = array(); |
989 | 989 | $temp_array = array(); |
990 | 990 | |
991 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
991 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
992 | 992 | { |
993 | 993 | $temp_array['date_name'] = $row['date_name']; |
994 | 994 | $temp_array['date_count'] = $row['date_count']; |
@@ -1014,7 +1014,7 @@ discard block |
||
1014 | 1014 | $datetime = new DateTime(); |
1015 | 1015 | $offset = $datetime->format('P'); |
1016 | 1016 | } else $offset = '+00:00'; |
1017 | - $filter_query = $this->getFilter($filters,true,true); |
|
1017 | + $filter_query = $this->getFilter($filters, true, true); |
|
1018 | 1018 | if ($globalDBdriver == 'mysql') { |
1019 | 1019 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1020 | 1020 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | $date_array = array(); |
1036 | 1036 | $temp_array = array(); |
1037 | 1037 | |
1038 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1038 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1039 | 1039 | { |
1040 | 1040 | $temp_array['date_name'] = $row['date_name']; |
1041 | 1041 | $temp_array['date_count'] = $row['date_count']; |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | $datetime = new DateTime(); |
1061 | 1061 | $offset = $datetime->format('P'); |
1062 | 1062 | } else $offset = '+00:00'; |
1063 | - $filter_query = $this->getFilter($filters,true,true); |
|
1063 | + $filter_query = $this->getFilter($filters, true, true); |
|
1064 | 1064 | if ($globalDBdriver == 'mysql') { |
1065 | 1065 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
1066 | 1066 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | $date_array = array(); |
1082 | 1082 | $temp_array = array(); |
1083 | 1083 | |
1084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1085 | 1085 | { |
1086 | 1086 | $temp_array['date_name'] = $row['date_name']; |
1087 | 1087 | $temp_array['date_count'] = $row['date_count']; |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | $date_array = array(); |
1129 | 1129 | $temp_array = array(); |
1130 | 1130 | |
1131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1132 | 1132 | { |
1133 | 1133 | $temp_array['month_name'] = $row['month_name']; |
1134 | 1134 | $temp_array['year_name'] = $row['year_name']; |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | $datetime = new DateTime(); |
1158 | 1158 | $offset = $datetime->format('P'); |
1159 | 1159 | } else $offset = '+00:00'; |
1160 | - $filter_query = $this->getFilter($filters,true,true); |
|
1160 | + $filter_query = $this->getFilter($filters, true, true); |
|
1161 | 1161 | if ($globalDBdriver == 'mysql') { |
1162 | 1162 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
1163 | 1163 | FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | $date_array = array(); |
1179 | 1179 | $temp_array = array(); |
1180 | 1180 | |
1181 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1181 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1182 | 1182 | { |
1183 | 1183 | $temp_array['year_name'] = $row['year_name']; |
1184 | 1184 | $temp_array['month_name'] = $row['month_name']; |
@@ -1198,7 +1198,7 @@ discard block |
||
1198 | 1198 | * @return Array the hour list |
1199 | 1199 | * |
1200 | 1200 | */ |
1201 | - public function countAllHours($orderby,$filters = array()) |
|
1201 | + public function countAllHours($orderby, $filters = array()) |
|
1202 | 1202 | { |
1203 | 1203 | global $globalTimezone, $globalDBdriver; |
1204 | 1204 | if ($globalTimezone != '') { |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | $hour_array = array(); |
1247 | 1247 | $temp_array = array(); |
1248 | 1248 | |
1249 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1249 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1250 | 1250 | { |
1251 | 1251 | $temp_array['hour_name'] = $row['hour_name']; |
1252 | 1252 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1268,8 +1268,8 @@ discard block |
||
1268 | 1268 | public function countAllHoursByDate($date, $filters = array()) |
1269 | 1269 | { |
1270 | 1270 | global $globalTimezone, $globalDBdriver; |
1271 | - $filter_query = $this->getFilter($filters,true,true); |
|
1272 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
1271 | + $filter_query = $this->getFilter($filters, true, true); |
|
1272 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
1273 | 1273 | if ($globalTimezone != '') { |
1274 | 1274 | date_default_timezone_set($globalTimezone); |
1275 | 1275 | $datetime = new DateTime($date); |
@@ -1277,12 +1277,12 @@ discard block |
||
1277 | 1277 | } else $offset = '+00:00'; |
1278 | 1278 | |
1279 | 1279 | if ($globalDBdriver == 'mysql') { |
1280 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1280 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1281 | 1281 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date |
1282 | 1282 | GROUP BY hour_name |
1283 | 1283 | ORDER BY hour_name ASC"; |
1284 | 1284 | } else { |
1285 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1285 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1286 | 1286 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
1287 | 1287 | GROUP BY hour_name |
1288 | 1288 | ORDER BY hour_name ASC"; |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | $hour_array = array(); |
1295 | 1295 | $temp_array = array(); |
1296 | 1296 | |
1297 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1297 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1298 | 1298 | { |
1299 | 1299 | $temp_array['hour_name'] = $row['hour_name']; |
1300 | 1300 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1316,8 +1316,8 @@ discard block |
||
1316 | 1316 | public function countAllHoursByIdent($ident, $filters = array()) |
1317 | 1317 | { |
1318 | 1318 | global $globalTimezone, $globalDBdriver; |
1319 | - $filter_query = $this->getFilter($filters,true,true); |
|
1320 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
1319 | + $filter_query = $this->getFilter($filters, true, true); |
|
1320 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
1321 | 1321 | if ($globalTimezone != '') { |
1322 | 1322 | date_default_timezone_set($globalTimezone); |
1323 | 1323 | $datetime = new DateTime(); |
@@ -1325,12 +1325,12 @@ discard block |
||
1325 | 1325 | } else $offset = '+00:00'; |
1326 | 1326 | |
1327 | 1327 | if ($globalDBdriver == 'mysql') { |
1328 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1328 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1329 | 1329 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1330 | 1330 | GROUP BY hour_name |
1331 | 1331 | ORDER BY hour_name ASC"; |
1332 | 1332 | } else { |
1333 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1333 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1334 | 1334 | FROM marine_output".$filter_query." marine_output.ident = :ident |
1335 | 1335 | GROUP BY hour_name |
1336 | 1336 | ORDER BY hour_name ASC"; |
@@ -1338,12 +1338,12 @@ discard block |
||
1338 | 1338 | |
1339 | 1339 | |
1340 | 1340 | $sth = $this->db->prepare($query); |
1341 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
1341 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
1342 | 1342 | |
1343 | 1343 | $hour_array = array(); |
1344 | 1344 | $temp_array = array(); |
1345 | 1345 | |
1346 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1346 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1347 | 1347 | { |
1348 | 1348 | $temp_array['hour_name'] = $row['hour_name']; |
1349 | 1349 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1362,33 +1362,33 @@ discard block |
||
1362 | 1362 | * @return Integer the number of vessels |
1363 | 1363 | * |
1364 | 1364 | */ |
1365 | - public function countOverallMarine($filters = array(),$year = '',$month = '') |
|
1365 | + public function countOverallMarine($filters = array(), $year = '', $month = '') |
|
1366 | 1366 | { |
1367 | 1367 | global $globalDBdriver; |
1368 | 1368 | //$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output"; |
1369 | - $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1369 | + $queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output"; |
|
1370 | 1370 | $query_values = array(); |
1371 | 1371 | $query = ''; |
1372 | 1372 | if ($year != '') { |
1373 | 1373 | if ($globalDBdriver == 'mysql') { |
1374 | 1374 | $query .= " AND YEAR(marine_output.date) = :year"; |
1375 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1375 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1376 | 1376 | } else { |
1377 | 1377 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1378 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1378 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1379 | 1379 | } |
1380 | 1380 | } |
1381 | 1381 | if ($month != '') { |
1382 | 1382 | if ($globalDBdriver == 'mysql') { |
1383 | 1383 | $query .= " AND MONTH(marine_output.date) = :month"; |
1384 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1384 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1385 | 1385 | } else { |
1386 | 1386 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1387 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1387 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1388 | 1388 | } |
1389 | 1389 | } |
1390 | 1390 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1391 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1392 | 1392 | |
1393 | 1393 | $sth = $this->db->prepare($queryi); |
1394 | 1394 | $sth->execute($query_values); |
@@ -1401,32 +1401,32 @@ discard block |
||
1401 | 1401 | * @return Integer the number of vessels |
1402 | 1402 | * |
1403 | 1403 | */ |
1404 | - public function countOverallMarineTypes($filters = array(),$year = '',$month = '') |
|
1404 | + public function countOverallMarineTypes($filters = array(), $year = '', $month = '') |
|
1405 | 1405 | { |
1406 | 1406 | global $globalDBdriver; |
1407 | - $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1407 | + $queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output"; |
|
1408 | 1408 | $query_values = array(); |
1409 | 1409 | $query = ''; |
1410 | 1410 | if ($year != '') { |
1411 | 1411 | if ($globalDBdriver == 'mysql') { |
1412 | 1412 | $query .= " AND YEAR(marine_output.date) = :year"; |
1413 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1413 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1414 | 1414 | } else { |
1415 | 1415 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1416 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1416 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1417 | 1417 | } |
1418 | 1418 | } |
1419 | 1419 | if ($month != '') { |
1420 | 1420 | if ($globalDBdriver == 'mysql') { |
1421 | 1421 | $query .= " AND MONTH(marine_output.date) = :month"; |
1422 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1422 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1423 | 1423 | } else { |
1424 | 1424 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1425 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1425 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1426 | 1426 | } |
1427 | 1427 | } |
1428 | 1428 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1429 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
1430 | 1430 | |
1431 | 1431 | $sth = $this->db->prepare($queryi); |
1432 | 1432 | $sth->execute($query_values); |
@@ -1443,7 +1443,7 @@ discard block |
||
1443 | 1443 | public function countAllHoursFromToday($filters = array()) |
1444 | 1444 | { |
1445 | 1445 | global $globalTimezone, $globalDBdriver; |
1446 | - $filter_query = $this->getFilter($filters,true,true); |
|
1446 | + $filter_query = $this->getFilter($filters, true, true); |
|
1447 | 1447 | if ($globalTimezone != '') { |
1448 | 1448 | date_default_timezone_set($globalTimezone); |
1449 | 1449 | $datetime = new DateTime(); |
@@ -1451,12 +1451,12 @@ discard block |
||
1451 | 1451 | } else $offset = '+00:00'; |
1452 | 1452 | |
1453 | 1453 | if ($globalDBdriver == 'mysql') { |
1454 | - $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1454 | + $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
1455 | 1455 | FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE() |
1456 | 1456 | GROUP BY hour_name |
1457 | 1457 | ORDER BY hour_name ASC"; |
1458 | 1458 | } else { |
1459 | - $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1459 | + $query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
1460 | 1460 | FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
1461 | 1461 | GROUP BY hour_name |
1462 | 1462 | ORDER BY hour_name ASC"; |
@@ -1468,7 +1468,7 @@ discard block |
||
1468 | 1468 | $hour_array = array(); |
1469 | 1469 | $temp_array = array(); |
1470 | 1470 | |
1471 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1471 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1472 | 1472 | { |
1473 | 1473 | $temp_array['hour_name'] = $row['hour_name']; |
1474 | 1474 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -1487,9 +1487,9 @@ discard block |
||
1487 | 1487 | */ |
1488 | 1488 | public function getMarineIDBasedOnFamMarineID($fammarine_id) |
1489 | 1489 | { |
1490 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
1490 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
1491 | 1491 | |
1492 | - $query = "SELECT marine_output.marine_id |
|
1492 | + $query = "SELECT marine_output.marine_id |
|
1493 | 1493 | FROM marine_output |
1494 | 1494 | WHERE marine_output.fammarine_id = '".$fammarine_id."'"; |
1495 | 1495 | |
@@ -1497,7 +1497,7 @@ discard block |
||
1497 | 1497 | $sth = $this->db->prepare($query); |
1498 | 1498 | $sth->execute(); |
1499 | 1499 | |
1500 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1500 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1501 | 1501 | { |
1502 | 1502 | return $row['marine_id']; |
1503 | 1503 | } |
@@ -1522,23 +1522,23 @@ discard block |
||
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | $current_date = date("Y-m-d H:i:s"); |
1525 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
1525 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
1526 | 1526 | |
1527 | 1527 | $diff = abs(strtotime($current_date) - strtotime($date)); |
1528 | 1528 | |
1529 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
1529 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
1530 | 1530 | $years = $time_array['years']; |
1531 | 1531 | |
1532 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
1532 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
1533 | 1533 | $months = $time_array['months']; |
1534 | 1534 | |
1535 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
1535 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
1536 | 1536 | $days = $time_array['days']; |
1537 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
1537 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
1538 | 1538 | $hours = $time_array['hours']; |
1539 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
1539 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
1540 | 1540 | $minutes = $time_array['minutes']; |
1541 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1541 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
1542 | 1542 | |
1543 | 1543 | return $time_array; |
1544 | 1544 | } |
@@ -1561,63 +1561,63 @@ discard block |
||
1561 | 1561 | $temp_array['direction_degree'] = $direction; |
1562 | 1562 | $temp_array['direction_shortname'] = "N"; |
1563 | 1563 | $temp_array['direction_fullname'] = "North"; |
1564 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
1564 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
1565 | 1565 | $temp_array['direction_degree'] = $direction; |
1566 | 1566 | $temp_array['direction_shortname'] = "NNE"; |
1567 | 1567 | $temp_array['direction_fullname'] = "North-Northeast"; |
1568 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
1568 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
1569 | 1569 | $temp_array['direction_degree'] = $direction; |
1570 | 1570 | $temp_array['direction_shortname'] = "NE"; |
1571 | 1571 | $temp_array['direction_fullname'] = "Northeast"; |
1572 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
1572 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
1573 | 1573 | $temp_array['direction_degree'] = $direction; |
1574 | 1574 | $temp_array['direction_shortname'] = "ENE"; |
1575 | 1575 | $temp_array['direction_fullname'] = "East-Northeast"; |
1576 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
1576 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
1577 | 1577 | $temp_array['direction_degree'] = $direction; |
1578 | 1578 | $temp_array['direction_shortname'] = "E"; |
1579 | 1579 | $temp_array['direction_fullname'] = "East"; |
1580 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
1580 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
1581 | 1581 | $temp_array['direction_degree'] = $direction; |
1582 | 1582 | $temp_array['direction_shortname'] = "ESE"; |
1583 | 1583 | $temp_array['direction_fullname'] = "East-Southeast"; |
1584 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
1584 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
1585 | 1585 | $temp_array['direction_degree'] = $direction; |
1586 | 1586 | $temp_array['direction_shortname'] = "SE"; |
1587 | 1587 | $temp_array['direction_fullname'] = "Southeast"; |
1588 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
1588 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
1589 | 1589 | $temp_array['direction_degree'] = $direction; |
1590 | 1590 | $temp_array['direction_shortname'] = "SSE"; |
1591 | 1591 | $temp_array['direction_fullname'] = "South-Southeast"; |
1592 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
1592 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
1593 | 1593 | $temp_array['direction_degree'] = $direction; |
1594 | 1594 | $temp_array['direction_shortname'] = "S"; |
1595 | 1595 | $temp_array['direction_fullname'] = "South"; |
1596 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
1596 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
1597 | 1597 | $temp_array['direction_degree'] = $direction; |
1598 | 1598 | $temp_array['direction_shortname'] = "SSW"; |
1599 | 1599 | $temp_array['direction_fullname'] = "South-Southwest"; |
1600 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
1600 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
1601 | 1601 | $temp_array['direction_degree'] = $direction; |
1602 | 1602 | $temp_array['direction_shortname'] = "SW"; |
1603 | 1603 | $temp_array['direction_fullname'] = "Southwest"; |
1604 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
1604 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
1605 | 1605 | $temp_array['direction_degree'] = $direction; |
1606 | 1606 | $temp_array['direction_shortname'] = "WSW"; |
1607 | 1607 | $temp_array['direction_fullname'] = "West-Southwest"; |
1608 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
1608 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
1609 | 1609 | $temp_array['direction_degree'] = $direction; |
1610 | 1610 | $temp_array['direction_shortname'] = "W"; |
1611 | 1611 | $temp_array['direction_fullname'] = "West"; |
1612 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
1612 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
1613 | 1613 | $temp_array['direction_degree'] = $direction; |
1614 | 1614 | $temp_array['direction_shortname'] = "WNW"; |
1615 | 1615 | $temp_array['direction_fullname'] = "West-Northwest"; |
1616 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
1616 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
1617 | 1617 | $temp_array['direction_degree'] = $direction; |
1618 | 1618 | $temp_array['direction_shortname'] = "NW"; |
1619 | 1619 | $temp_array['direction_fullname'] = "Northwest"; |
1620 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
1620 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
1621 | 1621 | $temp_array['direction_degree'] = $direction; |
1622 | 1622 | $temp_array['direction_shortname'] = "NNW"; |
1623 | 1623 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -1634,11 +1634,11 @@ discard block |
||
1634 | 1634 | * @param Float $longitude longitute of the flight |
1635 | 1635 | * @return String the countrie |
1636 | 1636 | */ |
1637 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
1637 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
1638 | 1638 | { |
1639 | 1639 | global $globalDBdriver, $globalDebug; |
1640 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
1640 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1641 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
1642 | 1642 | |
1643 | 1643 | $Connection = new Connection($this->db); |
1644 | 1644 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1678,7 +1678,7 @@ discard block |
||
1678 | 1678 | public function getCountryFromISO2($iso2) |
1679 | 1679 | { |
1680 | 1680 | global $globalDBdriver, $globalDebug; |
1681 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
1681 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
1682 | 1682 | |
1683 | 1683 | $Connection = new Connection($this->db); |
1684 | 1684 | if (!$Connection->tableExists('countries')) return ''; |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | |
1727 | 1727 | $bitly_data = json_decode($bitly_data); |
1728 | 1728 | $bitly_url = ''; |
1729 | - if ($bitly_data->status_txt = "OK"){ |
|
1729 | + if ($bitly_data->status_txt = "OK") { |
|
1730 | 1730 | $bitly_url = $bitly_data->data->url; |
1731 | 1731 | } |
1732 | 1732 | |
@@ -1740,11 +1740,11 @@ discard block |
||
1740 | 1740 | * @return Array the vessel type list |
1741 | 1741 | * |
1742 | 1742 | */ |
1743 | - public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
1743 | + public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
1744 | 1744 | { |
1745 | 1745 | global $globalDBdriver; |
1746 | - $filter_query = $this->getFilter($filters,true,true); |
|
1747 | - $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1746 | + $filter_query = $this->getFilter($filters, true, true); |
|
1747 | + $query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count |
|
1748 | 1748 | FROM marine_output ".$filter_query." marine_output.type <> ''"; |
1749 | 1749 | if ($olderthanmonths > 0) { |
1750 | 1750 | if ($globalDBdriver == 'mysql') { |
@@ -1764,28 +1764,28 @@ discard block |
||
1764 | 1764 | if ($year != '') { |
1765 | 1765 | if ($globalDBdriver == 'mysql') { |
1766 | 1766 | $query .= " AND YEAR(marine_output.date) = :year"; |
1767 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1767 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1768 | 1768 | } else { |
1769 | 1769 | $query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year"; |
1770 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
1770 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
1771 | 1771 | } |
1772 | 1772 | } |
1773 | 1773 | if ($month != '') { |
1774 | 1774 | if ($globalDBdriver == 'mysql') { |
1775 | 1775 | $query .= " AND MONTH(marine_output.date) = :month"; |
1776 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1776 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1777 | 1777 | } else { |
1778 | 1778 | $query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month"; |
1779 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
1779 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
1780 | 1780 | } |
1781 | 1781 | } |
1782 | 1782 | if ($day != '') { |
1783 | 1783 | if ($globalDBdriver == 'mysql') { |
1784 | 1784 | $query .= " AND DAY(marine_output.date) = :day"; |
1785 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1785 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1786 | 1786 | } else { |
1787 | 1787 | $query .= " AND EXTRACT(DAY FROM marine_output.date) = :day"; |
1788 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
1788 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
1789 | 1789 | } |
1790 | 1790 | } |
1791 | 1791 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | $sth->execute($query_values); |
1795 | 1795 | $marine_array = array(); |
1796 | 1796 | $temp_array = array(); |
1797 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1797 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1798 | 1798 | { |
1799 | 1799 | $temp_array['marine_type'] = $row['marine_type']; |
1800 | 1800 | $temp_array['marine_type_count'] = $row['marine_type_count']; |
@@ -1805,7 +1805,7 @@ discard block |
||
1805 | 1805 | |
1806 | 1806 | public function getOrderBy() |
1807 | 1807 | { |
1808 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC")); |
|
1808 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC")); |
|
1809 | 1809 | |
1810 | 1810 | return $orderby; |
1811 | 1811 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (Marine)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (Marine)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | /** |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -69,8 +73,11 @@ discard block |
||
69 | 73 | $filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
70 | 74 | } |
71 | 75 | } |
72 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
73 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
76 | + if ($filter_query_where == '' && $where) { |
|
77 | + $filter_query_where = ' WHERE'; |
|
78 | + } elseif ($filter_query_where != '' && $and) { |
|
79 | + $filter_query_where .= ' AND'; |
|
80 | + } |
|
74 | 81 | if ($filter_query_where != '') { |
75 | 82 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
76 | 83 | } |
@@ -124,32 +131,54 @@ discard block |
||
124 | 131 | $temp_array['spotter_id'] = $row['spotter_archive_id']; |
125 | 132 | } elseif (isset($row['spotter_archive_output_id'])) { |
126 | 133 | $temp_array['spotter_id'] = $row['spotter_archive_output_id']; |
127 | - */} |
|
128 | - elseif (isset($row['marineid'])) { |
|
134 | + */} elseif (isset($row['marineid'])) { |
|
129 | 135 | $temp_array['marine_id'] = $row['marineid']; |
130 | 136 | } else { |
131 | 137 | $temp_array['marine_id'] = ''; |
132 | 138 | } |
133 | - if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
134 | - if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi']; |
|
135 | - if (isset($row['type'])) $temp_array['type'] = $row['type']; |
|
136 | - if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id']; |
|
137 | - if (isset($row['ident'])) $temp_array['ident'] = $row['ident']; |
|
138 | - if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude']; |
|
139 | - if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude']; |
|
140 | - if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
|
139 | + if (isset($row['fammarine_id'])) { |
|
140 | + $temp_array['fammarine_id'] = $row['fammarine_id']; |
|
141 | + } |
|
142 | + if (isset($row['mmsi'])) { |
|
143 | + $temp_array['mmsi'] = $row['mmsi']; |
|
144 | + } |
|
145 | + if (isset($row['type'])) { |
|
146 | + $temp_array['type'] = $row['type']; |
|
147 | + } |
|
148 | + if (isset($row['type_id'])) { |
|
149 | + $temp_array['type_id'] = $row['type_id']; |
|
150 | + } |
|
151 | + if (isset($row['ident'])) { |
|
152 | + $temp_array['ident'] = $row['ident']; |
|
153 | + } |
|
154 | + if (isset($row['latitude'])) { |
|
155 | + $temp_array['latitude'] = $row['latitude']; |
|
156 | + } |
|
157 | + if (isset($row['longitude'])) { |
|
158 | + $temp_array['longitude'] = $row['longitude']; |
|
159 | + } |
|
160 | + if (isset($row['format_source'])) { |
|
161 | + $temp_array['format_source'] = $row['format_source']; |
|
162 | + } |
|
141 | 163 | if (isset($row['heading'])) { |
142 | 164 | $temp_array['heading'] = $row['heading']; |
143 | 165 | $heading_direction = $this->parseDirection($row['heading']); |
144 | - if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
166 | + if (isset($heading_direction[0]['direction_fullname'])) { |
|
167 | + $temp_array['heading_name'] = $heading_direction[0]['direction_fullname']; |
|
168 | + } |
|
169 | + } |
|
170 | + if (isset($row['ground_speed'])) { |
|
171 | + $temp_array['ground_speed'] = $row['ground_speed']; |
|
145 | 172 | } |
146 | - if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed']; |
|
147 | 173 | |
148 | 174 | if($temp_array['mmsi'] != "") |
149 | 175 | { |
150 | 176 | $Image = new Image($this->db); |
151 | - if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
152 | - else $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
177 | + if (isset($temp_array['ident']) && $temp_array['ident'] != '') { |
|
178 | + $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']); |
|
179 | + } else { |
|
180 | + $image_array = $Image->getMarineImage($temp_array['mmsi']); |
|
181 | + } |
|
153 | 182 | unset($Image); |
154 | 183 | if (count($image_array) > 0) { |
155 | 184 | $temp_array['image'] = $image_array[0]['image']; |
@@ -201,13 +230,21 @@ discard block |
||
201 | 230 | } |
202 | 231 | |
203 | 232 | $fromsource = NULL; |
204 | - if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name']; |
|
205 | - if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country']; |
|
206 | - if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance']; |
|
233 | + if (isset($row['source_name']) && $row['source_name'] != '') { |
|
234 | + $temp_array['source_name'] = $row['source_name']; |
|
235 | + } |
|
236 | + if (isset($row['over_country']) && $row['over_country'] != '') { |
|
237 | + $temp_array['over_country'] = $row['over_country']; |
|
238 | + } |
|
239 | + if (isset($row['distance']) && $row['distance'] != '') { |
|
240 | + $temp_array['distance'] = $row['distance']; |
|
241 | + } |
|
207 | 242 | $temp_array['query_number_rows'] = $num_rows; |
208 | 243 | $spotter_array[] = $temp_array; |
209 | 244 | } |
210 | - if ($num_rows == 0) return array(); |
|
245 | + if ($num_rows == 0) { |
|
246 | + return array(); |
|
247 | + } |
|
211 | 248 | $spotter_array[0]['query_number_rows'] = $num_rows; |
212 | 249 | return $spotter_array; |
213 | 250 | } |
@@ -233,8 +270,12 @@ discard block |
||
233 | 270 | { |
234 | 271 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
235 | 272 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
236 | - } else $limit_query = ""; |
|
237 | - } else $limit_query = ""; |
|
273 | + } else { |
|
274 | + $limit_query = ""; |
|
275 | + } |
|
276 | + } else { |
|
277 | + $limit_query = ""; |
|
278 | + } |
|
238 | 279 | if ($sort != "") |
239 | 280 | { |
240 | 281 | $search_orderby_array = $this->getOrderBy(); |
@@ -258,7 +299,9 @@ discard block |
||
258 | 299 | global $global_query; |
259 | 300 | |
260 | 301 | date_default_timezone_set('UTC'); |
261 | - if ($id == '') return array(); |
|
302 | + if ($id == '') { |
|
303 | + return array(); |
|
304 | + } |
|
262 | 305 | $additional_query = "marine_output.fammarine_id = :id"; |
263 | 306 | $query_values = array(':id' => $id); |
264 | 307 | $query = $global_query." WHERE ".$additional_query." "; |
@@ -401,8 +444,11 @@ discard block |
||
401 | 444 | $query .= " ORDER BY marine_output.source_name ASC"; |
402 | 445 | |
403 | 446 | $sth = $this->db->prepare($query); |
404 | - if (!empty($query_values)) $sth->execute($query_values); |
|
405 | - else $sth->execute(); |
|
447 | + if (!empty($query_values)) { |
|
448 | + $sth->execute($query_values); |
|
449 | + } else { |
|
450 | + $sth->execute(); |
|
451 | + } |
|
406 | 452 | |
407 | 453 | $source_array = array(); |
408 | 454 | $temp_array = array(); |
@@ -457,8 +503,11 @@ discard block |
||
457 | 503 | $sth = $this->db->prepare($query); |
458 | 504 | $sth->execute(array(':mmsi' => $mmsi)); |
459 | 505 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
460 | - if (isset($result[0])) return $result[0]; |
|
461 | - else return array(); |
|
506 | + if (isset($result[0])) { |
|
507 | + return $result[0]; |
|
508 | + } else { |
|
509 | + return array(); |
|
510 | + } |
|
462 | 511 | } |
463 | 512 | |
464 | 513 | /* |
@@ -474,7 +523,9 @@ discard block |
||
474 | 523 | date_default_timezone_set($globalTimezone); |
475 | 524 | $datetime = new DateTime(); |
476 | 525 | $offset = $datetime->format('P'); |
477 | - } else $offset = '+00:00'; |
|
526 | + } else { |
|
527 | + $offset = '+00:00'; |
|
528 | + } |
|
478 | 529 | |
479 | 530 | if ($globalDBdriver == 'mysql') { |
480 | 531 | $query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date |
@@ -704,9 +755,15 @@ discard block |
||
704 | 755 | $latitude = 0; |
705 | 756 | $longitude = 0; |
706 | 757 | } |
707 | - if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
708 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
709 | - if ($arrival_date == '') $arrival_date = NULL; |
|
758 | + if ($heading == '' || $Common->isInteger($heading) === false) { |
|
759 | + $heading = 0; |
|
760 | + } |
|
761 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) { |
|
762 | + $groundspeed = 0; |
|
763 | + } |
|
764 | + if ($arrival_date == '') { |
|
765 | + $arrival_date = NULL; |
|
766 | + } |
|
710 | 767 | $query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) |
711 | 768 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)"; |
712 | 769 | |
@@ -814,7 +871,9 @@ discard block |
||
814 | 871 | global $globalDBdriver, $globalArchive; |
815 | 872 | //$filter_query = $this->getFilter($filters,true,true); |
816 | 873 | $Connection= new Connection($this->db); |
817 | - if (!$Connection->tableExists('countries')) return array(); |
|
874 | + if (!$Connection->tableExists('countries')) { |
|
875 | + return array(); |
|
876 | + } |
|
818 | 877 | require_once('class.SpotterLive.php'); |
819 | 878 | if (!isset($globalArchive) || $globalArchive !== TRUE) { |
820 | 879 | $MarineLive = new MarineLive($this->db); |
@@ -858,7 +917,9 @@ discard block |
||
858 | 917 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country "; |
859 | 918 | } |
860 | 919 | $query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC"; |
861 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
920 | + if ($limit) { |
|
921 | + $query .= " LIMIT 10 OFFSET 0"; |
|
922 | + } |
|
862 | 923 | |
863 | 924 | $sth = $this->db->prepare($query); |
864 | 925 | $sth->execute(); |
@@ -892,12 +953,18 @@ discard block |
||
892 | 953 | $query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count |
893 | 954 | FROM marine_output".$filter_query." marine_output.ident <> ''"; |
894 | 955 | if ($olderthanmonths > 0) { |
895 | - if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
896 | - else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
956 | + if ($globalDBdriver == 'mysql') { |
|
957 | + $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
|
958 | + } else { |
|
959 | + $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
|
960 | + } |
|
897 | 961 | } |
898 | 962 | if ($sincedate != '') { |
899 | - if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'"; |
|
900 | - else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
963 | + if ($globalDBdriver == 'mysql') { |
|
964 | + $query .= " AND marine_output.date > '".$sincedate."'"; |
|
965 | + } else { |
|
966 | + $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)"; |
|
967 | + } |
|
901 | 968 | } |
902 | 969 | $query_values = array(); |
903 | 970 | if ($year != '') { |
@@ -928,7 +995,9 @@ discard block |
||
928 | 995 | } |
929 | 996 | } |
930 | 997 | $query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC"; |
931 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
998 | + if ($limit) { |
|
999 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1000 | + } |
|
932 | 1001 | |
933 | 1002 | $sth = $this->db->prepare($query); |
934 | 1003 | $sth->execute($query_values); |
@@ -963,7 +1032,9 @@ discard block |
||
963 | 1032 | date_default_timezone_set($globalTimezone); |
964 | 1033 | $datetime = new DateTime(); |
965 | 1034 | $offset = $datetime->format('P'); |
966 | - } else $offset = '+00:00'; |
|
1035 | + } else { |
|
1036 | + $offset = '+00:00'; |
|
1037 | + } |
|
967 | 1038 | |
968 | 1039 | if ($globalDBdriver == 'mysql') { |
969 | 1040 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1013,7 +1084,9 @@ discard block |
||
1013 | 1084 | date_default_timezone_set($globalTimezone); |
1014 | 1085 | $datetime = new DateTime(); |
1015 | 1086 | $offset = $datetime->format('P'); |
1016 | - } else $offset = '+00:00'; |
|
1087 | + } else { |
|
1088 | + $offset = '+00:00'; |
|
1089 | + } |
|
1017 | 1090 | $filter_query = $this->getFilter($filters,true,true); |
1018 | 1091 | if ($globalDBdriver == 'mysql') { |
1019 | 1092 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1059,7 +1132,9 @@ discard block |
||
1059 | 1132 | date_default_timezone_set($globalTimezone); |
1060 | 1133 | $datetime = new DateTime(); |
1061 | 1134 | $offset = $datetime->format('P'); |
1062 | - } else $offset = '+00:00'; |
|
1135 | + } else { |
|
1136 | + $offset = '+00:00'; |
|
1137 | + } |
|
1063 | 1138 | $filter_query = $this->getFilter($filters,true,true); |
1064 | 1139 | if ($globalDBdriver == 'mysql') { |
1065 | 1140 | $query = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
@@ -1107,7 +1182,9 @@ discard block |
||
1107 | 1182 | date_default_timezone_set($globalTimezone); |
1108 | 1183 | $datetime = new DateTime(); |
1109 | 1184 | $offset = $datetime->format('P'); |
1110 | - } else $offset = '+00:00'; |
|
1185 | + } else { |
|
1186 | + $offset = '+00:00'; |
|
1187 | + } |
|
1111 | 1188 | |
1112 | 1189 | if ($globalDBdriver == 'mysql') { |
1113 | 1190 | $query = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
@@ -1156,7 +1233,9 @@ discard block |
||
1156 | 1233 | date_default_timezone_set($globalTimezone); |
1157 | 1234 | $datetime = new DateTime(); |
1158 | 1235 | $offset = $datetime->format('P'); |
1159 | - } else $offset = '+00:00'; |
|
1236 | + } else { |
|
1237 | + $offset = '+00:00'; |
|
1238 | + } |
|
1160 | 1239 | $filter_query = $this->getFilter($filters,true,true); |
1161 | 1240 | if ($globalDBdriver == 'mysql') { |
1162 | 1241 | $query = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
@@ -1205,7 +1284,9 @@ discard block |
||
1205 | 1284 | date_default_timezone_set($globalTimezone); |
1206 | 1285 | $datetime = new DateTime(); |
1207 | 1286 | $offset = $datetime->format('P'); |
1208 | - } else $offset = '+00:00'; |
|
1287 | + } else { |
|
1288 | + $offset = '+00:00'; |
|
1289 | + } |
|
1209 | 1290 | |
1210 | 1291 | $orderby_sql = ''; |
1211 | 1292 | if ($orderby == "hour") |
@@ -1274,7 +1355,9 @@ discard block |
||
1274 | 1355 | date_default_timezone_set($globalTimezone); |
1275 | 1356 | $datetime = new DateTime($date); |
1276 | 1357 | $offset = $datetime->format('P'); |
1277 | - } else $offset = '+00:00'; |
|
1358 | + } else { |
|
1359 | + $offset = '+00:00'; |
|
1360 | + } |
|
1278 | 1361 | |
1279 | 1362 | if ($globalDBdriver == 'mysql') { |
1280 | 1363 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1322,7 +1405,9 @@ discard block |
||
1322 | 1405 | date_default_timezone_set($globalTimezone); |
1323 | 1406 | $datetime = new DateTime(); |
1324 | 1407 | $offset = $datetime->format('P'); |
1325 | - } else $offset = '+00:00'; |
|
1408 | + } else { |
|
1409 | + $offset = '+00:00'; |
|
1410 | + } |
|
1326 | 1411 | |
1327 | 1412 | if ($globalDBdriver == 'mysql') { |
1328 | 1413 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1387,8 +1472,11 @@ discard block |
||
1387 | 1472 | $query_values = array_merge($query_values,array(':month' => $month)); |
1388 | 1473 | } |
1389 | 1474 | } |
1390 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1391 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1475 | + if (empty($query_values)) { |
|
1476 | + $queryi .= $this->getFilter($filters); |
|
1477 | + } else { |
|
1478 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1479 | + } |
|
1392 | 1480 | |
1393 | 1481 | $sth = $this->db->prepare($queryi); |
1394 | 1482 | $sth->execute($query_values); |
@@ -1425,8 +1513,11 @@ discard block |
||
1425 | 1513 | $query_values = array_merge($query_values,array(':month' => $month)); |
1426 | 1514 | } |
1427 | 1515 | } |
1428 | - if (empty($query_values)) $queryi .= $this->getFilter($filters); |
|
1429 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1516 | + if (empty($query_values)) { |
|
1517 | + $queryi .= $this->getFilter($filters); |
|
1518 | + } else { |
|
1519 | + $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
1520 | + } |
|
1430 | 1521 | |
1431 | 1522 | $sth = $this->db->prepare($queryi); |
1432 | 1523 | $sth->execute($query_values); |
@@ -1448,7 +1539,9 @@ discard block |
||
1448 | 1539 | date_default_timezone_set($globalTimezone); |
1449 | 1540 | $datetime = new DateTime(); |
1450 | 1541 | $offset = $datetime->format('P'); |
1451 | - } else $offset = '+00:00'; |
|
1542 | + } else { |
|
1543 | + $offset = '+00:00'; |
|
1544 | + } |
|
1452 | 1545 | |
1453 | 1546 | if ($globalDBdriver == 'mysql') { |
1454 | 1547 | $query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
@@ -1552,7 +1645,9 @@ discard block |
||
1552 | 1645 | */ |
1553 | 1646 | public function parseDirection($direction = 0) |
1554 | 1647 | { |
1555 | - if ($direction == '') $direction = 0; |
|
1648 | + if ($direction == '') { |
|
1649 | + $direction = 0; |
|
1650 | + } |
|
1556 | 1651 | $direction_array = array(); |
1557 | 1652 | $temp_array = array(); |
1558 | 1653 | |
@@ -1641,7 +1736,9 @@ discard block |
||
1641 | 1736 | $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
1642 | 1737 | |
1643 | 1738 | $Connection = new Connection($this->db); |
1644 | - if (!$Connection->tableExists('countries')) return ''; |
|
1739 | + if (!$Connection->tableExists('countries')) { |
|
1740 | + return ''; |
|
1741 | + } |
|
1645 | 1742 | |
1646 | 1743 | try { |
1647 | 1744 | /* |
@@ -1661,9 +1758,13 @@ discard block |
||
1661 | 1758 | $sth->closeCursor(); |
1662 | 1759 | if (count($row) > 0) { |
1663 | 1760 | return $row; |
1664 | - } else return ''; |
|
1761 | + } else { |
|
1762 | + return ''; |
|
1763 | + } |
|
1665 | 1764 | } catch (PDOException $e) { |
1666 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1765 | + if (isset($globalDebug) && $globalDebug) { |
|
1766 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1767 | + } |
|
1667 | 1768 | return ''; |
1668 | 1769 | } |
1669 | 1770 | |
@@ -1681,7 +1782,9 @@ discard block |
||
1681 | 1782 | $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
1682 | 1783 | |
1683 | 1784 | $Connection = new Connection($this->db); |
1684 | - if (!$Connection->tableExists('countries')) return ''; |
|
1785 | + if (!$Connection->tableExists('countries')) { |
|
1786 | + return ''; |
|
1787 | + } |
|
1685 | 1788 | |
1686 | 1789 | try { |
1687 | 1790 | $query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1"; |
@@ -1693,9 +1796,13 @@ discard block |
||
1693 | 1796 | $sth->closeCursor(); |
1694 | 1797 | if (count($row) > 0) { |
1695 | 1798 | return $row; |
1696 | - } else return ''; |
|
1799 | + } else { |
|
1800 | + return ''; |
|
1801 | + } |
|
1697 | 1802 | } catch (PDOException $e) { |
1698 | - if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n"; |
|
1803 | + if (isset($globalDebug) && $globalDebug) { |
|
1804 | + echo 'Error : '.$e->getMessage()."\n"; |
|
1805 | + } |
|
1699 | 1806 | return ''; |
1700 | 1807 | } |
1701 | 1808 | |
@@ -1713,7 +1820,9 @@ discard block |
||
1713 | 1820 | { |
1714 | 1821 | global $globalBitlyAccessToken; |
1715 | 1822 | |
1716 | - if ($globalBitlyAccessToken == '') return $url; |
|
1823 | + if ($globalBitlyAccessToken == '') { |
|
1824 | + return $url; |
|
1825 | + } |
|
1717 | 1826 | |
1718 | 1827 | $google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url; |
1719 | 1828 | |
@@ -1789,7 +1898,9 @@ discard block |
||
1789 | 1898 | } |
1790 | 1899 | } |
1791 | 1900 | $query .= " GROUP BY marine_output.type ORDER BY marine_type_count DESC"; |
1792 | - if ($limit) $query .= " LIMIT 10 OFFSET 0"; |
|
1901 | + if ($limit) { |
|
1902 | + $query .= " LIMIT 10 OFFSET 0"; |
|
1903 | + } |
|
1793 | 1904 | $sth = $this->db->prepare($query); |
1794 | 1905 | $sth->execute($query_values); |
1795 | 1906 | $marine_array = array(); |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -794,10 +794,6 @@ discard block |
||
794 | 794 | * |
795 | 795 | * @param String $fammarine_id the ID from flightaware |
796 | 796 | * @param String $ident the flight ident |
797 | - * @param String $aircraft_icao the aircraft type |
|
798 | - * @param String $departure_airport_icao the departure airport |
|
799 | - * @param String $arrival_airport_icao the arrival airport |
|
800 | - * @return String success or false |
|
801 | 797 | * |
802 | 798 | */ |
803 | 799 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Gets Minimal Live Spotter data |
|
138 | - * |
|
139 | - * @return Array the spotter information |
|
140 | - * |
|
141 | - */ |
|
137 | + * Gets Minimal Live Spotter data |
|
138 | + * |
|
139 | + * @return Array the spotter information |
|
140 | + * |
|
141 | + */ |
|
142 | 142 | public function getMinLiveMarineData($filter = array()) |
143 | 143 | { |
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | - * Gets Minimal Live Spotter data since xx seconds |
|
172 | - * |
|
173 | - * @return Array the spotter information |
|
174 | - * |
|
175 | - */ |
|
171 | + * Gets Minimal Live Spotter data since xx seconds |
|
172 | + * |
|
173 | + * @return Array the spotter information |
|
174 | + * |
|
175 | + */ |
|
176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Gets number of latest data entry |
|
247 | - * |
|
248 | - * @return String number of entry |
|
249 | - * |
|
250 | - */ |
|
246 | + * Gets number of latest data entry |
|
247 | + * |
|
248 | + * @return String number of entry |
|
249 | + * |
|
250 | + */ |
|
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Gets all the spotter information based on the latest data entry and coord |
|
276 | - * |
|
277 | - * @return Array the spotter information |
|
278 | - * |
|
279 | - */ |
|
275 | + * Gets all the spotter information based on the latest data entry and coord |
|
276 | + * |
|
277 | + * @return Array the spotter information |
|
278 | + * |
|
279 | + */ |
|
280 | 280 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
281 | 281 | { |
282 | 282 | global $globalDBdriver, $globalLiveInterval; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Gets all the spotter information based on the latest data entry and coord |
|
304 | - * |
|
305 | - * @return Array the spotter information |
|
306 | - * |
|
307 | - */ |
|
303 | + * Gets all the spotter information based on the latest data entry and coord |
|
304 | + * |
|
305 | + * @return Array the spotter information |
|
306 | + * |
|
307 | + */ |
|
308 | 308 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
309 | 309 | { |
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * Gets all the spotter information based on a user's latitude and longitude |
|
377 | - * |
|
378 | - * @return Array the spotter information |
|
379 | - * |
|
380 | - */ |
|
376 | + * Gets all the spotter information based on a user's latitude and longitude |
|
377 | + * |
|
378 | + * @return Array the spotter information |
|
379 | + * |
|
380 | + */ |
|
381 | 381 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
382 | 382 | { |
383 | 383 | $Marine = new Marine($this->db); |
@@ -390,134 +390,134 @@ discard block |
||
390 | 390 | if ($lng != '') |
391 | 391 | { |
392 | 392 | if (!is_numeric($lng)) |
393 | - { |
|
394 | - return false; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - if ($radius != '') |
|
399 | - { |
|
400 | - if (!is_numeric($radius)) |
|
401 | - { |
|
402 | - return false; |
|
403 | - } |
|
404 | - } |
|
393 | + { |
|
394 | + return false; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + if ($radius != '') |
|
399 | + { |
|
400 | + if (!is_numeric($radius)) |
|
401 | + { |
|
402 | + return false; |
|
403 | + } |
|
404 | + } |
|
405 | 405 | $additional_query = ''; |
406 | 406 | if ($interval != '') |
407 | - { |
|
408 | - if (!is_string($interval)) |
|
409 | - { |
|
410 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | - return false; |
|
412 | - } else { |
|
413 | - if ($interval == '1m') |
|
414 | - { |
|
415 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | - } else if ($interval == '15m'){ |
|
417 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | - } |
|
419 | - } |
|
420 | - } else { |
|
421 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | - } |
|
423 | - |
|
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
407 | + { |
|
408 | + if (!is_string($interval)) |
|
409 | + { |
|
410 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | + return false; |
|
412 | + } else { |
|
413 | + if ($interval == '1m') |
|
414 | + { |
|
415 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | + } else if ($interval == '15m'){ |
|
417 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | + } |
|
419 | + } |
|
420 | + } else { |
|
421 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | + } |
|
423 | + |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
432 | 432 | |
433 | - return $spotter_array; |
|
434 | - } |
|
433 | + return $spotter_array; |
|
434 | + } |
|
435 | 435 | |
436 | 436 | |
437 | - /** |
|
438 | - * Gets all the spotter information based on a particular callsign |
|
439 | - * |
|
440 | - * @return Array the spotter information |
|
441 | - * |
|
442 | - */ |
|
437 | + /** |
|
438 | + * Gets all the spotter information based on a particular callsign |
|
439 | + * |
|
440 | + * @return Array the spotter information |
|
441 | + * |
|
442 | + */ |
|
443 | 443 | public function getLastLiveMarineDataByIdent($ident) |
444 | 444 | { |
445 | 445 | $Marine = new Marine($this->db); |
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | 451 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
455 | 455 | |
456 | - /** |
|
457 | - * Gets all the spotter information based on a particular callsign |
|
458 | - * |
|
459 | - * @return Array the spotter information |
|
460 | - * |
|
461 | - */ |
|
456 | + /** |
|
457 | + * Gets all the spotter information based on a particular callsign |
|
458 | + * |
|
459 | + * @return Array the spotter information |
|
460 | + * |
|
461 | + */ |
|
462 | 462 | public function getDateLiveMarineDataByIdent($ident,$date) |
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
470 | + $date = date('c',$date); |
|
471 | 471 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Gets last spotter information based on a particular callsign |
|
478 | - * |
|
479 | - * @return Array the spotter information |
|
480 | - * |
|
481 | - */ |
|
476 | + /** |
|
477 | + * Gets last spotter information based on a particular callsign |
|
478 | + * |
|
479 | + * @return Array the spotter information |
|
480 | + * |
|
481 | + */ |
|
482 | 482 | public function getLastLiveMarineDataById($id) |
483 | 483 | { |
484 | 484 | $Marine = new Marine($this->db); |
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | 490 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Gets last spotter information based on a particular callsign |
|
497 | - * |
|
498 | - * @return Array the spotter information |
|
499 | - * |
|
500 | - */ |
|
495 | + /** |
|
496 | + * Gets last spotter information based on a particular callsign |
|
497 | + * |
|
498 | + * @return Array the spotter information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getDateLiveMarineDataById($id,$date) |
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c',$date); |
|
509 | 509 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | - /** |
|
516 | - * Gets all the spotter information based on a particular id |
|
517 | - * |
|
518 | - * @return Array the spotter information |
|
519 | - * |
|
520 | - */ |
|
515 | + /** |
|
516 | + * Gets all the spotter information based on a particular id |
|
517 | + * |
|
518 | + * @return Array the spotter information |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | return $spotter_array; |
546 | 546 | } |
547 | 547 | |
548 | - /** |
|
549 | - * Gets all the spotter information based on a particular ident |
|
550 | - * |
|
551 | - * @return Array the spotter information |
|
552 | - * |
|
553 | - */ |
|
548 | + /** |
|
549 | + * Gets all the spotter information based on a particular ident |
|
550 | + * |
|
551 | + * @return Array the spotter information |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function getAllLiveMarineDataByIdent($ident) |
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | 558 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
@@ -570,23 +570,23 @@ discard block |
||
570 | 570 | |
571 | 571 | |
572 | 572 | /** |
573 | - * Deletes all info in the table |
|
574 | - * |
|
575 | - * @return String success or false |
|
576 | - * |
|
577 | - */ |
|
573 | + * Deletes all info in the table |
|
574 | + * |
|
575 | + * @return String success or false |
|
576 | + * |
|
577 | + */ |
|
578 | 578 | public function deleteLiveMarineData() |
579 | 579 | { |
580 | 580 | global $globalDBdriver; |
581 | 581 | if ($globalDBdriver == 'mysql') { |
582 | 582 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
583 | 583 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
584 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
584 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
585 | 585 | } else { |
586 | 586 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
587 | 587 | } |
588 | 588 | |
589 | - try { |
|
589 | + try { |
|
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
@@ -598,18 +598,18 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
601 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | - * |
|
603 | - * @return String success or false |
|
604 | - * |
|
605 | - */ |
|
601 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | + * |
|
603 | + * @return String success or false |
|
604 | + * |
|
605 | + */ |
|
606 | 606 | public function deleteLiveMarineDataNotUpdated() |
607 | 607 | { |
608 | 608 | global $globalDBdriver, $globalDebug; |
609 | 609 | if ($globalDBdriver == 'mysql') { |
610 | 610 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
611 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | - try { |
|
611 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | + try { |
|
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | - $i = 0; |
|
621 | - $j =0; |
|
620 | + $i = 0; |
|
621 | + $j =0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | 623 | foreach($all as $row) |
624 | 624 | { |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | $j++; |
627 | 627 | if ($j == 30) { |
628 | 628 | if ($globalDebug) echo "."; |
629 | - try { |
|
629 | + try { |
|
630 | 630 | |
631 | 631 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
632 | 632 | $sth->execute(); |
633 | 633 | } catch(PDOException $e) { |
634 | 634 | return "error"; |
635 | 635 | } |
636 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | - $j = 0; |
|
636 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | + $j = 0; |
|
638 | 638 | } |
639 | 639 | $query_delete .= "'".$row['fammarine_id']."',"; |
640 | 640 | } |
641 | 641 | if ($i > 0) { |
642 | - try { |
|
642 | + try { |
|
643 | 643 | |
644 | 644 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
645 | 645 | $sth->execute(); |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | return "success"; |
651 | 651 | } elseif ($globalDBdriver == 'pgsql') { |
652 | 652 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
653 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | - try { |
|
653 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
@@ -696,17 +696,17 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | - * Deletes all info in the table for an ident |
|
700 | - * |
|
701 | - * @return String success or false |
|
702 | - * |
|
703 | - */ |
|
699 | + * Deletes all info in the table for an ident |
|
700 | + * |
|
701 | + * @return String success or false |
|
702 | + * |
|
703 | + */ |
|
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | 707 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
708 | 708 | |
709 | - try { |
|
709 | + try { |
|
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
@@ -718,17 +718,17 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
721 | - * Deletes all info in the table for an id |
|
722 | - * |
|
723 | - * @return String success or false |
|
724 | - * |
|
725 | - */ |
|
721 | + * Deletes all info in the table for an id |
|
722 | + * |
|
723 | + * @return String success or false |
|
724 | + * |
|
725 | + */ |
|
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | 729 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
730 | 730 | |
731 | - try { |
|
731 | + try { |
|
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | |
742 | 742 | |
743 | 743 | /** |
744 | - * Gets the aircraft ident within the last hour |
|
745 | - * |
|
746 | - * @return String the ident |
|
747 | - * |
|
748 | - */ |
|
744 | + * Gets the aircraft ident within the last hour |
|
745 | + * |
|
746 | + * @return String the ident |
|
747 | + * |
|
748 | + */ |
|
749 | 749 | public function getIdentFromLastHour($ident) |
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
@@ -771,14 +771,14 @@ discard block |
||
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
773 | 773 | return $ident_result; |
774 | - } |
|
774 | + } |
|
775 | 775 | |
776 | 776 | /** |
777 | - * Check recent aircraft |
|
778 | - * |
|
779 | - * @return String the ident |
|
780 | - * |
|
781 | - */ |
|
777 | + * Check recent aircraft |
|
778 | + * |
|
779 | + * @return String the ident |
|
780 | + * |
|
781 | + */ |
|
782 | 782 | public function checkIdentRecent($ident) |
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
@@ -804,14 +804,14 @@ discard block |
||
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
806 | 806 | return $ident_result; |
807 | - } |
|
807 | + } |
|
808 | 808 | |
809 | 809 | /** |
810 | - * Check recent aircraft by id |
|
811 | - * |
|
812 | - * @return String the ident |
|
813 | - * |
|
814 | - */ |
|
810 | + * Check recent aircraft by id |
|
811 | + * |
|
812 | + * @return String the ident |
|
813 | + * |
|
814 | + */ |
|
815 | 815 | public function checkIdRecent($id) |
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
@@ -837,14 +837,14 @@ discard block |
||
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
839 | 839 | return $ident_result; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | 842 | /** |
843 | - * Check recent aircraft by mmsi |
|
844 | - * |
|
845 | - * @return String the ident |
|
846 | - * |
|
847 | - */ |
|
843 | + * Check recent aircraft by mmsi |
|
844 | + * |
|
845 | + * @return String the ident |
|
846 | + * |
|
847 | + */ |
|
848 | 848 | public function checkMMSIRecent($mmsi) |
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
@@ -870,19 +870,19 @@ discard block |
||
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
872 | 872 | return $ident_result; |
873 | - } |
|
873 | + } |
|
874 | 874 | |
875 | 875 | /** |
876 | - * Adds a new spotter data |
|
877 | - * |
|
878 | - * @param String $fammarine_id the ID from flightaware |
|
879 | - * @param String $ident the flight ident |
|
880 | - * @param String $aircraft_icao the aircraft type |
|
881 | - * @param String $departure_airport_icao the departure airport |
|
882 | - * @param String $arrival_airport_icao the arrival airport |
|
883 | - * @return String success or false |
|
884 | - * |
|
885 | - */ |
|
876 | + * Adds a new spotter data |
|
877 | + * |
|
878 | + * @param String $fammarine_id the ID from flightaware |
|
879 | + * @param String $ident the flight ident |
|
880 | + * @param String $aircraft_icao the aircraft type |
|
881 | + * @param String $departure_airport_icao the departure airport |
|
882 | + * @param String $arrival_airport_icao the arrival airport |
|
883 | + * @return String success or false |
|
884 | + * |
|
885 | + */ |
|
886 | 886 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,10 +953,10 @@ discard block |
||
953 | 953 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
959 | - $query = ''; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | + if ($arrival_date == '') $arrival_date = NULL; |
|
959 | + $query = ''; |
|
960 | 960 | if ($globalArchive) { |
961 | 961 | if ($globalDebug) echo '-- Delete previous data -- '; |
962 | 962 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -17,33 +17,33 @@ discard block |
||
17 | 17 | * @param Array $filter the filter |
18 | 18 | * @return Array the SQL part |
19 | 19 | */ |
20 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
20 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
23 | 23 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
24 | 24 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
25 | 25 | $filters = $globalStatsFilters[$globalFilterName]; |
26 | 26 | } else { |
27 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
27 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | if (isset($filter[0]['source'])) { |
31 | - $filters = array_merge($filters,$filter); |
|
31 | + $filters = array_merge($filters, $filter); |
|
32 | 32 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
33 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
34 | 34 | $filter_query_join = ''; |
35 | 35 | $filter_query_where = ''; |
36 | - foreach($filters as $flt) { |
|
36 | + foreach ($filters as $flt) { |
|
37 | 37 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
38 | 38 | if (isset($flt['source'])) { |
39 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
39 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
40 | 40 | } else { |
41 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
41 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | if (isset($filter['source']) && !empty($filter['source'])) { |
46 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
46 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
47 | 47 | } |
48 | 48 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
49 | 49 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | $filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'"; |
73 | 73 | } |
74 | 74 | } |
75 | - $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
75 | + $filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id"; |
|
76 | 76 | } |
77 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
78 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
79 | 79 | } |
80 | 80 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
81 | 81 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
82 | 82 | if ($filter_query_where != '') { |
83 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
83 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
84 | 84 | } |
85 | 85 | $filter_query = $filter_query_join.$filter_query_where; |
86 | 86 | return $filter_query; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if ($limit != '') |
104 | 104 | { |
105 | 105 | $limit_array = explode(',', $limit); |
106 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
107 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
106 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
107 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
108 | 108 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
109 | 109 | { |
110 | 110 | $limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0]; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 120 | } |
121 | 121 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
122 | + if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC'; |
|
123 | 123 | |
124 | 124 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
125 | 125 | if ($globalDBdriver == 'mysql') { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | $query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query; |
130 | 130 | } |
131 | - $spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true); |
|
131 | + $spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true); |
|
132 | 132 | |
133 | 133 | return $spotter_array; |
134 | 134 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
145 | 145 | date_default_timezone_set('UTC'); |
146 | 146 | |
147 | - $filter_query = $this->getFilter($filter,true,true); |
|
147 | + $filter_query = $this->getFilter($filter, true, true); |
|
148 | 148 | |
149 | 149 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
150 | 150 | if ($globalDBdriver == 'mysql') { |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | try { |
159 | 159 | $sth = $this->db->prepare($query); |
160 | 160 | $sth->execute(); |
161 | - } catch(PDOException $e) { |
|
161 | + } catch (PDOException $e) { |
|
162 | 162 | echo $e->getMessage(); |
163 | 163 | die; |
164 | 164 | } |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | * @return Array the spotter information |
174 | 174 | * |
175 | 175 | */ |
176 | - public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
|
176 | + public function getMinLastLiveMarineData($coord = array(), $filter = array(), $limit = false) |
|
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
179 | 179 | date_default_timezone_set('UTC'); |
180 | 180 | $usecoord = false; |
181 | 181 | if (is_array($coord) && !empty($coord)) { |
182 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
183 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
184 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
185 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
182 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
183 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
184 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
185 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
186 | 186 | $usecoord = true; |
187 | 187 | } |
188 | - $filter_query = $this->getFilter($filter,true,true); |
|
188 | + $filter_query = $this->getFilter($filter, true, true); |
|
189 | 189 | |
190 | 190 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
191 | 191 | if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | try { |
235 | 235 | $sth = $this->db->prepare($query); |
236 | 236 | $sth->execute(); |
237 | - } catch(PDOException $e) { |
|
237 | + } catch (PDOException $e) { |
|
238 | 238 | echo $e->getMessage(); |
239 | 239 | die; |
240 | 240 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
254 | - $filter_query = $this->getFilter($filter,true,true); |
|
254 | + $filter_query = $this->getFilter($filter, true, true); |
|
255 | 255 | |
256 | 256 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
257 | 257 | if ($globalDBdriver == 'mysql') { |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | try { |
263 | 263 | $sth = $this->db->prepare($query); |
264 | 264 | $sth->execute(); |
265 | - } catch(PDOException $e) { |
|
265 | + } catch (PDOException $e) { |
|
266 | 266 | echo $e->getMessage(); |
267 | 267 | die; |
268 | 268 | } |
@@ -285,10 +285,10 @@ discard block |
||
285 | 285 | $filter_query = $this->getFilter($filter); |
286 | 286 | |
287 | 287 | if (is_array($coord)) { |
288 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
289 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
290 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
291 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
288 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
289 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
290 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
291 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
292 | 292 | } else return array(); |
293 | 293 | if ($globalDBdriver == 'mysql') { |
294 | 294 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 311 | $Marine = new Marine($this->db); |
312 | 312 | if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
313 | - $filter_query = $this->getFilter($filter,true,true); |
|
313 | + $filter_query = $this->getFilter($filter, true, true); |
|
314 | 314 | |
315 | 315 | if (is_array($coord)) { |
316 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
317 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
318 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
319 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
316 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
317 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
318 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
319 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
320 | 320 | } else return array(); |
321 | 321 | /* |
322 | 322 | if ($globalDBdriver == 'mysql') { |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | */ |
332 | 332 | if ($globalDBdriver == 'mysql') { |
333 | 333 | if (isset($globalArchive) && $globalArchive === TRUE) { |
334 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
334 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
335 | 335 | FROM marine_live |
336 | 336 | '.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= marine_live.date |
337 | 337 | AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' |
338 | 338 | AND marine_live.latitude <> 0 AND marine_live.longitude <> 0'; |
339 | 339 | } else { |
340 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
340 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
341 | 341 | FROM marine_live |
342 | 342 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
343 | 343 | FROM marine_live l |
@@ -349,14 +349,14 @@ discard block |
||
349 | 349 | } |
350 | 350 | } else { |
351 | 351 | if (isset($globalArchive) && $globalArchive === TRUE) { |
352 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
352 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
353 | 353 | FROM marine_live |
354 | 354 | ".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date |
355 | 355 | AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." |
356 | 356 | AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." |
357 | 357 | AND marine_live.latitude <> '0' AND marine_live.longitude <> '0'"; |
358 | 358 | } else { |
359 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
359 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
|
360 | 360 | FROM marine_live |
361 | 361 | INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate |
362 | 362 | FROM marine_live l |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | if ($interval == '1m') |
414 | 414 | { |
415 | 415 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
416 | - } else if ($interval == '15m'){ |
|
416 | + } else if ($interval == '15m') { |
|
417 | 417 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
418 | 418 | } |
419 | 419 | } |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
422 | 422 | } |
423 | 423 | |
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius)); |
|
432 | 432 | |
433 | 433 | return $spotter_array; |
434 | 434 | } |
@@ -446,9 +446,9 @@ discard block |
||
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
|
451 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true); |
|
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | * @return Array the spotter information |
460 | 460 | * |
461 | 461 | */ |
462 | - public function getDateLiveMarineDataByIdent($ident,$date) |
|
462 | + public function getDateLiveMarineDataByIdent($ident, $date) |
|
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
471 | - $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
470 | + $date = date('c', $date); |
|
471 | + $spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
@@ -485,9 +485,9 @@ discard block |
||
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
|
490 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true); |
|
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
@@ -498,15 +498,15 @@ discard block |
||
498 | 498 | * @return Array the spotter information |
499 | 499 | * |
500 | 500 | */ |
501 | - public function getDateLiveMarineDataById($id,$date) |
|
501 | + public function getDateLiveMarineDataById($id, $date) |
|
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
509 | - $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c', $date); |
|
509 | + $spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true); |
|
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @return Array the spotter information |
519 | 519 | * |
520 | 520 | */ |
521 | - public function getAllLiveMarineDataById($id,$liveinterval = false) |
|
521 | + public function getAllLiveMarineDataById($id, $liveinterval = false) |
|
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
524 | 524 | date_default_timezone_set('UTC'); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | try { |
538 | 538 | $sth = $this->db->prepare($query); |
539 | 539 | $sth->execute(array(':id' => $id)); |
540 | - } catch(PDOException $e) { |
|
540 | + } catch (PDOException $e) { |
|
541 | 541 | echo $e->getMessage(); |
542 | 542 | die; |
543 | 543 | } |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | - $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
558 | + $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
|
559 | 559 | try { |
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
563 | - } catch(PDOException $e) { |
|
563 | + } catch (PDOException $e) { |
|
564 | 564 | echo $e->getMessage(); |
565 | 565 | die; |
566 | 566 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
593 | - } catch(PDOException $e) { |
|
593 | + } catch (PDOException $e) { |
|
594 | 594 | return "error"; |
595 | 595 | } |
596 | 596 | |
@@ -613,14 +613,14 @@ discard block |
||
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
616 | - } catch(PDOException $e) { |
|
616 | + } catch (PDOException $e) { |
|
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | 620 | $i = 0; |
621 | - $j =0; |
|
621 | + $j = 0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | - foreach($all as $row) |
|
623 | + foreach ($all as $row) |
|
624 | 624 | { |
625 | 625 | $i++; |
626 | 626 | $j++; |
@@ -628,9 +628,9 @@ discard block |
||
628 | 628 | if ($globalDebug) echo "."; |
629 | 629 | try { |
630 | 630 | |
631 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
631 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
632 | 632 | $sth->execute(); |
633 | - } catch(PDOException $e) { |
|
633 | + } catch (PDOException $e) { |
|
634 | 634 | return "error"; |
635 | 635 | } |
636 | 636 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | if ($i > 0) { |
642 | 642 | try { |
643 | 643 | |
644 | - $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
|
644 | + $sth = $this->db->prepare(substr($query_delete, 0, -1).")"); |
|
645 | 645 | $sth->execute(); |
646 | - } catch(PDOException $e) { |
|
646 | + } catch (PDOException $e) { |
|
647 | 647 | return "error"; |
648 | 648 | } |
649 | 649 | } |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
659 | - } catch(PDOException $e) { |
|
659 | + } catch (PDOException $e) { |
|
660 | 660 | return "error"; |
661 | 661 | } |
662 | 662 | /* $query_delete = "DELETE FROM marine_live WHERE fammarine_id IN ("; |
@@ -704,13 +704,13 @@ discard block |
||
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | - $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
707 | + $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
|
708 | 708 | |
709 | 709 | try { |
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
713 | - } catch(PDOException $e) { |
|
713 | + } catch (PDOException $e) { |
|
714 | 714 | return "error"; |
715 | 715 | } |
716 | 716 | |
@@ -726,13 +726,13 @@ discard block |
||
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | - $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
729 | + $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
|
730 | 730 | |
731 | 731 | try { |
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
735 | - } catch(PDOException $e) { |
|
735 | + } catch (PDOException $e) { |
|
736 | 736 | return "error"; |
737 | 737 | } |
738 | 738 | |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
752 | 752 | if ($globalDBdriver == 'mysql') { |
753 | - $query = 'SELECT marine_live.ident FROM marine_live |
|
753 | + $query = 'SELECT marine_live.ident FROM marine_live |
|
754 | 754 | WHERE marine_live.ident = :ident |
755 | 755 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
756 | 756 | AND marine_live.date < UTC_TIMESTAMP()'; |
757 | 757 | $query_data = array(':ident' => $ident); |
758 | 758 | } else { |
759 | - $query = "SELECT marine_live.ident FROM marine_live |
|
759 | + $query = "SELECT marine_live.ident FROM marine_live |
|
760 | 760 | WHERE marine_live.ident = :ident |
761 | 761 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
762 | 762 | AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -765,8 +765,8 @@ discard block |
||
765 | 765 | |
766 | 766 | $sth = $this->db->prepare($query); |
767 | 767 | $sth->execute($query_data); |
768 | - $ident_result=''; |
|
769 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
768 | + $ident_result = ''; |
|
769 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
770 | 770 | { |
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
@@ -783,13 +783,13 @@ discard block |
||
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
785 | 785 | if ($globalDBdriver == 'mysql') { |
786 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
786 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
787 | 787 | WHERE marine_live.ident = :ident |
788 | 788 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; |
789 | 789 | // AND marine_live.date < UTC_TIMESTAMP()"; |
790 | 790 | $query_data = array(':ident' => $ident); |
791 | 791 | } else { |
792 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
792 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
793 | 793 | WHERE marine_live.ident = :ident |
794 | 794 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'"; |
795 | 795 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | |
799 | 799 | $sth = $this->db->prepare($query); |
800 | 800 | $sth->execute($query_data); |
801 | - $ident_result=''; |
|
802 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
801 | + $ident_result = ''; |
|
802 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
803 | 803 | { |
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
@@ -816,13 +816,13 @@ discard block |
||
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
818 | 818 | if ($globalDBdriver == 'mysql') { |
819 | - $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
819 | + $query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
820 | 820 | WHERE marine_live.fammarine_id = :id |
821 | 821 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
822 | 822 | // AND marine_live.date < UTC_TIMESTAMP()"; |
823 | 823 | $query_data = array(':id' => $id); |
824 | 824 | } else { |
825 | - $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
825 | + $query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live |
|
826 | 826 | WHERE marine_live.fammarine_id = :id |
827 | 827 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
828 | 828 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -831,8 +831,8 @@ discard block |
||
831 | 831 | |
832 | 832 | $sth = $this->db->prepare($query); |
833 | 833 | $sth->execute($query_data); |
834 | - $ident_result=''; |
|
835 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
834 | + $ident_result = ''; |
|
835 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
836 | 836 | { |
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
@@ -849,13 +849,13 @@ discard block |
||
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
851 | 851 | if ($globalDBdriver == 'mysql') { |
852 | - $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
852 | + $query = 'SELECT marine_live.fammarine_id FROM marine_live |
|
853 | 853 | WHERE marine_live.mmsi = :mmsi |
854 | 854 | AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; |
855 | 855 | // AND marine_live.date < UTC_TIMESTAMP()"; |
856 | 856 | $query_data = array(':mmsi' => $mmsi); |
857 | 857 | } else { |
858 | - $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
858 | + $query = "SELECT marine_live.fammarine_id FROM marine_live |
|
859 | 859 | WHERE marine_live.mmsi = :mmsi |
860 | 860 | AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'"; |
861 | 861 | // AND marine_live.date < now() AT TIME ZONE 'UTC'"; |
@@ -864,8 +864,8 @@ discard block |
||
864 | 864 | |
865 | 865 | $sth = $this->db->prepare($query); |
866 | 866 | $sth->execute($query_data); |
867 | - $ident_result=''; |
|
868 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
867 | + $ident_result = ''; |
|
868 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
869 | 869 | { |
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | * @return String success or false |
884 | 884 | * |
885 | 885 | */ |
886 | - public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
|
886 | + public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') |
|
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
889 | 889 | $Common = new Common(); |
@@ -935,26 +935,26 @@ discard block |
||
935 | 935 | if ($date == '') $date = date("Y-m-d H:i:s", time()); |
936 | 936 | |
937 | 937 | |
938 | - $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
|
939 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
940 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
941 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
942 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
943 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
944 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
945 | - $source_name = filter_var($source_name,FILTER_SANITIZE_STRING); |
|
946 | - $over_country = filter_var($over_country,FILTER_SANITIZE_STRING); |
|
947 | - $type = filter_var($type,FILTER_SANITIZE_STRING); |
|
948 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT); |
|
949 | - $status = filter_var($status,FILTER_SANITIZE_STRING); |
|
950 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
951 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
952 | - $arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING); |
|
953 | - $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
|
938 | + $fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING); |
|
939 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
940 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
941 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
942 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
943 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
944 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
945 | + $source_name = filter_var($source_name, FILTER_SANITIZE_STRING); |
|
946 | + $over_country = filter_var($over_country, FILTER_SANITIZE_STRING); |
|
947 | + $type = filter_var($type, FILTER_SANITIZE_STRING); |
|
948 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT); |
|
949 | + $status = filter_var($status, FILTER_SANITIZE_STRING); |
|
950 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
951 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
952 | + $arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING); |
|
953 | + $arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING); |
|
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
|
958 | 958 | if ($arrival_date == '') $arrival_date = NULL; |
959 | 959 | $query = ''; |
960 | 960 | if ($globalArchive) { |
@@ -964,19 +964,19 @@ discard block |
||
964 | 964 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
965 | 965 | VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)'; |
966 | 966 | |
967 | - $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date); |
|
967 | + $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date); |
|
968 | 968 | try { |
969 | 969 | $sth = $this->db->prepare($query); |
970 | 970 | $sth->execute($query_values); |
971 | 971 | $sth->closeCursor(); |
972 | - } catch(PDOException $e) { |
|
972 | + } catch (PDOException $e) { |
|
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | 975 | |
976 | 976 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | 977 | if ($globalDebug) echo '(Add to Marine archive : '; |
978 | 978 | $MarineArchive = new MarineArchive($this->db); |
979 | - $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
|
979 | + $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $noarchive, $format_source, $source_name, $over_country); |
|
980 | 980 | if ($globalDebug) echo $result.')'; |
981 | 981 | } |
982 | 982 | return "success"; |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | |
985 | 985 | public function getOrderBy() |
986 | 986 | { |
987 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
987 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC")); |
|
988 | 988 | return $orderby; |
989 | 989 | } |
990 | 990 |
@@ -8,7 +8,9 @@ discard block |
||
8 | 8 | public function __construct($dbc = null) { |
9 | 9 | $Connection = new Connection($dbc); |
10 | 10 | $this->db = $Connection->db(); |
11 | - if ($this->db === null) die('Error: No DB connection. (MarineLive)'); |
|
11 | + if ($this->db === null) { |
|
12 | + die('Error: No DB connection. (MarineLive)'); |
|
13 | + } |
|
12 | 14 | } |
13 | 15 | |
14 | 16 | |
@@ -30,7 +32,9 @@ discard block |
||
30 | 32 | if (isset($filter[0]['source'])) { |
31 | 33 | $filters = array_merge($filters,$filter); |
32 | 34 | } |
33 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
35 | + if (is_array($globalFilter)) { |
|
36 | + $filter = array_merge($filter,$globalFilter); |
|
37 | + } |
|
34 | 38 | $filter_query_join = ''; |
35 | 39 | $filter_query_where = ''; |
36 | 40 | foreach($filters as $flt) { |
@@ -77,8 +81,11 @@ discard block |
||
77 | 81 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
78 | 82 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
79 | 83 | } |
80 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
81 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
84 | + if ($filter_query_where == '' && $where) { |
|
85 | + $filter_query_where = ' WHERE'; |
|
86 | + } elseif ($filter_query_where != '' && $and) { |
|
87 | + $filter_query_where .= ' AND'; |
|
88 | + } |
|
82 | 89 | if ($filter_query_where != '') { |
83 | 90 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
84 | 91 | } |
@@ -119,9 +126,13 @@ discard block |
||
119 | 126 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
120 | 127 | } |
121 | 128 | } |
122 | - if ($orderby_query == '') $orderby_query= ' ORDER BY date DESC'; |
|
129 | + if ($orderby_query == '') { |
|
130 | + $orderby_query= ' ORDER BY date DESC'; |
|
131 | + } |
|
123 | 132 | |
124 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
133 | + if (!isset($globalLiveInterval)) { |
|
134 | + $globalLiveInterval = '200'; |
|
135 | + } |
|
125 | 136 | if ($globalDBdriver == 'mysql') { |
126 | 137 | //$query = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate"; |
127 | 138 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -146,7 +157,9 @@ discard block |
||
146 | 157 | |
147 | 158 | $filter_query = $this->getFilter($filter,true,true); |
148 | 159 | |
149 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
160 | + if (!isset($globalLiveInterval)) { |
|
161 | + $globalLiveInterval = '200'; |
|
162 | + } |
|
150 | 163 | if ($globalDBdriver == 'mysql') { |
151 | 164 | $query = 'SELECT marine_live.mmsi, marine_live.ident, marine_live.type,marine_live.fammarine_id, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
152 | 165 | FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate'.$filter_query." marine_live.latitude <> 0 AND marine_live.longitude <> 0"; |
@@ -187,48 +200,72 @@ discard block |
||
187 | 200 | } |
188 | 201 | $filter_query = $this->getFilter($filter,true,true); |
189 | 202 | |
190 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
191 | - if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') $globalMap3DMarinesLimit = '300'; |
|
203 | + if (!isset($globalLiveInterval)) { |
|
204 | + $globalLiveInterval = '200'; |
|
205 | + } |
|
206 | + if (!isset($globalMap3DMarinesLimit) || $globalMap3DMarinesLimit == '') { |
|
207 | + $globalMap3DMarinesLimit = '300'; |
|
208 | + } |
|
192 | 209 | if ($globalDBdriver == 'mysql') { |
193 | 210 | if (isset($globalArchive) && $globalArchive === TRUE) { |
194 | 211 | $query = 'SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id,marine_archive.type, marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
195 | 212 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
196 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
213 | + if ($usecoord) { |
|
214 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
215 | + } |
|
197 | 216 | $query .= "UNION |
198 | 217 | SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
199 | 218 | FROM marine_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date"; |
200 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
219 | + if ($usecoord) { |
|
220 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
221 | + } |
|
201 | 222 | $query .= ") AS marine |
202 | 223 | WHERE latitude <> '0' AND longitude <> '0' |
203 | 224 | ORDER BY fammarine_id, date"; |
204 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
225 | + if ($limit) { |
|
226 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
227 | + } |
|
205 | 228 | } else { |
206 | 229 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
207 | 230 | FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date "; |
208 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
231 | + if ($usecoord) { |
|
232 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
233 | + } |
|
209 | 234 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
210 | 235 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
211 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
236 | + if ($limit) { |
|
237 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
238 | + } |
|
212 | 239 | } |
213 | 240 | } else { |
214 | 241 | if (isset($globalArchive) && $globalArchive === TRUE) { |
215 | 242 | $query = "SELECT * FROM (SELECT marine_archive.ident, marine_archive.fammarine_id, marine_archive.type,marine_archive.latitude, marine_archive.longitude, marine_archive.heading, marine_archive.ground_speed, marine_archive.date, marine_archive.format_source |
216 | 243 | FROM marine_archive INNER JOIN (SELECT fammarine_id FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date) l ON l.fammarine_id = marine_archive.fammarine_id "; |
217 | - if ($usecoord) $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
244 | + if ($usecoord) { |
|
245 | + $query .= "AND marine_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_archive.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
246 | + } |
|
218 | 247 | $query .= "UNION |
219 | 248 | SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
220 | 249 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date"; |
221 | - if ($usecoord) $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
250 | + if ($usecoord) { |
|
251 | + $query .= " AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong; |
|
252 | + } |
|
222 | 253 | $query .= ") AS marine WHERE latitude <> '0' AND longitude <> '0' "; |
223 | 254 | $query .= "ORDER BY fammarine_id, date"; |
224 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
255 | + if ($limit) { |
|
256 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
257 | + } |
|
225 | 258 | } else { |
226 | 259 | $query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
227 | 260 | FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date "; |
228 | - if ($usecoord) $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
261 | + if ($usecoord) { |
|
262 | + $query .= "AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong." "; |
|
263 | + } |
|
229 | 264 | $query .= "AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' |
230 | 265 | ORDER BY marine_live.fammarine_id, marine_live.date"; |
231 | - if ($limit) $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
266 | + if ($limit) { |
|
267 | + $query .= " LIMIT ".$globalMap3DMarinesLimit; |
|
268 | + } |
|
232 | 269 | } |
233 | 270 | } |
234 | 271 | try { |
@@ -253,7 +290,9 @@ discard block |
||
253 | 290 | global $globalDBdriver, $globalLiveInterval; |
254 | 291 | $filter_query = $this->getFilter($filter,true,true); |
255 | 292 | |
256 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
293 | + if (!isset($globalLiveInterval)) { |
|
294 | + $globalLiveInterval = '200'; |
|
295 | + } |
|
257 | 296 | if ($globalDBdriver == 'mysql') { |
258 | 297 | $query = 'SELECT COUNT(DISTINCT marine_live.fammarine_id) as nb FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
259 | 298 | } else { |
@@ -281,7 +320,9 @@ discard block |
||
281 | 320 | { |
282 | 321 | global $globalDBdriver, $globalLiveInterval; |
283 | 322 | $Marine = new Marine($this->db); |
284 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
323 | + if (!isset($globalLiveInterval)) { |
|
324 | + $globalLiveInterval = '200'; |
|
325 | + } |
|
285 | 326 | $filter_query = $this->getFilter($filter); |
286 | 327 | |
287 | 328 | if (is_array($coord)) { |
@@ -289,7 +330,9 @@ discard block |
||
289 | 330 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
290 | 331 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
291 | 332 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
292 | - } else return array(); |
|
333 | + } else { |
|
334 | + return array(); |
|
335 | + } |
|
293 | 336 | if ($globalDBdriver == 'mysql') { |
294 | 337 | $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query; |
295 | 338 | } else { |
@@ -309,7 +352,9 @@ discard block |
||
309 | 352 | { |
310 | 353 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
311 | 354 | $Marine = new Marine($this->db); |
312 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
355 | + if (!isset($globalLiveInterval)) { |
|
356 | + $globalLiveInterval = '200'; |
|
357 | + } |
|
313 | 358 | $filter_query = $this->getFilter($filter,true,true); |
314 | 359 | |
315 | 360 | if (is_array($coord)) { |
@@ -317,7 +362,9 @@ discard block |
||
317 | 362 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
318 | 363 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
319 | 364 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
320 | - } else return array(); |
|
365 | + } else { |
|
366 | + return array(); |
|
367 | + } |
|
321 | 368 | /* |
322 | 369 | if ($globalDBdriver == 'mysql') { |
323 | 370 | $query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source |
@@ -526,11 +573,15 @@ discard block |
||
526 | 573 | //$query = self::$global_query.' WHERE marine_live.fammarine_id = :id ORDER BY date'; |
527 | 574 | if ($globalDBdriver == 'mysql') { |
528 | 575 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
529 | - if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
576 | + if ($liveinterval) { |
|
577 | + $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'; |
|
578 | + } |
|
530 | 579 | $query .= ' ORDER BY date'; |
531 | 580 | } else { |
532 | 581 | $query = 'SELECT marine_live.* FROM marine_live WHERE marine_live.fammarine_id = :id'; |
533 | - if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
582 | + if ($liveinterval) { |
|
583 | + $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date"; |
|
584 | + } |
|
534 | 585 | $query .= ' ORDER BY date'; |
535 | 586 | } |
536 | 587 | |
@@ -625,7 +676,9 @@ discard block |
||
625 | 676 | $i++; |
626 | 677 | $j++; |
627 | 678 | if ($j == 30) { |
628 | - if ($globalDebug) echo "."; |
|
679 | + if ($globalDebug) { |
|
680 | + echo "."; |
|
681 | + } |
|
629 | 682 | try { |
630 | 683 | |
631 | 684 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -905,7 +958,9 @@ discard block |
||
905 | 958 | { |
906 | 959 | return false; |
907 | 960 | } |
908 | - } else return ''; |
|
961 | + } else { |
|
962 | + return ''; |
|
963 | + } |
|
909 | 964 | |
910 | 965 | if ($longitude != '') |
911 | 966 | { |
@@ -913,7 +968,9 @@ discard block |
||
913 | 968 | { |
914 | 969 | return false; |
915 | 970 | } |
916 | - } else return ''; |
|
971 | + } else { |
|
972 | + return ''; |
|
973 | + } |
|
917 | 974 | |
918 | 975 | |
919 | 976 | if ($heading != '') |
@@ -922,7 +979,9 @@ discard block |
||
922 | 979 | { |
923 | 980 | return false; |
924 | 981 | } |
925 | - } else $heading = 0; |
|
982 | + } else { |
|
983 | + $heading = 0; |
|
984 | + } |
|
926 | 985 | |
927 | 986 | if ($groundspeed != '') |
928 | 987 | { |
@@ -930,9 +989,13 @@ discard block |
||
930 | 989 | { |
931 | 990 | return false; |
932 | 991 | } |
933 | - } else $groundspeed = 0; |
|
992 | + } else { |
|
993 | + $groundspeed = 0; |
|
994 | + } |
|
934 | 995 | date_default_timezone_set('UTC'); |
935 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
996 | + if ($date == '') { |
|
997 | + $date = date("Y-m-d H:i:s", time()); |
|
998 | + } |
|
936 | 999 | |
937 | 1000 | |
938 | 1001 | $fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING); |
@@ -953,12 +1016,20 @@ discard block |
||
953 | 1016 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 1017 | |
955 | 1018 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
1019 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) { |
|
1020 | + $groundspeed = 0; |
|
1021 | + } |
|
1022 | + if ($heading == '' || $Common->isInteger($heading) === false ) { |
|
1023 | + $heading = 0; |
|
1024 | + } |
|
1025 | + if ($arrival_date == '') { |
|
1026 | + $arrival_date = NULL; |
|
1027 | + } |
|
959 | 1028 | $query = ''; |
960 | 1029 | if ($globalArchive) { |
961 | - if ($globalDebug) echo '-- Delete previous data -- '; |
|
1030 | + if ($globalDebug) { |
|
1031 | + echo '-- Delete previous data -- '; |
|
1032 | + } |
|
962 | 1033 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
963 | 1034 | } |
964 | 1035 | $query .= 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) |
@@ -974,10 +1045,14 @@ discard block |
||
974 | 1045 | } |
975 | 1046 | |
976 | 1047 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
977 | - if ($globalDebug) echo '(Add to Marine archive : '; |
|
1048 | + if ($globalDebug) { |
|
1049 | + echo '(Add to Marine archive : '; |
|
1050 | + } |
|
978 | 1051 | $MarineArchive = new MarineArchive($this->db); |
979 | 1052 | $result = $MarineArchive->addMarineArchiveData($fammarine_id, $ident, $latitude, $longitude, $heading, $groundspeed, $date, $putinarchive, $mmsi,$type,$typeid,$imo, $callsign,$arrival_code,$arrival_date,$status,$noarchive,$format_source, $source_name, $over_country); |
980 | - if ($globalDebug) echo $result.')'; |
|
1053 | + if ($globalDebug) { |
|
1054 | + echo $result.')'; |
|
1055 | + } |
|
981 | 1056 | } |
982 | 1057 | return "success"; |
983 | 1058 | } |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST, 'ident', FILTER_SANITIZE_STRING); |
|
5 | +if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
6 | 6 | if ($ident != '') |
7 | 7 | { |
8 | 8 | if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
@@ -1,13 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $ident = ''; |
4 | -if (isset($_POST['ident'])) $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
5 | -if (isset($_GET['ident'])) $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
4 | +if (isset($_POST['ident'])) { |
|
5 | + $ident = filter_input(INPUT_POST,'ident',FILTER_SANITIZE_STRING); |
|
6 | +} |
|
7 | +if (isset($_GET['ident'])) { |
|
8 | + $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
9 | +} |
|
6 | 10 | if ($ident != '') |
7 | 11 | { |
8 | - if (isset($_GET['marine'])) header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
9 | - else header('Location: '.$globalURL.'/ident/'.$ident); |
|
10 | -} else { |
|
12 | + if (isset($_GET['marine'])) { |
|
13 | + header('Location: '.$globalURL.'/marine/ident/'.$ident); |
|
14 | + } else { |
|
15 | + header('Location: '.$globalURL.'/ident/'.$ident); |
|
16 | + } |
|
17 | + } else { |
|
11 | 18 | header('Location: '.$globalURL); |
12 | 19 | } |
13 | 20 | ?> |
14 | 21 | \ No newline at end of file |
@@ -4,21 +4,21 @@ discard block |
||
4 | 4 | |
5 | 5 | $type = ''; |
6 | 6 | if (isset($_GET['marine'])) { |
7 | - require_once('require/class.Marine.php');; |
|
7 | + require_once('require/class.Marine.php'); ; |
|
8 | 8 | require_once('require/class.MarineLive.php'); |
9 | - $MarineLive=new MarineLive(); |
|
9 | + $MarineLive = new MarineLive(); |
|
10 | 10 | $type = 'marine'; |
11 | 11 | $page_url = $globalURL.'/marine/currently'; |
12 | 12 | } elseif (isset($_GET['tracker'])) { |
13 | - require_once('require/class.Tracker.php');; |
|
13 | + require_once('require/class.Tracker.php'); ; |
|
14 | 14 | require_once('require/class.TrackerLive.php'); |
15 | - $TrackerLive=new TrackerLive(); |
|
15 | + $TrackerLive = new TrackerLive(); |
|
16 | 16 | $type = 'tracker'; |
17 | 17 | $page_url = $globalURL.'/tracker/currently'; |
18 | 18 | } else { |
19 | - require_once('require/class.Spotter.php');; |
|
19 | + require_once('require/class.Spotter.php'); ; |
|
20 | 20 | require_once('require/class.SpotterLive.php'); |
21 | - $SpotterLive=new SpotterLive(); |
|
21 | + $SpotterLive = new SpotterLive(); |
|
22 | 22 | $type = 'aircraft'; |
23 | 23 | $page_url = $globalURL.'/currently'; |
24 | 24 | } |
@@ -26,12 +26,12 @@ discard block |
||
26 | 26 | $title = "Current Activity"; |
27 | 27 | require_once('header.php'); |
28 | 28 | //calculuation for the pagination |
29 | -if(!isset($_GET['limit'])) |
|
29 | +if (!isset($_GET['limit'])) |
|
30 | 30 | { |
31 | 31 | $limit_start = 0; |
32 | 32 | $limit_end = 25; |
33 | 33 | $absolute_difference = 25; |
34 | -} else { |
|
34 | +} else { |
|
35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
36 | 36 | $limit_start = $limit_explode[0]; |
37 | 37 | $limit_end = $limit_explode[1]; |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
55 | 55 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
56 | 56 | |
57 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
57 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
58 | 58 | if ($sort != '') { |
59 | 59 | if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
60 | 60 | elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | $limit_start = 0; |
32 | 32 | $limit_end = 25; |
33 | 33 | $absolute_difference = 25; |
34 | -} else { |
|
34 | +} else { |
|
35 | 35 | $limit_explode = explode(",", $_GET['limit']); |
36 | 36 | $limit_start = $limit_explode[0]; |
37 | 37 | $limit_end = $limit_explode[1]; |
@@ -50,20 +50,32 @@ discard block |
||
50 | 50 | print '</div>'; |
51 | 51 | |
52 | 52 | print '<div class="table column">'; |
53 | -if ($type == 'aircraft') print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
54 | -elseif ($type == 'marine') print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
55 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
53 | +if ($type == 'aircraft') { |
|
54 | + print '<p>'._("The table below shows the detailed information of all current flights.").'</p>'; |
|
55 | +} elseif ($type == 'marine') { |
|
56 | + print '<p>'._("The table below shows the detailed information of all current vessels.").'</p>'; |
|
57 | +} elseif ($type == 'tracker') { |
|
58 | + print '<p>'._("The table below shows the detailed information of all current trackers.").'</p>'; |
|
59 | +} |
|
56 | 60 | |
57 | 61 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
58 | 62 | if ($sort != '') { |
59 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
60 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
61 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
62 | -} else { |
|
63 | - if ($type == 'aircraft') $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
64 | - elseif ($type == 'marine') $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
65 | - elseif ($type == 'tracker') $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
66 | -} |
|
63 | + if ($type == 'aircraft') { |
|
64 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference, $sort); |
|
65 | + } elseif ($type == 'marine') { |
|
66 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference, $sort); |
|
67 | + } elseif ($type == 'tracker') { |
|
68 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference, $sort); |
|
69 | + } |
|
70 | + } else { |
|
71 | + if ($type == 'aircraft') { |
|
72 | + $spotter_array = $SpotterLive->getLiveSpotterData($limit_start.",".$absolute_difference); |
|
73 | + } elseif ($type == 'marine') { |
|
74 | + $spotter_array = $MarineLive->getLiveMarineData($limit_start.",".$absolute_difference); |
|
75 | + } elseif ($type == 'tracker') { |
|
76 | + $spotter_array = $TrackerLive->getLiveTrackerData($limit_start.",".$absolute_difference); |
|
77 | + } |
|
78 | + } |
|
67 | 79 | |
68 | 80 | if (!empty($spotter_array)) |
69 | 81 | { |
@@ -3,7 +3,7 @@ |
||
3 | 3 | $type = 'aircraft'; |
4 | 4 | if (isset($_GET['marine'])) $type = 'marine'; |
5 | 5 | elseif (isset($_GET['tracker'])) $type = 'tracker'; |
6 | -$date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
|
6 | +$date = filter_input(INPUT_POST, 'date', FILTER_SANITIZE_STRING); |
|
7 | 7 | if ($date == '') $date = date('Y-m-d'); |
8 | 8 | if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
9 | 9 | elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
@@ -1,11 +1,20 @@ |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/require/settings.php'); |
3 | 3 | $type = 'aircraft'; |
4 | -if (isset($_GET['marine'])) $type = 'marine'; |
|
5 | -elseif (isset($_GET['tracker'])) $type = 'tracker'; |
|
4 | +if (isset($_GET['marine'])) { |
|
5 | + $type = 'marine'; |
|
6 | +} elseif (isset($_GET['tracker'])) { |
|
7 | + $type = 'tracker'; |
|
8 | +} |
|
6 | 9 | $date = filter_input(INPUT_POST,'date',FILTER_SANITIZE_STRING); |
7 | -if ($date == '') $date = date('Y-m-d'); |
|
8 | -if ($type == 'marine') header('Location: '.$globalURL.'/marine/date/'.$date); |
|
9 | -elseif ($type == 'tracker') header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
10 | -else header('Location: '.$globalURL.'/date/'.$date); |
|
10 | +if ($date == '') { |
|
11 | + $date = date('Y-m-d'); |
|
12 | +} |
|
13 | +if ($type == 'marine') { |
|
14 | + header('Location: '.$globalURL.'/marine/date/'.$date); |
|
15 | +} elseif ($type == 'tracker') { |
|
16 | + header('Location: '.$globalURL.'/tracker/date/'.$date); |
|
17 | +} else { |
|
18 | + header('Location: '.$globalURL.'/date/'.$date); |
|
19 | +} |
|
11 | 20 | ?> |
12 | 21 | \ No newline at end of file |
@@ -2,34 +2,34 @@ discard block |
||
2 | 2 | require_once('require/class.Connection.php'); |
3 | 3 | require_once('require/class.Language.php'); |
4 | 4 | $type = ''; |
5 | -$date = filter_input(INPUT_GET,'date',FILTER_SANITIZE_STRING); |
|
5 | +$date = filter_input(INPUT_GET, 'date', FILTER_SANITIZE_STRING); |
|
6 | 6 | if (isset($_GET['marine'])) { |
7 | - require_once('require/class.Marine.php');; |
|
7 | + require_once('require/class.Marine.php'); ; |
|
8 | 8 | $Marine = new Marine(); |
9 | 9 | $type = 'marine'; |
10 | 10 | $page_url = $globalURL.'/marine/date/'.$date; |
11 | 11 | } elseif (isset($_GET['tracker'])) { |
12 | - require_once('require/class.Tracker.php');; |
|
12 | + require_once('require/class.Tracker.php'); ; |
|
13 | 13 | $Tracker = new Tracker(); |
14 | 14 | $type = 'tracker'; |
15 | 15 | $page_url = $globalURL.'/tracker/date/'.$date; |
16 | 16 | } else { |
17 | - require_once('require/class.Spotter.php');; |
|
17 | + require_once('require/class.Spotter.php'); ; |
|
18 | 18 | $Spotter = new Spotter(); |
19 | 19 | $type = 'aircraft'; |
20 | 20 | $page_url = $globalURL.'/date/'.$date; |
21 | 21 | } |
22 | 22 | |
23 | -if (!isset($_GET['date'])){ |
|
23 | +if (!isset($_GET['date'])) { |
|
24 | 24 | header('Location: '.$globalURL.''); |
25 | 25 | } else { |
26 | 26 | //calculuation for the pagination |
27 | - if(!isset($_GET['limit'])) |
|
27 | + if (!isset($_GET['limit'])) |
|
28 | 28 | { |
29 | 29 | $limit_start = 0; |
30 | 30 | $limit_end = 25; |
31 | 31 | $absolute_difference = 25; |
32 | - } else { |
|
32 | + } else { |
|
33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
34 | 34 | $limit_start = $limit_explode[0]; |
35 | 35 | $limit_end = $limit_explode[1]; |
@@ -43,24 +43,24 @@ discard block |
||
43 | 43 | $limit_previous_1 = $limit_start - $absolute_difference; |
44 | 44 | $limit_previous_2 = $limit_end - $absolute_difference; |
45 | 45 | |
46 | - $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
46 | + $sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
47 | 47 | if ($sort != '') |
48 | 48 | { |
49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
49 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
50 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
51 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference, $sort); |
|
52 | 52 | } else { |
53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
53 | + if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date, $limit_start.",".$absolute_difference); |
|
54 | + elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date, $limit_start.",".$absolute_difference); |
|
55 | + else $spotter_array = $Spotter->getSpotterDataByDate($date, $limit_start.",".$absolute_difference); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if (!empty($spotter_array)) |
59 | 59 | { |
60 | 60 | date_default_timezone_set($globalTimezone); |
61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
61 | + if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | + elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | + else $title = sprintf(_("Detailed View for flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
64 | 64 | |
65 | 65 | require_once('header.php'); |
66 | 66 | print '<div class="select-item">'; |
@@ -78,15 +78,15 @@ discard block |
||
78 | 78 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
79 | 79 | print '<br />'; |
80 | 80 | print '<div class="info column">'; |
81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
81 | + if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | + else print '<h1>'.sprintf(_("Flights from %s"), date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
83 | 83 | print '</div>'; |
84 | 84 | |
85 | 85 | if ($type == 'aircraft') include('date-sub-menu.php'); |
86 | 86 | print '<div class="table column">'; |
87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
87 | + if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | + elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | + else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."), date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
90 | 90 | |
91 | 91 | include('table-output.php'); |
92 | 92 | print '<div class="pagination">'; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $limit_start = 0; |
30 | 30 | $limit_end = 25; |
31 | 31 | $absolute_difference = 25; |
32 | - } else { |
|
32 | + } else { |
|
33 | 33 | $limit_explode = explode(",", $_GET['limit']); |
34 | 34 | $limit_start = $limit_explode[0]; |
35 | 35 | $limit_end = $limit_explode[1]; |
@@ -46,21 +46,33 @@ discard block |
||
46 | 46 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
47 | 47 | if ($sort != '') |
48 | 48 | { |
49 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
50 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
49 | + if ($type == 'marine') { |
|
50 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
51 | + } elseif ($type == 'tracker') { |
|
52 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
53 | + } else { |
|
54 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference, $sort); |
|
55 | + } |
|
52 | 56 | } else { |
53 | - if ($type == 'marine') $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
54 | - elseif ($type == 'tracker') $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
55 | - else $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
57 | + if ($type == 'marine') { |
|
58 | + $spotter_array = $Marine->getMarineDataByDate($date,$limit_start.",".$absolute_difference); |
|
59 | + } elseif ($type == 'tracker') { |
|
60 | + $spotter_array = $Tracker->getTrackerDataByDate($date,$limit_start.",".$absolute_difference); |
|
61 | + } else { |
|
62 | + $spotter_array = $Spotter->getSpotterDataByDate($date,$limit_start.",".$absolute_difference); |
|
63 | + } |
|
56 | 64 | } |
57 | 65 | |
58 | 66 | if (!empty($spotter_array)) |
59 | 67 | { |
60 | 68 | date_default_timezone_set($globalTimezone); |
61 | - if ($type == 'marine') $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
62 | - elseif ($type == 'tracker') $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
63 | - else $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
69 | + if ($type == 'marine') { |
|
70 | + $title = sprintf(_("Detailed View for vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
71 | + } elseif ($type == 'tracker') { |
|
72 | + $title = sprintf(_("Detailed View for trackers from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
73 | + } else { |
|
74 | + $title = sprintf(_("Detailed View for flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
|
75 | + } |
|
64 | 76 | |
65 | 77 | require_once('header.php'); |
66 | 78 | print '<div class="select-item">'; |
@@ -78,15 +90,24 @@ discard block |
||
78 | 90 | print '<script type="text/javascript">$(function () { $("#datepicker").datetimepicker({ format: "YYYY-MM-DD", defaultDate: "'.$date.'" }); }); </script>'; |
79 | 91 | print '<br />'; |
80 | 92 | print '<div class="info column">'; |
81 | - if ($type == 'marine') print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
82 | - else print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
93 | + if ($type == 'marine') { |
|
94 | + print '<h1>'.sprintf(_("Vessels from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
95 | + } else { |
|
96 | + print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
|
97 | + } |
|
83 | 98 | print '</div>'; |
84 | 99 | |
85 | - if ($type == 'aircraft') include('date-sub-menu.php'); |
|
100 | + if ($type == 'aircraft') { |
|
101 | + include('date-sub-menu.php'); |
|
102 | + } |
|
86 | 103 | print '<div class="table column">'; |
87 | - if ($type == 'marine') print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
88 | - elseif ($type == 'tracker') print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
89 | - else print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
104 | + if ($type == 'marine') { |
|
105 | + print '<p>'.sprintf(_("The table below shows the detailed information of all vessels on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
106 | + } elseif ($type == 'tracker') { |
|
107 | + print '<p>'.sprintf(_("The table below shows the detailed information of all trackers on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
108 | + } else { |
|
109 | + print '<p>'.sprintf(_("The table below shows the detailed information of all flights on <strong>%s</strong>."),date("l M j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
|
110 | + } |
|
90 | 111 | |
91 | 112 | include('table-output.php'); |
92 | 113 | print '<div class="pagination">'; |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | require_once('header.php'); |
24 | 24 | |
25 | 25 | //calculuation for the pagination |
26 | -if(!isset($_GET['limit'])) |
|
26 | +if (!isset($_GET['limit'])) |
|
27 | 27 | { |
28 | 28 | $limit_start = 0; |
29 | 29 | $limit_end = 25; |
30 | 30 | $absolute_difference = 25; |
31 | -} else { |
|
31 | +} else { |
|
32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
33 | 33 | $limit_start = $limit_explode[0]; |
34 | 34 | $limit_end = $limit_explode[1]; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
52 | 52 | else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
53 | 53 | |
54 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
54 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
55 | 55 | $sql_begin = microtime(true); |
56 | 56 | if ($type == 'marine') { |
57 | 57 | $spotter_array = $Marine->getLatestMarineData($limit_start.",".$absolute_difference, $sort); |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } else { |
61 | 61 | $spotter_array = $Spotter->getLatestSpotterData($limit_start.",".$absolute_difference, $sort); |
62 | 62 | } |
63 | -$sql_time = microtime(true)-$sql_begin; |
|
63 | +$sql_time = microtime(true) - $sql_begin; |
|
64 | 64 | $page_begin = microtime(true); |
65 | 65 | if (!empty($spotter_array)) |
66 | 66 | { |
@@ -77,6 +77,6 @@ discard block |
||
77 | 77 | print '</div>'; |
78 | 78 | print '</div>'; |
79 | 79 | } |
80 | -$page_time = microtime(true)-$page_begin; |
|
80 | +$page_time = microtime(true) - $page_begin; |
|
81 | 81 | require_once('footer.php'); |
82 | 82 | ?> |
83 | 83 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $limit_start = 0; |
29 | 29 | $limit_end = 25; |
30 | 30 | $absolute_difference = 25; |
31 | -} else { |
|
31 | +} else { |
|
32 | 32 | $limit_explode = explode(",", $_GET['limit']); |
33 | 33 | $limit_start = $limit_explode[0]; |
34 | 34 | $limit_end = $limit_explode[1]; |
@@ -47,9 +47,13 @@ discard block |
||
47 | 47 | print '<h1>'._("Latest Activity").'</h1>'; |
48 | 48 | print '</div>'; |
49 | 49 | print '<div class="table column">'; |
50 | -if ($type == 'marine') print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
51 | -elseif ($type == 'tracker') print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
52 | -else print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
50 | +if ($type == 'marine') { |
|
51 | + print '<p>'._("The table below shows the detailed information of all recent vessels.").'</p>'; |
|
52 | +} elseif ($type == 'tracker') { |
|
53 | + print '<p>'._("The table below shows the detailed information of all recent trackers.").'</p>'; |
|
54 | +} else { |
|
55 | + print '<p>'._("The table below shows the detailed information of all recent flights.").'</p>'; |
|
56 | +} |
|
53 | 57 | |
54 | 58 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
55 | 59 | $sql_begin = microtime(true); |
@@ -14,7 +14,7 @@ |
||
14 | 14 | /** |
15 | 15 | * Get SQL query part for filter used |
16 | 16 | * @param Array $filter the filter |
17 | - * @return Array the SQL part |
|
17 | + * @return string the SQL part |
|
18 | 18 | */ |
19 | 19 | public function getFilter($filter = array(),$where = false,$and = false) { |
20 | 20 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
13 | - * Get SQL query part for filter used |
|
14 | - * @param Array $filter the filter |
|
15 | - * @return Array the SQL part |
|
16 | - */ |
|
13 | + * Get SQL query part for filter used |
|
14 | + * @param Array $filter the filter |
|
15 | + * @return Array the SQL part |
|
16 | + */ |
|
17 | 17 | public function getFilter($filter = array(),$where = false,$and = false) { |
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
@@ -106,44 +106,44 @@ discard block |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | - /** |
|
110 | - * Gets all the spotter information based on a particular callsign |
|
111 | - * |
|
112 | - * @return Array the spotter information |
|
113 | - * |
|
114 | - */ |
|
115 | - public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | - { |
|
109 | + /** |
|
110 | + * Gets all the spotter information based on a particular callsign |
|
111 | + * |
|
112 | + * @return Array the spotter information |
|
113 | + * |
|
114 | + */ |
|
115 | + public function getLastArchiveTrackerDataByIdent($ident) |
|
116 | + { |
|
117 | 117 | $Tracker = new Tracker($this->db); |
118 | - date_default_timezone_set('UTC'); |
|
118 | + date_default_timezone_set('UTC'); |
|
119 | 119 | |
120 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
120 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
121 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
125 | 125 | |
126 | - return $spotter_array; |
|
127 | - } |
|
126 | + return $spotter_array; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * Gets last the spotter information based on a particular id |
|
132 | - * |
|
133 | - * @return Array the spotter information |
|
134 | - * |
|
135 | - */ |
|
136 | - public function getLastArchiveTrackerDataById($id) |
|
137 | - { |
|
138 | - $Tracker = new Tracker($this->db); |
|
139 | - date_default_timezone_set('UTC'); |
|
140 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | - //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | - //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
130 | + /** |
|
131 | + * Gets last the spotter information based on a particular id |
|
132 | + * |
|
133 | + * @return Array the spotter information |
|
134 | + * |
|
135 | + */ |
|
136 | + public function getLastArchiveTrackerDataById($id) |
|
137 | + { |
|
138 | + $Tracker = new Tracker($this->db); |
|
139 | + date_default_timezone_set('UTC'); |
|
140 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
141 | + //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
|
142 | + //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | - /* |
|
146 | + /* |
|
147 | 147 | try { |
148 | 148 | $Connection = new Connection(); |
149 | 149 | $sth = Connection->$db->prepare($query); |
@@ -153,188 +153,188 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | - |
|
158 | - return $spotter_array; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Gets all the spotter information based on a particular id |
|
163 | - * |
|
164 | - * @return Array the spotter information |
|
165 | - * |
|
166 | - */ |
|
167 | - public function getAllArchiveTrackerDataById($id) |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
157 | + |
|
158 | + return $spotter_array; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Gets all the spotter information based on a particular id |
|
163 | + * |
|
164 | + * @return Array the spotter information |
|
165 | + * |
|
166 | + */ |
|
167 | + public function getAllArchiveTrackerDataById($id) |
|
168 | 168 | { |
169 | - date_default_timezone_set('UTC'); |
|
170 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
169 | + date_default_timezone_set('UTC'); |
|
170 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | - try { |
|
176 | - $sth = $this->db->prepare($query); |
|
177 | - $sth->execute(array(':id' => $id)); |
|
178 | - } catch(PDOException $e) { |
|
179 | - echo $e->getMessage(); |
|
180 | - die; |
|
181 | - } |
|
182 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | - |
|
184 | - return $spotter_array; |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Gets coordinate & time spotter information based on a particular id |
|
189 | - * |
|
190 | - * @return Array the spotter information |
|
191 | - * |
|
192 | - */ |
|
193 | - public function getCoordArchiveTrackerDataById($id) |
|
194 | - { |
|
195 | - date_default_timezone_set('UTC'); |
|
196 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
175 | + try { |
|
176 | + $sth = $this->db->prepare($query); |
|
177 | + $sth->execute(array(':id' => $id)); |
|
178 | + } catch(PDOException $e) { |
|
179 | + echo $e->getMessage(); |
|
180 | + die; |
|
181 | + } |
|
182 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
183 | + |
|
184 | + return $spotter_array; |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Gets coordinate & time spotter information based on a particular id |
|
189 | + * |
|
190 | + * @return Array the spotter information |
|
191 | + * |
|
192 | + */ |
|
193 | + public function getCoordArchiveTrackerDataById($id) |
|
194 | + { |
|
195 | + date_default_timezone_set('UTC'); |
|
196 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | - try { |
|
202 | - $sth = $this->db->prepare($query); |
|
203 | - $sth->execute(array(':id' => $id)); |
|
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(':id' => $id)); |
|
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 | 213 | |
214 | - /** |
|
215 | - * Gets altitude information based on a particular callsign |
|
216 | - * |
|
217 | - * @return Array the spotter information |
|
218 | - * |
|
219 | - */ |
|
220 | - public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | - { |
|
214 | + /** |
|
215 | + * Gets altitude information based on a particular callsign |
|
216 | + * |
|
217 | + * @return Array the spotter information |
|
218 | + * |
|
219 | + */ |
|
220 | + public function getAltitudeArchiveTrackerDataByIdent($ident) |
|
221 | + { |
|
222 | 222 | |
223 | - date_default_timezone_set('UTC'); |
|
223 | + date_default_timezone_set('UTC'); |
|
224 | 224 | |
225 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
225 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | - try { |
|
229 | - $sth = $this->db->prepare($query); |
|
230 | - $sth->execute(array(':ident' => $ident)); |
|
231 | - } catch(PDOException $e) { |
|
232 | - echo $e->getMessage(); |
|
233 | - die; |
|
234 | - } |
|
235 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
228 | + try { |
|
229 | + $sth = $this->db->prepare($query); |
|
230 | + $sth->execute(array(':ident' => $ident)); |
|
231 | + } catch(PDOException $e) { |
|
232 | + echo $e->getMessage(); |
|
233 | + die; |
|
234 | + } |
|
235 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
236 | 236 | |
237 | - return $spotter_array; |
|
238 | - } |
|
237 | + return $spotter_array; |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Gets altitude information based on a particular id |
|
242 | - * |
|
243 | - * @return Array the spotter information |
|
244 | - * |
|
245 | - */ |
|
246 | - public function getAltitudeArchiveTrackerDataById($id) |
|
247 | - { |
|
240 | + /** |
|
241 | + * Gets altitude information based on a particular id |
|
242 | + * |
|
243 | + * @return Array the spotter information |
|
244 | + * |
|
245 | + */ |
|
246 | + public function getAltitudeArchiveTrackerDataById($id) |
|
247 | + { |
|
248 | 248 | |
249 | - date_default_timezone_set('UTC'); |
|
249 | + date_default_timezone_set('UTC'); |
|
250 | 250 | |
251 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
251 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | - try { |
|
255 | - $sth = $this->db->prepare($query); |
|
256 | - $sth->execute(array(':id' => $id)); |
|
257 | - } catch(PDOException $e) { |
|
258 | - echo $e->getMessage(); |
|
259 | - die; |
|
260 | - } |
|
261 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
254 | + try { |
|
255 | + $sth = $this->db->prepare($query); |
|
256 | + $sth->execute(array(':id' => $id)); |
|
257 | + } catch(PDOException $e) { |
|
258 | + echo $e->getMessage(); |
|
259 | + die; |
|
260 | + } |
|
261 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
262 | 262 | |
263 | - return $spotter_array; |
|
264 | - } |
|
263 | + return $spotter_array; |
|
264 | + } |
|
265 | 265 | |
266 | - /** |
|
267 | - * Gets altitude & speed information based on a particular id |
|
268 | - * |
|
269 | - * @return Array the spotter information |
|
270 | - * |
|
271 | - */ |
|
272 | - public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | - { |
|
266 | + /** |
|
267 | + * Gets altitude & speed information based on a particular id |
|
268 | + * |
|
269 | + * @return Array the spotter information |
|
270 | + * |
|
271 | + */ |
|
272 | + public function getAltitudeSpeedArchiveTrackerDataById($id) |
|
273 | + { |
|
274 | 274 | |
275 | - date_default_timezone_set('UTC'); |
|
275 | + date_default_timezone_set('UTC'); |
|
276 | 276 | |
277 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
277 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | - try { |
|
281 | - $sth = $this->db->prepare($query); |
|
282 | - $sth->execute(array(':id' => $id)); |
|
283 | - } catch(PDOException $e) { |
|
284 | - echo $e->getMessage(); |
|
285 | - die; |
|
286 | - } |
|
287 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
280 | + try { |
|
281 | + $sth = $this->db->prepare($query); |
|
282 | + $sth->execute(array(':id' => $id)); |
|
283 | + } catch(PDOException $e) { |
|
284 | + echo $e->getMessage(); |
|
285 | + die; |
|
286 | + } |
|
287 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
288 | 288 | |
289 | - return $spotter_array; |
|
290 | - } |
|
289 | + return $spotter_array; |
|
290 | + } |
|
291 | 291 | |
292 | 292 | |
293 | - /** |
|
294 | - * Gets altitude information based on a particular callsign |
|
295 | - * |
|
296 | - * @return Array the spotter information |
|
297 | - * |
|
298 | - */ |
|
299 | - public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | - { |
|
293 | + /** |
|
294 | + * Gets altitude information based on a particular callsign |
|
295 | + * |
|
296 | + * @return Array the spotter information |
|
297 | + * |
|
298 | + */ |
|
299 | + public function getLastAltitudeArchiveTrackerDataByIdent($ident) |
|
300 | + { |
|
301 | 301 | |
302 | - date_default_timezone_set('UTC'); |
|
302 | + date_default_timezone_set('UTC'); |
|
303 | 303 | |
304 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
304 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | - try { |
|
309 | - $sth = $this->db->prepare($query); |
|
310 | - $sth->execute(array(':ident' => $ident)); |
|
311 | - } catch(PDOException $e) { |
|
312 | - echo $e->getMessage(); |
|
313 | - die; |
|
314 | - } |
|
315 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
308 | + try { |
|
309 | + $sth = $this->db->prepare($query); |
|
310 | + $sth->execute(array(':ident' => $ident)); |
|
311 | + } catch(PDOException $e) { |
|
312 | + echo $e->getMessage(); |
|
313 | + die; |
|
314 | + } |
|
315 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
316 | 316 | |
317 | - return $spotter_array; |
|
318 | - } |
|
317 | + return $spotter_array; |
|
318 | + } |
|
319 | 319 | |
320 | 320 | |
321 | 321 | |
322 | - /** |
|
323 | - * Gets all the archive spotter information |
|
324 | - * |
|
325 | - * @return Array the spotter information |
|
326 | - * |
|
327 | - */ |
|
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | - { |
|
330 | - $Tracker = new Tracker($this->db); |
|
331 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
322 | + /** |
|
323 | + * Gets all the archive spotter information |
|
324 | + * |
|
325 | + * @return Array the spotter information |
|
326 | + * |
|
327 | + */ |
|
328 | + public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
329 | + { |
|
330 | + $Tracker = new Tracker($this->db); |
|
331 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
335 | 335 | |
336 | - return $spotter_array; |
|
337 | - } |
|
336 | + return $spotter_array; |
|
337 | + } |
|
338 | 338 | |
339 | 339 | public function deleteTrackerArchiveTrackData() |
340 | 340 | { |
@@ -354,34 +354,34 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Gets Minimal Live Tracker data |
|
358 | - * |
|
359 | - * @return Array the spotter information |
|
360 | - * |
|
361 | - */ |
|
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | - { |
|
364 | - global $globalDBdriver, $globalLiveInterval; |
|
365 | - date_default_timezone_set('UTC'); |
|
366 | - |
|
367 | - $filter_query = ''; |
|
368 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | - } |
|
371 | - // Use spotter_output also ? |
|
372 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | - } |
|
375 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | - } |
|
378 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | - } |
|
357 | + * Gets Minimal Live Tracker data |
|
358 | + * |
|
359 | + * @return Array the spotter information |
|
360 | + * |
|
361 | + */ |
|
362 | + public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
363 | + { |
|
364 | + global $globalDBdriver, $globalLiveInterval; |
|
365 | + date_default_timezone_set('UTC'); |
|
381 | 366 | |
382 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | - if ($globalDBdriver == 'mysql') { |
|
384 | - /* |
|
367 | + $filter_query = ''; |
|
368 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
370 | + } |
|
371 | + // Use spotter_output also ? |
|
372 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | + } |
|
375 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
376 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
377 | + } |
|
378 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
380 | + } |
|
381 | + |
|
382 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
383 | + if ($globalDBdriver == 'mysql') { |
|
384 | + /* |
|
385 | 385 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
386 | 386 | FROM tracker_archive |
387 | 387 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -400,56 +400,56 @@ discard block |
||
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | - } else { |
|
404 | - //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
403 | + } else { |
|
404 | + //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
409 | 409 | '.$filter_query.' ORDER BY famtrackid'; |
410 | - } |
|
411 | - //echo $query; |
|
412 | - try { |
|
413 | - $sth = $this->db->prepare($query); |
|
414 | - $sth->execute(); |
|
415 | - } catch(PDOException $e) { |
|
416 | - echo $e->getMessage(); |
|
417 | - die; |
|
418 | - } |
|
419 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
410 | + } |
|
411 | + //echo $query; |
|
412 | + try { |
|
413 | + $sth = $this->db->prepare($query); |
|
414 | + $sth->execute(); |
|
415 | + } catch(PDOException $e) { |
|
416 | + echo $e->getMessage(); |
|
417 | + die; |
|
418 | + } |
|
419 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
420 | 420 | |
421 | - return $spotter_array; |
|
422 | - } |
|
421 | + return $spotter_array; |
|
422 | + } |
|
423 | 423 | |
424 | 424 | /** |
425 | - * Gets Minimal Live Tracker data |
|
426 | - * |
|
427 | - * @return Array the spotter information |
|
428 | - * |
|
429 | - */ |
|
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | - { |
|
432 | - global $globalDBdriver, $globalLiveInterval; |
|
433 | - date_default_timezone_set('UTC'); |
|
434 | - |
|
435 | - $filter_query = ''; |
|
436 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | - } |
|
439 | - // Should use spotter_output also ? |
|
440 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | - } |
|
443 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | - } |
|
446 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | - } |
|
425 | + * Gets Minimal Live Tracker data |
|
426 | + * |
|
427 | + * @return Array the spotter information |
|
428 | + * |
|
429 | + */ |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
431 | + { |
|
432 | + global $globalDBdriver, $globalLiveInterval; |
|
433 | + date_default_timezone_set('UTC'); |
|
434 | + |
|
435 | + $filter_query = ''; |
|
436 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
438 | + } |
|
439 | + // Should use spotter_output also ? |
|
440 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | + } |
|
443 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
444 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
445 | + } |
|
446 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
448 | + } |
|
449 | 449 | |
450 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | - if ($globalDBdriver == 'mysql') { |
|
452 | - /* |
|
450 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
451 | + if ($globalDBdriver == 'mysql') { |
|
452 | + /* |
|
453 | 453 | $query = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk |
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
@@ -460,95 +460,95 @@ discard block |
||
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
461 | 461 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
462 | 462 | |
463 | - } else { |
|
464 | - //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | - /* |
|
463 | + } else { |
|
464 | + //$query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao'; |
|
465 | + /* |
|
466 | 466 | $query = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
467 | 467 | FROM tracker_archive_output |
468 | 468 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
476 | 476 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
477 | 477 | // .' GROUP BY spotter_output.famtrackid, 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'; |
478 | 478 | |
479 | - } |
|
480 | - //echo $query; |
|
481 | - try { |
|
482 | - $sth = $this->db->prepare($query); |
|
483 | - $sth->execute(); |
|
484 | - } catch(PDOException $e) { |
|
485 | - echo $e->getMessage(); |
|
486 | - die; |
|
487 | - } |
|
488 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
479 | + } |
|
480 | + //echo $query; |
|
481 | + try { |
|
482 | + $sth = $this->db->prepare($query); |
|
483 | + $sth->execute(); |
|
484 | + } catch(PDOException $e) { |
|
485 | + echo $e->getMessage(); |
|
486 | + die; |
|
487 | + } |
|
488 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
489 | 489 | |
490 | - return $spotter_array; |
|
491 | - } |
|
490 | + return $spotter_array; |
|
491 | + } |
|
492 | 492 | |
493 | 493 | /** |
494 | - * Gets count Live Tracker data |
|
495 | - * |
|
496 | - * @return Array the spotter information |
|
497 | - * |
|
498 | - */ |
|
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | - { |
|
501 | - global $globalDBdriver, $globalLiveInterval; |
|
502 | - date_default_timezone_set('UTC'); |
|
503 | - |
|
504 | - $filter_query = ''; |
|
505 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | - } |
|
508 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | - } |
|
511 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | - } |
|
514 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | - } |
|
494 | + * Gets count Live Tracker data |
|
495 | + * |
|
496 | + * @return Array the spotter information |
|
497 | + * |
|
498 | + */ |
|
499 | + public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
500 | + { |
|
501 | + global $globalDBdriver, $globalLiveInterval; |
|
502 | + date_default_timezone_set('UTC'); |
|
517 | 503 | |
518 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | - if ($globalDBdriver == 'mysql') { |
|
504 | + $filter_query = ''; |
|
505 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
507 | + } |
|
508 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | + } |
|
511 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
512 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
|
513 | + } |
|
514 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
516 | + } |
|
517 | + |
|
518 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
519 | + if ($globalDBdriver == 'mysql') { |
|
520 | 520 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb |
521 | 521 | FROM tracker_archive l |
522 | 522 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
523 | - } else { |
|
523 | + } else { |
|
524 | 524 | $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
525 | - } |
|
526 | - //echo $query; |
|
527 | - try { |
|
528 | - $sth = $this->db->prepare($query); |
|
529 | - $sth->execute(); |
|
530 | - } catch(PDOException $e) { |
|
531 | - echo $e->getMessage(); |
|
532 | - die; |
|
533 | - } |
|
525 | + } |
|
526 | + //echo $query; |
|
527 | + try { |
|
528 | + $sth = $this->db->prepare($query); |
|
529 | + $sth->execute(); |
|
530 | + } catch(PDOException $e) { |
|
531 | + echo $e->getMessage(); |
|
532 | + die; |
|
533 | + } |
|
534 | 534 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
535 | 535 | $sth->closeCursor(); |
536 | - return $result['nb']; |
|
536 | + return $result['nb']; |
|
537 | 537 | |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | 540 | |
541 | 541 | |
542 | 542 | // tracker_archive_output |
543 | 543 | |
544 | - /** |
|
545 | - * Gets all the spotter information |
|
546 | - * |
|
547 | - * @return Array the spotter information |
|
548 | - * |
|
549 | - */ |
|
550 | - public function searchTrackerData($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()) |
|
551 | - { |
|
544 | + /** |
|
545 | + * Gets all the spotter information |
|
546 | + * |
|
547 | + * @return Array the spotter information |
|
548 | + * |
|
549 | + */ |
|
550 | + public function searchTrackerData($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()) |
|
551 | + { |
|
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
554 | 554 | $Translation = new Translation($this->db); |
@@ -562,159 +562,159 @@ discard block |
||
562 | 562 | $filter_query = $this->getFilter($filters); |
563 | 563 | if ($q != "") |
564 | 564 | { |
565 | - if (!is_string($q)) |
|
566 | - { |
|
565 | + if (!is_string($q)) |
|
566 | + { |
|
567 | 567 | return false; |
568 | - } else { |
|
568 | + } else { |
|
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | 572 | foreach ($q_array as $q_item){ |
573 | - $additional_query .= " AND ("; |
|
574 | - $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | - $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | - $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | - $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | - $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | - $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | - $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | - $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | - $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | - $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | - $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | - $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | - $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | - $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | - $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | - $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | - $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | - $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | - $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | - $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | - $translate = $Translation->ident2icao($q_item); |
|
595 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | - $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | - $additional_query .= ")"; |
|
573 | + $additional_query .= " AND ("; |
|
574 | + $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
575 | + $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
576 | + $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
577 | + $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
578 | + $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
579 | + $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR "; |
|
580 | + $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR "; |
|
581 | + $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
582 | + $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
583 | + $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
584 | + $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
585 | + $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
586 | + $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
587 | + $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
588 | + $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
589 | + $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR "; |
|
590 | + $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR "; |
|
591 | + $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
592 | + $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
593 | + $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
|
594 | + $translate = $Translation->ident2icao($q_item); |
|
595 | + if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
596 | + $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
|
597 | + $additional_query .= ")"; |
|
598 | + } |
|
598 | 599 | } |
599 | - } |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | - if (!is_string($registration)) |
|
606 | - { |
|
604 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
605 | + if (!is_string($registration)) |
|
606 | + { |
|
607 | 607 | return false; |
608 | - } else { |
|
608 | + } else { |
|
609 | 609 | $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')"; |
610 | - } |
|
610 | + } |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | - if (!is_string($aircraft_icao)) |
|
617 | - { |
|
615 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
616 | + if (!is_string($aircraft_icao)) |
|
617 | + { |
|
618 | 618 | return false; |
619 | - } else { |
|
619 | + } else { |
|
620 | 620 | $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
621 | - } |
|
621 | + } |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | - if (!is_string($aircraft_manufacturer)) |
|
628 | - { |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
627 | + if (!is_string($aircraft_manufacturer)) |
|
628 | + { |
|
629 | 629 | return false; |
630 | - } else { |
|
630 | + } else { |
|
631 | 631 | $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
632 | - } |
|
632 | + } |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | if ($highlights == "true") |
636 | 636 | { |
637 | - if (!is_string($highlights)) |
|
638 | - { |
|
637 | + if (!is_string($highlights)) |
|
638 | + { |
|
639 | 639 | return false; |
640 | - } else { |
|
640 | + } else { |
|
641 | 641 | $additional_query .= " AND (tracker_archive_output.highlight <> '')"; |
642 | - } |
|
642 | + } |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | - if (!is_string($airline_icao)) |
|
649 | - { |
|
647 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
648 | + if (!is_string($airline_icao)) |
|
649 | + { |
|
650 | 650 | return false; |
651 | - } else { |
|
651 | + } else { |
|
652 | 652 | $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')"; |
653 | - } |
|
653 | + } |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | - if (!is_string($airline_country)) |
|
660 | - { |
|
658 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
659 | + if (!is_string($airline_country)) |
|
660 | + { |
|
661 | 661 | return false; |
662 | - } else { |
|
662 | + } else { |
|
663 | 663 | $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')"; |
664 | - } |
|
664 | + } |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | - if (!is_string($airline_type)) |
|
671 | - { |
|
669 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
670 | + if (!is_string($airline_type)) |
|
671 | + { |
|
672 | 672 | return false; |
673 | - } else { |
|
673 | + } else { |
|
674 | 674 | if ($airline_type == "passenger") |
675 | 675 | { |
676 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
676 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')"; |
|
677 | 677 | } |
678 | 678 | if ($airline_type == "cargo") |
679 | 679 | { |
680 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
680 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')"; |
|
681 | 681 | } |
682 | 682 | if ($airline_type == "military") |
683 | 683 | { |
684 | - $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
684 | + $additional_query .= " AND (tracker_archive_output.airline_type = 'military')"; |
|
685 | + } |
|
685 | 686 | } |
686 | - } |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | - if (!is_string($airport)) |
|
693 | - { |
|
691 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
692 | + if (!is_string($airport)) |
|
693 | + { |
|
694 | 694 | return false; |
695 | - } else { |
|
695 | + } else { |
|
696 | 696 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))"; |
697 | - } |
|
697 | + } |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | - if (!is_string($airport_country)) |
|
704 | - { |
|
702 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
703 | + if (!is_string($airport_country)) |
|
704 | + { |
|
705 | 705 | return false; |
706 | - } else { |
|
706 | + } else { |
|
707 | 707 | $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))"; |
708 | - } |
|
708 | + } |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | - if (!is_string($callsign)) |
|
715 | - { |
|
713 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
714 | + if (!is_string($callsign)) |
|
715 | + { |
|
716 | 716 | return false; |
717 | - } else { |
|
717 | + } else { |
|
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
@@ -722,99 +722,99 @@ discard block |
||
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
725 | - } |
|
725 | + } |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | - if (!is_string($owner)) |
|
732 | - { |
|
730 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
731 | + if (!is_string($owner)) |
|
732 | + { |
|
733 | 733 | return false; |
734 | - } else { |
|
734 | + } else { |
|
735 | 735 | $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')"; |
736 | - } |
|
736 | + } |
|
737 | 737 | } |
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | - if (!is_string($pilot_name)) |
|
743 | - { |
|
741 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
742 | + if (!is_string($pilot_name)) |
|
743 | + { |
|
744 | 744 | return false; |
745 | - } else { |
|
745 | + } else { |
|
746 | 746 | $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')"; |
747 | - } |
|
747 | + } |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | - if (!is_string($pilot_id)) |
|
754 | - { |
|
752 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
753 | + if (!is_string($pilot_id)) |
|
754 | + { |
|
755 | 755 | return false; |
756 | - } else { |
|
756 | + } else { |
|
757 | 757 | $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')"; |
758 | - } |
|
758 | + } |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | - if (!is_string($departure_airport_route)) |
|
765 | - { |
|
763 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
764 | + if (!is_string($departure_airport_route)) |
|
765 | + { |
|
766 | 766 | return false; |
767 | - } else { |
|
767 | + } else { |
|
768 | 768 | $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
769 | - } |
|
769 | + } |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | - if (!is_string($arrival_airport_route)) |
|
776 | - { |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
775 | + if (!is_string($arrival_airport_route)) |
|
776 | + { |
|
777 | 777 | return false; |
778 | - } else { |
|
778 | + } else { |
|
779 | 779 | $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
780 | - } |
|
780 | + } |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | if ($altitude != "") |
784 | 784 | { |
785 | - $altitude_array = explode(",", $altitude); |
|
785 | + $altitude_array = explode(",", $altitude); |
|
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | - if ($altitude_array[1] != "") |
|
792 | - { |
|
791 | + if ($altitude_array[1] != "") |
|
792 | + { |
|
793 | 793 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
794 | 794 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
795 | 795 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
796 | - } else { |
|
796 | + } else { |
|
797 | 797 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
798 | 798 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
799 | - } |
|
799 | + } |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | if ($date_posted != "") |
803 | 803 | { |
804 | - $date_array = explode(",", $date_posted); |
|
804 | + $date_array = explode(",", $date_posted); |
|
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | - if ($globalTimezone != '') { |
|
809 | + if ($globalTimezone != '') { |
|
810 | 810 | date_default_timezone_set($globalTimezone); |
811 | 811 | $datetime = new DateTime(); |
812 | 812 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
813 | + } else $offset = '+00:00'; |
|
814 | 814 | |
815 | 815 | |
816 | - if ($date_array[1] != "") |
|
817 | - { |
|
816 | + if ($date_array[1] != "") |
|
817 | + { |
|
818 | 818 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
819 | 819 | $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1])); |
820 | 820 | if ($globalDBdriver == 'mysql') { |
@@ -822,28 +822,28 @@ discard block |
||
822 | 822 | } else { |
823 | 823 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) "; |
824 | 824 | } |
825 | - } else { |
|
825 | + } else { |
|
826 | 826 | $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0])); |
827 | - if ($globalDBdriver == 'mysql') { |
|
827 | + if ($globalDBdriver == 'mysql') { |
|
828 | 828 | $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' "; |
829 | 829 | } else { |
830 | 830 | $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) "; |
831 | 831 | } |
832 | - } |
|
832 | + } |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | if ($limit != "") |
836 | 836 | { |
837 | - $limit_array = explode(",", $limit); |
|
837 | + $limit_array = explode(",", $limit); |
|
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | - { |
|
842 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
843 | + { |
|
844 | 844 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
845 | 845 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
846 | - } |
|
846 | + } |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | |
@@ -874,33 +874,33 @@ discard block |
||
874 | 874 | $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - public function deleteTrackerArchiveData() |
|
880 | - { |
|
879 | + public function deleteTrackerArchiveData() |
|
880 | + { |
|
881 | 881 | global $globalArchiveKeepMonths, $globalDBdriver; |
882 | - date_default_timezone_set('UTC'); |
|
883 | - if ($globalDBdriver == 'mysql') { |
|
882 | + date_default_timezone_set('UTC'); |
|
883 | + if ($globalDBdriver == 'mysql') { |
|
884 | 884 | $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)'; |
885 | 885 | } else { |
886 | 886 | $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'"; |
887 | 887 | } |
888 | - try { |
|
889 | - $sth = $this->db->prepare($query); |
|
890 | - $sth->execute(); |
|
891 | - } catch(PDOException $e) { |
|
892 | - return "error"; |
|
893 | - } |
|
888 | + try { |
|
889 | + $sth = $this->db->prepare($query); |
|
890 | + $sth->execute(); |
|
891 | + } catch(PDOException $e) { |
|
892 | + return "error"; |
|
893 | + } |
|
894 | 894 | } |
895 | 895 | |
896 | - /** |
|
897 | - * Gets all the spotter information based on the callsign |
|
898 | - * |
|
899 | - * @return Array the spotter information |
|
900 | - * |
|
901 | - */ |
|
902 | - public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | - { |
|
896 | + /** |
|
897 | + * Gets all the spotter information based on the callsign |
|
898 | + * |
|
899 | + * @return Array the spotter information |
|
900 | + * |
|
901 | + */ |
|
902 | + public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '') |
|
903 | + { |
|
904 | 904 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
905 | 905 | |
906 | 906 | date_default_timezone_set('UTC'); |
@@ -912,35 +912,35 @@ discard block |
||
912 | 912 | |
913 | 913 | if ($ident != "") |
914 | 914 | { |
915 | - if (!is_string($ident)) |
|
916 | - { |
|
915 | + if (!is_string($ident)) |
|
916 | + { |
|
917 | 917 | return false; |
918 | - } else { |
|
918 | + } else { |
|
919 | 919 | $additional_query = " AND (tracker_archive_output.ident = :ident)"; |
920 | 920 | $query_values = array(':ident' => $ident); |
921 | - } |
|
921 | + } |
|
922 | 922 | } |
923 | 923 | |
924 | 924 | if ($limit != "") |
925 | 925 | { |
926 | - $limit_array = explode(",", $limit); |
|
926 | + $limit_array = explode(",", $limit); |
|
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | - { |
|
931 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
932 | + { |
|
933 | 933 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
934 | 934 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
935 | - } |
|
935 | + } |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | if ($sort != "") |
939 | 939 | { |
940 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
940 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
941 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
942 | 942 | } else { |
943 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
943 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
944 | 944 | } |
945 | 945 | |
946 | 946 | $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -948,17 +948,17 @@ discard block |
||
948 | 948 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
949 | 949 | |
950 | 950 | return $spotter_array; |
951 | - } |
|
951 | + } |
|
952 | 952 | |
953 | 953 | |
954 | - /** |
|
955 | - * Gets all the spotter information based on the owner |
|
956 | - * |
|
957 | - * @return Array the spotter information |
|
958 | - * |
|
959 | - */ |
|
960 | - public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | - { |
|
954 | + /** |
|
955 | + * Gets all the spotter information based on the owner |
|
956 | + * |
|
957 | + * @return Array the spotter information |
|
958 | + * |
|
959 | + */ |
|
960 | + public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
961 | + { |
|
962 | 962 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
963 | 963 | |
964 | 964 | date_default_timezone_set('UTC'); |
@@ -971,35 +971,35 @@ discard block |
||
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
974 | - if (!is_string($owner)) |
|
975 | - { |
|
974 | + if (!is_string($owner)) |
|
975 | + { |
|
976 | 976 | return false; |
977 | - } else { |
|
977 | + } else { |
|
978 | 978 | $additional_query = " AND (tracker_archive_output.owner_name = :owner)"; |
979 | 979 | $query_values = array(':owner' => $owner); |
980 | - } |
|
980 | + } |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | if ($limit != "") |
984 | 984 | { |
985 | - $limit_array = explode(",", $limit); |
|
985 | + $limit_array = explode(",", $limit); |
|
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | - { |
|
990 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
991 | + { |
|
992 | 992 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
993 | 993 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
994 | - } |
|
994 | + } |
|
995 | 995 | } |
996 | 996 | |
997 | 997 | if ($sort != "") |
998 | 998 | { |
999 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
999 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1000 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1001 | 1001 | } else { |
1002 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1002 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | 1005 | $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1007,16 +1007,16 @@ discard block |
||
1007 | 1007 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1008 | 1008 | |
1009 | 1009 | return $spotter_array; |
1010 | - } |
|
1011 | - |
|
1012 | - /** |
|
1013 | - * Gets all the spotter information based on the pilot |
|
1014 | - * |
|
1015 | - * @return Array the spotter information |
|
1016 | - * |
|
1017 | - */ |
|
1018 | - public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | - { |
|
1010 | + } |
|
1011 | + |
|
1012 | + /** |
|
1013 | + * Gets all the spotter information based on the pilot |
|
1014 | + * |
|
1015 | + * @return Array the spotter information |
|
1016 | + * |
|
1017 | + */ |
|
1018 | + public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1019 | + { |
|
1020 | 1020 | $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output"; |
1021 | 1021 | |
1022 | 1022 | date_default_timezone_set('UTC'); |
@@ -1035,24 +1035,24 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | if ($limit != "") |
1037 | 1037 | { |
1038 | - $limit_array = explode(",", $limit); |
|
1038 | + $limit_array = explode(",", $limit); |
|
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | - { |
|
1043 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1044 | + { |
|
1045 | 1045 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1046 | 1046 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1047 | - } |
|
1047 | + } |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | 1050 | if ($sort != "") |
1051 | 1051 | { |
1052 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1052 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1053 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1054 | 1054 | } else { |
1055 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1055 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1060,16 +1060,16 @@ discard block |
||
1060 | 1060 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1061 | 1061 | |
1062 | 1062 | return $spotter_array; |
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Gets all number of flight over countries |
|
1067 | - * |
|
1068 | - * @return Array the airline country list |
|
1069 | - * |
|
1070 | - */ |
|
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | - { |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Gets all number of flight over countries |
|
1067 | + * |
|
1068 | + * @return Array the airline country list |
|
1069 | + * |
|
1070 | + */ |
|
1071 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1072 | + { |
|
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
1075 | 1075 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1079,14 +1079,14 @@ discard block |
||
1079 | 1079 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1080 | 1080 | FROM countries c, tracker_archive s |
1081 | 1081 | WHERE c.iso2 = s.over_country "; |
1082 | - if ($olderthanmonths > 0) { |
|
1083 | - if ($globalDBdriver == 'mysql') { |
|
1082 | + if ($olderthanmonths > 0) { |
|
1083 | + if ($globalDBdriver == 'mysql') { |
|
1084 | 1084 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1085 | 1085 | } else { |
1086 | 1086 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1087 | 1087 | } |
1088 | 1088 | } |
1089 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1089 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1090 | 1090 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1091 | 1091 | if ($limit) $query .= " LIMIT 0,10"; |
1092 | 1092 | |
@@ -1099,23 +1099,23 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1101 | 1101 | { |
1102 | - $temp_array['flight_count'] = $row['nb']; |
|
1103 | - $temp_array['flight_country'] = $row['name']; |
|
1104 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | - $flight_array[] = $temp_array; |
|
1102 | + $temp_array['flight_count'] = $row['nb']; |
|
1103 | + $temp_array['flight_country'] = $row['name']; |
|
1104 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1105 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1106 | + $flight_array[] = $temp_array; |
|
1107 | 1107 | } |
1108 | 1108 | return $flight_array; |
1109 | - } |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * Gets all number of flight over countries |
|
1113 | - * |
|
1114 | - * @return Array the airline country list |
|
1115 | - * |
|
1116 | - */ |
|
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | - { |
|
1109 | + } |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * Gets all number of flight over countries |
|
1113 | + * |
|
1114 | + * @return Array the airline country list |
|
1115 | + * |
|
1116 | + */ |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1118 | + { |
|
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
1121 | 1121 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1125,14 +1125,14 @@ discard block |
||
1125 | 1125 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1126 | 1126 | FROM countries c, tracker_archive s, spotter_output o |
1127 | 1127 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid "; |
1128 | - if ($olderthanmonths > 0) { |
|
1129 | - if ($globalDBdriver == 'mysql') { |
|
1128 | + if ($olderthanmonths > 0) { |
|
1129 | + if ($globalDBdriver == 'mysql') { |
|
1130 | 1130 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1131 | 1131 | } else { |
1132 | 1132 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1133 | } |
1134 | 1134 | } |
1135 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1135 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1136 | 1136 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | 1137 | if ($limit) $query .= " LIMIT 0,10"; |
1138 | 1138 | |
@@ -1145,24 +1145,24 @@ discard block |
||
1145 | 1145 | |
1146 | 1146 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1147 | 1147 | { |
1148 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | - $temp_array['flight_count'] = $row['nb']; |
|
1150 | - $temp_array['flight_country'] = $row['name']; |
|
1151 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | - $flight_array[] = $temp_array; |
|
1148 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1149 | + $temp_array['flight_count'] = $row['nb']; |
|
1150 | + $temp_array['flight_country'] = $row['name']; |
|
1151 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1152 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1153 | + $flight_array[] = $temp_array; |
|
1154 | 1154 | } |
1155 | 1155 | return $flight_array; |
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * Gets last spotter information based on a particular callsign |
|
1160 | - * |
|
1161 | - * @return Array the spotter information |
|
1162 | - * |
|
1163 | - */ |
|
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | - { |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * Gets last spotter information based on a particular callsign |
|
1160 | + * |
|
1161 | + * @return Array the spotter information |
|
1162 | + * |
|
1163 | + */ |
|
1164 | + public function getDateArchiveTrackerDataById($id,$date) |
|
1165 | + { |
|
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1170,16 +1170,16 @@ discard block |
||
1170 | 1170 | $date = date('c',$date); |
1171 | 1171 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1172 | 1172 | return $spotter_array; |
1173 | - } |
|
1174 | - |
|
1175 | - /** |
|
1176 | - * Gets all the spotter information based on a particular callsign |
|
1177 | - * |
|
1178 | - * @return Array the spotter information |
|
1179 | - * |
|
1180 | - */ |
|
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | - { |
|
1173 | + } |
|
1174 | + |
|
1175 | + /** |
|
1176 | + * Gets all the spotter information based on a particular callsign |
|
1177 | + * |
|
1178 | + * @return Array the spotter information |
|
1179 | + * |
|
1180 | + */ |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1182 | + { |
|
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1187,16 +1187,16 @@ discard block |
||
1187 | 1187 | $date = date('c',$date); |
1188 | 1188 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1189 | 1189 | return $spotter_array; |
1190 | - } |
|
1191 | - |
|
1192 | - /** |
|
1193 | - * Gets all the spotter information based on the airport |
|
1194 | - * |
|
1195 | - * @return Array the spotter information |
|
1196 | - * |
|
1197 | - */ |
|
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | - { |
|
1190 | + } |
|
1191 | + |
|
1192 | + /** |
|
1193 | + * Gets all the spotter information based on the airport |
|
1194 | + * |
|
1195 | + * @return Array the spotter information |
|
1196 | + * |
|
1197 | + */ |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1199 | + { |
|
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
1202 | 1202 | date_default_timezone_set('UTC'); |
@@ -1207,35 +1207,35 @@ discard block |
||
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
1210 | - if (!is_string($airport)) |
|
1211 | - { |
|
1210 | + if (!is_string($airport)) |
|
1211 | + { |
|
1212 | 1212 | return false; |
1213 | - } else { |
|
1213 | + } else { |
|
1214 | 1214 | $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))"; |
1215 | 1215 | $query_values = array(':airport' => $airport); |
1216 | - } |
|
1216 | + } |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | if ($limit != "") |
1220 | 1220 | { |
1221 | - $limit_array = explode(",", $limit); |
|
1221 | + $limit_array = explode(",", $limit); |
|
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | - { |
|
1226 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1227 | + { |
|
1228 | 1228 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1229 | 1229 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | } |
1232 | 1232 | |
1233 | 1233 | if ($sort != "") |
1234 | 1234 | { |
1235 | - $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1235 | + $search_orderby_array = $Tracker->getOrderBy(); |
|
1236 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1237 | 1237 | } else { |
1238 | - $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1238 | + $orderby_query = " ORDER BY tracker_archive_output.date DESC"; |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1243,6 +1243,6 @@ discard block |
||
1243 | 1243 | $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
1244 | 1244 | |
1245 | 1245 | return $spotter_array; |
1246 | - } |
|
1246 | + } |
|
1247 | 1247 | } |
1248 | 1248 | ?> |
1249 | 1249 | \ No newline at end of file |
@@ -14,33 +14,33 @@ discard block |
||
14 | 14 | * @param Array $filter the filter |
15 | 15 | * @return Array the SQL part |
16 | 16 | */ |
17 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
17 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
18 | 18 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
19 | 19 | $filters = array(); |
20 | 20 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
21 | 21 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
22 | 22 | $filters = $globalStatsFilters[$globalFilterName]; |
23 | 23 | } else { |
24 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
24 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | if (isset($filter[0]['source'])) { |
28 | - $filters = array_merge($filters,$filter); |
|
28 | + $filters = array_merge($filters, $filter); |
|
29 | 29 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
30 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
31 | 31 | $filter_query_join = ''; |
32 | 32 | $filter_query_where = ''; |
33 | - foreach($filters as $flt) { |
|
33 | + foreach ($filters as $flt) { |
|
34 | 34 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
35 | 35 | if (isset($flt['source'])) { |
36 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
36 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
37 | 37 | } else { |
38 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
38 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid"; |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
42 | 42 | if (isset($filter['source']) && !empty($filter['source'])) { |
43 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
43 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
44 | 44 | } |
45 | 45 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
46 | 46 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
@@ -68,38 +68,38 @@ discard block |
||
68 | 68 | $filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'"; |
69 | 69 | } |
70 | 70 | } |
71 | - $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
71 | + $filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid"; |
|
72 | 72 | } |
73 | 73 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
74 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
75 | 75 | } |
76 | 76 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
77 | 77 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
78 | 78 | if ($filter_query_where != '') { |
79 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
79 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
80 | 80 | } |
81 | 81 | $filter_query = $filter_query_join.$filter_query_where; |
82 | 82 | return $filter_query; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // tracker_archive |
86 | - public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') { |
|
86 | + public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') { |
|
87 | 87 | require_once(dirname(__FILE__).'/class.Tracker.php'); |
88 | 88 | if ($over_country == '') { |
89 | 89 | $Tracker = new Tracker($this->db); |
90 | - $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
|
90 | + $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude); |
|
91 | 91 | if (!empty($data_country)) $country = $data_country['iso2']; |
92 | 92 | else $country = ''; |
93 | 93 | } else $country = $over_country; |
94 | 94 | // Route is not added in tracker_archive |
95 | - $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
95 | + $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
|
96 | 96 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
97 | - $query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type); |
|
97 | + $query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type); |
|
98 | 98 | try { |
99 | 99 | $sth = $this->db->prepare($query); |
100 | 100 | $sth->execute($query_values); |
101 | 101 | $sth->closeCursor(); |
102 | - } catch(PDOException $e) { |
|
102 | + } catch (PDOException $e) { |
|
103 | 103 | return "error : ".$e->getMessage(); |
104 | 104 | } |
105 | 105 | return "success"; |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
121 | 121 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
122 | - $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
122 | + $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
123 | 123 | |
124 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident)); |
|
124 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident)); |
|
125 | 125 | |
126 | 126 | return $spotter_array; |
127 | 127 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
141 | 141 | //$query = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id"; |
142 | 142 | //$query = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
143 | - $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
143 | + $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1"; |
|
144 | 144 | |
145 | 145 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
146 | 146 | /* |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | } |
154 | 154 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
155 | 155 | */ |
156 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id)); |
|
156 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id)); |
|
157 | 157 | |
158 | 158 | return $spotter_array; |
159 | 159 | } |
@@ -168,14 +168,14 @@ discard block |
||
168 | 168 | { |
169 | 169 | date_default_timezone_set('UTC'); |
170 | 170 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
171 | - $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
171 | + $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
172 | 172 | |
173 | 173 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
174 | 174 | |
175 | 175 | try { |
176 | 176 | $sth = $this->db->prepare($query); |
177 | 177 | $sth->execute(array(':id' => $id)); |
178 | - } catch(PDOException $e) { |
|
178 | + } catch (PDOException $e) { |
|
179 | 179 | echo $e->getMessage(); |
180 | 180 | die; |
181 | 181 | } |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | { |
195 | 195 | date_default_timezone_set('UTC'); |
196 | 196 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
197 | - $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
197 | + $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id"; |
|
198 | 198 | |
199 | 199 | // $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id)); |
200 | 200 | |
201 | 201 | try { |
202 | 202 | $sth = $this->db->prepare($query); |
203 | 203 | $sth->execute(array(':id' => $id)); |
204 | - } catch(PDOException $e) { |
|
204 | + } catch (PDOException $e) { |
|
205 | 205 | echo $e->getMessage(); |
206 | 206 | die; |
207 | 207 | } |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | date_default_timezone_set('UTC'); |
224 | 224 | |
225 | 225 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
226 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
226 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
227 | 227 | |
228 | 228 | try { |
229 | 229 | $sth = $this->db->prepare($query); |
230 | 230 | $sth->execute(array(':ident' => $ident)); |
231 | - } catch(PDOException $e) { |
|
231 | + } catch (PDOException $e) { |
|
232 | 232 | echo $e->getMessage(); |
233 | 233 | die; |
234 | 234 | } |
@@ -249,12 +249,12 @@ discard block |
||
249 | 249 | date_default_timezone_set('UTC'); |
250 | 250 | |
251 | 251 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
252 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
252 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date"; |
|
253 | 253 | |
254 | 254 | try { |
255 | 255 | $sth = $this->db->prepare($query); |
256 | 256 | $sth->execute(array(':id' => $id)); |
257 | - } catch(PDOException $e) { |
|
257 | + } catch (PDOException $e) { |
|
258 | 258 | echo $e->getMessage(); |
259 | 259 | die; |
260 | 260 | } |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | date_default_timezone_set('UTC'); |
276 | 276 | |
277 | 277 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
278 | - $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
278 | + $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date"; |
|
279 | 279 | |
280 | 280 | try { |
281 | 281 | $sth = $this->db->prepare($query); |
282 | 282 | $sth->execute(array(':id' => $id)); |
283 | - } catch(PDOException $e) { |
|
283 | + } catch (PDOException $e) { |
|
284 | 284 | echo $e->getMessage(); |
285 | 285 | die; |
286 | 286 | } |
@@ -302,13 +302,13 @@ discard block |
||
302 | 302 | date_default_timezone_set('UTC'); |
303 | 303 | |
304 | 304 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
305 | - $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
305 | + $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1"; |
|
306 | 306 | // $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident"; |
307 | 307 | |
308 | 308 | try { |
309 | 309 | $sth = $this->db->prepare($query); |
310 | 310 | $sth->execute(array(':ident' => $ident)); |
311 | - } catch(PDOException $e) { |
|
311 | + } catch (PDOException $e) { |
|
312 | 312 | echo $e->getMessage(); |
313 | 313 | die; |
314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | * @return Array the spotter information |
326 | 326 | * |
327 | 327 | */ |
328 | - public function getTrackerArchiveData($ident,$famtrackid,$date) |
|
328 | + public function getTrackerArchiveData($ident, $famtrackid, $date) |
|
329 | 329 | { |
330 | 330 | $Tracker = new Tracker($this->db); |
331 | 331 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
332 | - $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
332 | + $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate"; |
|
333 | 333 | |
334 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%')); |
|
334 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%')); |
|
335 | 335 | |
336 | 336 | return $spotter_array; |
337 | 337 | } |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | try { |
348 | 348 | $sth = $this->db->prepare($query); |
349 | 349 | $sth->execute(); |
350 | - } catch(PDOException $e) { |
|
350 | + } catch (PDOException $e) { |
|
351 | 351 | echo $e->getMessage(); |
352 | 352 | die; |
353 | 353 | } |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | * @return Array the spotter information |
360 | 360 | * |
361 | 361 | */ |
362 | - public function getMinLiveTrackerData($begindate,$enddate,$filter = array()) |
|
362 | + public function getMinLiveTrackerData($begindate, $enddate, $filter = array()) |
|
363 | 363 | { |
364 | 364 | global $globalDBdriver, $globalLiveInterval; |
365 | 365 | date_default_timezone_set('UTC'); |
366 | 366 | |
367 | 367 | $filter_query = ''; |
368 | 368 | if (isset($filter['source']) && !empty($filter['source'])) { |
369 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
369 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
370 | 370 | } |
371 | 371 | // Use spotter_output also ? |
372 | 372 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
373 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
373 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
374 | 374 | } |
375 | 375 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
376 | 376 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
377 | 377 | } |
378 | 378 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
379 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
379 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -395,14 +395,14 @@ discard block |
||
395 | 395 | GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid |
396 | 396 | AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
397 | 397 | */ |
398 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
398 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
399 | 399 | FROM tracker_archive |
400 | 400 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
401 | 401 | WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
402 | 402 | '.$filter_query.' ORDER BY famtrackid'; |
403 | 403 | } else { |
404 | 404 | //$query = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao'; |
405 | - $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
405 | + $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
406 | 406 | FROM tracker_archive |
407 | 407 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao |
408 | 408 | WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".' |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | try { |
413 | 413 | $sth = $this->db->prepare($query); |
414 | 414 | $sth->execute(); |
415 | - } catch(PDOException $e) { |
|
415 | + } catch (PDOException $e) { |
|
416 | 416 | echo $e->getMessage(); |
417 | 417 | die; |
418 | 418 | } |
@@ -427,24 +427,24 @@ discard block |
||
427 | 427 | * @return Array the spotter information |
428 | 428 | * |
429 | 429 | */ |
430 | - public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array()) |
|
430 | + public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array()) |
|
431 | 431 | { |
432 | 432 | global $globalDBdriver, $globalLiveInterval; |
433 | 433 | date_default_timezone_set('UTC'); |
434 | 434 | |
435 | 435 | $filter_query = ''; |
436 | 436 | if (isset($filter['source']) && !empty($filter['source'])) { |
437 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
437 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
438 | 438 | } |
439 | 439 | // Should use spotter_output also ? |
440 | 440 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
441 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
441 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
442 | 442 | } |
443 | 443 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
444 | 444 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
445 | 445 | } |
446 | 446 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
447 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
447 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | FROM tracker_archive |
455 | 455 | INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao'; |
456 | 456 | */ |
457 | - $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
457 | + $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk |
|
458 | 458 | FROM tracker_archive_output |
459 | 459 | LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao |
460 | 460 | WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
470 | 470 | '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow'; |
471 | 471 | */ |
472 | - $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
472 | + $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow |
|
473 | 473 | FROM tracker_archive_output |
474 | 474 | INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao |
475 | 475 | WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".' |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | try { |
482 | 482 | $sth = $this->db->prepare($query); |
483 | 483 | $sth->execute(); |
484 | - } catch(PDOException $e) { |
|
484 | + } catch (PDOException $e) { |
|
485 | 485 | echo $e->getMessage(); |
486 | 486 | die; |
487 | 487 | } |
@@ -496,23 +496,23 @@ discard block |
||
496 | 496 | * @return Array the spotter information |
497 | 497 | * |
498 | 498 | */ |
499 | - public function getLiveTrackerCount($begindate,$enddate,$filter = array()) |
|
499 | + public function getLiveTrackerCount($begindate, $enddate, $filter = array()) |
|
500 | 500 | { |
501 | 501 | global $globalDBdriver, $globalLiveInterval; |
502 | 502 | date_default_timezone_set('UTC'); |
503 | 503 | |
504 | 504 | $filter_query = ''; |
505 | 505 | if (isset($filter['source']) && !empty($filter['source'])) { |
506 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
506 | + $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') "; |
|
507 | 507 | } |
508 | 508 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
509 | - $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
509 | + $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid "; |
|
510 | 510 | } |
511 | 511 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
512 | 512 | $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid "; |
513 | 513 | } |
514 | 514 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
515 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
515 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | try { |
528 | 528 | $sth = $this->db->prepare($query); |
529 | 529 | $sth->execute(); |
530 | - } catch(PDOException $e) { |
|
530 | + } catch (PDOException $e) { |
|
531 | 531 | echo $e->getMessage(); |
532 | 532 | die; |
533 | 533 | } |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @return Array the spotter information |
548 | 548 | * |
549 | 549 | */ |
550 | - public function searchTrackerData($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()) |
|
550 | + public function searchTrackerData($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()) |
|
551 | 551 | { |
552 | 552 | global $globalTimezone, $globalDBdriver; |
553 | 553 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | |
570 | 570 | $q_array = explode(" ", $q); |
571 | 571 | |
572 | - foreach ($q_array as $q_item){ |
|
572 | + foreach ($q_array as $q_item) { |
|
573 | 573 | $additional_query .= " AND ("; |
574 | 574 | $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR "; |
575 | 575 | $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | |
602 | 602 | if ($registration != "") |
603 | 603 | { |
604 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
604 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
605 | 605 | if (!is_string($registration)) |
606 | 606 | { |
607 | 607 | return false; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | |
613 | 613 | if ($aircraft_icao != "") |
614 | 614 | { |
615 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
615 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
616 | 616 | if (!is_string($aircraft_icao)) |
617 | 617 | { |
618 | 618 | return false; |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | if ($aircraft_manufacturer != "") |
625 | 625 | { |
626 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
626 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
627 | 627 | if (!is_string($aircraft_manufacturer)) |
628 | 628 | { |
629 | 629 | return false; |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | if ($airline_icao != "") |
646 | 646 | { |
647 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
647 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
648 | 648 | if (!is_string($airline_icao)) |
649 | 649 | { |
650 | 650 | return false; |
@@ -655,7 +655,7 @@ discard block |
||
655 | 655 | |
656 | 656 | if ($airline_country != "") |
657 | 657 | { |
658 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
658 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
659 | 659 | if (!is_string($airline_country)) |
660 | 660 | { |
661 | 661 | return false; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | |
667 | 667 | if ($airline_type != "") |
668 | 668 | { |
669 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
669 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
670 | 670 | if (!is_string($airline_type)) |
671 | 671 | { |
672 | 672 | return false; |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | |
689 | 689 | if ($airport != "") |
690 | 690 | { |
691 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
691 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
692 | 692 | if (!is_string($airport)) |
693 | 693 | { |
694 | 694 | return false; |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | if ($airport_country != "") |
701 | 701 | { |
702 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
702 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
703 | 703 | if (!is_string($airport_country)) |
704 | 704 | { |
705 | 705 | return false; |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | |
711 | 711 | if ($callsign != "") |
712 | 712 | { |
713 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
713 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
714 | 714 | if (!is_string($callsign)) |
715 | 715 | { |
716 | 716 | return false; |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | $translate = $Translation->ident2icao($callsign); |
719 | 719 | if ($translate != $callsign) { |
720 | 720 | $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)"; |
721 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
721 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
722 | 722 | } else { |
723 | 723 | $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')"; |
724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
727 | 727 | |
728 | 728 | if ($owner != "") |
729 | 729 | { |
730 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
730 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
731 | 731 | if (!is_string($owner)) |
732 | 732 | { |
733 | 733 | return false; |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | |
739 | 739 | if ($pilot_name != "") |
740 | 740 | { |
741 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
741 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
742 | 742 | if (!is_string($pilot_name)) |
743 | 743 | { |
744 | 744 | return false; |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | |
750 | 750 | if ($pilot_id != "") |
751 | 751 | { |
752 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
752 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT); |
|
753 | 753 | if (!is_string($pilot_id)) |
754 | 754 | { |
755 | 755 | return false; |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | |
761 | 761 | if ($departure_airport_route != "") |
762 | 762 | { |
763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
764 | 764 | if (!is_string($departure_airport_route)) |
765 | 765 | { |
766 | 766 | return false; |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | |
772 | 772 | if ($arrival_airport_route != "") |
773 | 773 | { |
774 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
774 | + $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING); |
|
775 | 775 | if (!is_string($arrival_airport_route)) |
776 | 776 | { |
777 | 777 | return false; |
@@ -784,8 +784,8 @@ discard block |
||
784 | 784 | { |
785 | 785 | $altitude_array = explode(",", $altitude); |
786 | 786 | |
787 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
788 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
787 | + $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
788 | + $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
789 | 789 | |
790 | 790 | |
791 | 791 | if ($altitude_array[1] != "") |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | { |
804 | 804 | $date_array = explode(",", $date_posted); |
805 | 805 | |
806 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
807 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
806 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
807 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
808 | 808 | |
809 | 809 | if ($globalTimezone != '') { |
810 | 810 | date_default_timezone_set($globalTimezone); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | { |
837 | 837 | $limit_array = explode(",", $limit); |
838 | 838 | |
839 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
840 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
839 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
840 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
841 | 841 | |
842 | 842 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
843 | 843 | { |
@@ -848,8 +848,8 @@ discard block |
||
848 | 848 | |
849 | 849 | |
850 | 850 | if ($origLat != "" && $origLon != "" && $dist != "") { |
851 | - $dist = number_format($dist*0.621371,2,'.',''); |
|
852 | - $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
851 | + $dist = number_format($dist*0.621371, 2, '.', ''); |
|
852 | + $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
853 | 853 | FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
854 | 854 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance"; |
855 | 855 | } else { |
@@ -866,12 +866,12 @@ discard block |
||
866 | 866 | $additional_query .= " AND (tracker_archive_output.waypoints <> '')"; |
867 | 867 | } |
868 | 868 | |
869 | - $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
869 | + $query = "SELECT tracker_archive_output.* FROM tracker_archive_output |
|
870 | 870 | WHERE tracker_archive_output.ident <> '' |
871 | 871 | ".$additional_query." |
872 | 872 | ".$filter_query.$orderby_query; |
873 | 873 | } |
874 | - $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query); |
|
874 | + $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query); |
|
875 | 875 | |
876 | 876 | return $spotter_array; |
877 | 877 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | try { |
889 | 889 | $sth = $this->db->prepare($query); |
890 | 890 | $sth->execute(); |
891 | - } catch(PDOException $e) { |
|
891 | + } catch (PDOException $e) { |
|
892 | 892 | return "error"; |
893 | 893 | } |
894 | 894 | } |
@@ -925,8 +925,8 @@ discard block |
||
925 | 925 | { |
926 | 926 | $limit_array = explode(",", $limit); |
927 | 927 | |
928 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
929 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
928 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
929 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
930 | 930 | |
931 | 931 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
932 | 932 | { |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | $query_values = array(); |
968 | 968 | $limit_query = ''; |
969 | 969 | $additional_query = ''; |
970 | - $filter_query = $this->getFilter($filter,true,true); |
|
970 | + $filter_query = $this->getFilter($filter, true, true); |
|
971 | 971 | |
972 | 972 | if ($owner != "") |
973 | 973 | { |
@@ -984,8 +984,8 @@ discard block |
||
984 | 984 | { |
985 | 985 | $limit_array = explode(",", $limit); |
986 | 986 | |
987 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
988 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
987 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
988 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
989 | 989 | |
990 | 990 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
991 | 991 | { |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $query_values = array(); |
1026 | 1026 | $limit_query = ''; |
1027 | 1027 | $additional_query = ''; |
1028 | - $filter_query = $this->getFilter($filter,true,true); |
|
1028 | + $filter_query = $this->getFilter($filter, true, true); |
|
1029 | 1029 | |
1030 | 1030 | if ($pilot != "") |
1031 | 1031 | { |
@@ -1037,8 +1037,8 @@ discard block |
||
1037 | 1037 | { |
1038 | 1038 | $limit_array = explode(",", $limit); |
1039 | 1039 | |
1040 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1040 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | 1042 | |
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
@@ -1068,7 +1068,7 @@ discard block |
||
1068 | 1068 | * @return Array the airline country list |
1069 | 1069 | * |
1070 | 1070 | */ |
1071 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1071 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1072 | 1072 | { |
1073 | 1073 | global $globalDBdriver; |
1074 | 1074 | /* |
@@ -1097,7 +1097,7 @@ discard block |
||
1097 | 1097 | $flight_array = array(); |
1098 | 1098 | $temp_array = array(); |
1099 | 1099 | |
1100 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1100 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1101 | 1101 | { |
1102 | 1102 | $temp_array['flight_count'] = $row['nb']; |
1103 | 1103 | $temp_array['flight_country'] = $row['name']; |
@@ -1114,7 +1114,7 @@ discard block |
||
1114 | 1114 | * @return Array the airline country list |
1115 | 1115 | * |
1116 | 1116 | */ |
1117 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1117 | + public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
|
1118 | 1118 | { |
1119 | 1119 | global $globalDBdriver; |
1120 | 1120 | /* |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | $flight_array = array(); |
1144 | 1144 | $temp_array = array(); |
1145 | 1145 | |
1146 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1146 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
1147 | 1147 | { |
1148 | 1148 | $temp_array['airline_icao'] = $row['airline_icao']; |
1149 | 1149 | $temp_array['flight_count'] = $row['nb']; |
@@ -1161,14 +1161,14 @@ discard block |
||
1161 | 1161 | * @return Array the spotter information |
1162 | 1162 | * |
1163 | 1163 | */ |
1164 | - public function getDateArchiveTrackerDataById($id,$date) |
|
1164 | + public function getDateArchiveTrackerDataById($id, $date) |
|
1165 | 1165 | { |
1166 | 1166 | $Tracker = new Tracker($this->db); |
1167 | 1167 | date_default_timezone_set('UTC'); |
1168 | 1168 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
1169 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1170 | - $date = date('c',$date); |
|
1171 | - $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
|
1169 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1170 | + $date = date('c', $date); |
|
1171 | + $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date)); |
|
1172 | 1172 | return $spotter_array; |
1173 | 1173 | } |
1174 | 1174 | |
@@ -1178,14 +1178,14 @@ discard block |
||
1178 | 1178 | * @return Array the spotter information |
1179 | 1179 | * |
1180 | 1180 | */ |
1181 | - public function getDateArchiveTrackerDataByIdent($ident,$date) |
|
1181 | + public function getDateArchiveTrackerDataByIdent($ident, $date) |
|
1182 | 1182 | { |
1183 | 1183 | $Tracker = new Tracker($this->db); |
1184 | 1184 | date_default_timezone_set('UTC'); |
1185 | 1185 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
1186 | - $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1187 | - $date = date('c',$date); |
|
1188 | - $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
|
1186 | + $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC'; |
|
1187 | + $date = date('c', $date); |
|
1188 | + $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date)); |
|
1189 | 1189 | return $spotter_array; |
1190 | 1190 | } |
1191 | 1191 | |
@@ -1195,7 +1195,7 @@ discard block |
||
1195 | 1195 | * @return Array the spotter information |
1196 | 1196 | * |
1197 | 1197 | */ |
1198 | - public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1198 | + public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
1199 | 1199 | { |
1200 | 1200 | global $global_query; |
1201 | 1201 | $Tracker = new Tracker($this->db); |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | $query_values = array(); |
1204 | 1204 | $limit_query = ''; |
1205 | 1205 | $additional_query = ''; |
1206 | - $filter_query = $this->getFilter($filters,true,true); |
|
1206 | + $filter_query = $this->getFilter($filters, true, true); |
|
1207 | 1207 | |
1208 | 1208 | if ($airport != "") |
1209 | 1209 | { |
@@ -1220,8 +1220,8 @@ discard block |
||
1220 | 1220 | { |
1221 | 1221 | $limit_array = explode(",", $limit); |
1222 | 1222 | |
1223 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1224 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1223 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1224 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1225 | 1225 | |
1226 | 1226 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1227 | 1227 | { |
@@ -6,7 +6,9 @@ discard block |
||
6 | 6 | public function __construct($dbc = null) { |
7 | 7 | $Connection = new Connection($dbc); |
8 | 8 | $this->db = $Connection->db; |
9 | - if ($this->db === null) die('Error: No DB connection. (TrackerArchive)'); |
|
9 | + if ($this->db === null) { |
|
10 | + die('Error: No DB connection. (TrackerArchive)'); |
|
11 | + } |
|
10 | 12 | } |
11 | 13 | |
12 | 14 | /** |
@@ -27,7 +29,9 @@ discard block |
||
27 | 29 | if (isset($filter[0]['source'])) { |
28 | 30 | $filters = array_merge($filters,$filter); |
29 | 31 | } |
30 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
32 | + if (is_array($globalFilter)) { |
|
33 | + $filter = array_merge($filter,$globalFilter); |
|
34 | + } |
|
31 | 35 | $filter_query_join = ''; |
32 | 36 | $filter_query_where = ''; |
33 | 37 | foreach($filters as $flt) { |
@@ -73,8 +77,11 @@ discard block |
||
73 | 77 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
74 | 78 | $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
75 | 79 | } |
76 | - if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
|
77 | - elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
|
80 | + if ($filter_query_where == '' && $where) { |
|
81 | + $filter_query_where = ' WHERE'; |
|
82 | + } elseif ($filter_query_where != '' && $and) { |
|
83 | + $filter_query_where .= ' AND'; |
|
84 | + } |
|
78 | 85 | if ($filter_query_where != '') { |
79 | 86 | $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
80 | 87 | } |
@@ -88,9 +95,14 @@ discard block |
||
88 | 95 | if ($over_country == '') { |
89 | 96 | $Tracker = new Tracker($this->db); |
90 | 97 | $data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude); |
91 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
92 | - else $country = ''; |
|
93 | - } else $country = $over_country; |
|
98 | + if (!empty($data_country)) { |
|
99 | + $country = $data_country['iso2']; |
|
100 | + } else { |
|
101 | + $country = ''; |
|
102 | + } |
|
103 | + } else { |
|
104 | + $country = $over_country; |
|
105 | + } |
|
94 | 106 | // Route is not added in tracker_archive |
95 | 107 | $query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) |
96 | 108 | VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)'; |
@@ -592,7 +604,9 @@ discard block |
||
592 | 604 | $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR "; |
593 | 605 | $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR "; |
594 | 606 | $translate = $Translation->ident2icao($q_item); |
595 | - if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
607 | + if ($translate != $q_item) { |
|
608 | + $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR "; |
|
609 | + } |
|
596 | 610 | $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')"; |
597 | 611 | $additional_query .= ")"; |
598 | 612 | } |
@@ -810,7 +824,9 @@ discard block |
||
810 | 824 | date_default_timezone_set($globalTimezone); |
811 | 825 | $datetime = new DateTime(); |
812 | 826 | $offset = $datetime->format('P'); |
813 | - } else $offset = '+00:00'; |
|
827 | + } else { |
|
828 | + $offset = '+00:00'; |
|
829 | + } |
|
814 | 830 | |
815 | 831 | |
816 | 832 | if ($date_array[1] != "") |
@@ -1086,9 +1102,13 @@ discard block |
||
1086 | 1102 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1087 | 1103 | } |
1088 | 1104 | } |
1089 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1105 | + if ($sincedate != '') { |
|
1106 | + $query .= "AND date > '".$sincedate."' "; |
|
1107 | + } |
|
1090 | 1108 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1091 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1109 | + if ($limit) { |
|
1110 | + $query .= " LIMIT 0,10"; |
|
1111 | + } |
|
1092 | 1112 | |
1093 | 1113 | |
1094 | 1114 | $sth = $this->db->prepare($query); |
@@ -1132,9 +1152,13 @@ discard block |
||
1132 | 1152 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1133 | 1153 | } |
1134 | 1154 | } |
1135 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1155 | + if ($sincedate != '') { |
|
1156 | + $query .= "AND s.date > '".$sincedate."' "; |
|
1157 | + } |
|
1136 | 1158 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1137 | - if ($limit) $query .= " LIMIT 0,10"; |
|
1159 | + if ($limit) { |
|
1160 | + $query .= " LIMIT 0,10"; |
|
1161 | + } |
|
1138 | 1162 | |
1139 | 1163 | |
1140 | 1164 | $sth = $this->db->prepare($query); |