@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | }; |
397 | 397 | |
398 | 398 | <?php |
399 | - if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
399 | + if (isset($globalTSK) && $globalTSK && isset($_GET['tsk'])) { |
|
400 | 400 | ?> |
401 | 401 | function tskPopup (feature, layer) { |
402 | 402 | var output = ''; |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | }; |
432 | 432 | update_tsk(); |
433 | 433 | <?php |
434 | - } |
|
434 | + } |
|
435 | 435 | ?> |
436 | 436 | map.on('moveend', function() { |
437 | 437 | if (map.hasLayer(locationsLayer) == true) { |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | } |
450 | 450 | ?> |
451 | 451 | <?php |
452 | - // Add support for custom json via $globalMapJson |
|
453 | - if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
452 | + // Add support for custom json via $globalMapJson |
|
453 | + if (isset($globalMapJson) && is_array($globalMapJson)) { |
|
454 | 454 | foreach ($globalMapJson as $json) { |
455 | - if (isset($json['url'])) { |
|
455 | + if (isset($json['url'])) { |
|
456 | 456 | ?> |
457 | 457 | update_genLayer('<?php print $json['url']; ?>'); |
458 | 458 | <?php |
@@ -461,9 +461,9 @@ discard block |
||
461 | 461 | setInterval(function(){if (noTimeout) update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>); |
462 | 462 | <?php |
463 | 463 | } |
464 | - } |
|
464 | + } |
|
465 | + } |
|
465 | 466 | } |
466 | - } |
|
467 | 467 | |
468 | 468 | ?> |
469 | 469 | //adds the bootstrap tooltip to the map icons |
@@ -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(); |
@@ -158,44 +158,44 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | |
161 | - /** |
|
162 | - * Gets all the spotter information based on a particular callsign |
|
163 | - * |
|
164 | - * @return Array the spotter information |
|
165 | - * |
|
166 | - */ |
|
167 | - public function getLastArchiveSpotterDataByIdent($ident) |
|
168 | - { |
|
161 | + /** |
|
162 | + * Gets all the spotter information based on a particular callsign |
|
163 | + * |
|
164 | + * @return Array the spotter information |
|
165 | + * |
|
166 | + */ |
|
167 | + public function getLastArchiveSpotterDataByIdent($ident) |
|
168 | + { |
|
169 | 169 | $Spotter = new Spotter($this->db); |
170 | - date_default_timezone_set('UTC'); |
|
170 | + date_default_timezone_set('UTC'); |
|
171 | 171 | |
172 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
173 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
174 | - $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
172 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
173 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
174 | + $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1"; |
|
175 | 175 | |
176 | - $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
176 | + $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident)); |
|
177 | 177 | |
178 | - return $spotter_array; |
|
179 | - } |
|
178 | + return $spotter_array; |
|
179 | + } |
|
180 | 180 | |
181 | 181 | |
182 | - /** |
|
183 | - * Gets last the spotter information based on a particular id |
|
184 | - * |
|
185 | - * @return Array the spotter information |
|
186 | - * |
|
187 | - */ |
|
188 | - public function getLastArchiveSpotterDataById($id) |
|
189 | - { |
|
190 | - $Spotter = new Spotter($this->db); |
|
191 | - date_default_timezone_set('UTC'); |
|
192 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
193 | - //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
194 | - //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
195 | - $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
182 | + /** |
|
183 | + * Gets last the spotter information based on a particular id |
|
184 | + * |
|
185 | + * @return Array the spotter information |
|
186 | + * |
|
187 | + */ |
|
188 | + public function getLastArchiveSpotterDataById($id) |
|
189 | + { |
|
190 | + $Spotter = new Spotter($this->db); |
|
191 | + date_default_timezone_set('UTC'); |
|
192 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
193 | + //$query = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id"; |
|
194 | + //$query = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1"; |
|
195 | + $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1"; |
|
196 | 196 | |
197 | 197 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
198 | - /* |
|
198 | + /* |
|
199 | 199 | try { |
200 | 200 | $Connection = new Connection(); |
201 | 201 | $sth = Connection->$db->prepare($query); |
@@ -205,118 +205,118 @@ discard block |
||
205 | 205 | } |
206 | 206 | $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC); |
207 | 207 | */ |
208 | - $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
209 | - |
|
210 | - return $spotter_array; |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Gets all the spotter information based on a particular id |
|
215 | - * |
|
216 | - * @return Array the spotter information |
|
217 | - * |
|
218 | - */ |
|
219 | - public function getAllArchiveSpotterDataById($id) |
|
208 | + $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id)); |
|
209 | + |
|
210 | + return $spotter_array; |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Gets all the spotter information based on a particular id |
|
215 | + * |
|
216 | + * @return Array the spotter information |
|
217 | + * |
|
218 | + */ |
|
219 | + public function getAllArchiveSpotterDataById($id) |
|
220 | 220 | { |
221 | - date_default_timezone_set('UTC'); |
|
222 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
223 | - $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
221 | + date_default_timezone_set('UTC'); |
|
222 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
223 | + $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date"; |
|
224 | 224 | |
225 | 225 | // $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id)); |
226 | 226 | |
227 | - try { |
|
228 | - $sth = $this->db->prepare($query); |
|
229 | - $sth->execute(array(':id' => $id)); |
|
230 | - } catch(PDOException $e) { |
|
231 | - echo $e->getMessage(); |
|
232 | - die; |
|
233 | - } |
|
234 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
235 | - |
|
236 | - return $spotter_array; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * Gets coordinate & time spotter information based on a particular id |
|
241 | - * |
|
242 | - * @return Array the spotter information |
|
243 | - * |
|
244 | - */ |
|
245 | - public function getCoordArchiveSpotterDataById($id) |
|
246 | - { |
|
247 | - date_default_timezone_set('UTC'); |
|
248 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
249 | - $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
250 | - try { |
|
251 | - $sth = $this->db->prepare($query); |
|
252 | - $sth->execute(array(':id' => $id)); |
|
253 | - } catch(PDOException $e) { |
|
254 | - echo $e->getMessage(); |
|
255 | - die; |
|
256 | - } |
|
257 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | - return $spotter_array; |
|
259 | - } |
|
227 | + try { |
|
228 | + $sth = $this->db->prepare($query); |
|
229 | + $sth->execute(array(':id' => $id)); |
|
230 | + } catch(PDOException $e) { |
|
231 | + echo $e->getMessage(); |
|
232 | + die; |
|
233 | + } |
|
234 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
260 | 235 | |
236 | + return $spotter_array; |
|
237 | + } |
|
261 | 238 | |
262 | - /** |
|
263 | - * Gets altitude information based on a particular callsign |
|
264 | - * |
|
265 | - * @return Array the spotter information |
|
266 | - * |
|
267 | - */ |
|
268 | - public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
269 | - { |
|
239 | + /** |
|
240 | + * Gets coordinate & time spotter information based on a particular id |
|
241 | + * |
|
242 | + * @return Array the spotter information |
|
243 | + * |
|
244 | + */ |
|
245 | + public function getCoordArchiveSpotterDataById($id) |
|
246 | + { |
|
247 | + date_default_timezone_set('UTC'); |
|
248 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
249 | + $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER by spotter_archive.date ASC"; |
|
250 | + try { |
|
251 | + $sth = $this->db->prepare($query); |
|
252 | + $sth->execute(array(':id' => $id)); |
|
253 | + } catch(PDOException $e) { |
|
254 | + echo $e->getMessage(); |
|
255 | + die; |
|
256 | + } |
|
257 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
258 | + return $spotter_array; |
|
259 | + } |
|
270 | 260 | |
271 | - date_default_timezone_set('UTC'); |
|
272 | 261 | |
273 | - $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
274 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
262 | + /** |
|
263 | + * Gets altitude information based on a particular callsign |
|
264 | + * |
|
265 | + * @return Array the spotter information |
|
266 | + * |
|
267 | + */ |
|
268 | + public function getAltitudeArchiveSpotterDataByIdent($ident) |
|
269 | + { |
|
275 | 270 | |
276 | - try { |
|
277 | - $sth = $this->db->prepare($query); |
|
278 | - $sth->execute(array(':ident' => $ident)); |
|
279 | - } catch(PDOException $e) { |
|
280 | - echo $e->getMessage(); |
|
281 | - die; |
|
282 | - } |
|
283 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
271 | + date_default_timezone_set('UTC'); |
|
284 | 272 | |
285 | - return $spotter_array; |
|
286 | - } |
|
273 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
274 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
287 | 275 | |
288 | - /** |
|
289 | - * Gets altitude information based on a particular id |
|
290 | - * |
|
291 | - * @return Array the spotter information |
|
292 | - * |
|
293 | - */ |
|
294 | - public function getAltitudeArchiveSpotterDataById($id) |
|
295 | - { |
|
276 | + try { |
|
277 | + $sth = $this->db->prepare($query); |
|
278 | + $sth->execute(array(':ident' => $ident)); |
|
279 | + } catch(PDOException $e) { |
|
280 | + echo $e->getMessage(); |
|
281 | + die; |
|
282 | + } |
|
283 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
296 | 284 | |
297 | - date_default_timezone_set('UTC'); |
|
285 | + return $spotter_array; |
|
286 | + } |
|
298 | 287 | |
299 | - $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
300 | - $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
288 | + /** |
|
289 | + * Gets altitude information based on a particular id |
|
290 | + * |
|
291 | + * @return Array the spotter information |
|
292 | + * |
|
293 | + */ |
|
294 | + public function getAltitudeArchiveSpotterDataById($id) |
|
295 | + { |
|
301 | 296 | |
302 | - try { |
|
303 | - $sth = $this->db->prepare($query); |
|
304 | - $sth->execute(array(':id' => $id)); |
|
305 | - } catch(PDOException $e) { |
|
306 | - echo $e->getMessage(); |
|
307 | - die; |
|
308 | - } |
|
309 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
297 | + date_default_timezone_set('UTC'); |
|
298 | + |
|
299 | + $id = filter_var($id, FILTER_SANITIZE_STRING); |
|
300 | + $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date"; |
|
301 | + |
|
302 | + try { |
|
303 | + $sth = $this->db->prepare($query); |
|
304 | + $sth->execute(array(':id' => $id)); |
|
305 | + } catch(PDOException $e) { |
|
306 | + echo $e->getMessage(); |
|
307 | + die; |
|
308 | + } |
|
309 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
310 | 310 | |
311 | - return $spotter_array; |
|
312 | - } |
|
311 | + return $spotter_array; |
|
312 | + } |
|
313 | 313 | |
314 | - /** |
|
315 | - * Gets altitude & speed information based on a particular id |
|
316 | - * |
|
317 | - * @return Array the spotter information |
|
318 | - * |
|
319 | - */ |
|
314 | + /** |
|
315 | + * Gets altitude & speed information based on a particular id |
|
316 | + * |
|
317 | + * @return Array the spotter information |
|
318 | + * |
|
319 | + */ |
|
320 | 320 | public function getAltitudeSpeedArchiveSpotterDataById($id) |
321 | 321 | { |
322 | 322 | date_default_timezone_set('UTC'); |
@@ -333,12 +333,12 @@ discard block |
||
333 | 333 | return $spotter_array; |
334 | 334 | } |
335 | 335 | |
336 | - /** |
|
337 | - * Gets altitude information based on a particular callsign |
|
338 | - * |
|
339 | - * @return Array the spotter information |
|
340 | - * |
|
341 | - */ |
|
336 | + /** |
|
337 | + * Gets altitude information based on a particular callsign |
|
338 | + * |
|
339 | + * @return Array the spotter information |
|
340 | + * |
|
341 | + */ |
|
342 | 342 | public function getLastAltitudeArchiveSpotterDataByIdent($ident) |
343 | 343 | { |
344 | 344 | date_default_timezone_set('UTC'); |
@@ -358,12 +358,12 @@ discard block |
||
358 | 358 | |
359 | 359 | |
360 | 360 | |
361 | - /** |
|
362 | - * Gets all the archive spotter information |
|
363 | - * |
|
364 | - * @return Array the spotter information |
|
365 | - * |
|
366 | - */ |
|
361 | + /** |
|
362 | + * Gets all the archive spotter information |
|
363 | + * |
|
364 | + * @return Array the spotter information |
|
365 | + * |
|
366 | + */ |
|
367 | 367 | public function getSpotterArchiveData($ident,$flightaware_id,$date) |
368 | 368 | { |
369 | 369 | $Spotter = new Spotter($this->db); |
@@ -391,34 +391,34 @@ discard block |
||
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
394 | - * Gets Minimal Live Spotter data |
|
395 | - * |
|
396 | - * @return Array the spotter information |
|
397 | - * |
|
398 | - */ |
|
399 | - public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
400 | - { |
|
401 | - global $globalDBdriver, $globalLiveInterval; |
|
402 | - date_default_timezone_set('UTC'); |
|
403 | - |
|
404 | - $filter_query = ''; |
|
405 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
406 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
407 | - } |
|
408 | - // Use spotter_output also ? |
|
409 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
410 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
411 | - } |
|
412 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
413 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
414 | - } |
|
415 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
416 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
417 | - } |
|
394 | + * Gets Minimal Live Spotter data |
|
395 | + * |
|
396 | + * @return Array the spotter information |
|
397 | + * |
|
398 | + */ |
|
399 | + public function getMinLiveSpotterData($begindate,$enddate,$filter = array()) |
|
400 | + { |
|
401 | + global $globalDBdriver, $globalLiveInterval; |
|
402 | + date_default_timezone_set('UTC'); |
|
403 | + |
|
404 | + $filter_query = ''; |
|
405 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
406 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
407 | + } |
|
408 | + // Use spotter_output also ? |
|
409 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
410 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
411 | + } |
|
412 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
413 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
414 | + } |
|
415 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
416 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
417 | + } |
|
418 | 418 | |
419 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
420 | - if ($globalDBdriver == 'mysql') { |
|
421 | - /* |
|
419 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
420 | + if ($globalDBdriver == 'mysql') { |
|
421 | + /* |
|
422 | 422 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
423 | 423 | FROM spotter_archive |
424 | 424 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -437,56 +437,56 @@ discard block |
||
437 | 437 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
438 | 438 | WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' |
439 | 439 | '.$filter_query.' ORDER BY flightaware_id'; |
440 | - } else { |
|
441 | - //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
442 | - $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
440 | + } else { |
|
441 | + //$query = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao'; |
|
442 | + $query = 'SELECT spotter_archive.flightaware_id, spotter_archive.date, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category |
|
443 | 443 | FROM spotter_archive |
444 | 444 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao |
445 | 445 | WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".' |
446 | 446 | '.$filter_query.' ORDER BY flightaware_id'; |
447 | - } |
|
448 | - //echo $query; |
|
449 | - try { |
|
450 | - $sth = $this->db->prepare($query); |
|
451 | - $sth->execute(); |
|
452 | - } catch(PDOException $e) { |
|
453 | - echo $e->getMessage(); |
|
454 | - die; |
|
455 | - } |
|
456 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
447 | + } |
|
448 | + //echo $query; |
|
449 | + try { |
|
450 | + $sth = $this->db->prepare($query); |
|
451 | + $sth->execute(); |
|
452 | + } catch(PDOException $e) { |
|
453 | + echo $e->getMessage(); |
|
454 | + die; |
|
455 | + } |
|
456 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
457 | 457 | |
458 | - return $spotter_array; |
|
459 | - } |
|
458 | + return $spotter_array; |
|
459 | + } |
|
460 | 460 | |
461 | 461 | /** |
462 | - * Gets Minimal Live Spotter data |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
467 | - public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
468 | - { |
|
469 | - global $globalDBdriver, $globalLiveInterval; |
|
470 | - date_default_timezone_set('UTC'); |
|
471 | - |
|
472 | - $filter_query = ''; |
|
473 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
474 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
475 | - } |
|
476 | - // Should use spotter_output also ? |
|
477 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
478 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
479 | - } |
|
480 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
481 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
482 | - } |
|
483 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
484 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
485 | - } |
|
462 | + * Gets Minimal Live Spotter data |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | + public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array()) |
|
468 | + { |
|
469 | + global $globalDBdriver, $globalLiveInterval; |
|
470 | + date_default_timezone_set('UTC'); |
|
471 | + |
|
472 | + $filter_query = ''; |
|
473 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
474 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
475 | + } |
|
476 | + // Should use spotter_output also ? |
|
477 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
478 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
479 | + } |
|
480 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
481 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
482 | + } |
|
483 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
484 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
485 | + } |
|
486 | 486 | |
487 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
488 | - if ($globalDBdriver == 'mysql') { |
|
489 | - /* |
|
487 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
488 | + if ($globalDBdriver == 'mysql') { |
|
489 | + /* |
|
490 | 490 | $query = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk |
491 | 491 | FROM spotter_archive |
492 | 492 | INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao'; |
@@ -497,95 +497,95 @@ discard block |
||
497 | 497 | WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') |
498 | 498 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
499 | 499 | |
500 | - } else { |
|
501 | - //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
502 | - /* |
|
500 | + } else { |
|
501 | + //$query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao'; |
|
502 | + /* |
|
503 | 503 | $query = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
504 | 504 | FROM spotter_archive_output |
505 | 505 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
506 | 506 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
507 | 507 | '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow'; |
508 | 508 | */ |
509 | - $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
509 | + $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow |
|
510 | 510 | FROM spotter_archive_output |
511 | 511 | INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao |
512 | 512 | WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".' |
513 | 513 | '.$filter_query.' LIMIT 200 OFFSET 0'; |
514 | 514 | // .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow'; |
515 | 515 | |
516 | - } |
|
517 | - //echo $query; |
|
518 | - try { |
|
519 | - $sth = $this->db->prepare($query); |
|
520 | - $sth->execute(); |
|
521 | - } catch(PDOException $e) { |
|
522 | - echo $e->getMessage(); |
|
523 | - die; |
|
524 | - } |
|
525 | - $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
516 | + } |
|
517 | + //echo $query; |
|
518 | + try { |
|
519 | + $sth = $this->db->prepare($query); |
|
520 | + $sth->execute(); |
|
521 | + } catch(PDOException $e) { |
|
522 | + echo $e->getMessage(); |
|
523 | + die; |
|
524 | + } |
|
525 | + $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC); |
|
526 | 526 | |
527 | - return $spotter_array; |
|
528 | - } |
|
527 | + return $spotter_array; |
|
528 | + } |
|
529 | 529 | |
530 | 530 | /** |
531 | - * Gets count Live Spotter data |
|
532 | - * |
|
533 | - * @return Array the spotter information |
|
534 | - * |
|
535 | - */ |
|
536 | - public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
537 | - { |
|
538 | - global $globalDBdriver, $globalLiveInterval; |
|
539 | - date_default_timezone_set('UTC'); |
|
540 | - |
|
541 | - $filter_query = ''; |
|
542 | - if (isset($filter['source']) && !empty($filter['source'])) { |
|
543 | - $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
544 | - } |
|
545 | - if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
546 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
547 | - } |
|
548 | - if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
549 | - $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
550 | - } |
|
551 | - if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
552 | - $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
553 | - } |
|
531 | + * Gets count Live Spotter data |
|
532 | + * |
|
533 | + * @return Array the spotter information |
|
534 | + * |
|
535 | + */ |
|
536 | + public function getLiveSpotterCount($begindate,$enddate,$filter = array()) |
|
537 | + { |
|
538 | + global $globalDBdriver, $globalLiveInterval; |
|
539 | + date_default_timezone_set('UTC'); |
|
554 | 540 | |
555 | - //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
556 | - if ($globalDBdriver == 'mysql') { |
|
541 | + $filter_query = ''; |
|
542 | + if (isset($filter['source']) && !empty($filter['source'])) { |
|
543 | + $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') "; |
|
544 | + } |
|
545 | + if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
|
546 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id "; |
|
547 | + } |
|
548 | + if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
|
549 | + $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id "; |
|
550 | + } |
|
551 | + if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
|
552 | + $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
553 | + } |
|
554 | + |
|
555 | + //if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
556 | + if ($globalDBdriver == 'mysql') { |
|
557 | 557 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb |
558 | 558 | FROM spotter_archive l |
559 | 559 | WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query; |
560 | - } else { |
|
560 | + } else { |
|
561 | 561 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query; |
562 | - } |
|
563 | - //echo $query; |
|
564 | - try { |
|
565 | - $sth = $this->db->prepare($query); |
|
566 | - $sth->execute(); |
|
567 | - } catch(PDOException $e) { |
|
568 | - echo $e->getMessage(); |
|
569 | - die; |
|
570 | - } |
|
562 | + } |
|
563 | + //echo $query; |
|
564 | + try { |
|
565 | + $sth = $this->db->prepare($query); |
|
566 | + $sth->execute(); |
|
567 | + } catch(PDOException $e) { |
|
568 | + echo $e->getMessage(); |
|
569 | + die; |
|
570 | + } |
|
571 | 571 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
572 | 572 | $sth->closeCursor(); |
573 | - return $result['nb']; |
|
573 | + return $result['nb']; |
|
574 | 574 | |
575 | - } |
|
575 | + } |
|
576 | 576 | |
577 | 577 | |
578 | 578 | |
579 | 579 | // Spotter_Archive_output |
580 | 580 | |
581 | - /** |
|
582 | - * Gets all the spotter information |
|
583 | - * |
|
584 | - * @return Array the spotter information |
|
585 | - * |
|
586 | - */ |
|
587 | - public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
588 | - { |
|
581 | + /** |
|
582 | + * Gets all the spotter information |
|
583 | + * |
|
584 | + * @return Array the spotter information |
|
585 | + * |
|
586 | + */ |
|
587 | + public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array()) |
|
588 | + { |
|
589 | 589 | global $globalTimezone, $globalDBdriver; |
590 | 590 | require_once(dirname(__FILE__).'/class.Translation.php'); |
591 | 591 | $Translation = new Translation($this->db); |
@@ -599,159 +599,159 @@ discard block |
||
599 | 599 | $filter_query = $this->getFilter($filters); |
600 | 600 | if ($q != "") |
601 | 601 | { |
602 | - if (!is_string($q)) |
|
603 | - { |
|
602 | + if (!is_string($q)) |
|
603 | + { |
|
604 | 604 | return false; |
605 | - } else { |
|
605 | + } else { |
|
606 | 606 | |
607 | 607 | $q_array = explode(" ", $q); |
608 | 608 | |
609 | 609 | foreach ($q_array as $q_item){ |
610 | - $additional_query .= " AND ("; |
|
611 | - $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
612 | - $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
613 | - $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
614 | - $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
615 | - $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
616 | - $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
617 | - $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
618 | - $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
619 | - $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
620 | - $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
621 | - $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
622 | - $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
623 | - $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
624 | - $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
625 | - $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
626 | - $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
627 | - $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
628 | - $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
629 | - $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
630 | - $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
631 | - $translate = $Translation->ident2icao($q_item); |
|
632 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
633 | - $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
634 | - $additional_query .= ")"; |
|
610 | + $additional_query .= " AND ("; |
|
611 | + $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR "; |
|
612 | + $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR "; |
|
613 | + $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR "; |
|
614 | + $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR "; |
|
615 | + $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR "; |
|
616 | + $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR "; |
|
617 | + $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR "; |
|
618 | + $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR "; |
|
619 | + $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR "; |
|
620 | + $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR "; |
|
621 | + $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR "; |
|
622 | + $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR "; |
|
623 | + $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR "; |
|
624 | + $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR "; |
|
625 | + $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR "; |
|
626 | + $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR "; |
|
627 | + $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR "; |
|
628 | + $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR "; |
|
629 | + $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
|
630 | + $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
|
631 | + $translate = $Translation->ident2icao($q_item); |
|
632 | + if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
633 | + $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
|
634 | + $additional_query .= ")"; |
|
635 | + } |
|
635 | 636 | } |
636 | - } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | if ($registration != "") |
640 | 640 | { |
641 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
642 | - if (!is_string($registration)) |
|
643 | - { |
|
641 | + $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
642 | + if (!is_string($registration)) |
|
643 | + { |
|
644 | 644 | return false; |
645 | - } else { |
|
645 | + } else { |
|
646 | 646 | $additional_query .= " AND (spotter_archive_output.registration = '".$registration."')"; |
647 | - } |
|
647 | + } |
|
648 | 648 | } |
649 | 649 | |
650 | 650 | if ($aircraft_icao != "") |
651 | 651 | { |
652 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
653 | - if (!is_string($aircraft_icao)) |
|
654 | - { |
|
652 | + $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
653 | + if (!is_string($aircraft_icao)) |
|
654 | + { |
|
655 | 655 | return false; |
656 | - } else { |
|
656 | + } else { |
|
657 | 657 | $additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')"; |
658 | - } |
|
658 | + } |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | if ($aircraft_manufacturer != "") |
662 | 662 | { |
663 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
664 | - if (!is_string($aircraft_manufacturer)) |
|
665 | - { |
|
663 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
664 | + if (!is_string($aircraft_manufacturer)) |
|
665 | + { |
|
666 | 666 | return false; |
667 | - } else { |
|
667 | + } else { |
|
668 | 668 | $additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')"; |
669 | - } |
|
669 | + } |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | if ($highlights == "true") |
673 | 673 | { |
674 | - if (!is_string($highlights)) |
|
675 | - { |
|
674 | + if (!is_string($highlights)) |
|
675 | + { |
|
676 | 676 | return false; |
677 | - } else { |
|
677 | + } else { |
|
678 | 678 | $additional_query .= " AND (spotter_archive_output.highlight <> '')"; |
679 | - } |
|
679 | + } |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | if ($airline_icao != "") |
683 | 683 | { |
684 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
685 | - if (!is_string($airline_icao)) |
|
686 | - { |
|
684 | + $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
685 | + if (!is_string($airline_icao)) |
|
686 | + { |
|
687 | 687 | return false; |
688 | - } else { |
|
688 | + } else { |
|
689 | 689 | $additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')"; |
690 | - } |
|
690 | + } |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | if ($airline_country != "") |
694 | 694 | { |
695 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
696 | - if (!is_string($airline_country)) |
|
697 | - { |
|
695 | + $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
696 | + if (!is_string($airline_country)) |
|
697 | + { |
|
698 | 698 | return false; |
699 | - } else { |
|
699 | + } else { |
|
700 | 700 | $additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')"; |
701 | - } |
|
701 | + } |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | if ($airline_type != "") |
705 | 705 | { |
706 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
707 | - if (!is_string($airline_type)) |
|
708 | - { |
|
706 | + $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
707 | + if (!is_string($airline_type)) |
|
708 | + { |
|
709 | 709 | return false; |
710 | - } else { |
|
710 | + } else { |
|
711 | 711 | if ($airline_type == "passenger") |
712 | 712 | { |
713 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
713 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')"; |
|
714 | 714 | } |
715 | 715 | if ($airline_type == "cargo") |
716 | 716 | { |
717 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
717 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')"; |
|
718 | 718 | } |
719 | 719 | if ($airline_type == "military") |
720 | 720 | { |
721 | - $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
721 | + $additional_query .= " AND (spotter_archive_output.airline_type = 'military')"; |
|
722 | + } |
|
722 | 723 | } |
723 | - } |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | if ($airport != "") |
727 | 727 | { |
728 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
729 | - if (!is_string($airport)) |
|
730 | - { |
|
728 | + $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
729 | + if (!is_string($airport)) |
|
730 | + { |
|
731 | 731 | return false; |
732 | - } else { |
|
732 | + } else { |
|
733 | 733 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))"; |
734 | - } |
|
734 | + } |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | if ($airport_country != "") |
738 | 738 | { |
739 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
740 | - if (!is_string($airport_country)) |
|
741 | - { |
|
739 | + $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
740 | + if (!is_string($airport_country)) |
|
741 | + { |
|
742 | 742 | return false; |
743 | - } else { |
|
743 | + } else { |
|
744 | 744 | $additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))"; |
745 | - } |
|
745 | + } |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | if ($callsign != "") |
749 | 749 | { |
750 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
751 | - if (!is_string($callsign)) |
|
752 | - { |
|
750 | + $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
751 | + if (!is_string($callsign)) |
|
752 | + { |
|
753 | 753 | return false; |
754 | - } else { |
|
754 | + } else { |
|
755 | 755 | $translate = $Translation->ident2icao($callsign); |
756 | 756 | if ($translate != $callsign) { |
757 | 757 | $additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)"; |
@@ -759,81 +759,81 @@ discard block |
||
759 | 759 | } else { |
760 | 760 | $additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')"; |
761 | 761 | } |
762 | - } |
|
762 | + } |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | if ($owner != "") |
766 | 766 | { |
767 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
768 | - if (!is_string($owner)) |
|
769 | - { |
|
767 | + $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
768 | + if (!is_string($owner)) |
|
769 | + { |
|
770 | 770 | return false; |
771 | - } else { |
|
771 | + } else { |
|
772 | 772 | $additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')"; |
773 | - } |
|
773 | + } |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | if ($pilot_name != "") |
777 | 777 | { |
778 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
779 | - if (!is_string($pilot_name)) |
|
780 | - { |
|
778 | + $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
779 | + if (!is_string($pilot_name)) |
|
780 | + { |
|
781 | 781 | return false; |
782 | - } else { |
|
782 | + } else { |
|
783 | 783 | $additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')"; |
784 | - } |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | |
787 | 787 | if ($pilot_id != "") |
788 | 788 | { |
789 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
790 | - if (!is_string($pilot_id)) |
|
791 | - { |
|
789 | + $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT); |
|
790 | + if (!is_string($pilot_id)) |
|
791 | + { |
|
792 | 792 | return false; |
793 | - } else { |
|
793 | + } else { |
|
794 | 794 | $additional_query .= " AND (spotter_archive_output.pilot_id = '".$pilot_id."')"; |
795 | - } |
|
795 | + } |
|
796 | 796 | } |
797 | 797 | |
798 | 798 | if ($departure_airport_route != "") |
799 | 799 | { |
800 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
801 | - if (!is_string($departure_airport_route)) |
|
802 | - { |
|
800 | + $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
801 | + if (!is_string($departure_airport_route)) |
|
802 | + { |
|
803 | 803 | return false; |
804 | - } else { |
|
804 | + } else { |
|
805 | 805 | $additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')"; |
806 | - } |
|
806 | + } |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | if ($arrival_airport_route != "") |
810 | 810 | { |
811 | - $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
812 | - if (!is_string($arrival_airport_route)) |
|
813 | - { |
|
811 | + $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING); |
|
812 | + if (!is_string($arrival_airport_route)) |
|
813 | + { |
|
814 | 814 | return false; |
815 | - } else { |
|
815 | + } else { |
|
816 | 816 | $additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')"; |
817 | - } |
|
817 | + } |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | if ($altitude != "") |
821 | 821 | { |
822 | - $altitude_array = explode(",", $altitude); |
|
822 | + $altitude_array = explode(",", $altitude); |
|
823 | 823 | |
824 | - $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
825 | - $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
824 | + $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
825 | + $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
826 | 826 | |
827 | 827 | |
828 | - if ($altitude_array[1] != "") |
|
829 | - { |
|
828 | + if ($altitude_array[1] != "") |
|
829 | + { |
|
830 | 830 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
831 | 831 | $altitude_array[1] = substr($altitude_array[1], 0, -2); |
832 | 832 | $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' "; |
833 | - } else { |
|
833 | + } else { |
|
834 | 834 | $altitude_array[0] = substr($altitude_array[0], 0, -2); |
835 | 835 | $additional_query .= " AND altitude <= '".$altitude_array[0]."' "; |
836 | - } |
|
836 | + } |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | if ($date_posted != "") |
@@ -918,14 +918,14 @@ discard block |
||
918 | 918 | } |
919 | 919 | } |
920 | 920 | |
921 | - /** |
|
922 | - * Gets all the spotter information based on the callsign |
|
923 | - * |
|
924 | - * @return Array the spotter information |
|
925 | - * |
|
926 | - */ |
|
927 | - public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
928 | - { |
|
921 | + /** |
|
922 | + * Gets all the spotter information based on the callsign |
|
923 | + * |
|
924 | + * @return Array the spotter information |
|
925 | + * |
|
926 | + */ |
|
927 | + public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '') |
|
928 | + { |
|
929 | 929 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
930 | 930 | |
931 | 931 | date_default_timezone_set('UTC'); |
@@ -937,35 +937,35 @@ discard block |
||
937 | 937 | |
938 | 938 | if ($ident != "") |
939 | 939 | { |
940 | - if (!is_string($ident)) |
|
941 | - { |
|
940 | + if (!is_string($ident)) |
|
941 | + { |
|
942 | 942 | return false; |
943 | - } else { |
|
943 | + } else { |
|
944 | 944 | $additional_query = " AND spotter_archive_output.ident = :ident"; |
945 | 945 | $query_values = array(':ident' => $ident); |
946 | - } |
|
946 | + } |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | if ($limit != "") |
950 | 950 | { |
951 | - $limit_array = explode(",", $limit); |
|
951 | + $limit_array = explode(",", $limit); |
|
952 | 952 | |
953 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
953 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
954 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
955 | 955 | |
956 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
957 | - { |
|
956 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
957 | + { |
|
958 | 958 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
959 | 959 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
960 | - } |
|
960 | + } |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | if ($sort != "") |
964 | 964 | { |
965 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
966 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
965 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
966 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
967 | 967 | } else { |
968 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
968 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | $query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query; |
@@ -973,17 +973,17 @@ discard block |
||
973 | 973 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
974 | 974 | |
975 | 975 | return $spotter_array; |
976 | - } |
|
976 | + } |
|
977 | 977 | |
978 | 978 | |
979 | - /** |
|
980 | - * Gets all the spotter information based on the owner |
|
981 | - * |
|
982 | - * @return Array the spotter information |
|
983 | - * |
|
984 | - */ |
|
985 | - public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
986 | - { |
|
979 | + /** |
|
980 | + * Gets all the spotter information based on the owner |
|
981 | + * |
|
982 | + * @return Array the spotter information |
|
983 | + * |
|
984 | + */ |
|
985 | + public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '', $filter = array()) |
|
986 | + { |
|
987 | 987 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
988 | 988 | |
989 | 989 | date_default_timezone_set('UTC'); |
@@ -996,35 +996,35 @@ discard block |
||
996 | 996 | |
997 | 997 | if ($owner != "") |
998 | 998 | { |
999 | - if (!is_string($owner)) |
|
1000 | - { |
|
999 | + if (!is_string($owner)) |
|
1000 | + { |
|
1001 | 1001 | return false; |
1002 | - } else { |
|
1002 | + } else { |
|
1003 | 1003 | $additional_query = " AND (spotter_archive_output.owner_name = :owner)"; |
1004 | 1004 | $query_values = array(':owner' => $owner); |
1005 | - } |
|
1005 | + } |
|
1006 | 1006 | } |
1007 | 1007 | |
1008 | 1008 | if ($limit != "") |
1009 | 1009 | { |
1010 | - $limit_array = explode(",", $limit); |
|
1010 | + $limit_array = explode(",", $limit); |
|
1011 | 1011 | |
1012 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1012 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1013 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1014 | 1014 | |
1015 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1016 | - { |
|
1015 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1016 | + { |
|
1017 | 1017 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1018 | 1018 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1019 | - } |
|
1019 | + } |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | if ($sort != "") |
1023 | 1023 | { |
1024 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1025 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1024 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1025 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1026 | 1026 | } else { |
1027 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1027 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1028 | 1028 | } |
1029 | 1029 | |
1030 | 1030 | $query = $global_query.$filter_query." spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1032,16 +1032,16 @@ discard block |
||
1032 | 1032 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1033 | 1033 | |
1034 | 1034 | return $spotter_array; |
1035 | - } |
|
1036 | - |
|
1037 | - /** |
|
1038 | - * Gets all the spotter information based on the pilot |
|
1039 | - * |
|
1040 | - * @return Array the spotter information |
|
1041 | - * |
|
1042 | - */ |
|
1043 | - public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1044 | - { |
|
1035 | + } |
|
1036 | + |
|
1037 | + /** |
|
1038 | + * Gets all the spotter information based on the pilot |
|
1039 | + * |
|
1040 | + * @return Array the spotter information |
|
1041 | + * |
|
1042 | + */ |
|
1043 | + public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array()) |
|
1044 | + { |
|
1045 | 1045 | $global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output"; |
1046 | 1046 | |
1047 | 1047 | date_default_timezone_set('UTC'); |
@@ -1060,24 +1060,24 @@ discard block |
||
1060 | 1060 | |
1061 | 1061 | if ($limit != "") |
1062 | 1062 | { |
1063 | - $limit_array = explode(",", $limit); |
|
1063 | + $limit_array = explode(",", $limit); |
|
1064 | 1064 | |
1065 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1065 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1066 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1067 | 1067 | |
1068 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1069 | - { |
|
1068 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1069 | + { |
|
1070 | 1070 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1071 | 1071 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | if ($sort != "") |
1076 | 1076 | { |
1077 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1078 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1077 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1078 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1079 | 1079 | } else { |
1080 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1080 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | $query = $global_query.$filter_query." spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query; |
@@ -1085,16 +1085,16 @@ discard block |
||
1085 | 1085 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1086 | 1086 | |
1087 | 1087 | return $spotter_array; |
1088 | - } |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * Gets all number of flight over countries |
|
1092 | - * |
|
1093 | - * @return Array the airline country list |
|
1094 | - * |
|
1095 | - */ |
|
1096 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1097 | - { |
|
1088 | + } |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * Gets all number of flight over countries |
|
1092 | + * |
|
1093 | + * @return Array the airline country list |
|
1094 | + * |
|
1095 | + */ |
|
1096 | + public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1097 | + { |
|
1098 | 1098 | global $globalDBdriver; |
1099 | 1099 | /* |
1100 | 1100 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1104,14 +1104,14 @@ discard block |
||
1104 | 1104 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
1105 | 1105 | FROM countries c, spotter_archive s |
1106 | 1106 | WHERE c.iso2 = s.over_country "; |
1107 | - if ($olderthanmonths > 0) { |
|
1108 | - if ($globalDBdriver == 'mysql') { |
|
1107 | + if ($olderthanmonths > 0) { |
|
1108 | + if ($globalDBdriver == 'mysql') { |
|
1109 | 1109 | $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1110 | 1110 | } else { |
1111 | 1111 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1112 | 1112 | } |
1113 | 1113 | } |
1114 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1114 | + if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
1115 | 1115 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1116 | 1116 | if ($limit) $query .= " LIMIT 0,10"; |
1117 | 1117 | |
@@ -1124,23 +1124,23 @@ discard block |
||
1124 | 1124 | |
1125 | 1125 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1126 | 1126 | { |
1127 | - $temp_array['flight_count'] = $row['nb']; |
|
1128 | - $temp_array['flight_country'] = $row['name']; |
|
1129 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1130 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1131 | - $flight_array[] = $temp_array; |
|
1127 | + $temp_array['flight_count'] = $row['nb']; |
|
1128 | + $temp_array['flight_country'] = $row['name']; |
|
1129 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1130 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1131 | + $flight_array[] = $temp_array; |
|
1132 | 1132 | } |
1133 | 1133 | return $flight_array; |
1134 | - } |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * Gets all number of flight over countries |
|
1138 | - * |
|
1139 | - * @return Array the airline country list |
|
1140 | - * |
|
1141 | - */ |
|
1142 | - public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1143 | - { |
|
1134 | + } |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * Gets all number of flight over countries |
|
1138 | + * |
|
1139 | + * @return Array the airline country list |
|
1140 | + * |
|
1141 | + */ |
|
1142 | + public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '') |
|
1143 | + { |
|
1144 | 1144 | global $globalDBdriver; |
1145 | 1145 | /* |
1146 | 1146 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -1150,14 +1150,14 @@ discard block |
||
1150 | 1150 | $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb |
1151 | 1151 | FROM countries c, spotter_archive s, spotter_output o |
1152 | 1152 | WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id "; |
1153 | - if ($olderthanmonths > 0) { |
|
1154 | - if ($globalDBdriver == 'mysql') { |
|
1153 | + if ($olderthanmonths > 0) { |
|
1154 | + if ($globalDBdriver == 'mysql') { |
|
1155 | 1155 | $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
1156 | 1156 | } else { |
1157 | 1157 | $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
1158 | 1158 | } |
1159 | 1159 | } |
1160 | - if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1160 | + if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' "; |
|
1161 | 1161 | $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
1162 | 1162 | if ($limit) $query .= " LIMIT 0,10"; |
1163 | 1163 | |
@@ -1170,24 +1170,24 @@ discard block |
||
1170 | 1170 | |
1171 | 1171 | while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
1172 | 1172 | { |
1173 | - $temp_array['airline_icao'] = $row['airline_icao']; |
|
1174 | - $temp_array['flight_count'] = $row['nb']; |
|
1175 | - $temp_array['flight_country'] = $row['name']; |
|
1176 | - $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1177 | - $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1178 | - $flight_array[] = $temp_array; |
|
1173 | + $temp_array['airline_icao'] = $row['airline_icao']; |
|
1174 | + $temp_array['flight_count'] = $row['nb']; |
|
1175 | + $temp_array['flight_country'] = $row['name']; |
|
1176 | + $temp_array['flight_country_iso3'] = $row['iso3']; |
|
1177 | + $temp_array['flight_country_iso2'] = $row['iso2']; |
|
1178 | + $flight_array[] = $temp_array; |
|
1179 | 1179 | } |
1180 | 1180 | return $flight_array; |
1181 | - } |
|
1182 | - |
|
1183 | - /** |
|
1184 | - * Gets last spotter information based on a particular callsign |
|
1185 | - * |
|
1186 | - * @return Array the spotter information |
|
1187 | - * |
|
1188 | - */ |
|
1189 | - public function getDateArchiveSpotterDataById($id,$date) |
|
1190 | - { |
|
1181 | + } |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * Gets last spotter information based on a particular callsign |
|
1185 | + * |
|
1186 | + * @return Array the spotter information |
|
1187 | + * |
|
1188 | + */ |
|
1189 | + public function getDateArchiveSpotterDataById($id,$date) |
|
1190 | + { |
|
1191 | 1191 | $Spotter = new Spotter($this->db); |
1192 | 1192 | date_default_timezone_set('UTC'); |
1193 | 1193 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
@@ -1195,16 +1195,16 @@ discard block |
||
1195 | 1195 | $date = date('c',$date); |
1196 | 1196 | $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date)); |
1197 | 1197 | return $spotter_array; |
1198 | - } |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Gets all the spotter information based on a particular callsign |
|
1202 | - * |
|
1203 | - * @return Array the spotter information |
|
1204 | - * |
|
1205 | - */ |
|
1206 | - public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1207 | - { |
|
1198 | + } |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Gets all the spotter information based on a particular callsign |
|
1202 | + * |
|
1203 | + * @return Array the spotter information |
|
1204 | + * |
|
1205 | + */ |
|
1206 | + public function getDateArchiveSpotterDataByIdent($ident,$date) |
|
1207 | + { |
|
1208 | 1208 | $Spotter = new Spotter($this->db); |
1209 | 1209 | date_default_timezone_set('UTC'); |
1210 | 1210 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
@@ -1212,16 +1212,16 @@ discard block |
||
1212 | 1212 | $date = date('c',$date); |
1213 | 1213 | $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
1214 | 1214 | return $spotter_array; |
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * Gets all the spotter information based on the airport |
|
1219 | - * |
|
1220 | - * @return Array the spotter information |
|
1221 | - * |
|
1222 | - */ |
|
1223 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1224 | - { |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * Gets all the spotter information based on the airport |
|
1219 | + * |
|
1220 | + * @return Array the spotter information |
|
1221 | + * |
|
1222 | + */ |
|
1223 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
1224 | + { |
|
1225 | 1225 | global $global_query; |
1226 | 1226 | $Spotter = new Spotter($this->db); |
1227 | 1227 | date_default_timezone_set('UTC'); |
@@ -1232,35 +1232,35 @@ discard block |
||
1232 | 1232 | |
1233 | 1233 | if ($airport != "") |
1234 | 1234 | { |
1235 | - if (!is_string($airport)) |
|
1236 | - { |
|
1235 | + if (!is_string($airport)) |
|
1236 | + { |
|
1237 | 1237 | return false; |
1238 | - } else { |
|
1238 | + } else { |
|
1239 | 1239 | $additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))"; |
1240 | 1240 | $query_values = array(':airport' => $airport); |
1241 | - } |
|
1241 | + } |
|
1242 | 1242 | } |
1243 | 1243 | |
1244 | 1244 | if ($limit != "") |
1245 | 1245 | { |
1246 | - $limit_array = explode(",", $limit); |
|
1246 | + $limit_array = explode(",", $limit); |
|
1247 | 1247 | |
1248 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1248 | + $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1249 | + $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1250 | 1250 | |
1251 | - if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1252 | - { |
|
1251 | + if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
1252 | + { |
|
1253 | 1253 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
1254 | 1254 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
1255 | - } |
|
1255 | + } |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | 1258 | if ($sort != "") |
1259 | 1259 | { |
1260 | - $search_orderby_array = $Spotter->getOrderBy(); |
|
1261 | - $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1260 | + $search_orderby_array = $Spotter->getOrderBy(); |
|
1261 | + $orderby_query = $search_orderby_array[$sort]['sql']; |
|
1262 | 1262 | } else { |
1263 | - $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1263 | + $orderby_query = " ORDER BY spotter_archive_output.date DESC"; |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | $query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query; |
@@ -1268,6 +1268,6 @@ discard block |
||
1268 | 1268 | $spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query); |
1269 | 1269 | |
1270 | 1270 | return $spotter_array; |
1271 | - } |
|
1271 | + } |
|
1272 | 1272 | } |
1273 | 1273 | ?> |
1274 | 1274 | \ No newline at end of file |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
18 | 18 | if (isset($globalMarine) && $globalMarine) { |
19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; |
@@ -25,46 +25,46 @@ discard block |
||
25 | 25 | // Check if schema is at latest version |
26 | 26 | $Connection = new Connection(); |
27 | 27 | if ($Connection->connectionExists() === false) { |
28 | - echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | - exit(); |
|
28 | + echo "Can't connect to your database. Check DB is running, user/password and database logs."; |
|
29 | + exit(); |
|
30 | 30 | } |
31 | 31 | if ($Connection->latest() === false) { |
32 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | - exit(); |
|
32 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | if (PHP_SAPI != 'cli') { |
36 | - echo "This script MUST be called from console, not a web browser."; |
|
36 | + echo "This script MUST be called from console, not a web browser."; |
|
37 | 37 | // exit(); |
38 | 38 | } |
39 | 39 | |
40 | 40 | // This is to be compatible with old version of settings.php |
41 | 41 | if (!isset($globalSources)) { |
42 | - if (isset($globalSBS1Hosts)) { |
|
43 | - //$hosts = $globalSBS1Hosts; |
|
44 | - foreach ($globalSBS1Hosts as $host) { |
|
45 | - $globalSources[] = array('host' => $host); |
|
46 | - } |
|
47 | - } else { |
|
48 | - if (!isset($globalSBS1Host)) { |
|
49 | - echo '$globalSources MUST be defined !'; |
|
50 | - die; |
|
42 | + if (isset($globalSBS1Hosts)) { |
|
43 | + //$hosts = $globalSBS1Hosts; |
|
44 | + foreach ($globalSBS1Hosts as $host) { |
|
45 | + $globalSources[] = array('host' => $host); |
|
46 | + } |
|
47 | + } else { |
|
48 | + if (!isset($globalSBS1Host)) { |
|
49 | + echo '$globalSources MUST be defined !'; |
|
50 | + die; |
|
51 | 51 | } |
52 | 52 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
53 | 53 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
54 | - } |
|
54 | + } |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine')); |
58 | 58 | //if (isset($options['s'])) $hosts = array($options['s']); |
59 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
60 | 60 | if (isset($options['s'])) { |
61 | - $globalSources = array(); |
|
62 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | - else $globalSources[] = array('host' => $options['s']); |
|
61 | + $globalSources = array(); |
|
62 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); |
|
63 | + else $globalSources[] = array('host' => $options['s']); |
|
64 | 64 | } elseif (isset($options['source'])) { |
65 | - $globalSources = array(); |
|
66 | - if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | - else $globalSources[] = array('host' => $options['source']); |
|
65 | + $globalSources = array(); |
|
66 | + if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); |
|
67 | + else $globalSources[] = array('host' => $options['source']); |
|
68 | 68 | } |
69 | 69 | if (isset($options['aprsserverhost'])) { |
70 | 70 | $globalServerAPRS = TRUE; |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
104 | 104 | else $id_source = 1; |
105 | 105 | if (isset($globalServer) && $globalServer) { |
106 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | - $SI=new SpotterServer(); |
|
106 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
107 | + $SI=new SpotterServer(); |
|
108 | 108 | /* |
109 | 109 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
110 | 110 | $SI = new adsb2aprs(); |
@@ -114,14 +114,14 @@ discard block |
||
114 | 114 | |
115 | 115 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); |
116 | 116 | if (isset($globalMarine) && $globalMarine) { |
117 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
117 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); |
|
118 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); |
122 | 122 | if (isset($globalMarine) && $globalMarine) { |
123 | - $AIS = new AIS(); |
|
124 | - $MI = new MarineImport($Connection->db); |
|
123 | + $AIS = new AIS(); |
|
124 | + $MI = new MarineImport($Connection->db); |
|
125 | 125 | } |
126 | 126 | //$APRS=new APRS($Connection->db); |
127 | 127 | $SBS=new SBS(); |
@@ -134,12 +134,12 @@ discard block |
||
134 | 134 | //$servertz = system('date +%Z'); |
135 | 135 | // signal handler - playing nice with sockets and dump1090 |
136 | 136 | if (function_exists('pcntl_fork')) { |
137 | - pcntl_signal(SIGINT, function() { |
|
138 | - global $sockets; |
|
139 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | - die("Bye!\n"); |
|
141 | - }); |
|
142 | - pcntl_signal_dispatch(); |
|
137 | + pcntl_signal(SIGINT, function() { |
|
138 | + global $sockets; |
|
139 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
140 | + die("Bye!\n"); |
|
141 | + }); |
|
142 | + pcntl_signal_dispatch(); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | // let's try and connect |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | $reset = 0; |
150 | 150 | |
151 | 151 | function connect_all($hosts) { |
152 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | - $reset++; |
|
155 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | - foreach ($hosts as $id => $value) { |
|
152 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
153 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; |
|
154 | + $reset++; |
|
155 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
156 | + foreach ($hosts as $id => $value) { |
|
157 | 157 | $host = $value['host']; |
158 | 158 | $globalSources[$id]['last_exec'] = 0; |
159 | 159 | // Here we check type of source(s) |
160 | 160 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
161 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | - //$formats[$id] = 'deltadbtxt'; |
|
163 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | - //$last_exec['deltadbtxt'] = 0; |
|
165 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | - //$formats[$id] = 'vatsimtxt'; |
|
168 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | - //$last_exec['vatsimtxt'] = 0; |
|
170 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | - //$formats[$id] = 'aircraftlistjson'; |
|
173 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | - //$last_exec['aircraftlistjson'] = 0; |
|
175 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | - } else if (preg_match('/aircraft.json$/i',$host)) { |
|
177 | - //$formats[$id] = 'aircraftjson'; |
|
178 | - $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | - //$last_exec['aircraftlistjson'] = 0; |
|
180 | - if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
181 | - } else if (preg_match('/aircraft$/i',$host)) { |
|
182 | - //$formats[$id] = 'planefinderclient'; |
|
183 | - $globalSources[$id]['format'] = 'planefinderclient'; |
|
184 | - //$last_exec['aircraftlistjson'] = 0; |
|
185 | - if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
186 | - } else if (preg_match('/opensky/i',$host)) { |
|
187 | - //$formats[$id] = 'aircraftlistjson'; |
|
188 | - $globalSources[$id]['format'] = 'opensky'; |
|
189 | - //$last_exec['aircraftlistjson'] = 0; |
|
190 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
191 | - /* |
|
161 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
162 | + //$formats[$id] = 'deltadbtxt'; |
|
163 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
164 | + //$last_exec['deltadbtxt'] = 0; |
|
165 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
166 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
167 | + //$formats[$id] = 'vatsimtxt'; |
|
168 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
169 | + //$last_exec['vatsimtxt'] = 0; |
|
170 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
171 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
172 | + //$formats[$id] = 'aircraftlistjson'; |
|
173 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
174 | + //$last_exec['aircraftlistjson'] = 0; |
|
175 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
176 | + } else if (preg_match('/aircraft.json$/i',$host)) { |
|
177 | + //$formats[$id] = 'aircraftjson'; |
|
178 | + $globalSources[$id]['format'] = 'aircraftjson'; |
|
179 | + //$last_exec['aircraftlistjson'] = 0; |
|
180 | + if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n"; |
|
181 | + } else if (preg_match('/aircraft$/i',$host)) { |
|
182 | + //$formats[$id] = 'planefinderclient'; |
|
183 | + $globalSources[$id]['format'] = 'planefinderclient'; |
|
184 | + //$last_exec['aircraftlistjson'] = 0; |
|
185 | + if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n"; |
|
186 | + } else if (preg_match('/opensky/i',$host)) { |
|
187 | + //$formats[$id] = 'aircraftlistjson'; |
|
188 | + $globalSources[$id]['format'] = 'opensky'; |
|
189 | + //$last_exec['aircraftlistjson'] = 0; |
|
190 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
191 | + /* |
|
192 | 192 | // Disabled for now, site change source format |
193 | 193 | } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { |
194 | 194 | //$formats[$id] = 'radarvirtueljson'; |
@@ -200,127 +200,127 @@ discard block |
||
200 | 200 | exit(0); |
201 | 201 | } |
202 | 202 | */ |
203 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
204 | - //$formats[$id] = 'planeupdatefaa'; |
|
205 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
206 | - //$last_exec['planeupdatefaa'] = 0; |
|
207 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
208 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | - exit(0); |
|
211 | - } |
|
212 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
213 | - //$formats[$id] = 'phpvmacars'; |
|
214 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
215 | - //$last_exec['phpvmacars'] = 0; |
|
216 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
217 | - } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
218 | - //$formats[$id] = 'phpvmacars'; |
|
219 | - $globalSources[$id]['format'] = 'vaos'; |
|
220 | - //$last_exec['phpvmacars'] = 0; |
|
221 | - if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
222 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
223 | - //$formats[$id] = 'phpvmacars'; |
|
224 | - $globalSources[$id]['format'] = 'vam'; |
|
225 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
226 | - } else if (preg_match('/whazzup/i',$host)) { |
|
227 | - //$formats[$id] = 'whazzup'; |
|
228 | - $globalSources[$id]['format'] = 'whazzup'; |
|
229 | - //$last_exec['whazzup'] = 0; |
|
230 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
231 | - } else if (preg_match('/blitzortung/i',$host)) { |
|
232 | - $globalSources[$id]['format'] = 'blitzortung'; |
|
233 | - if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
234 | - } else if (preg_match('/airwhere/i',$host)) { |
|
235 | - $globalSources[$id]['format'] = 'airwhere'; |
|
236 | - if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
237 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
238 | - //$formats[$id] = 'pirepsjson'; |
|
239 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
240 | - //$last_exec['pirepsjson'] = 0; |
|
241 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
242 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
243 | - //$formats[$id] = 'fr24json'; |
|
244 | - $globalSources[$id]['format'] = 'fr24json'; |
|
245 | - //$last_exec['fr24json'] = 0; |
|
246 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
247 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
248 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
249 | - exit(0); |
|
250 | - } |
|
251 | - } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
252 | - //$formats[$id] = 'fr24json'; |
|
253 | - $globalSources[$id]['format'] = 'myshiptracking'; |
|
254 | - //$last_exec['fr24json'] = 0; |
|
255 | - if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
256 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | - exit(0); |
|
259 | - } |
|
260 | - //} else if (preg_match('/10001/',$host)) { |
|
261 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
262 | - //$formats[$id] = 'tsv'; |
|
263 | - $globalSources[$id]['format'] = 'tsv'; |
|
264 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
265 | - } |
|
266 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
267 | - if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
268 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
269 | - if ($idf !== false) { |
|
270 | - $httpfeeds[$id] = $idf; |
|
271 | - if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
272 | - } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
273 | - } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
274 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
275 | - $hostport = explode(':',$host); |
|
276 | - if (isset($hostport[1])) { |
|
203 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
204 | + //$formats[$id] = 'planeupdatefaa'; |
|
205 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
206 | + //$last_exec['planeupdatefaa'] = 0; |
|
207 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
208 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
209 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
210 | + exit(0); |
|
211 | + } |
|
212 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
213 | + //$formats[$id] = 'phpvmacars'; |
|
214 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
215 | + //$last_exec['phpvmacars'] = 0; |
|
216 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
217 | + } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) { |
|
218 | + //$formats[$id] = 'phpvmacars'; |
|
219 | + $globalSources[$id]['format'] = 'vaos'; |
|
220 | + //$last_exec['phpvmacars'] = 0; |
|
221 | + if ($globalDebug) echo "Connect to vaos source (".$host.")...\n"; |
|
222 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
223 | + //$formats[$id] = 'phpvmacars'; |
|
224 | + $globalSources[$id]['format'] = 'vam'; |
|
225 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
226 | + } else if (preg_match('/whazzup/i',$host)) { |
|
227 | + //$formats[$id] = 'whazzup'; |
|
228 | + $globalSources[$id]['format'] = 'whazzup'; |
|
229 | + //$last_exec['whazzup'] = 0; |
|
230 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
231 | + } else if (preg_match('/blitzortung/i',$host)) { |
|
232 | + $globalSources[$id]['format'] = 'blitzortung'; |
|
233 | + if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n"; |
|
234 | + } else if (preg_match('/airwhere/i',$host)) { |
|
235 | + $globalSources[$id]['format'] = 'airwhere'; |
|
236 | + if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; |
|
237 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
238 | + //$formats[$id] = 'pirepsjson'; |
|
239 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
240 | + //$last_exec['pirepsjson'] = 0; |
|
241 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
242 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
243 | + //$formats[$id] = 'fr24json'; |
|
244 | + $globalSources[$id]['format'] = 'fr24json'; |
|
245 | + //$last_exec['fr24json'] = 0; |
|
246 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
247 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
248 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
249 | + exit(0); |
|
250 | + } |
|
251 | + } else if (preg_match(':myshiptracking.com/:i',$host)) { |
|
252 | + //$formats[$id] = 'fr24json'; |
|
253 | + $globalSources[$id]['format'] = 'myshiptracking'; |
|
254 | + //$last_exec['fr24json'] = 0; |
|
255 | + if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; |
|
256 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
257 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
258 | + exit(0); |
|
259 | + } |
|
260 | + //} else if (preg_match('/10001/',$host)) { |
|
261 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
262 | + //$formats[$id] = 'tsv'; |
|
263 | + $globalSources[$id]['format'] = 'tsv'; |
|
264 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
265 | + } |
|
266 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
267 | + if ($globalSources[$id]['format'] == 'aisnmeahttp') { |
|
268 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); |
|
269 | + if ($idf !== false) { |
|
270 | + $httpfeeds[$id] = $idf; |
|
271 | + if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
272 | + } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; |
|
273 | + } elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
274 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
275 | + $hostport = explode(':',$host); |
|
276 | + if (isset($hostport[1])) { |
|
277 | 277 | $port = $hostport[1]; |
278 | 278 | $hostn = $hostport[0]; |
279 | - } else { |
|
279 | + } else { |
|
280 | 280 | $port = $globalSources[$id]['port']; |
281 | 281 | $hostn = $globalSources[$id]['host']; |
282 | - } |
|
283 | - $Common = new Common(); |
|
284 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
285 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
286 | - } else { |
|
287 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
288 | - } |
|
289 | - if ($s) { |
|
290 | - $sockets[$id] = $s; |
|
291 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
292 | - if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
282 | + } |
|
283 | + $Common = new Common(); |
|
284 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
285 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); |
|
286 | + } else { |
|
287 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); |
|
288 | + } |
|
289 | + if ($s) { |
|
290 | + $sockets[$id] = $s; |
|
291 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
292 | + if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { |
|
293 | 293 | //$formats[$id] = 'aprs'; |
294 | 294 | $globalSources[$id]['format'] = 'aprs'; |
295 | 295 | //$aprs_connect = 0; |
296 | 296 | //$use_aprs = true; |
297 | - } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
297 | + } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { |
|
298 | 298 | $globalSources[$id]['format'] = 'vrstcp'; |
299 | - } elseif ($port == '10001') { |
|
300 | - //$formats[$id] = 'tsv'; |
|
301 | - $globalSources[$id]['format'] = 'tsv'; |
|
302 | - } elseif ($port == '30002') { |
|
303 | - //$formats[$id] = 'raw'; |
|
304 | - $globalSources[$id]['format'] = 'raw'; |
|
305 | - } elseif ($port == '5001') { |
|
306 | - //$formats[$id] = 'raw'; |
|
307 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
308 | - } elseif ($port == '30005') { |
|
299 | + } elseif ($port == '10001') { |
|
300 | + //$formats[$id] = 'tsv'; |
|
301 | + $globalSources[$id]['format'] = 'tsv'; |
|
302 | + } elseif ($port == '30002') { |
|
303 | + //$formats[$id] = 'raw'; |
|
304 | + $globalSources[$id]['format'] = 'raw'; |
|
305 | + } elseif ($port == '5001') { |
|
306 | + //$formats[$id] = 'raw'; |
|
307 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
308 | + } elseif ($port == '30005') { |
|
309 | 309 | // Not yet supported |
310 | - //$formats[$id] = 'beast'; |
|
311 | - $globalSources[$id]['format'] = 'beast'; |
|
312 | - //} else $formats[$id] = 'sbs'; |
|
313 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
314 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
310 | + //$formats[$id] = 'beast'; |
|
311 | + $globalSources[$id]['format'] = 'beast'; |
|
312 | + //} else $formats[$id] = 'sbs'; |
|
313 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
314 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
315 | 315 | } |
316 | 316 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
317 | - } else { |
|
317 | + } else { |
|
318 | 318 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
319 | 319 | sleep(10); |
320 | 320 | connect_all($hosts); |
321 | - } |
|
322 | - } |
|
323 | - } |
|
321 | + } |
|
322 | + } |
|
323 | + } |
|
324 | 324 | } |
325 | 325 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
326 | 326 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | //connect_all($globalSources); |
344 | 344 | |
345 | 345 | if (isset($globalProxy) && $globalProxy) { |
346 | - $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
346 | + $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); |
|
347 | 347 | } else { |
348 | - $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
348 | + $context = stream_context_create(array('http' => array('timeout' => $timeout))); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | // APRS Configuration |
@@ -354,21 +354,21 @@ discard block |
||
354 | 354 | die; |
355 | 355 | } |
356 | 356 | foreach ($globalSources as $key => $source) { |
357 | - if (!isset($source['format'])) { |
|
358 | - $globalSources[$key]['format'] = 'auto'; |
|
359 | - } |
|
360 | - if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
361 | - unset($globalSources[$key]); |
|
362 | - } |
|
357 | + if (!isset($source['format'])) { |
|
358 | + $globalSources[$key]['format'] = 'auto'; |
|
359 | + } |
|
360 | + if (isset($source['callback']) && $source['callback'] === TRUE) { |
|
361 | + unset($globalSources[$key]); |
|
362 | + } |
|
363 | 363 | } |
364 | 364 | connect_all($globalSources); |
365 | 365 | foreach ($globalSources as $key => $source) { |
366 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
366 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
367 | 367 | $aprs_connect = 0; |
368 | 368 | $use_aprs = true; |
369 | 369 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
370 | 370 | break; |
371 | - } |
|
371 | + } |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | if ($use_aprs) { |
@@ -409,133 +409,133 @@ discard block |
||
409 | 409 | |
410 | 410 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
411 | 411 | while ($i > 0) { |
412 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
412 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
413 | 413 | |
414 | - if (!$globalDaemon) $i = $endtime-time(); |
|
415 | - // Delete old ATC |
|
416 | - if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
414 | + if (!$globalDaemon) $i = $endtime-time(); |
|
415 | + // Delete old ATC |
|
416 | + if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
417 | 417 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
418 | - $ATC->deleteOldATC(); |
|
419 | - } |
|
418 | + $ATC->deleteOldATC(); |
|
419 | + } |
|
420 | 420 | |
421 | - if (count($last_exec) == count($globalSources)) { |
|
421 | + if (count($last_exec) == count($globalSources)) { |
|
422 | 422 | $max = $globalMinFetch; |
423 | 423 | foreach ($last_exec as $last) { |
424 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
424 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
425 | 425 | } |
426 | 426 | if ($max < $globalMinFetch) { |
427 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
428 | - sleep($globalMinFetch-$max+2); |
|
427 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
428 | + sleep($globalMinFetch-$max+2); |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | 431 | |
432 | 432 | |
433 | - //foreach ($formats as $id => $value) { |
|
434 | - foreach ($globalSources as $id => $value) { |
|
433 | + //foreach ($formats as $id => $value) { |
|
434 | + foreach ($globalSources as $id => $value) { |
|
435 | 435 | date_default_timezone_set('UTC'); |
436 | 436 | //if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n"; |
437 | 437 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
438 | 438 | if ($value['format'] === 'deltadbtxt' && |
439 | - ( |
|
439 | + ( |
|
440 | 440 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
441 | 441 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
442 | - ) |
|
442 | + ) |
|
443 | 443 | ) { |
444 | - //$buffer = $Common->getData($hosts[$id]); |
|
445 | - $buffer = $Common->getData($value['host']); |
|
446 | - if ($buffer != '') $reset = 0; |
|
447 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
448 | - $buffer = explode('\n',$buffer); |
|
449 | - foreach ($buffer as $line) { |
|
450 | - if ($line != '' && count($line) > 7) { |
|
451 | - $line = explode(',', $line); |
|
452 | - $data = array(); |
|
453 | - $data['hex'] = $line[1]; // hex |
|
454 | - $data['ident'] = $line[2]; // ident |
|
455 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
456 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
457 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
458 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
459 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
460 | - $data['verticalrate'] = ''; // vertical rate |
|
461 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
462 | - $data['emergency'] = ''; // emergency |
|
463 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
464 | - $data['format_source'] = 'deltadbtxt'; |
|
465 | - $data['id_source'] = $id_source; |
|
466 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
467 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
468 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
469 | - $SI->add($data); |
|
470 | - unset($data); |
|
471 | - } |
|
472 | - } |
|
473 | - $last_exec[$id]['last'] = time(); |
|
444 | + //$buffer = $Common->getData($hosts[$id]); |
|
445 | + $buffer = $Common->getData($value['host']); |
|
446 | + if ($buffer != '') $reset = 0; |
|
447 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
448 | + $buffer = explode('\n',$buffer); |
|
449 | + foreach ($buffer as $line) { |
|
450 | + if ($line != '' && count($line) > 7) { |
|
451 | + $line = explode(',', $line); |
|
452 | + $data = array(); |
|
453 | + $data['hex'] = $line[1]; // hex |
|
454 | + $data['ident'] = $line[2]; // ident |
|
455 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
456 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
457 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
458 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
459 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
460 | + $data['verticalrate'] = ''; // vertical rate |
|
461 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
462 | + $data['emergency'] = ''; // emergency |
|
463 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
464 | + $data['format_source'] = 'deltadbtxt'; |
|
465 | + $data['id_source'] = $id_source; |
|
466 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
467 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
468 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
469 | + $SI->add($data); |
|
470 | + unset($data); |
|
471 | + } |
|
472 | + } |
|
473 | + $last_exec[$id]['last'] = time(); |
|
474 | 474 | } elseif ($value['format'] === 'aisnmeatxt' && |
475 | - ( |
|
475 | + ( |
|
476 | 476 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
477 | 477 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
478 | - ) |
|
478 | + ) |
|
479 | 479 | ) { |
480 | - date_default_timezone_set('CET'); |
|
481 | - $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
482 | - date_default_timezone_set('UTC'); |
|
483 | - if ($buffer != '') $reset = 0; |
|
484 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
485 | - $buffer = explode('\n',$buffer); |
|
486 | - foreach ($buffer as $line) { |
|
480 | + date_default_timezone_set('CET'); |
|
481 | + $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); |
|
482 | + date_default_timezone_set('UTC'); |
|
483 | + if ($buffer != '') $reset = 0; |
|
484 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
485 | + $buffer = explode('\n',$buffer); |
|
486 | + foreach ($buffer as $line) { |
|
487 | 487 | if ($line != '') { |
488 | - //echo "'".$line."'\n"; |
|
489 | - $add = false; |
|
490 | - $ais_data = $AIS->parse_line(trim($line)); |
|
491 | - $data = array(); |
|
492 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
493 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
494 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
495 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
496 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
497 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
498 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
499 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
500 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
501 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
502 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
503 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
504 | - if (isset($ais_data['timestamp'])) { |
|
488 | + //echo "'".$line."'\n"; |
|
489 | + $add = false; |
|
490 | + $ais_data = $AIS->parse_line(trim($line)); |
|
491 | + $data = array(); |
|
492 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
493 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
494 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
495 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
496 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
497 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
498 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
499 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
500 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
501 | + if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; |
|
502 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
503 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
504 | + if (isset($ais_data['timestamp'])) { |
|
505 | 505 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
506 | 506 | if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { |
507 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
508 | - $add = true; |
|
507 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; |
|
508 | + $add = true; |
|
509 | 509 | } |
510 | - } else { |
|
510 | + } else { |
|
511 | 511 | $data['datetime'] = date('Y-m-d H:i:s'); |
512 | 512 | $add = true; |
513 | - } |
|
514 | - $data['format_source'] = 'aisnmeatxt'; |
|
515 | - $data['id_source'] = $id_source; |
|
516 | - //print_r($data); |
|
517 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
518 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
519 | - unset($data); |
|
513 | + } |
|
514 | + $data['format_source'] = 'aisnmeatxt'; |
|
515 | + $data['id_source'] = $id_source; |
|
516 | + //print_r($data); |
|
517 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
518 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
519 | + unset($data); |
|
520 | 520 | } |
521 | - } |
|
522 | - $last_exec[$id]['last'] = time(); |
|
521 | + } |
|
522 | + $last_exec[$id]['last'] = time(); |
|
523 | 523 | } elseif ($value['format'] === 'aisnmeahttp') { |
524 | - $arr = $httpfeeds; |
|
525 | - $w = $e = null; |
|
524 | + $arr = $httpfeeds; |
|
525 | + $w = $e = null; |
|
526 | 526 | |
527 | - if (isset($arr[$id])) { |
|
527 | + if (isset($arr[$id])) { |
|
528 | 528 | $nn = stream_select($arr,$w,$e,$timeout); |
529 | 529 | if ($nn > 0) { |
530 | - foreach ($httpfeeds as $feed) { |
|
530 | + foreach ($httpfeeds as $feed) { |
|
531 | 531 | $buffer = stream_get_line($feed,2000,"\n"); |
532 | 532 | if ($buffer === FALSE) { |
533 | - connect_all($globalSources); |
|
533 | + connect_all($globalSources); |
|
534 | 534 | } |
535 | 535 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
536 | 536 | $buffer = explode('\n',$buffer); |
537 | 537 | foreach ($buffer as $line) { |
538 | - if ($line != '') { |
|
538 | + if ($line != '') { |
|
539 | 539 | $ais_data = $AIS->parse_line(trim($line)); |
540 | 540 | $data = array(); |
541 | 541 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
@@ -553,117 +553,117 @@ discard block |
||
553 | 553 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
554 | 554 | if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
555 | 555 | if (isset($ais_data['timestamp'])) { |
556 | - $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
556 | + $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
|
557 | 557 | } else { |
558 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
558 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
559 | 559 | } |
560 | 560 | $data['format_source'] = 'aisnmeahttp'; |
561 | 561 | $data['id_source'] = $id_source; |
562 | 562 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
563 | 563 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
564 | 564 | unset($data); |
565 | - } |
|
565 | + } |
|
566 | + } |
|
566 | 567 | } |
567 | - } |
|
568 | 568 | } else { |
569 | - $format = $value['format']; |
|
570 | - if (isset($tt[$format])) $tt[$format]++; |
|
571 | - else $tt[$format] = 0; |
|
572 | - if ($tt[$format] > 30) { |
|
569 | + $format = $value['format']; |
|
570 | + if (isset($tt[$format])) $tt[$format]++; |
|
571 | + else $tt[$format] = 0; |
|
572 | + if ($tt[$format] > 30) { |
|
573 | 573 | if ($globalDebug) echo 'Reconnect...'."\n"; |
574 | 574 | sleep(2); |
575 | 575 | //$sourceeen[] = $value; |
576 | 576 | //connect_all($sourceeen); |
577 | 577 | //$sourceeen = array(); |
578 | 578 | connect_all($globalSources); |
579 | - } |
|
579 | + } |
|
580 | + } |
|
580 | 581 | } |
581 | - } |
|
582 | 582 | } elseif ($value['format'] === 'myshiptracking' && |
583 | - ( |
|
583 | + ( |
|
584 | 584 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
585 | 585 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
586 | - ) |
|
586 | + ) |
|
587 | 587 | ) { |
588 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
589 | - if ($buffer != '') { |
|
588 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
589 | + if ($buffer != '') { |
|
590 | 590 | //echo $buffer; |
591 | 591 | $all_data = json_decode($buffer,true); |
592 | 592 | //print_r($all_data); |
593 | 593 | if (isset($all_data[0]['DATA'])) { |
594 | - foreach ($all_data[0]['DATA'] as $line) { |
|
594 | + foreach ($all_data[0]['DATA'] as $line) { |
|
595 | 595 | if ($line != '') { |
596 | - $data = array(); |
|
597 | - $data['ident'] = $line['NAME']; |
|
598 | - $data['mmsi'] = $line['MMSI']; |
|
599 | - if (strlen($data['mmsi']) > 9) { |
|
596 | + $data = array(); |
|
597 | + $data['ident'] = $line['NAME']; |
|
598 | + $data['mmsi'] = $line['MMSI']; |
|
599 | + if (strlen($data['mmsi']) > 9) { |
|
600 | 600 | $data['mmsi'] = substr($data['mmsi'],-9); |
601 | - } |
|
602 | - $data['speed'] = $line['SOG']; |
|
603 | - $data['heading'] = $line['COG']; |
|
604 | - $data['latitude'] = $line['LAT']; |
|
605 | - $data['longitude'] = $line['LNG']; |
|
606 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
607 | - //$data['type_id'] = $line['TYPE']; |
|
608 | - $data['imo'] = $line['IMO']; |
|
609 | - if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
610 | - if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
611 | - $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
612 | - $data['format_source'] = 'myshiptracking'; |
|
613 | - $data['id_source'] = $id_source; |
|
614 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
615 | - $MI->add($data); |
|
616 | - unset($data); |
|
601 | + } |
|
602 | + $data['speed'] = $line['SOG']; |
|
603 | + $data['heading'] = $line['COG']; |
|
604 | + $data['latitude'] = $line['LAT']; |
|
605 | + $data['longitude'] = $line['LNG']; |
|
606 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
607 | + //$data['type_id'] = $line['TYPE']; |
|
608 | + $data['imo'] = $line['IMO']; |
|
609 | + if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST']; |
|
610 | + if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV'])); |
|
611 | + $data['datetime'] = date('Y-m-d H:i:s',$line['T']); |
|
612 | + $data['format_source'] = 'myshiptracking'; |
|
613 | + $data['id_source'] = $id_source; |
|
614 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
615 | + $MI->add($data); |
|
616 | + unset($data); |
|
617 | 617 | } |
618 | - } |
|
618 | + } |
|
619 | + } |
|
619 | 620 | } |
620 | - } |
|
621 | - $last_exec[$id]['last'] = time(); |
|
621 | + $last_exec[$id]['last'] = time(); |
|
622 | 622 | } elseif ($value['format'] === 'boatbeaconapp' && |
623 | - ( |
|
623 | + ( |
|
624 | 624 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
625 | 625 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
626 | - ) |
|
626 | + ) |
|
627 | 627 | ) { |
628 | - $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
629 | - if ($buffer != '') { |
|
628 | + $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); |
|
629 | + if ($buffer != '') { |
|
630 | 630 | $all_data = json_decode($buffer,true); |
631 | 631 | if (isset($all_data[0]['mmsi'])) { |
632 | - foreach ($all_data as $line) { |
|
632 | + foreach ($all_data as $line) { |
|
633 | 633 | if ($line != '') { |
634 | - $data = array(); |
|
635 | - $data['ident'] = $line['shipname']; |
|
636 | - $data['callsign'] = $line['callsign']; |
|
637 | - $data['mmsi'] = substr($line['mmsi'],-9); |
|
638 | - $data['speed'] = $line['sog']; |
|
639 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
640 | - $data['latitude'] = $line['latitude']; |
|
641 | - $data['longitude'] = $line['longitude']; |
|
642 | - $data['type_id'] = $line['shiptype']; |
|
643 | - $data['arrival_code'] = $line['destination']; |
|
644 | - $data['datetime'] = $line['time']; |
|
645 | - $data['format_source'] = 'boatbeaconapp'; |
|
646 | - $data['id_source'] = $id_source; |
|
647 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
648 | - $MI->add($data); |
|
649 | - unset($data); |
|
634 | + $data = array(); |
|
635 | + $data['ident'] = $line['shipname']; |
|
636 | + $data['callsign'] = $line['callsign']; |
|
637 | + $data['mmsi'] = substr($line['mmsi'],-9); |
|
638 | + $data['speed'] = $line['sog']; |
|
639 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; |
|
640 | + $data['latitude'] = $line['latitude']; |
|
641 | + $data['longitude'] = $line['longitude']; |
|
642 | + $data['type_id'] = $line['shiptype']; |
|
643 | + $data['arrival_code'] = $line['destination']; |
|
644 | + $data['datetime'] = $line['time']; |
|
645 | + $data['format_source'] = 'boatbeaconapp'; |
|
646 | + $data['id_source'] = $id_source; |
|
647 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
648 | + $MI->add($data); |
|
649 | + unset($data); |
|
650 | + } |
|
650 | 651 | } |
651 | - } |
|
652 | 652 | } |
653 | 653 | |
654 | - } |
|
655 | - $last_exec[$id]['last'] = time(); |
|
654 | + } |
|
655 | + $last_exec[$id]['last'] = time(); |
|
656 | 656 | } elseif ($value['format'] === 'boatnerd' && |
657 | - ( |
|
657 | + ( |
|
658 | 658 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
659 | 659 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
660 | - ) |
|
660 | + ) |
|
661 | 661 | ) { |
662 | - $buffer = $Common->getData($value['host']); |
|
663 | - if ($buffer != '') { |
|
662 | + $buffer = $Common->getData($value['host']); |
|
663 | + if ($buffer != '') { |
|
664 | 664 | $all_data = json_decode($buffer,true); |
665 | 665 | if (isset($all_data['features'][0]['id'])) { |
666 | - foreach ($all_data['features'] as $line) { |
|
666 | + foreach ($all_data['features'] as $line) { |
|
667 | 667 | print_r($line); |
668 | 668 | $data = array(); |
669 | 669 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; |
@@ -683,80 +683,80 @@ discard block |
||
683 | 683 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
684 | 684 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); |
685 | 685 | unset($data); |
686 | - } |
|
686 | + } |
|
687 | 687 | } |
688 | 688 | |
689 | - } |
|
690 | - $last_exec[$id]['last'] = time(); |
|
689 | + } |
|
690 | + $last_exec[$id]['last'] = time(); |
|
691 | 691 | } elseif ($value['format'] === 'shipplotter' && |
692 | - ( |
|
692 | + ( |
|
693 | 693 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
694 | 694 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) |
695 | - ) |
|
695 | + ) |
|
696 | 696 | ) { |
697 | - echo 'download...'; |
|
698 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
699 | - echo 'done !'."\n"; |
|
700 | - // FIXME: Need more work |
|
701 | - if ($buffer != '') $reset = 0; |
|
702 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
703 | - $buffer = explode('\n',$buffer); |
|
704 | - foreach ($buffer as $line) { |
|
697 | + echo 'download...'; |
|
698 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); |
|
699 | + echo 'done !'."\n"; |
|
700 | + // FIXME: Need more work |
|
701 | + if ($buffer != '') $reset = 0; |
|
702 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
703 | + $buffer = explode('\n',$buffer); |
|
704 | + foreach ($buffer as $line) { |
|
705 | 705 | if ($line != '') { |
706 | - $data = array(); |
|
707 | - echo $line."\n"; |
|
708 | - $data['mmsi'] = (int)substr($line,0,9); |
|
709 | - $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
710 | - $data['status_id'] = substr($line,21,2); |
|
711 | - $data['type_id'] = substr($line,24,3); |
|
712 | - $data['latitude'] = substr($line,29,9); |
|
713 | - $data['longitude'] = substr($line,41,9); |
|
714 | - $data['speed'] = round(substr($line,51,5)); |
|
715 | - //$data['course'] = substr($line,57,5); |
|
716 | - $data['heading'] = round(substr($line,63,3)); |
|
717 | - //$data['draft'] = substr($line,67,4); |
|
718 | - //$data['length'] = substr($line,72,3); |
|
719 | - //$data['beam'] = substr($line,76,2); |
|
720 | - $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
721 | - //$data['callsign'] = trim(substr($line,100,7); |
|
722 | - $data['arrival_code'] = substr($line,108,20); |
|
723 | - //$data['etaDate'] = substr($line,129,5); |
|
724 | - //$data['etaTime'] = substr($line,135,5); |
|
725 | - $data['format_source'] = 'shipplotter'; |
|
726 | - $data['id_source'] = $id_source; |
|
727 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
728 | - //print_r($data); |
|
729 | - echo 'Add...'."\n"; |
|
730 | - $MI->add($data); |
|
731 | - unset($data); |
|
706 | + $data = array(); |
|
707 | + echo $line."\n"; |
|
708 | + $data['mmsi'] = (int)substr($line,0,9); |
|
709 | + $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); |
|
710 | + $data['status_id'] = substr($line,21,2); |
|
711 | + $data['type_id'] = substr($line,24,3); |
|
712 | + $data['latitude'] = substr($line,29,9); |
|
713 | + $data['longitude'] = substr($line,41,9); |
|
714 | + $data['speed'] = round(substr($line,51,5)); |
|
715 | + //$data['course'] = substr($line,57,5); |
|
716 | + $data['heading'] = round(substr($line,63,3)); |
|
717 | + //$data['draft'] = substr($line,67,4); |
|
718 | + //$data['length'] = substr($line,72,3); |
|
719 | + //$data['beam'] = substr($line,76,2); |
|
720 | + $data['ident'] = trim(utf8_encode(substr($line,78,20))); |
|
721 | + //$data['callsign'] = trim(substr($line,100,7); |
|
722 | + $data['arrival_code'] = substr($line,108,20); |
|
723 | + //$data['etaDate'] = substr($line,129,5); |
|
724 | + //$data['etaTime'] = substr($line,135,5); |
|
725 | + $data['format_source'] = 'shipplotter'; |
|
726 | + $data['id_source'] = $id_source; |
|
727 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
728 | + //print_r($data); |
|
729 | + echo 'Add...'."\n"; |
|
730 | + $MI->add($data); |
|
731 | + unset($data); |
|
732 | 732 | } |
733 | - } |
|
734 | - $last_exec[$id]['last'] = time(); |
|
733 | + } |
|
734 | + $last_exec[$id]['last'] = time(); |
|
735 | 735 | //} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
736 | 736 | } elseif ( |
737 | - ( |
|
737 | + ( |
|
738 | 738 | $value['format'] === 'whazzup' && |
739 | 739 | ( |
740 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
741 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
740 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
741 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
742 | 742 | ) |
743 | - ) || ( |
|
743 | + ) || ( |
|
744 | 744 | $value['format'] === 'vatsimtxt' && |
745 | 745 | ( |
746 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
747 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
746 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
747 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
748 | + ) |
|
748 | 749 | ) |
749 | - ) |
|
750 | 750 | ) { |
751 | - //$buffer = $Common->getData($hosts[$id]); |
|
752 | - $buffer = $Common->getData($value['host']); |
|
753 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
754 | - $buffer = explode('\n',$buffer); |
|
755 | - $reset = 0; |
|
756 | - foreach ($buffer as $line) { |
|
757 | - if ($line != '') { |
|
758 | - $line = explode(':', $line); |
|
759 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
751 | + //$buffer = $Common->getData($hosts[$id]); |
|
752 | + $buffer = $Common->getData($value['host']); |
|
753 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
754 | + $buffer = explode('\n',$buffer); |
|
755 | + $reset = 0; |
|
756 | + foreach ($buffer as $line) { |
|
757 | + if ($line != '') { |
|
758 | + $line = explode(':', $line); |
|
759 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
760 | 760 | $data = array(); |
761 | 761 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
762 | 762 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -769,37 +769,37 @@ discard block |
||
769 | 769 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
770 | 770 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
771 | 771 | $data['latitude'] = $line[5]; // lat |
772 | - $data['longitude'] = $line[6]; // long |
|
773 | - $data['verticalrate'] = ''; // vertical rate |
|
774 | - $data['squawk'] = ''; // squawk |
|
775 | - $data['emergency'] = ''; // emergency |
|
776 | - $data['waypoints'] = $line[30]; |
|
772 | + $data['longitude'] = $line[6]; // long |
|
773 | + $data['verticalrate'] = ''; // vertical rate |
|
774 | + $data['squawk'] = ''; // squawk |
|
775 | + $data['emergency'] = ''; // emergency |
|
776 | + $data['waypoints'] = $line[30]; |
|
777 | 777 | $data['datetime'] = date('Y-m-d H:i:s'); |
778 | 778 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
779 | 779 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
780 | - $data['departure_airport_icao'] = $line[11]; |
|
781 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
782 | - $data['arrival_airport_icao'] = $line[13]; |
|
780 | + $data['departure_airport_icao'] = $line[11]; |
|
781 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
782 | + $data['arrival_airport_icao'] = $line[13]; |
|
783 | 783 | $data['frequency'] = $line[4]; |
784 | 784 | $data['type'] = $line[18]; |
785 | 785 | $data['range'] = $line[19]; |
786 | 786 | if (isset($line[35])) $data['info'] = $line[35]; |
787 | - $data['id_source'] = $id_source; |
|
788 | - //$data['arrival_airport_time'] = ; |
|
789 | - if ($line[9] != '') { |
|
790 | - $aircraft_data = explode('/',$line[9]); |
|
791 | - if (isset($aircraft_data[1])) { |
|
792 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
793 | - } |
|
794 | - } |
|
795 | - /* |
|
787 | + $data['id_source'] = $id_source; |
|
788 | + //$data['arrival_airport_time'] = ; |
|
789 | + if ($line[9] != '') { |
|
790 | + $aircraft_data = explode('/',$line[9]); |
|
791 | + if (isset($aircraft_data[1])) { |
|
792 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
793 | + } |
|
794 | + } |
|
795 | + /* |
|
796 | 796 | if ($value === 'whazzup') $data['format_source'] = 'whazzup'; |
797 | 797 | elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
798 | 798 | */ |
799 | - $data['format_source'] = $value['format']; |
|
799 | + $data['format_source'] = $value['format']; |
|
800 | 800 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
801 | 801 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
802 | - if ($line[3] === 'PILOT') $SI->add($data); |
|
802 | + if ($line[3] === 'PILOT') $SI->add($data); |
|
803 | 803 | elseif ($line[3] === 'ATC') { |
804 | 804 | //print_r($data); |
805 | 805 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -820,21 +820,21 @@ discard block |
||
820 | 820 | else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']); |
821 | 821 | } |
822 | 822 | } |
823 | - unset($data); |
|
824 | - } |
|
825 | - } |
|
826 | - } |
|
827 | - //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
828 | - //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
829 | - $last_exec[$id]['last'] = time(); |
|
830 | - } elseif ($value['format'] === 'airwhere' && |
|
831 | - ( |
|
832 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
833 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
834 | - ) |
|
835 | - ) { |
|
836 | - $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
837 | - if ($buffer != '') { |
|
823 | + unset($data); |
|
824 | + } |
|
825 | + } |
|
826 | + } |
|
827 | + //if ($value === 'whazzup') $last_exec['whazzup'] = time(); |
|
828 | + //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
829 | + $last_exec[$id]['last'] = time(); |
|
830 | + } elseif ($value['format'] === 'airwhere' && |
|
831 | + ( |
|
832 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
833 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
834 | + ) |
|
835 | + ) { |
|
836 | + $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); |
|
837 | + if ($buffer != '') { |
|
838 | 838 | $all_data = simplexml_load_string($buffer); |
839 | 839 | foreach($all_data->children() as $childdata) { |
840 | 840 | $data = array(); |
@@ -856,10 +856,10 @@ discard block |
||
856 | 856 | $SI->add($data); |
857 | 857 | unset($data); |
858 | 858 | } |
859 | - } |
|
860 | - $Source->deleteOldLocationByType('gs'); |
|
861 | - $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
862 | - if ($buffer != '') { |
|
859 | + } |
|
860 | + $Source->deleteOldLocationByType('gs'); |
|
861 | + $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); |
|
862 | + if ($buffer != '') { |
|
863 | 863 | $all_data = simplexml_load_string($buffer); |
864 | 864 | foreach($all_data->children() as $childdata) { |
865 | 865 | $data = array(); |
@@ -877,8 +877,8 @@ discard block |
||
877 | 877 | } |
878 | 878 | unset($data); |
879 | 879 | } |
880 | - } |
|
881 | - $last_exec[$id]['last'] = time(); |
|
880 | + } |
|
881 | + $last_exec[$id]['last'] = time(); |
|
882 | 882 | /* |
883 | 883 | } if ($value['format'] === 'aircraftlistjson') { |
884 | 884 | print_r($globalSources); |
@@ -886,17 +886,17 @@ discard block |
||
886 | 886 | echo $globalMinFetch; |
887 | 887 | */ |
888 | 888 | } elseif ($value['format'] === 'aircraftlistjson' && |
889 | - ( |
|
889 | + ( |
|
890 | 890 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
891 | 891 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
892 | - ) |
|
892 | + ) |
|
893 | 893 | ) { |
894 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
895 | - if ($buffer != '') { |
|
896 | - $all_data = json_decode($buffer,true); |
|
894 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
895 | + if ($buffer != '') { |
|
896 | + $all_data = json_decode($buffer,true); |
|
897 | 897 | if (isset($all_data['acList'])) { |
898 | - $reset = 0; |
|
899 | - foreach ($all_data['acList'] as $line) { |
|
898 | + $reset = 0; |
|
899 | + foreach ($all_data['acList'] as $line) { |
|
900 | 900 | $data = array(); |
901 | 901 | $data['hex'] = $line['Icao']; // hex |
902 | 902 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
@@ -919,10 +919,10 @@ discard block |
||
919 | 919 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
920 | 920 | if (isset($data['latitude'])) $SI->add($data); |
921 | 921 | unset($data); |
922 | - } |
|
922 | + } |
|
923 | 923 | } elseif (is_array($all_data)) { |
924 | - $reset = 0; |
|
925 | - foreach ($all_data as $line) { |
|
924 | + $reset = 0; |
|
925 | + foreach ($all_data as $line) { |
|
926 | 926 | $data = array(); |
927 | 927 | $data['hex'] = $line['hex']; // hex |
928 | 928 | $data['ident'] = $line['flight']; // ident |
@@ -942,291 +942,291 @@ discard block |
||
942 | 942 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
943 | 943 | $SI->add($data); |
944 | 944 | unset($data); |
945 | - } |
|
945 | + } |
|
946 | 946 | } |
947 | - } elseif ($globalDebug) echo 'No data'."\n"; |
|
948 | - //$last_exec['aircraftlistjson'] = time(); |
|
949 | - $last_exec[$id]['last'] = time(); |
|
950 | - //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
951 | - } elseif ($value['format'] === 'planeupdatefaa' && |
|
952 | - ( |
|
953 | - (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
954 | - (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
955 | - ) |
|
956 | - ) { |
|
957 | - $buffer = $Common->getData($value['host']); |
|
958 | - $all_data = json_decode($buffer,true); |
|
959 | - if (isset($all_data['planes'])) { |
|
947 | + } elseif ($globalDebug) echo 'No data'."\n"; |
|
948 | + //$last_exec['aircraftlistjson'] = time(); |
|
949 | + $last_exec[$id]['last'] = time(); |
|
950 | + //} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
951 | + } elseif ($value['format'] === 'planeupdatefaa' && |
|
952 | + ( |
|
953 | + (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
|
954 | + (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
|
955 | + ) |
|
956 | + ) { |
|
957 | + $buffer = $Common->getData($value['host']); |
|
958 | + $all_data = json_decode($buffer,true); |
|
959 | + if (isset($all_data['planes'])) { |
|
960 | 960 | $reset = 0; |
961 | 961 | foreach ($all_data['planes'] as $key => $line) { |
962 | - $data = array(); |
|
963 | - $data['hex'] = $key; // hex |
|
964 | - $data['ident'] = $line[3]; // ident |
|
965 | - $data['altitude'] = $line[6]; // altitude |
|
966 | - $data['speed'] = $line[8]; // speed |
|
967 | - $data['heading'] = $line[7]; // heading |
|
968 | - $data['latitude'] = $line[4]; // lat |
|
969 | - $data['longitude'] = $line[5]; // long |
|
970 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
971 | - $data['squawk'] = $line[10]; // squawk |
|
972 | - $data['emergency'] = ''; // emergency |
|
973 | - $data['registration'] = $line[2]; |
|
974 | - $data['aircraft_icao'] = $line[0]; |
|
975 | - $deparr = explode('-',$line[1]); |
|
976 | - if (count($deparr) === 2) { |
|
962 | + $data = array(); |
|
963 | + $data['hex'] = $key; // hex |
|
964 | + $data['ident'] = $line[3]; // ident |
|
965 | + $data['altitude'] = $line[6]; // altitude |
|
966 | + $data['speed'] = $line[8]; // speed |
|
967 | + $data['heading'] = $line[7]; // heading |
|
968 | + $data['latitude'] = $line[4]; // lat |
|
969 | + $data['longitude'] = $line[5]; // long |
|
970 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
971 | + $data['squawk'] = $line[10]; // squawk |
|
972 | + $data['emergency'] = ''; // emergency |
|
973 | + $data['registration'] = $line[2]; |
|
974 | + $data['aircraft_icao'] = $line[0]; |
|
975 | + $deparr = explode('-',$line[1]); |
|
976 | + if (count($deparr) === 2) { |
|
977 | 977 | $data['departure_airport_icao'] = $deparr[0]; |
978 | 978 | $data['arrival_airport_icao'] = $deparr[1]; |
979 | - } |
|
980 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
981 | - $data['format_source'] = 'planeupdatefaa'; |
|
982 | - $data['id_source'] = $id_source; |
|
983 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
984 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
985 | - $SI->add($data); |
|
986 | - unset($data); |
|
979 | + } |
|
980 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
981 | + $data['format_source'] = 'planeupdatefaa'; |
|
982 | + $data['id_source'] = $id_source; |
|
983 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
984 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
985 | + $SI->add($data); |
|
986 | + unset($data); |
|
987 | 987 | } |
988 | - } |
|
989 | - //$last_exec['planeupdatefaa'] = time(); |
|
990 | - $last_exec[$id]['last'] = time(); |
|
988 | + } |
|
989 | + //$last_exec['planeupdatefaa'] = time(); |
|
990 | + $last_exec[$id]['last'] = time(); |
|
991 | 991 | } elseif ($value['format'] === 'opensky' && |
992 | - ( |
|
992 | + ( |
|
993 | 993 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
994 | 994 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
995 | - ) |
|
995 | + ) |
|
996 | 996 | ) { |
997 | - $buffer = $Common->getData($value['host']); |
|
998 | - $all_data = json_decode($buffer,true); |
|
999 | - if (isset($all_data['states'])) { |
|
997 | + $buffer = $Common->getData($value['host']); |
|
998 | + $all_data = json_decode($buffer,true); |
|
999 | + if (isset($all_data['states'])) { |
|
1000 | 1000 | $reset = 0; |
1001 | 1001 | foreach ($all_data['states'] as $key => $line) { |
1002 | - $data = array(); |
|
1003 | - $data['hex'] = $line[0]; // hex |
|
1004 | - $data['ident'] = trim($line[1]); // ident |
|
1005 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1006 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
1007 | - $data['heading'] = round($line[10]); // heading |
|
1008 | - $data['latitude'] = $line[6]; // lat |
|
1009 | - $data['longitude'] = $line[5]; // long |
|
1010 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
1011 | - //$data['squawk'] = $line[10]; // squawk |
|
1012 | - //$data['emergency'] = ''; // emergency |
|
1013 | - //$data['registration'] = $line[2]; |
|
1014 | - //$data['aircraft_icao'] = $line[0]; |
|
1015 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1016 | - $data['format_source'] = 'opensky'; |
|
1017 | - $data['id_source'] = $id_source; |
|
1018 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1019 | - $SI->add($data); |
|
1020 | - unset($data); |
|
1002 | + $data = array(); |
|
1003 | + $data['hex'] = $line[0]; // hex |
|
1004 | + $data['ident'] = trim($line[1]); // ident |
|
1005 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
1006 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
1007 | + $data['heading'] = round($line[10]); // heading |
|
1008 | + $data['latitude'] = $line[6]; // lat |
|
1009 | + $data['longitude'] = $line[5]; // long |
|
1010 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
1011 | + //$data['squawk'] = $line[10]; // squawk |
|
1012 | + //$data['emergency'] = ''; // emergency |
|
1013 | + //$data['registration'] = $line[2]; |
|
1014 | + //$data['aircraft_icao'] = $line[0]; |
|
1015 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
1016 | + $data['format_source'] = 'opensky'; |
|
1017 | + $data['id_source'] = $id_source; |
|
1018 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1019 | + $SI->add($data); |
|
1020 | + unset($data); |
|
1021 | + } |
|
1021 | 1022 | } |
1022 | - } |
|
1023 | - //$last_exec['planeupdatefaa'] = time(); |
|
1024 | - $last_exec[$id]['last'] = time(); |
|
1023 | + //$last_exec['planeupdatefaa'] = time(); |
|
1024 | + $last_exec[$id]['last'] = time(); |
|
1025 | 1025 | } elseif ($value['format'] === 'aircraftjson' && |
1026 | - ( |
|
1026 | + ( |
|
1027 | 1027 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1028 | 1028 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1029 | - ) |
|
1029 | + ) |
|
1030 | 1030 | ) { |
1031 | - $buffer = $Common->getData($value['host']); |
|
1032 | - $all_data = json_decode($buffer,true); |
|
1033 | - if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1031 | + $buffer = $Common->getData($value['host']); |
|
1032 | + $all_data = json_decode($buffer,true); |
|
1033 | + if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) { |
|
1034 | 1034 | $reset = 0; |
1035 | 1035 | foreach ($all_data['aircraft'] as $key => $line) { |
1036 | - $data = array(); |
|
1037 | - // add support for ground vehicule with ~ in front of hex |
|
1038 | - if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1039 | - if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1040 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1041 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1042 | - if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1043 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1044 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1045 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1046 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1047 | - //$data['emergency'] = ''; // emergency |
|
1048 | - //$data['registration'] = $line[2]; |
|
1049 | - //$data['aircraft_icao'] = $line[0]; |
|
1050 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1051 | - $data['format_source'] = 'aircraftjson'; |
|
1052 | - $data['id_source'] = $id_source; |
|
1053 | - if (isset($value['name']) && $value['name'] != '') { |
|
1054 | - if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1055 | - else $data['source_name'] = $value['name']; |
|
1056 | - } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1057 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1058 | - $SI->add($data); |
|
1059 | - unset($data); |
|
1036 | + $data = array(); |
|
1037 | + // add support for ground vehicule with ~ in front of hex |
|
1038 | + if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex |
|
1039 | + if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident |
|
1040 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1041 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1042 | + if (isset($line['track'])) $data['heading'] = $line['track']; // heading |
|
1043 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1044 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1045 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1046 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1047 | + //$data['emergency'] = ''; // emergency |
|
1048 | + //$data['registration'] = $line[2]; |
|
1049 | + //$data['aircraft_icao'] = $line[0]; |
|
1050 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1051 | + $data['format_source'] = 'aircraftjson'; |
|
1052 | + $data['id_source'] = $id_source; |
|
1053 | + if (isset($value['name']) && $value['name'] != '') { |
|
1054 | + if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT'; |
|
1055 | + else $data['source_name'] = $value['name']; |
|
1056 | + } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT'; |
|
1057 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1058 | + $SI->add($data); |
|
1059 | + unset($data); |
|
1060 | 1060 | } |
1061 | - } |
|
1062 | - //$last_exec['planeupdatefaa'] = time(); |
|
1063 | - $last_exec[$id]['last'] = time(); |
|
1061 | + } |
|
1062 | + //$last_exec['planeupdatefaa'] = time(); |
|
1063 | + $last_exec[$id]['last'] = time(); |
|
1064 | 1064 | } elseif ($value['format'] === 'planefinderclient' && |
1065 | - ( |
|
1065 | + ( |
|
1066 | 1066 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1067 | 1067 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1068 | - ) |
|
1068 | + ) |
|
1069 | 1069 | ) { |
1070 | - $buffer = $Common->getData($value['host']); |
|
1071 | - $all_data = json_decode($buffer,true); |
|
1072 | - if (isset($all_data['aircraft'])) { |
|
1070 | + $buffer = $Common->getData($value['host']); |
|
1071 | + $all_data = json_decode($buffer,true); |
|
1072 | + if (isset($all_data['aircraft'])) { |
|
1073 | 1073 | $reset = 0; |
1074 | 1074 | foreach ($all_data['aircraft'] as $key => $line) { |
1075 | - $data = array(); |
|
1076 | - $data['hex'] = $key; // hex |
|
1077 | - if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1078 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1079 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1080 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1081 | - if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1082 | - if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1083 | - if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1084 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1085 | - //$data['emergency'] = ''; // emergency |
|
1086 | - if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1087 | - if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1088 | - $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1089 | - $data['format_source'] = 'planefinderclient'; |
|
1090 | - $data['id_source'] = $id_source; |
|
1091 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1092 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1093 | - $SI->add($data); |
|
1094 | - unset($data); |
|
1075 | + $data = array(); |
|
1076 | + $data['hex'] = $key; // hex |
|
1077 | + if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident |
|
1078 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude |
|
1079 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed |
|
1080 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1081 | + if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat |
|
1082 | + if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long |
|
1083 | + if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate |
|
1084 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk |
|
1085 | + //$data['emergency'] = ''; // emergency |
|
1086 | + if (isset($line['reg'])) $data['registration'] = $line['reg']; |
|
1087 | + if (isset($line['type'])) $data['aircraft_icao'] = $line['type']; |
|
1088 | + $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']); |
|
1089 | + $data['format_source'] = 'planefinderclient'; |
|
1090 | + $data['id_source'] = $id_source; |
|
1091 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1092 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1093 | + $SI->add($data); |
|
1094 | + unset($data); |
|
1095 | 1095 | } |
1096 | - } |
|
1097 | - $last_exec[$id]['last'] = time(); |
|
1096 | + } |
|
1097 | + $last_exec[$id]['last'] = time(); |
|
1098 | 1098 | //} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
1099 | 1099 | } elseif ($value['format'] === 'fr24json' && |
1100 | - ( |
|
1100 | + ( |
|
1101 | 1101 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1102 | 1102 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1103 | - ) |
|
1103 | + ) |
|
1104 | 1104 | ) { |
1105 | - //$buffer = $Common->getData($hosts[$id]); |
|
1106 | - $buffer = $Common->getData($value['host']); |
|
1107 | - $all_data = json_decode($buffer,true); |
|
1108 | - if (!empty($all_data)) $reset = 0; |
|
1109 | - foreach ($all_data as $key => $line) { |
|
1105 | + //$buffer = $Common->getData($hosts[$id]); |
|
1106 | + $buffer = $Common->getData($value['host']); |
|
1107 | + $all_data = json_decode($buffer,true); |
|
1108 | + if (!empty($all_data)) $reset = 0; |
|
1109 | + foreach ($all_data as $key => $line) { |
|
1110 | 1110 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
1111 | - $data = array(); |
|
1112 | - $data['hex'] = $line[0]; |
|
1113 | - $data['ident'] = $line[16]; //$line[13] |
|
1114 | - $data['altitude'] = $line[4]; // altitude |
|
1115 | - $data['speed'] = $line[5]; // speed |
|
1116 | - $data['heading'] = $line[3]; // heading |
|
1117 | - $data['latitude'] = $line[1]; // lat |
|
1118 | - $data['longitude'] = $line[2]; // long |
|
1119 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
1120 | - $data['squawk'] = $line[6]; // squawk |
|
1121 | - $data['aircraft_icao'] = $line[8]; |
|
1122 | - $data['registration'] = $line[9]; |
|
1123 | - $data['departure_airport_iata'] = $line[11]; |
|
1124 | - $data['arrival_airport_iata'] = $line[12]; |
|
1125 | - $data['emergency'] = ''; // emergency |
|
1126 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1127 | - $data['format_source'] = 'fr24json'; |
|
1128 | - $data['id_source'] = $id_source; |
|
1129 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1130 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1131 | - $SI->add($data); |
|
1132 | - unset($data); |
|
1111 | + $data = array(); |
|
1112 | + $data['hex'] = $line[0]; |
|
1113 | + $data['ident'] = $line[16]; //$line[13] |
|
1114 | + $data['altitude'] = $line[4]; // altitude |
|
1115 | + $data['speed'] = $line[5]; // speed |
|
1116 | + $data['heading'] = $line[3]; // heading |
|
1117 | + $data['latitude'] = $line[1]; // lat |
|
1118 | + $data['longitude'] = $line[2]; // long |
|
1119 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
1120 | + $data['squawk'] = $line[6]; // squawk |
|
1121 | + $data['aircraft_icao'] = $line[8]; |
|
1122 | + $data['registration'] = $line[9]; |
|
1123 | + $data['departure_airport_iata'] = $line[11]; |
|
1124 | + $data['arrival_airport_iata'] = $line[12]; |
|
1125 | + $data['emergency'] = ''; // emergency |
|
1126 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
1127 | + $data['format_source'] = 'fr24json'; |
|
1128 | + $data['id_source'] = $id_source; |
|
1129 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1130 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1131 | + $SI->add($data); |
|
1132 | + unset($data); |
|
1133 | + } |
|
1133 | 1134 | } |
1134 | - } |
|
1135 | - //$last_exec['fr24json'] = time(); |
|
1136 | - $last_exec[$id]['last'] = time(); |
|
1135 | + //$last_exec['fr24json'] = time(); |
|
1136 | + $last_exec[$id]['last'] = time(); |
|
1137 | 1137 | //} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
1138 | 1138 | } elseif ($value['format'] === 'radarvirtueljson' && |
1139 | - ( |
|
1139 | + ( |
|
1140 | 1140 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1141 | 1141 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1142 | - ) |
|
1142 | + ) |
|
1143 | 1143 | ) { |
1144 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1145 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1146 | - //echo $buffer; |
|
1147 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1148 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1149 | - $all_data = json_decode($buffer,true); |
|
1150 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
1144 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
1145 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
1146 | + //echo $buffer; |
|
1147 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
1148 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
1149 | + $all_data = json_decode($buffer,true); |
|
1150 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
1151 | 1151 | die(json_last_error_msg()); |
1152 | - } |
|
1153 | - if (isset($all_data['mrkrs'])) { |
|
1152 | + } |
|
1153 | + if (isset($all_data['mrkrs'])) { |
|
1154 | 1154 | $reset = 0; |
1155 | 1155 | foreach ($all_data['mrkrs'] as $key => $line) { |
1156 | - if (isset($line['inf'])) { |
|
1156 | + if (isset($line['inf'])) { |
|
1157 | 1157 | $data = array(); |
1158 | 1158 | $data['hex'] = $line['inf']['ia']; |
1159 | 1159 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
1160 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1161 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1162 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1163 | - $data['latitude'] = $line['pt'][0]; // lat |
|
1164 | - $data['longitude'] = $line['pt'][1]; // long |
|
1165 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1166 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1167 | - //$data['aircraft_icao'] = $line[8]; |
|
1168 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1160 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
1161 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
1162 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
1163 | + $data['latitude'] = $line['pt'][0]; // lat |
|
1164 | + $data['longitude'] = $line['pt'][1]; // long |
|
1165 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
1166 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
1167 | + //$data['aircraft_icao'] = $line[8]; |
|
1168 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
1169 | 1169 | //$data['departure_airport_iata'] = $line[11]; |
1170 | 1170 | //$data['arrival_airport_iata'] = $line[12]; |
1171 | - //$data['emergency'] = ''; // emergency |
|
1171 | + //$data['emergency'] = ''; // emergency |
|
1172 | 1172 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
1173 | - $data['format_source'] = 'radarvirtueljson'; |
|
1174 | - $data['id_source'] = $id_source; |
|
1173 | + $data['format_source'] = 'radarvirtueljson'; |
|
1174 | + $data['id_source'] = $id_source; |
|
1175 | 1175 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
1176 | 1176 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1177 | 1177 | $SI->add($data); |
1178 | 1178 | unset($data); |
1179 | - } |
|
1179 | + } |
|
1180 | 1180 | } |
1181 | - } |
|
1182 | - //$last_exec['radarvirtueljson'] = time(); |
|
1183 | - $last_exec[$id]['last'] = time(); |
|
1181 | + } |
|
1182 | + //$last_exec['radarvirtueljson'] = time(); |
|
1183 | + $last_exec[$id]['last'] = time(); |
|
1184 | 1184 | //} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
1185 | 1185 | } elseif ($value['format'] === 'pirepsjson' && |
1186 | - ( |
|
1186 | + ( |
|
1187 | 1187 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1188 | 1188 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1189 | - ) |
|
1189 | + ) |
|
1190 | 1190 | ) { |
1191 | - //$buffer = $Common->getData($hosts[$id]); |
|
1192 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
1193 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
1191 | + //$buffer = $Common->getData($hosts[$id]); |
|
1192 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
1193 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
1194 | 1194 | |
1195 | - if (isset($all_data['pireps'])) { |
|
1195 | + if (isset($all_data['pireps'])) { |
|
1196 | 1196 | $reset = 0; |
1197 | - foreach ($all_data['pireps'] as $line) { |
|
1198 | - $data = array(); |
|
1199 | - $data['id'] = $line['id']; |
|
1200 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1201 | - $data['ident'] = $line['callsign']; // ident |
|
1202 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1203 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1204 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1205 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1206 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1207 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1208 | - $data['latitude'] = $line['lat']; // lat |
|
1209 | - $data['longitude'] = $line['lon']; // long |
|
1210 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1211 | - //$data['squawk'] = $line['squawk']; // squawk |
|
1212 | - //$data['emergency'] = ''; // emergency |
|
1213 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1214 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1215 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1216 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
1217 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1218 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1219 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1220 | - else $data['info'] = ''; |
|
1221 | - $data['format_source'] = 'pireps'; |
|
1222 | - $data['id_source'] = $id_source; |
|
1223 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1224 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1225 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1226 | - if ($line['icon'] === 'plane') { |
|
1197 | + foreach ($all_data['pireps'] as $line) { |
|
1198 | + $data = array(); |
|
1199 | + $data['id'] = $line['id']; |
|
1200 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
1201 | + $data['ident'] = $line['callsign']; // ident |
|
1202 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
1203 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
1204 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
1205 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
1206 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
1207 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1208 | + $data['latitude'] = $line['lat']; // lat |
|
1209 | + $data['longitude'] = $line['lon']; // long |
|
1210 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
1211 | + //$data['squawk'] = $line['squawk']; // squawk |
|
1212 | + //$data['emergency'] = ''; // emergency |
|
1213 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
1214 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
1215 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
1216 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
1217 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
1218 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
1219 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
1220 | + else $data['info'] = ''; |
|
1221 | + $data['format_source'] = 'pireps'; |
|
1222 | + $data['id_source'] = $id_source; |
|
1223 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1224 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1225 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1226 | + if ($line['icon'] === 'plane') { |
|
1227 | 1227 | $SI->add($data); |
1228 | - // print_r($data); |
|
1229 | - } elseif ($line['icon'] === 'ct') { |
|
1228 | + // print_r($data); |
|
1229 | + } elseif ($line['icon'] === 'ct') { |
|
1230 | 1230 | $data['info'] = str_replace('^§','<br />',$data['info']); |
1231 | 1231 | $data['info'] = str_replace('&sect;','',$data['info']); |
1232 | 1232 | $typec = substr($data['ident'],-3); |
@@ -1241,209 +1241,209 @@ discard block |
||
1241 | 1241 | elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre'; |
1242 | 1242 | else $data['type'] = 'Observer'; |
1243 | 1243 | if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']); |
1244 | - } |
|
1245 | - unset($data); |
|
1244 | + } |
|
1245 | + unset($data); |
|
1246 | 1246 | } |
1247 | - } |
|
1248 | - //$last_exec['pirepsjson'] = time(); |
|
1249 | - $last_exec[$id]['last'] = time(); |
|
1247 | + } |
|
1248 | + //$last_exec['pirepsjson'] = time(); |
|
1249 | + $last_exec[$id]['last'] = time(); |
|
1250 | 1250 | //} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
1251 | 1251 | } elseif ($value['format'] === 'phpvmacars' && |
1252 | - ( |
|
1252 | + ( |
|
1253 | 1253 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1254 | 1254 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1255 | - ) |
|
1255 | + ) |
|
1256 | 1256 | ) { |
1257 | - //$buffer = $Common->getData($hosts[$id]); |
|
1258 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1259 | - $buffer = $Common->getData($value['host']); |
|
1260 | - $all_data = json_decode($buffer,true); |
|
1261 | - if ($buffer != '' && is_array($all_data)) { |
|
1257 | + //$buffer = $Common->getData($hosts[$id]); |
|
1258 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1259 | + $buffer = $Common->getData($value['host']); |
|
1260 | + $all_data = json_decode($buffer,true); |
|
1261 | + if ($buffer != '' && is_array($all_data)) { |
|
1262 | 1262 | $reset = 0; |
1263 | 1263 | foreach ($all_data as $line) { |
1264 | - $data = array(); |
|
1265 | - //$data['id'] = $line['id']; // id not usable |
|
1266 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1267 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1268 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1269 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1270 | - $data['ident'] = $line['flightnum']; // ident |
|
1271 | - $data['altitude'] = $line['alt']; // altitude |
|
1272 | - $data['speed'] = $line['gs']; // speed |
|
1273 | - $data['heading'] = $line['heading']; // heading |
|
1274 | - $data['latitude'] = $line['lat']; // lat |
|
1275 | - $data['longitude'] = $line['lng']; // long |
|
1276 | - $data['verticalrate'] = ''; // verticale rate |
|
1277 | - $data['squawk'] = ''; // squawk |
|
1278 | - $data['emergency'] = ''; // emergency |
|
1279 | - //$data['datetime'] = $line['lastupdate']; |
|
1280 | - //$data['last_update'] = $line['lastupdate']; |
|
1281 | - if (isset($value['timezone'])) { |
|
1282 | - $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1283 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1284 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1285 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1286 | - $data['departure_airport_icao'] = $line['depicao']; |
|
1287 | - $data['departure_airport_time'] = $line['deptime']; |
|
1288 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
1289 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
1290 | - if (isset($line['registration'])) { |
|
1291 | - $data['registration'] = $line['registration']; |
|
1292 | - //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1293 | - } else $data['registration'] = $line['aircraft']; |
|
1294 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1295 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1296 | - if (isset($line['aircraftname'])) { |
|
1264 | + $data = array(); |
|
1265 | + //$data['id'] = $line['id']; // id not usable |
|
1266 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
1267 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1268 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
1269 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
1270 | + $data['ident'] = $line['flightnum']; // ident |
|
1271 | + $data['altitude'] = $line['alt']; // altitude |
|
1272 | + $data['speed'] = $line['gs']; // speed |
|
1273 | + $data['heading'] = $line['heading']; // heading |
|
1274 | + $data['latitude'] = $line['lat']; // lat |
|
1275 | + $data['longitude'] = $line['lng']; // long |
|
1276 | + $data['verticalrate'] = ''; // verticale rate |
|
1277 | + $data['squawk'] = ''; // squawk |
|
1278 | + $data['emergency'] = ''; // emergency |
|
1279 | + //$data['datetime'] = $line['lastupdate']; |
|
1280 | + //$data['last_update'] = $line['lastupdate']; |
|
1281 | + if (isset($value['timezone'])) { |
|
1282 | + $datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone'])); |
|
1283 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1284 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1285 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1286 | + $data['departure_airport_icao'] = $line['depicao']; |
|
1287 | + $data['departure_airport_time'] = $line['deptime']; |
|
1288 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
1289 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
1290 | + if (isset($line['registration'])) { |
|
1291 | + $data['registration'] = $line['registration']; |
|
1292 | + //if (isset($line['aircraft'])) $data['id'] = $line['aircraft']; |
|
1293 | + } else $data['registration'] = $line['aircraft']; |
|
1294 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1295 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1296 | + if (isset($line['aircraftname'])) { |
|
1297 | 1297 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
1298 | 1298 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
1299 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
1300 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1301 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1302 | - else { |
|
1303 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
1304 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1305 | - else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1306 | - } |
|
1307 | - } |
|
1308 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1309 | - $data['id_source'] = $id_source; |
|
1310 | - $data['format_source'] = 'phpvmacars'; |
|
1311 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1312 | - $SI->add($data); |
|
1313 | - unset($data); |
|
1299 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
1300 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; |
|
1301 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; |
|
1302 | + else { |
|
1303 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
1304 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); |
|
1305 | + else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); |
|
1306 | + } |
|
1307 | + } |
|
1308 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
1309 | + $data['id_source'] = $id_source; |
|
1310 | + $data['format_source'] = 'phpvmacars'; |
|
1311 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1312 | + $SI->add($data); |
|
1313 | + unset($data); |
|
1314 | 1314 | } |
1315 | 1315 | if ($globalDebug) echo 'No more data...'."\n"; |
1316 | 1316 | unset($buffer); |
1317 | 1317 | unset($all_data); |
1318 | - } |
|
1319 | - //$last_exec['phpvmacars'] = time(); |
|
1320 | - $last_exec[$id]['last'] = time(); |
|
1318 | + } |
|
1319 | + //$last_exec['phpvmacars'] = time(); |
|
1320 | + $last_exec[$id]['last'] = time(); |
|
1321 | 1321 | } elseif ($value['format'] === 'vaos' && |
1322 | - ( |
|
1322 | + ( |
|
1323 | 1323 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1324 | 1324 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1325 | - ) |
|
1325 | + ) |
|
1326 | 1326 | ) { |
1327 | - //$buffer = $Common->getData($hosts[$id]); |
|
1328 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1329 | - $buffer = $Common->getData($value['host']); |
|
1330 | - $all_data = json_decode($buffer,true); |
|
1331 | - if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1327 | + //$buffer = $Common->getData($hosts[$id]); |
|
1328 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1329 | + $buffer = $Common->getData($value['host']); |
|
1330 | + $all_data = json_decode($buffer,true); |
|
1331 | + if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) { |
|
1332 | 1332 | $reset = 0; |
1333 | 1333 | foreach ($all_data['ACARSData'] as $line) { |
1334 | - //print_r($line); |
|
1335 | - $data = array(); |
|
1336 | - //$data['id'] = $line['id']; // id not usable |
|
1337 | - $data['id'] = $line['id']; |
|
1338 | - //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1339 | - if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1340 | - if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1341 | - $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1342 | - if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1343 | - $data['altitude'] = $line['altitude']; // altitude |
|
1344 | - $data['speed'] = $line['groundspeed']; // speed |
|
1345 | - $data['heading'] = $line['heading']; // heading |
|
1346 | - $data['latitude'] = $line['lat']; // lat |
|
1347 | - $data['longitude'] = $line['lon']; // long |
|
1348 | - //$data['verticalrate'] = ''; // verticale rate |
|
1349 | - //$data['squawk'] = ''; // squawk |
|
1350 | - //$data['emergency'] = ''; // emergency |
|
1351 | - if (isset($value['timezone'])) { |
|
1352 | - $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1353 | - $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1354 | - $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1355 | - } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1334 | + //print_r($line); |
|
1335 | + $data = array(); |
|
1336 | + //$data['id'] = $line['id']; // id not usable |
|
1337 | + $data['id'] = $line['id']; |
|
1338 | + //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1339 | + if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username']; |
|
1340 | + if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id']; |
|
1341 | + $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident |
|
1342 | + if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident']; |
|
1343 | + $data['altitude'] = $line['altitude']; // altitude |
|
1344 | + $data['speed'] = $line['groundspeed']; // speed |
|
1345 | + $data['heading'] = $line['heading']; // heading |
|
1346 | + $data['latitude'] = $line['lat']; // lat |
|
1347 | + $data['longitude'] = $line['lon']; // long |
|
1348 | + //$data['verticalrate'] = ''; // verticale rate |
|
1349 | + //$data['squawk'] = ''; // squawk |
|
1350 | + //$data['emergency'] = ''; // emergency |
|
1351 | + if (isset($value['timezone'])) { |
|
1352 | + $datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone'])); |
|
1353 | + $datetime->setTimeZone(new DateTimeZone('UTC')); |
|
1354 | + $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
|
1355 | + } else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1356 | 1356 | |
1357 | - $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1358 | - $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1359 | - $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1360 | - $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1361 | - $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1357 | + $data['departure_airport_icao'] = $line['bid']['depapt']['icao']; |
|
1358 | + $data['departure_airport_time'] = $line['bid']['deptime']; |
|
1359 | + $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao']; |
|
1360 | + $data['arrival_airport_time'] = $line['bid']['arrtime']; |
|
1361 | + $data['registration'] = $line['bid']['aircraft']['registration']; |
|
1362 | 1362 | |
1363 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1364 | - if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1365 | - $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1363 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1364 | + if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route |
|
1365 | + $data['aircraft_icao'] = $line['bid']['aircraft']['icao']; |
|
1366 | 1366 | |
1367 | - $data['id_source'] = $id_source; |
|
1368 | - $data['format_source'] = 'vaos'; |
|
1369 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1370 | - $SI->add($data); |
|
1371 | - unset($data); |
|
1367 | + $data['id_source'] = $id_source; |
|
1368 | + $data['format_source'] = 'vaos'; |
|
1369 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1370 | + $SI->add($data); |
|
1371 | + unset($data); |
|
1372 | 1372 | } |
1373 | 1373 | if ($globalDebug) echo 'No more data...'."\n"; |
1374 | 1374 | unset($buffer); |
1375 | 1375 | unset($all_data); |
1376 | - } |
|
1377 | - //$last_exec['phpvmacars'] = time(); |
|
1378 | - $last_exec[$id]['last'] = time(); |
|
1376 | + } |
|
1377 | + //$last_exec['phpvmacars'] = time(); |
|
1378 | + $last_exec[$id]['last'] = time(); |
|
1379 | 1379 | } elseif ($value['format'] === 'vam' && |
1380 | - ( |
|
1380 | + ( |
|
1381 | 1381 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1382 | 1382 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1383 | - ) |
|
1383 | + ) |
|
1384 | 1384 | ) { |
1385 | - //$buffer = $Common->getData($hosts[$id]); |
|
1386 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1387 | - $buffer = $Common->getData($value['host']); |
|
1388 | - $all_data = json_decode($buffer,true); |
|
1389 | - if ($buffer != '' && is_array($all_data)) { |
|
1385 | + //$buffer = $Common->getData($hosts[$id]); |
|
1386 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1387 | + $buffer = $Common->getData($value['host']); |
|
1388 | + $all_data = json_decode($buffer,true); |
|
1389 | + if ($buffer != '' && is_array($all_data)) { |
|
1390 | 1390 | $reset = 0; |
1391 | 1391 | foreach ($all_data as $line) { |
1392 | - $data = array(); |
|
1393 | - //$data['id'] = $line['id']; // id not usable |
|
1394 | - $data['id'] = trim($line['flight_id']); |
|
1395 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1396 | - $data['pilot_name'] = $line['pilot_name']; |
|
1397 | - $data['pilot_id'] = $line['pilot_id']; |
|
1398 | - $data['ident'] = trim($line['callsign']); // ident |
|
1399 | - $data['altitude'] = $line['altitude']; // altitude |
|
1400 | - $data['speed'] = $line['gs']; // speed |
|
1401 | - $data['heading'] = $line['heading']; // heading |
|
1402 | - $data['latitude'] = $line['latitude']; // lat |
|
1403 | - $data['longitude'] = $line['longitude']; // long |
|
1404 | - $data['verticalrate'] = ''; // verticale rate |
|
1405 | - $data['squawk'] = ''; // squawk |
|
1406 | - $data['emergency'] = ''; // emergency |
|
1407 | - //$data['datetime'] = $line['lastupdate']; |
|
1408 | - $data['last_update'] = $line['last_update']; |
|
1409 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1410 | - $data['departure_airport_icao'] = $line['departure']; |
|
1411 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
1412 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
1413 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1414 | - //$data['registration'] = $line['aircraft']; |
|
1415 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1416 | - $data['aircraft_icao'] = $line['plane_type']; |
|
1417 | - $data['id_source'] = $id_source; |
|
1418 | - $data['format_source'] = 'vam'; |
|
1419 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1420 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1421 | - $SI->add($data); |
|
1422 | - unset($data); |
|
1392 | + $data = array(); |
|
1393 | + //$data['id'] = $line['id']; // id not usable |
|
1394 | + $data['id'] = trim($line['flight_id']); |
|
1395 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
1396 | + $data['pilot_name'] = $line['pilot_name']; |
|
1397 | + $data['pilot_id'] = $line['pilot_id']; |
|
1398 | + $data['ident'] = trim($line['callsign']); // ident |
|
1399 | + $data['altitude'] = $line['altitude']; // altitude |
|
1400 | + $data['speed'] = $line['gs']; // speed |
|
1401 | + $data['heading'] = $line['heading']; // heading |
|
1402 | + $data['latitude'] = $line['latitude']; // lat |
|
1403 | + $data['longitude'] = $line['longitude']; // long |
|
1404 | + $data['verticalrate'] = ''; // verticale rate |
|
1405 | + $data['squawk'] = ''; // squawk |
|
1406 | + $data['emergency'] = ''; // emergency |
|
1407 | + //$data['datetime'] = $line['lastupdate']; |
|
1408 | + $data['last_update'] = $line['last_update']; |
|
1409 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1410 | + $data['departure_airport_icao'] = $line['departure']; |
|
1411 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
1412 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
1413 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
1414 | + //$data['registration'] = $line['aircraft']; |
|
1415 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
1416 | + $data['aircraft_icao'] = $line['plane_type']; |
|
1417 | + $data['id_source'] = $id_source; |
|
1418 | + $data['format_source'] = 'vam'; |
|
1419 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1420 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
1421 | + $SI->add($data); |
|
1422 | + unset($data); |
|
1423 | 1423 | } |
1424 | 1424 | if ($globalDebug) echo 'No more data...'."\n"; |
1425 | 1425 | unset($buffer); |
1426 | 1426 | unset($all_data); |
1427 | - } |
|
1428 | - //$last_exec['phpvmacars'] = time(); |
|
1429 | - $last_exec[$id]['last'] = time(); |
|
1427 | + } |
|
1428 | + //$last_exec['phpvmacars'] = time(); |
|
1429 | + $last_exec[$id]['last'] = time(); |
|
1430 | 1430 | } elseif ($value['format'] === 'blitzortung' && |
1431 | - ( |
|
1431 | + ( |
|
1432 | 1432 | (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || |
1433 | 1433 | (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch)) |
1434 | - ) |
|
1434 | + ) |
|
1435 | 1435 | ) { |
1436 | - //$buffer = $Common->getData($hosts[$id]); |
|
1437 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
1438 | - $buffer = $Common->getData($value['host']); |
|
1439 | - $all_data = json_decode($buffer,true); |
|
1440 | - if ($buffer != '') { |
|
1436 | + //$buffer = $Common->getData($hosts[$id]); |
|
1437 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
1438 | + $buffer = $Common->getData($value['host']); |
|
1439 | + $all_data = json_decode($buffer,true); |
|
1440 | + if ($buffer != '') { |
|
1441 | 1441 | $Source->deleteLocationBySource('blitzortung'); |
1442 | 1442 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
1443 | 1443 | $buffer = explode('\n',$buffer); |
1444 | 1444 | foreach ($buffer as $buffer_line) { |
1445 | - $line = json_decode($buffer_line,true); |
|
1446 | - if (isset($line['time'])) { |
|
1445 | + $line = json_decode($buffer_line,true); |
|
1446 | + if (isset($line['time'])) { |
|
1447 | 1447 | $data = array(); |
1448 | 1448 | $data['altitude'] = $line['alt']; // altitude |
1449 | 1449 | $data['latitude'] = $line['lat']; // lat |
@@ -1455,94 +1455,94 @@ discard block |
||
1455 | 1455 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1456 | 1456 | $Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']); |
1457 | 1457 | unset($data); |
1458 | - } |
|
1458 | + } |
|
1459 | 1459 | } |
1460 | 1460 | if ($globalDebug) echo 'No more data...'."\n"; |
1461 | 1461 | unset($buffer); |
1462 | - } |
|
1463 | - $last_exec[$id]['last'] = time(); |
|
1462 | + } |
|
1463 | + $last_exec[$id]['last'] = time(); |
|
1464 | 1464 | //} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') { |
1465 | 1465 | } elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') { |
1466 | - //$last_exec[$id]['last'] = time(); |
|
1467 | - //$read = array( $sockets[$id] ); |
|
1468 | - $read = $sockets; |
|
1469 | - $write = NULL; |
|
1470 | - $e = NULL; |
|
1471 | - $n = socket_select($read, $write, $e, $timeout); |
|
1472 | - if ($e != NULL) var_dump($e); |
|
1473 | - if ($n > 0) { |
|
1466 | + //$last_exec[$id]['last'] = time(); |
|
1467 | + //$read = array( $sockets[$id] ); |
|
1468 | + $read = $sockets; |
|
1469 | + $write = NULL; |
|
1470 | + $e = NULL; |
|
1471 | + $n = socket_select($read, $write, $e, $timeout); |
|
1472 | + if ($e != NULL) var_dump($e); |
|
1473 | + if ($n > 0) { |
|
1474 | 1474 | $reset = 0; |
1475 | 1475 | foreach ($read as $nb => $r) { |
1476 | - //$value = $formats[$nb]; |
|
1477 | - $format = $globalSources[$nb]['format']; |
|
1478 | - if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1476 | + //$value = $formats[$nb]; |
|
1477 | + $format = $globalSources[$nb]['format']; |
|
1478 | + if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') { |
|
1479 | 1479 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); |
1480 | - } elseif ($format === 'vrstcp') { |
|
1480 | + } elseif ($format === 'vrstcp') { |
|
1481 | 1481 | $buffer = @socket_read($r, 6000); |
1482 | - } else { |
|
1482 | + } else { |
|
1483 | 1483 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
1484 | - } |
|
1485 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1486 | - //echo $buffer."\n"; |
|
1487 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
1488 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1489 | - $error = false; |
|
1490 | - //$SI::del(); |
|
1491 | - if ($buffer !== FALSE) { |
|
1484 | + } |
|
1485 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
1486 | + //echo $buffer."\n"; |
|
1487 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
1488 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
1489 | + $error = false; |
|
1490 | + //$SI::del(); |
|
1491 | + if ($buffer !== FALSE) { |
|
1492 | 1492 | if ($format === 'vrstcp') { |
1493 | - $buffer = explode('},{',$buffer); |
|
1493 | + $buffer = explode('},{',$buffer); |
|
1494 | 1494 | } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
1495 | - } |
|
1496 | - // SBS format is CSV format |
|
1497 | - if ($buffer !== FALSE && $buffer !== '') { |
|
1495 | + } |
|
1496 | + // SBS format is CSV format |
|
1497 | + if ($buffer !== FALSE && $buffer !== '') { |
|
1498 | 1498 | $tt[$format] = 0; |
1499 | 1499 | if ($format === 'acarssbs3') { |
1500 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1501 | - $ACARS->add(trim($buffer)); |
|
1502 | - $ACARS->deleteLiveAcarsData(); |
|
1500 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1501 | + $ACARS->add(trim($buffer)); |
|
1502 | + $ACARS->deleteLiveAcarsData(); |
|
1503 | 1503 | } elseif ($format === 'raw') { |
1504 | - // AVR format |
|
1505 | - $data = $SBS->parse($buffer); |
|
1506 | - if (is_array($data)) { |
|
1504 | + // AVR format |
|
1505 | + $data = $SBS->parse($buffer); |
|
1506 | + if (is_array($data)) { |
|
1507 | 1507 | $data['datetime'] = date('Y-m-d H:i:s'); |
1508 | 1508 | $data['format_source'] = 'raw'; |
1509 | 1509 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1510 | 1510 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
1511 | 1511 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1512 | 1512 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1513 | - } |
|
1513 | + } |
|
1514 | 1514 | } elseif ($format === 'ais') { |
1515 | - $ais_data = $AIS->parse_line(trim($buffer)); |
|
1516 | - $data = array(); |
|
1517 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1518 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1519 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1520 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1521 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1522 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1523 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1524 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1525 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1526 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1527 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1528 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1529 | - if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1530 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1531 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1532 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1515 | + $ais_data = $AIS->parse_line(trim($buffer)); |
|
1516 | + $data = array(); |
|
1517 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; |
|
1518 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9); |
|
1519 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; |
|
1520 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; |
|
1521 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; |
|
1522 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; |
|
1523 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; |
|
1524 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; |
|
1525 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; |
|
1526 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; |
|
1527 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; |
|
1528 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; |
|
1529 | + if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); |
|
1530 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1531 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1532 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1533 | 1533 | |
1534 | - if (isset($ais_data['timestamp'])) { |
|
1534 | + if (isset($ais_data['timestamp'])) { |
|
1535 | 1535 | $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); |
1536 | - } else { |
|
1536 | + } else { |
|
1537 | 1537 | $data['datetime'] = date('Y-m-d H:i:s'); |
1538 | - } |
|
1539 | - $data['format_source'] = 'aisnmea'; |
|
1540 | - $data['id_source'] = $id_source; |
|
1541 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1542 | - unset($data); |
|
1543 | - } elseif ($format === 'flightgearsp') { |
|
1544 | - //echo $buffer."\n"; |
|
1545 | - if (strlen($buffer) > 5) { |
|
1538 | + } |
|
1539 | + $data['format_source'] = 'aisnmea'; |
|
1540 | + $data['id_source'] = $id_source; |
|
1541 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data); |
|
1542 | + unset($data); |
|
1543 | + } elseif ($format === 'flightgearsp') { |
|
1544 | + //echo $buffer."\n"; |
|
1545 | + if (strlen($buffer) > 5) { |
|
1546 | 1546 | $line = explode(',',$buffer); |
1547 | 1547 | $data = array(); |
1548 | 1548 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -1559,38 +1559,38 @@ discard block |
||
1559 | 1559 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1560 | 1560 | if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
1561 | 1561 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1562 | - } |
|
1563 | - } elseif ($format === 'acars') { |
|
1564 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1565 | - $ACARS->add(trim($buffer)); |
|
1566 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1567 | - $ACARS->deleteLiveAcarsData(); |
|
1562 | + } |
|
1563 | + } elseif ($format === 'acars') { |
|
1564 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
1565 | + $ACARS->add(trim($buffer)); |
|
1566 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
1567 | + $ACARS->deleteLiveAcarsData(); |
|
1568 | 1568 | } elseif ($format === 'flightgearmp') { |
1569 | - if (substr($buffer,0,1) != '#') { |
|
1569 | + if (substr($buffer,0,1) != '#') { |
|
1570 | 1570 | $data = array(); |
1571 | 1571 | //echo $buffer."\n"; |
1572 | 1572 | $line = explode(' ',$buffer); |
1573 | 1573 | if (count($line) === 11) { |
1574 | - $userserver = explode('@',$line[0]); |
|
1575 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1576 | - $data['ident'] = $userserver[0]; |
|
1577 | - $data['registration'] = $userserver[0]; |
|
1578 | - $data['latitude'] = $line[4]; |
|
1579 | - $data['longitude'] = $line[5]; |
|
1580 | - $data['altitude'] = $line[6]; |
|
1581 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1582 | - $aircraft_type = $line[10]; |
|
1583 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1584 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1585 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1586 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1574 | + $userserver = explode('@',$line[0]); |
|
1575 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
1576 | + $data['ident'] = $userserver[0]; |
|
1577 | + $data['registration'] = $userserver[0]; |
|
1578 | + $data['latitude'] = $line[4]; |
|
1579 | + $data['longitude'] = $line[5]; |
|
1580 | + $data['altitude'] = $line[6]; |
|
1581 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1582 | + $aircraft_type = $line[10]; |
|
1583 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
1584 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
1585 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1586 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1587 | + } |
|
1587 | 1588 | } |
1588 | - } |
|
1589 | 1589 | } elseif ($format === 'beast') { |
1590 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1591 | - die; |
|
1590 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
1591 | + die; |
|
1592 | 1592 | } elseif ($format === 'vrstcp') { |
1593 | - foreach($buffer as $all_data) { |
|
1593 | + foreach($buffer as $all_data) { |
|
1594 | 1594 | $line = json_decode('{'.$all_data.'}',true); |
1595 | 1595 | $data = array(); |
1596 | 1596 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex |
@@ -1610,153 +1610,153 @@ discard block |
||
1610 | 1610 | */ |
1611 | 1611 | $data['datetime'] = date('Y-m-d H:i:s'); |
1612 | 1612 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
1613 | - $data['format_source'] = 'vrstcp'; |
|
1613 | + $data['format_source'] = 'vrstcp'; |
|
1614 | 1614 | $data['id_source'] = $id_source; |
1615 | 1615 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1616 | 1616 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
1617 | 1617 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); |
1618 | 1618 | unset($data); |
1619 | - } |
|
1619 | + } |
|
1620 | 1620 | } elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') { |
1621 | - $line = explode("\t", $buffer); |
|
1622 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
1621 | + $line = explode("\t", $buffer); |
|
1622 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
1623 | 1623 | $key = $line[$k]; |
1624 | - $lined[$key] = $line[$k+1]; |
|
1625 | - } |
|
1626 | - if (count($lined) > 3) { |
|
1627 | - $data['hex'] = $lined['hexid']; |
|
1628 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1629 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
1630 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1631 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1632 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1633 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1634 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1635 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1636 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1637 | - $data['id_source'] = $id_source; |
|
1638 | - $data['format_source'] = 'tsv'; |
|
1639 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1640 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1624 | + $lined[$key] = $line[$k+1]; |
|
1625 | + } |
|
1626 | + if (count($lined) > 3) { |
|
1627 | + $data['hex'] = $lined['hexid']; |
|
1628 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
1629 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
1630 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
1631 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
1632 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
1633 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
1634 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
1635 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
1636 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
1637 | + $data['id_source'] = $id_source; |
|
1638 | + $data['format_source'] = 'tsv'; |
|
1639 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
1640 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1641 | 1641 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1642 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1643 | - unset($lined); |
|
1644 | - unset($data); |
|
1645 | - } else $error = true; |
|
1642 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
1643 | + unset($lined); |
|
1644 | + unset($data); |
|
1645 | + } else $error = true; |
|
1646 | 1646 | } elseif ($format === 'aprs' && $use_aprs) { |
1647 | - if ($aprs_connect === 0) { |
|
1647 | + if ($aprs_connect === 0) { |
|
1648 | 1648 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
1649 | 1649 | $aprs_connect = 1; |
1650 | - } |
|
1650 | + } |
|
1651 | 1651 | |
1652 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1652 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
1653 | 1653 | $aprs_last_tx = time(); |
1654 | 1654 | $data_aprs = "# Keep alive"; |
1655 | 1655 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
1656 | - } |
|
1656 | + } |
|
1657 | 1657 | |
1658 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1659 | - //echo 'APRS data : '.$buffer."\n"; |
|
1660 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
1661 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
1662 | - //echo $buffer."\n"; |
|
1663 | - date_default_timezone_set('UTC'); |
|
1664 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1658 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
1659 | + //echo 'APRS data : '.$buffer."\n"; |
|
1660 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
1661 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
1662 | + //echo $buffer."\n"; |
|
1663 | + date_default_timezone_set('UTC'); |
|
1664 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
1665 | 1665 | $line = $APRS->parse($buffer); |
1666 | 1666 | //if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
1667 | 1667 | if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { |
1668 | - $aprs_last_tx = time(); |
|
1669 | - $data = array(); |
|
1670 | - //print_r($line); |
|
1671 | - if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1672 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1673 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1674 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1675 | - if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1676 | - if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1677 | - if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1678 | - if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1679 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1680 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1681 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1682 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1683 | - $data['latitude'] = $line['latitude']; |
|
1684 | - $data['longitude'] = $line['longitude']; |
|
1685 | - //$data['verticalrate'] = $line[16]; |
|
1686 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1687 | - //else $data['speed'] = 0; |
|
1688 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1689 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1690 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1691 | - //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1668 | + $aprs_last_tx = time(); |
|
1669 | + $data = array(); |
|
1670 | + //print_r($line); |
|
1671 | + if (isset($line['address'])) $data['hex'] = $line['address']; |
|
1672 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; |
|
1673 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; |
|
1674 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; |
|
1675 | + if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code']; |
|
1676 | + if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date']; |
|
1677 | + if (isset($line['typeid'])) $data['type_id'] = $line['typeid']; |
|
1678 | + if (isset($line['statusid'])) $data['status_id'] = $line['statusid']; |
|
1679 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
1680 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
1681 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
1682 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; |
|
1683 | + $data['latitude'] = $line['latitude']; |
|
1684 | + $data['longitude'] = $line['longitude']; |
|
1685 | + //$data['verticalrate'] = $line[16]; |
|
1686 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
1687 | + //else $data['speed'] = 0; |
|
1688 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; |
|
1689 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; |
|
1690 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; |
|
1691 | + //if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
1692 | 1692 | |
1693 | - if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1694 | - //else echo 'No heading...'."\n"; |
|
1695 | - //else $data['heading'] = 0; |
|
1696 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1697 | - //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1698 | - if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1699 | - elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1700 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1701 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1702 | - $data['id_source'] = $id_source; |
|
1703 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1704 | - else $data['format_source'] = 'aprs'; |
|
1705 | - $data['source_name'] = $line['source']; |
|
1706 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1707 | - else $data['source_type'] = 'flarm'; |
|
1708 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1709 | - $currentdate = date('Y-m-d H:i:s'); |
|
1710 | - $aprsdate = strtotime($data['datetime']); |
|
1711 | - if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1712 | - // Accept data if time <= system time + 20s |
|
1713 | - //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1714 | - if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1693 | + if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading']; |
|
1694 | + //else echo 'No heading...'."\n"; |
|
1695 | + //else $data['heading'] = 0; |
|
1696 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; |
|
1697 | + //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; |
|
1698 | + if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true; |
|
1699 | + elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false; |
|
1700 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
|
1701 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; |
|
1702 | + $data['id_source'] = $id_source; |
|
1703 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; |
|
1704 | + else $data['format_source'] = 'aprs'; |
|
1705 | + $data['source_name'] = $line['source']; |
|
1706 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; |
|
1707 | + else $data['source_type'] = 'flarm'; |
|
1708 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1709 | + $currentdate = date('Y-m-d H:i:s'); |
|
1710 | + $aprsdate = strtotime($data['datetime']); |
|
1711 | + if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL'; |
|
1712 | + // Accept data if time <= system time + 20s |
|
1713 | + //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1714 | + if (($data['source_type'] === 'modes') || isset($line['stealth']) && (!isset($data['hex']) || $data['hex'] != 'FFFFFF') && ($line['stealth'] === 0 || $line['stealth'] === '') && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
1715 | 1715 | $send = $SI->add($data); |
1716 | - } elseif ($data['source_type'] === 'ais') { |
|
1716 | + } elseif ($data['source_type'] === 'ais') { |
|
1717 | 1717 | $data['type'] = ''; |
1718 | 1718 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); |
1719 | - } elseif (isset($line['stealth'])) { |
|
1719 | + } elseif (isset($line['stealth'])) { |
|
1720 | 1720 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
1721 | 1721 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
1722 | - } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1723 | - //$line['symbol'] === 'Balloon' || |
|
1724 | - $line['symbol'] === 'Glider' || |
|
1725 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1726 | - if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1727 | - if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1728 | - $send = $SI->add($data); |
|
1729 | - } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1730 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1731 | - $line['symbol'] === 'Ship (Power Boat)')) { |
|
1732 | - $send = $MI->add($data); |
|
1733 | - } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1734 | - $line['symbol'] === 'Car' || |
|
1735 | - $line['symbol'] === 'Ambulance' || |
|
1736 | - $line['symbol'] === 'Van' || |
|
1737 | - $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1738 | - $line['symbol'] === 'Motorcycle' || |
|
1739 | - $line['symbol'] === 'Tractor' || |
|
1740 | - $line['symbol'] === 'Police' || |
|
1741 | - $line['symbol'] === 'Bike' || |
|
1742 | - $line['symbol'] === 'Jogger' || |
|
1743 | - $line['symbol'] === 'Horse' || |
|
1744 | - $line['symbol'] === 'Bus' || |
|
1745 | - $line['symbol'] === 'Jeep' || |
|
1746 | - $line['symbol'] === 'Recreational Vehicle' || |
|
1747 | - $line['symbol'] === 'Yacht (Sail)' || |
|
1748 | - $line['symbol'] === 'Ship (Power Boat)' || |
|
1749 | - $line['symbol'] === 'Firetruck' || |
|
1750 | - $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1751 | - $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1752 | - $line['symbol'] === 'SUV' || |
|
1753 | - $line['symbol'] === 'Snowmobile' || |
|
1754 | - $line['symbol'] === 'Mobile Satellite Station')) { |
|
1755 | - //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1722 | + } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1723 | + //$line['symbol'] === 'Balloon' || |
|
1724 | + $line['symbol'] === 'Glider' || |
|
1725 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) { |
|
1726 | + if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL'; |
|
1727 | + if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER'; |
|
1728 | + $send = $SI->add($data); |
|
1729 | + } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1730 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1731 | + $line['symbol'] === 'Ship (Power Boat)')) { |
|
1732 | + $send = $MI->add($data); |
|
1733 | + } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ( |
|
1734 | + $line['symbol'] === 'Car' || |
|
1735 | + $line['symbol'] === 'Ambulance' || |
|
1736 | + $line['symbol'] === 'Van' || |
|
1737 | + $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || |
|
1738 | + $line['symbol'] === 'Motorcycle' || |
|
1739 | + $line['symbol'] === 'Tractor' || |
|
1740 | + $line['symbol'] === 'Police' || |
|
1741 | + $line['symbol'] === 'Bike' || |
|
1742 | + $line['symbol'] === 'Jogger' || |
|
1743 | + $line['symbol'] === 'Horse' || |
|
1744 | + $line['symbol'] === 'Bus' || |
|
1745 | + $line['symbol'] === 'Jeep' || |
|
1746 | + $line['symbol'] === 'Recreational Vehicle' || |
|
1747 | + $line['symbol'] === 'Yacht (Sail)' || |
|
1748 | + $line['symbol'] === 'Ship (Power Boat)' || |
|
1749 | + $line['symbol'] === 'Firetruck' || |
|
1750 | + $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || |
|
1751 | + $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || |
|
1752 | + $line['symbol'] === 'SUV' || |
|
1753 | + $line['symbol'] === 'Snowmobile' || |
|
1754 | + $line['symbol'] === 'Mobile Satellite Station')) { |
|
1755 | + //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
|
1756 | 1756 | // } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') { |
1757 | 1757 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; |
1758 | 1758 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); |
1759 | - } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1759 | + } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) { |
|
1760 | 1760 | if (!isset($data['altitude'])) $data['altitude'] = 0; |
1761 | 1761 | $Source->deleteOldLocationByType('gs'); |
1762 | 1762 | if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) { |
@@ -1764,7 +1764,7 @@ discard block |
||
1764 | 1764 | } else { |
1765 | 1765 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); |
1766 | 1766 | } |
1767 | - } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1767 | + } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') { |
|
1768 | 1768 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1769 | 1769 | if ($globalDebug) echo '# Weather Station added'."\n"; |
1770 | 1770 | $Source->deleteOldLocationByType('wx'); |
@@ -1774,7 +1774,7 @@ discard block |
||
1774 | 1774 | } else { |
1775 | 1775 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data); |
1776 | 1776 | } |
1777 | - } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1777 | + } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) { |
|
1778 | 1778 | //if ($globalDebug) echo '!! Weather Station not yet supported'."\n"; |
1779 | 1779 | if ($globalDebug) echo '☈ Lightning added'."\n"; |
1780 | 1780 | $Source->deleteOldLocationByType('lightning'); |
@@ -1783,11 +1783,11 @@ discard block |
||
1783 | 1783 | } else { |
1784 | 1784 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']); |
1785 | 1785 | } |
1786 | - } elseif ($globalDebug) { |
|
1787 | - echo '/!\ Not added: '.$buffer."\n"; |
|
1788 | - print_r($line); |
|
1789 | - } |
|
1790 | - unset($data); |
|
1786 | + } elseif ($globalDebug) { |
|
1787 | + echo '/!\ Not added: '.$buffer."\n"; |
|
1788 | + print_r($line); |
|
1789 | + } |
|
1790 | + unset($data); |
|
1791 | 1791 | } |
1792 | 1792 | elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') { |
1793 | 1793 | $Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']); |
@@ -1806,12 +1806,12 @@ discard block |
||
1806 | 1806 | } elseif (!isset($globalSources[$nb]['last_weather_clean'])) { |
1807 | 1807 | $globalSources[$nb]['last_weather_clean'] = time(); |
1808 | 1808 | } |
1809 | - } |
|
1809 | + } |
|
1810 | 1810 | } else { |
1811 | - $line = explode(',', $buffer); |
|
1812 | - if (count($line) > 20) { |
|
1813 | - $data['hex'] = $line[4]; |
|
1814 | - /* |
|
1811 | + $line = explode(',', $buffer); |
|
1812 | + if (count($line) > 20) { |
|
1813 | + $data['hex'] = $line[4]; |
|
1814 | + /* |
|
1815 | 1815 | $data['datetime'] = $line[6].' '.$line[7]; |
1816 | 1816 | date_default_timezone_set($globalTimezone); |
1817 | 1817 | $datetime = new DateTime($data['datetime']); |
@@ -1819,31 +1819,31 @@ discard block |
||
1819 | 1819 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
1820 | 1820 | date_default_timezone_set('UTC'); |
1821 | 1821 | */ |
1822 | - // Force datetime to current UTC datetime |
|
1823 | - date_default_timezone_set('UTC'); |
|
1824 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
1825 | - $data['ident'] = trim($line[10]); |
|
1826 | - $data['latitude'] = $line[14]; |
|
1827 | - $data['longitude'] = $line[15]; |
|
1828 | - $data['verticalrate'] = $line[16]; |
|
1829 | - $data['emergency'] = $line[20]; |
|
1830 | - $data['speed'] = $line[12]; |
|
1831 | - $data['squawk'] = $line[17]; |
|
1832 | - $data['altitude'] = $line[11]; |
|
1833 | - $data['heading'] = $line[13]; |
|
1834 | - $data['ground'] = $line[21]; |
|
1835 | - $data['emergency'] = $line[19]; |
|
1836 | - $data['format_source'] = 'sbs'; |
|
1822 | + // Force datetime to current UTC datetime |
|
1823 | + date_default_timezone_set('UTC'); |
|
1824 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
1825 | + $data['ident'] = trim($line[10]); |
|
1826 | + $data['latitude'] = $line[14]; |
|
1827 | + $data['longitude'] = $line[15]; |
|
1828 | + $data['verticalrate'] = $line[16]; |
|
1829 | + $data['emergency'] = $line[20]; |
|
1830 | + $data['speed'] = $line[12]; |
|
1831 | + $data['squawk'] = $line[17]; |
|
1832 | + $data['altitude'] = $line[11]; |
|
1833 | + $data['heading'] = $line[13]; |
|
1834 | + $data['ground'] = $line[21]; |
|
1835 | + $data['emergency'] = $line[19]; |
|
1836 | + $data['format_source'] = 'sbs'; |
|
1837 | 1837 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
1838 | 1838 | elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT'; |
1839 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1839 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
1840 | 1840 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; |
1841 | - $data['id_source'] = $id_source; |
|
1842 | - if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1843 | - else $error = true; |
|
1844 | - unset($data); |
|
1845 | - } else $error = true; |
|
1846 | - if ($error) { |
|
1841 | + $data['id_source'] = $id_source; |
|
1842 | + if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
1843 | + else $error = true; |
|
1844 | + unset($data); |
|
1845 | + } else $error = true; |
|
1846 | + if ($error) { |
|
1847 | 1847 | if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { |
1848 | 1848 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
1849 | 1849 | } else { |
@@ -1859,13 +1859,13 @@ discard block |
||
1859 | 1859 | connect_all($sourceer); |
1860 | 1860 | $sourceer = array(); |
1861 | 1861 | } |
1862 | - } |
|
1862 | + } |
|
1863 | 1863 | } |
1864 | 1864 | // Sleep for xxx microseconds |
1865 | 1865 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
1866 | - } else { |
|
1866 | + } else { |
|
1867 | 1867 | if ($format === 'flightgearmp') { |
1868 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1868 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
1869 | 1869 | //@socket_close($r); |
1870 | 1870 | sleep($globalMinFetch); |
1871 | 1871 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1874,9 +1874,9 @@ discard block |
||
1874 | 1874 | break; |
1875 | 1875 | |
1876 | 1876 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
1877 | - if (isset($tt[$format])) $tt[$format]++; |
|
1878 | - else $tt[$format] = 0; |
|
1879 | - if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1877 | + if (isset($tt[$format])) $tt[$format]++; |
|
1878 | + else $tt[$format] = 0; |
|
1879 | + if ($tt[$format] > 30 || $buffer === FALSE) { |
|
1880 | 1880 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
1881 | 1881 | //@socket_close($r); |
1882 | 1882 | sleep(2); |
@@ -1887,24 +1887,24 @@ discard block |
||
1887 | 1887 | //connect_all($globalSources); |
1888 | 1888 | $tt[$format]=0; |
1889 | 1889 | break; |
1890 | - } |
|
1891 | - //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1890 | + } |
|
1891 | + //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."..."; |
|
1892 | + } |
|
1892 | 1893 | } |
1893 | - } |
|
1894 | 1894 | } |
1895 | - } else { |
|
1895 | + } else { |
|
1896 | 1896 | $error = socket_strerror(socket_last_error()); |
1897 | 1897 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { |
1898 | 1898 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
1899 | 1899 | if (isset($globalDebug)) echo "Restarting...\n"; |
1900 | 1900 | // Restart the script if possible |
1901 | 1901 | if (is_array($sockets)) { |
1902 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
1902 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
1903 | 1903 | |
1904 | - foreach ($sockets as $sock) { |
|
1904 | + foreach ($sockets as $sock) { |
|
1905 | 1905 | @socket_shutdown($sock,2); |
1906 | 1906 | @socket_close($sock); |
1907 | - } |
|
1907 | + } |
|
1908 | 1908 | |
1909 | 1909 | } |
1910 | 1910 | if ($globalDebug) echo "Waiting..."; |
@@ -1919,15 +1919,15 @@ discard block |
||
1919 | 1919 | if ($globalDebug) echo "Restart all connections..."; |
1920 | 1920 | connect_all($globalSources); |
1921 | 1921 | } |
1922 | - } |
|
1922 | + } |
|
1923 | 1923 | } |
1924 | 1924 | if ($globalDaemon === false) { |
1925 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
1926 | - if (isset($SI)) $SI->checkAll(); |
|
1927 | - if (isset($TI)) $TI->checkAll(); |
|
1928 | - if (isset($MI)) $MI->checkAll(); |
|
1925 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
1926 | + if (isset($SI)) $SI->checkAll(); |
|
1927 | + if (isset($TI)) $TI->checkAll(); |
|
1928 | + if (isset($MI)) $MI->checkAll(); |
|
1929 | + } |
|
1929 | 1930 | } |
1930 | - } |
|
1931 | 1931 | } |
1932 | 1932 | |
1933 | 1933 | ?> |