@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | } |
555 | 555 | } |
556 | 556 | <?php |
557 | - } else { |
|
558 | - ?> |
|
557 | + } else { |
|
558 | + ?> |
|
559 | 559 | if (map.getZoom() > 7) { |
560 | 560 | var style = { |
561 | 561 | "color": "#1a3151", |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | layer_tracker_data.addLayer(layer); |
575 | 575 | } |
576 | 576 | <?php |
577 | - } |
|
577 | + } |
|
578 | 578 | ?> |
579 | 579 | } |
580 | 580 | } |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | $( document ).ready(function() { |
600 | 600 | map.on('moveend', function() { |
601 | 601 | <?php |
602 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
602 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
603 | 603 | ?> |
604 | 604 | getLiveTrackerData(1); |
605 | 605 | <?php |
606 | - } |
|
606 | + } |
|
607 | 607 | ?> |
608 | 608 | }); |
609 | 609 | //load the function on startup |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveTrackerData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | - * Gets Minimal Live Spotter data |
|
137 | - * |
|
138 | - * @return Array the spotter information |
|
139 | - * |
|
140 | - */ |
|
136 | + * Gets Minimal Live Spotter data |
|
137 | + * |
|
138 | + * @return Array the spotter information |
|
139 | + * |
|
140 | + */ |
|
141 | 141 | public function getMinLiveTrackerData($filter = array()) |
142 | 142 | { |
143 | 143 | global $globalDBdriver, $globalLiveInterval; |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | - * Gets Minimal Live Spotter data since xx seconds |
|
175 | - * |
|
176 | - * @return Array the spotter information |
|
177 | - * |
|
178 | - */ |
|
174 | + * Gets Minimal Live Spotter data since xx seconds |
|
175 | + * |
|
176 | + * @return Array the spotter information |
|
177 | + * |
|
178 | + */ |
|
179 | 179 | public function getMinLastLiveTrackerData($coord,$filter = array(),$limit = false) |
180 | 180 | { |
181 | 181 | global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DTrackersLimit; |
@@ -249,11 +249,11 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * Gets number of latest data entry |
|
253 | - * |
|
254 | - * @return String number of entry |
|
255 | - * |
|
256 | - */ |
|
252 | + * Gets number of latest data entry |
|
253 | + * |
|
254 | + * @return String number of entry |
|
255 | + * |
|
256 | + */ |
|
257 | 257 | public function getLiveTrackerCount($filter = array()) |
258 | 258 | { |
259 | 259 | global $globalDBdriver, $globalLiveInterval; |
@@ -278,11 +278,11 @@ discard block |
||
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
281 | - * Gets all the spotter information based on the latest data entry and coord |
|
282 | - * |
|
283 | - * @return Array the spotter information |
|
284 | - * |
|
285 | - */ |
|
281 | + * Gets all the spotter information based on the latest data entry and coord |
|
282 | + * |
|
283 | + * @return Array the spotter information |
|
284 | + * |
|
285 | + */ |
|
286 | 286 | public function getLiveTrackerDatabyCoord($coord, $filter = array()) |
287 | 287 | { |
288 | 288 | global $globalDBdriver, $globalLiveInterval; |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | - * Gets all the spotter information based on the latest data entry and coord |
|
310 | - * |
|
311 | - * @return Array the spotter information |
|
312 | - * |
|
313 | - */ |
|
309 | + * Gets all the spotter information based on the latest data entry and coord |
|
310 | + * |
|
311 | + * @return Array the spotter information |
|
312 | + * |
|
313 | + */ |
|
314 | 314 | public function getMinLiveTrackerDatabyCoord($coord, $filter = array()) |
315 | 315 | { |
316 | 316 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -378,11 +378,11 @@ discard block |
||
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
381 | - * Gets all the spotter information based on a user's latitude and longitude |
|
382 | - * |
|
383 | - * @return Array the spotter information |
|
384 | - * |
|
385 | - */ |
|
381 | + * Gets all the spotter information based on a user's latitude and longitude |
|
382 | + * |
|
383 | + * @return Array the spotter information |
|
384 | + * |
|
385 | + */ |
|
386 | 386 | public function getLatestTrackerForLayar($lat, $lng, $radius, $interval) |
387 | 387 | { |
388 | 388 | $Tracker = new Tracker($this->db); |
@@ -395,142 +395,142 @@ discard block |
||
395 | 395 | if ($lng != '') |
396 | 396 | { |
397 | 397 | if (!is_numeric($lng)) |
398 | - { |
|
399 | - return false; |
|
400 | - } |
|
401 | - } |
|
402 | - |
|
403 | - if ($radius != '') |
|
404 | - { |
|
405 | - if (!is_numeric($radius)) |
|
406 | - { |
|
407 | - return false; |
|
408 | - } |
|
409 | - } |
|
398 | + { |
|
399 | + return false; |
|
400 | + } |
|
401 | + } |
|
402 | + |
|
403 | + if ($radius != '') |
|
404 | + { |
|
405 | + if (!is_numeric($radius)) |
|
406 | + { |
|
407 | + return false; |
|
408 | + } |
|
409 | + } |
|
410 | 410 | $additional_query = ''; |
411 | 411 | if ($interval != '') |
412 | - { |
|
413 | - if (!is_string($interval)) |
|
414 | - { |
|
415 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
416 | - return false; |
|
417 | - } else { |
|
418 | - if ($interval == '1m') |
|
419 | - { |
|
420 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
421 | - } else if ($interval == '15m'){ |
|
422 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
423 | - } |
|
424 | - } |
|
425 | - } else { |
|
426 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
427 | - } |
|
428 | - |
|
429 | - $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
412 | + { |
|
413 | + if (!is_string($interval)) |
|
414 | + { |
|
415 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
416 | + return false; |
|
417 | + } else { |
|
418 | + if ($interval == '1m') |
|
419 | + { |
|
420 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
421 | + } else if ($interval == '15m'){ |
|
422 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date '; |
|
423 | + } |
|
424 | + } |
|
425 | + } else { |
|
426 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date '; |
|
427 | + } |
|
428 | + |
|
429 | + $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live |
|
430 | 430 | WHERE tracker_live.latitude <> '' |
431 | 431 | AND tracker_live.longitude <> '' |
432 | 432 | ".$additional_query." |
433 | 433 | HAVING distance < :radius |
434 | 434 | ORDER BY distance"; |
435 | 435 | |
436 | - $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
436 | + $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
437 | 437 | |
438 | - return $spotter_array; |
|
439 | - } |
|
438 | + return $spotter_array; |
|
439 | + } |
|
440 | 440 | |
441 | 441 | |
442 | - /** |
|
443 | - * Gets all the spotter information based on a particular callsign |
|
444 | - * |
|
445 | - * @return Array the spotter information |
|
446 | - * |
|
447 | - */ |
|
442 | + /** |
|
443 | + * Gets all the spotter information based on a particular callsign |
|
444 | + * |
|
445 | + * @return Array the spotter information |
|
446 | + * |
|
447 | + */ |
|
448 | 448 | public function getLastLiveTrackerDataByIdent($ident) |
449 | 449 | { |
450 | 450 | $Tracker = new Tracker($this->db); |
451 | 451 | date_default_timezone_set('UTC'); |
452 | 452 | |
453 | 453 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
454 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
454 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
455 | 455 | |
456 | 456 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true); |
457 | 457 | |
458 | 458 | return $spotter_array; |
459 | 459 | } |
460 | 460 | |
461 | - /** |
|
462 | - * Gets all the spotter information based on a particular callsign |
|
463 | - * |
|
464 | - * @return Array the spotter information |
|
465 | - * |
|
466 | - */ |
|
461 | + /** |
|
462 | + * Gets all the spotter information based on a particular callsign |
|
463 | + * |
|
464 | + * @return Array the spotter information |
|
465 | + * |
|
466 | + */ |
|
467 | 467 | public function getDateLiveTrackerDataByIdent($ident,$date) |
468 | 468 | { |
469 | 469 | $Tracker = new Tracker($this->db); |
470 | 470 | date_default_timezone_set('UTC'); |
471 | 471 | |
472 | 472 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
473 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
473 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
474 | 474 | |
475 | - $date = date('c',$date); |
|
475 | + $date = date('c',$date); |
|
476 | 476 | $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
477 | 477 | |
478 | 478 | return $spotter_array; |
479 | 479 | } |
480 | 480 | |
481 | - /** |
|
482 | - * Gets last spotter information based on a particular callsign |
|
483 | - * |
|
484 | - * @return Array the spotter information |
|
485 | - * |
|
486 | - */ |
|
481 | + /** |
|
482 | + * Gets last spotter information based on a particular callsign |
|
483 | + * |
|
484 | + * @return Array the spotter information |
|
485 | + * |
|
486 | + */ |
|
487 | 487 | public function getLastLiveTrackerDataById($id) |
488 | 488 | { |
489 | 489 | $Tracker = new Tracker($this->db); |
490 | 490 | date_default_timezone_set('UTC'); |
491 | 491 | |
492 | 492 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
493 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
493 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
494 | 494 | |
495 | 495 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true); |
496 | 496 | |
497 | 497 | return $spotter_array; |
498 | 498 | } |
499 | 499 | |
500 | - /** |
|
501 | - * Gets last spotter information based on a particular callsign |
|
502 | - * |
|
503 | - * @return Array the spotter information |
|
504 | - * |
|
505 | - */ |
|
500 | + /** |
|
501 | + * Gets last spotter information based on a particular callsign |
|
502 | + * |
|
503 | + * @return Array the spotter information |
|
504 | + * |
|
505 | + */ |
|
506 | 506 | public function getDateLiveTrackerDataById($id,$date) |
507 | 507 | { |
508 | 508 | $Tracker = new Tracker($this->db); |
509 | 509 | date_default_timezone_set('UTC'); |
510 | 510 | |
511 | 511 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
512 | - $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
513 | - $date = date('c',$date); |
|
512 | + $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC'; |
|
513 | + $date = date('c',$date); |
|
514 | 514 | $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
515 | 515 | |
516 | 516 | return $spotter_array; |
517 | 517 | } |
518 | 518 | |
519 | - /** |
|
520 | - * Gets altitude information based on a particular callsign |
|
521 | - * |
|
522 | - * @return Array the spotter information |
|
523 | - * |
|
524 | - */ |
|
519 | + /** |
|
520 | + * Gets altitude information based on a particular callsign |
|
521 | + * |
|
522 | + * @return Array the spotter information |
|
523 | + * |
|
524 | + */ |
|
525 | 525 | public function getAltitudeLiveTrackerDataByIdent($ident) |
526 | 526 | { |
527 | 527 | |
528 | 528 | date_default_timezone_set('UTC'); |
529 | 529 | |
530 | 530 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
531 | - $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
531 | + $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident'; |
|
532 | 532 | |
533 | - try { |
|
533 | + try { |
|
534 | 534 | |
535 | 535 | $sth = $this->db->prepare($query); |
536 | 536 | $sth->execute(array(':ident' => $ident)); |
@@ -543,12 +543,12 @@ discard block |
||
543 | 543 | return $spotter_array; |
544 | 544 | } |
545 | 545 | |
546 | - /** |
|
547 | - * Gets all the spotter information based on a particular id |
|
548 | - * |
|
549 | - * @return Array the spotter information |
|
550 | - * |
|
551 | - */ |
|
546 | + /** |
|
547 | + * Gets all the spotter information based on a particular id |
|
548 | + * |
|
549 | + * @return Array the spotter information |
|
550 | + * |
|
551 | + */ |
|
552 | 552 | public function getAllLiveTrackerDataById($id,$liveinterval = false) |
553 | 553 | { |
554 | 554 | global $globalDBdriver, $globalLiveInterval; |
@@ -576,18 +576,18 @@ discard block |
||
576 | 576 | return $spotter_array; |
577 | 577 | } |
578 | 578 | |
579 | - /** |
|
580 | - * Gets all the spotter information based on a particular ident |
|
581 | - * |
|
582 | - * @return Array the spotter information |
|
583 | - * |
|
584 | - */ |
|
579 | + /** |
|
580 | + * Gets all the spotter information based on a particular ident |
|
581 | + * |
|
582 | + * @return Array the spotter information |
|
583 | + * |
|
584 | + */ |
|
585 | 585 | public function getAllLiveTrackerDataByIdent($ident) |
586 | 586 | { |
587 | 587 | date_default_timezone_set('UTC'); |
588 | 588 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
589 | 589 | $query = self::$global_query.' WHERE tracker_live.ident = :ident'; |
590 | - try { |
|
590 | + try { |
|
591 | 591 | |
592 | 592 | $sth = $this->db->prepare($query); |
593 | 593 | $sth->execute(array(':ident' => $ident)); |
@@ -601,23 +601,23 @@ discard block |
||
601 | 601 | |
602 | 602 | |
603 | 603 | /** |
604 | - * Deletes all info in the table |
|
605 | - * |
|
606 | - * @return String success or false |
|
607 | - * |
|
608 | - */ |
|
604 | + * Deletes all info in the table |
|
605 | + * |
|
606 | + * @return String success or false |
|
607 | + * |
|
608 | + */ |
|
609 | 609 | public function deleteLiveTrackerData() |
610 | 610 | { |
611 | 611 | global $globalDBdriver; |
612 | 612 | if ($globalDBdriver == 'mysql') { |
613 | 613 | //$query = "DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= tracker_live.date"; |
614 | 614 | $query = 'DELETE FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= tracker_live.date'; |
615 | - //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
615 | + //$query = "DELETE FROM tracker_live WHERE tracker_live.id IN (SELECT tracker_live.id FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= tracker_live.date)"; |
|
616 | 616 | } else { |
617 | 617 | $query = "DELETE FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date"; |
618 | 618 | } |
619 | 619 | |
620 | - try { |
|
620 | + try { |
|
621 | 621 | |
622 | 622 | $sth = $this->db->prepare($query); |
623 | 623 | $sth->execute(); |
@@ -629,18 +629,18 @@ discard block |
||
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
632 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
633 | - * |
|
634 | - * @return String success or false |
|
635 | - * |
|
636 | - */ |
|
632 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
633 | + * |
|
634 | + * @return String success or false |
|
635 | + * |
|
636 | + */ |
|
637 | 637 | public function deleteLiveTrackerDataNotUpdated() |
638 | 638 | { |
639 | 639 | global $globalDBdriver, $globalDebug; |
640 | 640 | if ($globalDBdriver == 'mysql') { |
641 | 641 | //$query = 'SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < tracker_live.date) LIMIT 800 OFFSET 0'; |
642 | - $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
643 | - try { |
|
642 | + $query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
643 | + try { |
|
644 | 644 | |
645 | 645 | $sth = $this->db->prepare($query); |
646 | 646 | $sth->execute(); |
@@ -648,8 +648,8 @@ discard block |
||
648 | 648 | return "error"; |
649 | 649 | } |
650 | 650 | $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
651 | - $i = 0; |
|
652 | - $j =0; |
|
651 | + $i = 0; |
|
652 | + $j =0; |
|
653 | 653 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
654 | 654 | foreach($all as $row) |
655 | 655 | { |
@@ -657,20 +657,20 @@ discard block |
||
657 | 657 | $j++; |
658 | 658 | if ($j == 30) { |
659 | 659 | if ($globalDebug) echo "."; |
660 | - try { |
|
660 | + try { |
|
661 | 661 | |
662 | 662 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
663 | 663 | $sth->execute(); |
664 | 664 | } catch(PDOException $e) { |
665 | 665 | return "error"; |
666 | 666 | } |
667 | - $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
668 | - $j = 0; |
|
667 | + $query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN ('; |
|
668 | + $j = 0; |
|
669 | 669 | } |
670 | 670 | $query_delete .= "'".$row['famtrackid']."',"; |
671 | 671 | } |
672 | 672 | if ($i > 0) { |
673 | - try { |
|
673 | + try { |
|
674 | 674 | |
675 | 675 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
676 | 676 | $sth->execute(); |
@@ -681,9 +681,9 @@ discard block |
||
681 | 681 | return "success"; |
682 | 682 | } elseif ($globalDBdriver == 'pgsql') { |
683 | 683 | //$query = "SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= tracker_live.date AND tracker_live.famtrackid NOT IN (SELECT famtrackid FROM tracker_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < tracker_live.date) LIMIT 800 OFFSET 0"; |
684 | - //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
685 | - $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
686 | - try { |
|
684 | + //$query = "SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
685 | + $query = "DELETE FROM tracker_live WHERE famtrackid IN (SELECT tracker_live.famtrackid FROM tracker_live INNER JOIN (SELECT famtrackid,MAX(date) as max_date FROM tracker_live GROUP BY famtrackid) s ON s.famtrackid = tracker_live.famtrackid AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
686 | + try { |
|
687 | 687 | |
688 | 688 | $sth = $this->db->prepare($query); |
689 | 689 | $sth->execute(); |
@@ -727,17 +727,17 @@ discard block |
||
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
730 | - * Deletes all info in the table for an ident |
|
731 | - * |
|
732 | - * @return String success or false |
|
733 | - * |
|
734 | - */ |
|
730 | + * Deletes all info in the table for an ident |
|
731 | + * |
|
732 | + * @return String success or false |
|
733 | + * |
|
734 | + */ |
|
735 | 735 | public function deleteLiveTrackerDataByIdent($ident) |
736 | 736 | { |
737 | 737 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
738 | 738 | $query = 'DELETE FROM tracker_live WHERE ident = :ident'; |
739 | 739 | |
740 | - try { |
|
740 | + try { |
|
741 | 741 | |
742 | 742 | $sth = $this->db->prepare($query); |
743 | 743 | $sth->execute(array(':ident' => $ident)); |
@@ -749,17 +749,17 @@ discard block |
||
749 | 749 | } |
750 | 750 | |
751 | 751 | /** |
752 | - * Deletes all info in the table for an id |
|
753 | - * |
|
754 | - * @return String success or false |
|
755 | - * |
|
756 | - */ |
|
752 | + * Deletes all info in the table for an id |
|
753 | + * |
|
754 | + * @return String success or false |
|
755 | + * |
|
756 | + */ |
|
757 | 757 | public function deleteLiveTrackerDataById($id) |
758 | 758 | { |
759 | 759 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
760 | 760 | $query = 'DELETE FROM tracker_live WHERE famtrackid = :id'; |
761 | 761 | |
762 | - try { |
|
762 | + try { |
|
763 | 763 | |
764 | 764 | $sth = $this->db->prepare($query); |
765 | 765 | $sth->execute(array(':id' => $id)); |
@@ -772,11 +772,11 @@ discard block |
||
772 | 772 | |
773 | 773 | |
774 | 774 | /** |
775 | - * Gets the aircraft ident within the last hour |
|
776 | - * |
|
777 | - * @return String the ident |
|
778 | - * |
|
779 | - */ |
|
775 | + * Gets the aircraft ident within the last hour |
|
776 | + * |
|
777 | + * @return String the ident |
|
778 | + * |
|
779 | + */ |
|
780 | 780 | public function getIdentFromLastHour($ident) |
781 | 781 | { |
782 | 782 | global $globalDBdriver, $globalTimezone; |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | $ident_result = $row['ident']; |
803 | 803 | } |
804 | 804 | return $ident_result; |
805 | - } |
|
805 | + } |
|
806 | 806 | |
807 | 807 | /** |
808 | - * Check recent aircraft |
|
809 | - * |
|
810 | - * @return String the ident |
|
811 | - * |
|
812 | - */ |
|
808 | + * Check recent aircraft |
|
809 | + * |
|
810 | + * @return String the ident |
|
811 | + * |
|
812 | + */ |
|
813 | 813 | public function checkIdentRecent($ident) |
814 | 814 | { |
815 | 815 | global $globalDBdriver, $globalTimezone; |
@@ -835,14 +835,14 @@ discard block |
||
835 | 835 | $ident_result = $row['famtrackid']; |
836 | 836 | } |
837 | 837 | return $ident_result; |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | /** |
841 | - * Check recent aircraft by id |
|
842 | - * |
|
843 | - * @return String the ident |
|
844 | - * |
|
845 | - */ |
|
841 | + * Check recent aircraft by id |
|
842 | + * |
|
843 | + * @return String the ident |
|
844 | + * |
|
845 | + */ |
|
846 | 846 | public function checkIdRecent($id) |
847 | 847 | { |
848 | 848 | global $globalDBdriver, $globalTimezone; |
@@ -868,19 +868,19 @@ discard block |
||
868 | 868 | $ident_result = $row['famtrackid']; |
869 | 869 | } |
870 | 870 | return $ident_result; |
871 | - } |
|
871 | + } |
|
872 | 872 | |
873 | 873 | /** |
874 | - * Adds a new spotter data |
|
875 | - * |
|
876 | - * @param String $famtrackid the ID from flightaware |
|
877 | - * @param String $ident the flight ident |
|
878 | - * @param String $aircraft_icao the aircraft type |
|
879 | - * @param String $departure_airport_icao the departure airport |
|
880 | - * @param String $arrival_airport_icao the arrival airport |
|
881 | - * @return String success or false |
|
882 | - * |
|
883 | - */ |
|
874 | + * Adds a new spotter data |
|
875 | + * |
|
876 | + * @param String $famtrackid the ID from flightaware |
|
877 | + * @param String $ident the flight ident |
|
878 | + * @param String $aircraft_icao the aircraft type |
|
879 | + * @param String $departure_airport_icao the departure airport |
|
880 | + * @param String $arrival_airport_icao the arrival airport |
|
881 | + * @return String success or false |
|
882 | + * |
|
883 | + */ |
|
884 | 884 | public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
885 | 885 | { |
886 | 886 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,8 +953,8 @@ discard block |
||
953 | 953 | $comment = filter_var($comment,FILTER_SANITIZE_STRING); |
954 | 954 | $type = filter_var($type,FILTER_SANITIZE_STRING); |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | 958 | |
959 | 959 | $query = ''; |
960 | 960 | if ($globalArchive) { |
@@ -972,15 +972,15 @@ discard block |
||
972 | 972 | } catch(PDOException $e) { |
973 | 973 | return "error : ".$e->getMessage(); |
974 | 974 | } |
975 | - /* |
|
975 | + /* |
|
976 | 976 | echo 'putinarchive : '.$putinarchive."\n"; |
977 | 977 | echo 'noarchive : '.$noarchive."\n"; |
978 | 978 | */ |
979 | 979 | if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) { |
980 | - if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
981 | - $TrackerArchive = new TrackerArchive($this->db); |
|
982 | - $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
983 | - if ($globalDebug) echo $result.')'; |
|
980 | + if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : '; |
|
981 | + $TrackerArchive = new TrackerArchive($this->db); |
|
982 | + $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country); |
|
983 | + if ($globalDebug) echo $result.')'; |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | return "success"; |
@@ -13,10 +13,10 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | - * Get SQL query part for filter used |
|
17 | - * @param Array $filter the filter |
|
18 | - * @return Array the SQL part |
|
19 | - */ |
|
16 | + * Get SQL query part for filter used |
|
17 | + * @param Array $filter the filter |
|
18 | + * @return Array the SQL part |
|
19 | + */ |
|
20 | 20 | public function getFilter($filter = array(),$where = false,$and = false) { |
21 | 21 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
22 | 22 | $filters = array(); |
@@ -87,11 +87,11 @@ discard block |
||
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | - * Gets all the spotter information based on the latest data entry |
|
91 | - * |
|
92 | - * @return Array the spotter information |
|
93 | - * |
|
94 | - */ |
|
90 | + * Gets all the spotter information based on the latest data entry |
|
91 | + * |
|
92 | + * @return Array the spotter information |
|
93 | + * |
|
94 | + */ |
|
95 | 95 | public function getLiveMarineData($limit = '', $sort = '', $filter = array()) |
96 | 96 | { |
97 | 97 | global $globalDBdriver, $globalLiveInterval; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | - * Gets Minimal Live Spotter data |
|
138 | - * |
|
139 | - * @return Array the spotter information |
|
140 | - * |
|
141 | - */ |
|
137 | + * Gets Minimal Live Spotter data |
|
138 | + * |
|
139 | + * @return Array the spotter information |
|
140 | + * |
|
141 | + */ |
|
142 | 142 | public function getMinLiveMarineData($filter = array()) |
143 | 143 | { |
144 | 144 | global $globalDBdriver, $globalLiveInterval; |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
171 | - * Gets Minimal Live Spotter data since xx seconds |
|
172 | - * |
|
173 | - * @return Array the spotter information |
|
174 | - * |
|
175 | - */ |
|
171 | + * Gets Minimal Live Spotter data since xx seconds |
|
172 | + * |
|
173 | + * @return Array the spotter information |
|
174 | + * |
|
175 | + */ |
|
176 | 176 | public function getMinLastLiveMarineData($coord = array(),$filter = array(), $limit = false) |
177 | 177 | { |
178 | 178 | global $globalDBdriver, $globalLiveInterval, $globalMap3DMarinesLimit, $globalArchive; |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | - * Gets number of latest data entry |
|
247 | - * |
|
248 | - * @return String number of entry |
|
249 | - * |
|
250 | - */ |
|
246 | + * Gets number of latest data entry |
|
247 | + * |
|
248 | + * @return String number of entry |
|
249 | + * |
|
250 | + */ |
|
251 | 251 | public function getLiveMarineCount($filter = array()) |
252 | 252 | { |
253 | 253 | global $globalDBdriver, $globalLiveInterval; |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | - * Gets all the spotter information based on the latest data entry and coord |
|
276 | - * |
|
277 | - * @return Array the spotter information |
|
278 | - * |
|
279 | - */ |
|
275 | + * Gets all the spotter information based on the latest data entry and coord |
|
276 | + * |
|
277 | + * @return Array the spotter information |
|
278 | + * |
|
279 | + */ |
|
280 | 280 | public function getLiveMarineDatabyCoord($coord, $filter = array()) |
281 | 281 | { |
282 | 282 | global $globalDBdriver, $globalLiveInterval; |
@@ -300,11 +300,11 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | - * Gets all the spotter information based on the latest data entry and coord |
|
304 | - * |
|
305 | - * @return Array the spotter information |
|
306 | - * |
|
307 | - */ |
|
303 | + * Gets all the spotter information based on the latest data entry and coord |
|
304 | + * |
|
305 | + * @return Array the spotter information |
|
306 | + * |
|
307 | + */ |
|
308 | 308 | public function getMinLiveMarineDatabyCoord($coord, $filter = array()) |
309 | 309 | { |
310 | 310 | global $globalDBdriver, $globalLiveInterval, $globalArchive; |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
376 | - * Gets all the spotter information based on a user's latitude and longitude |
|
377 | - * |
|
378 | - * @return Array the spotter information |
|
379 | - * |
|
380 | - */ |
|
376 | + * Gets all the spotter information based on a user's latitude and longitude |
|
377 | + * |
|
378 | + * @return Array the spotter information |
|
379 | + * |
|
380 | + */ |
|
381 | 381 | public function getLatestMarineForLayar($lat, $lng, $radius, $interval) |
382 | 382 | { |
383 | 383 | $Marine = new Marine($this->db); |
@@ -390,134 +390,134 @@ discard block |
||
390 | 390 | if ($lng != '') |
391 | 391 | { |
392 | 392 | if (!is_numeric($lng)) |
393 | - { |
|
394 | - return false; |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - if ($radius != '') |
|
399 | - { |
|
400 | - if (!is_numeric($radius)) |
|
401 | - { |
|
402 | - return false; |
|
403 | - } |
|
404 | - } |
|
393 | + { |
|
394 | + return false; |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + if ($radius != '') |
|
399 | + { |
|
400 | + if (!is_numeric($radius)) |
|
401 | + { |
|
402 | + return false; |
|
403 | + } |
|
404 | + } |
|
405 | 405 | $additional_query = ''; |
406 | 406 | if ($interval != '') |
407 | - { |
|
408 | - if (!is_string($interval)) |
|
409 | - { |
|
410 | - //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | - return false; |
|
412 | - } else { |
|
413 | - if ($interval == '1m') |
|
414 | - { |
|
415 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | - } else if ($interval == '15m'){ |
|
417 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | - } |
|
419 | - } |
|
420 | - } else { |
|
421 | - $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | - } |
|
423 | - |
|
424 | - $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
407 | + { |
|
408 | + if (!is_string($interval)) |
|
409 | + { |
|
410 | + //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
411 | + return false; |
|
412 | + } else { |
|
413 | + if ($interval == '1m') |
|
414 | + { |
|
415 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
416 | + } else if ($interval == '15m'){ |
|
417 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date '; |
|
418 | + } |
|
419 | + } |
|
420 | + } else { |
|
421 | + $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date '; |
|
422 | + } |
|
423 | + |
|
424 | + $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live |
|
425 | 425 | WHERE marine_live.latitude <> '' |
426 | 426 | AND marine_live.longitude <> '' |
427 | 427 | ".$additional_query." |
428 | 428 | HAVING distance < :radius |
429 | 429 | ORDER BY distance"; |
430 | 430 | |
431 | - $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
431 | + $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius)); |
|
432 | 432 | |
433 | - return $spotter_array; |
|
434 | - } |
|
433 | + return $spotter_array; |
|
434 | + } |
|
435 | 435 | |
436 | 436 | |
437 | - /** |
|
438 | - * Gets all the spotter information based on a particular callsign |
|
439 | - * |
|
440 | - * @return Array the spotter information |
|
441 | - * |
|
442 | - */ |
|
437 | + /** |
|
438 | + * Gets all the spotter information based on a particular callsign |
|
439 | + * |
|
440 | + * @return Array the spotter information |
|
441 | + * |
|
442 | + */ |
|
443 | 443 | public function getLastLiveMarineDataByIdent($ident) |
444 | 444 | { |
445 | 445 | $Marine = new Marine($this->db); |
446 | 446 | date_default_timezone_set('UTC'); |
447 | 447 | |
448 | 448 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
449 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
449 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
450 | 450 | |
451 | 451 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true); |
452 | 452 | |
453 | 453 | return $spotter_array; |
454 | 454 | } |
455 | 455 | |
456 | - /** |
|
457 | - * Gets all the spotter information based on a particular callsign |
|
458 | - * |
|
459 | - * @return Array the spotter information |
|
460 | - * |
|
461 | - */ |
|
456 | + /** |
|
457 | + * Gets all the spotter information based on a particular callsign |
|
458 | + * |
|
459 | + * @return Array the spotter information |
|
460 | + * |
|
461 | + */ |
|
462 | 462 | public function getDateLiveMarineDataByIdent($ident,$date) |
463 | 463 | { |
464 | 464 | $Marine = new Marine($this->db); |
465 | 465 | date_default_timezone_set('UTC'); |
466 | 466 | |
467 | 467 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
468 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
468 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
469 | 469 | |
470 | - $date = date('c',$date); |
|
470 | + $date = date('c',$date); |
|
471 | 471 | $spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date)); |
472 | 472 | |
473 | 473 | return $spotter_array; |
474 | 474 | } |
475 | 475 | |
476 | - /** |
|
477 | - * Gets last spotter information based on a particular callsign |
|
478 | - * |
|
479 | - * @return Array the spotter information |
|
480 | - * |
|
481 | - */ |
|
476 | + /** |
|
477 | + * Gets last spotter information based on a particular callsign |
|
478 | + * |
|
479 | + * @return Array the spotter information |
|
480 | + * |
|
481 | + */ |
|
482 | 482 | public function getLastLiveMarineDataById($id) |
483 | 483 | { |
484 | 484 | $Marine = new Marine($this->db); |
485 | 485 | date_default_timezone_set('UTC'); |
486 | 486 | |
487 | 487 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
488 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
488 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
489 | 489 | |
490 | 490 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true); |
491 | 491 | |
492 | 492 | return $spotter_array; |
493 | 493 | } |
494 | 494 | |
495 | - /** |
|
496 | - * Gets last spotter information based on a particular callsign |
|
497 | - * |
|
498 | - * @return Array the spotter information |
|
499 | - * |
|
500 | - */ |
|
495 | + /** |
|
496 | + * Gets last spotter information based on a particular callsign |
|
497 | + * |
|
498 | + * @return Array the spotter information |
|
499 | + * |
|
500 | + */ |
|
501 | 501 | public function getDateLiveMarineDataById($id,$date) |
502 | 502 | { |
503 | 503 | $Marine = new Marine($this->db); |
504 | 504 | date_default_timezone_set('UTC'); |
505 | 505 | |
506 | 506 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
507 | - $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | - $date = date('c',$date); |
|
507 | + $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC'; |
|
508 | + $date = date('c',$date); |
|
509 | 509 | $spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true); |
510 | 510 | |
511 | 511 | return $spotter_array; |
512 | 512 | } |
513 | 513 | |
514 | 514 | |
515 | - /** |
|
516 | - * Gets all the spotter information based on a particular id |
|
517 | - * |
|
518 | - * @return Array the spotter information |
|
519 | - * |
|
520 | - */ |
|
515 | + /** |
|
516 | + * Gets all the spotter information based on a particular id |
|
517 | + * |
|
518 | + * @return Array the spotter information |
|
519 | + * |
|
520 | + */ |
|
521 | 521 | public function getAllLiveMarineDataById($id,$liveinterval = false) |
522 | 522 | { |
523 | 523 | global $globalDBdriver, $globalLiveInterval; |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | return $spotter_array; |
546 | 546 | } |
547 | 547 | |
548 | - /** |
|
549 | - * Gets all the spotter information based on a particular ident |
|
550 | - * |
|
551 | - * @return Array the spotter information |
|
552 | - * |
|
553 | - */ |
|
548 | + /** |
|
549 | + * Gets all the spotter information based on a particular ident |
|
550 | + * |
|
551 | + * @return Array the spotter information |
|
552 | + * |
|
553 | + */ |
|
554 | 554 | public function getAllLiveMarineDataByIdent($ident) |
555 | 555 | { |
556 | 556 | date_default_timezone_set('UTC'); |
557 | 557 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
558 | 558 | $query = self::$global_query.' WHERE marine_live.ident = :ident'; |
559 | - try { |
|
559 | + try { |
|
560 | 560 | |
561 | 561 | $sth = $this->db->prepare($query); |
562 | 562 | $sth->execute(array(':ident' => $ident)); |
@@ -570,23 +570,23 @@ discard block |
||
570 | 570 | |
571 | 571 | |
572 | 572 | /** |
573 | - * Deletes all info in the table |
|
574 | - * |
|
575 | - * @return String success or false |
|
576 | - * |
|
577 | - */ |
|
573 | + * Deletes all info in the table |
|
574 | + * |
|
575 | + * @return String success or false |
|
576 | + * |
|
577 | + */ |
|
578 | 578 | public function deleteLiveMarineData() |
579 | 579 | { |
580 | 580 | global $globalDBdriver; |
581 | 581 | if ($globalDBdriver == 'mysql') { |
582 | 582 | //$query = "DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= marine_live.date"; |
583 | 583 | $query = 'DELETE FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= marine_live.date'; |
584 | - //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
584 | + //$query = "DELETE FROM marine_live WHERE marine_live.id IN (SELECT marine_live.id FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= marine_live.date)"; |
|
585 | 585 | } else { |
586 | 586 | $query = "DELETE FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date"; |
587 | 587 | } |
588 | 588 | |
589 | - try { |
|
589 | + try { |
|
590 | 590 | |
591 | 591 | $sth = $this->db->prepare($query); |
592 | 592 | $sth->execute(); |
@@ -598,18 +598,18 @@ discard block |
||
598 | 598 | } |
599 | 599 | |
600 | 600 | /** |
601 | - * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | - * |
|
603 | - * @return String success or false |
|
604 | - * |
|
605 | - */ |
|
601 | + * Deletes all info in the table for aircraft not seen since 2 HOUR |
|
602 | + * |
|
603 | + * @return String success or false |
|
604 | + * |
|
605 | + */ |
|
606 | 606 | public function deleteLiveMarineDataNotUpdated() |
607 | 607 | { |
608 | 608 | global $globalDBdriver, $globalDebug; |
609 | 609 | if ($globalDBdriver == 'mysql') { |
610 | 610 | //$query = 'SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < marine_live.date) LIMIT 800 OFFSET 0'; |
611 | - $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | - try { |
|
611 | + $query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 1200 OFFSET 0"; |
|
612 | + try { |
|
613 | 613 | |
614 | 614 | $sth = $this->db->prepare($query); |
615 | 615 | $sth->execute(); |
@@ -617,8 +617,8 @@ discard block |
||
617 | 617 | return "error"; |
618 | 618 | } |
619 | 619 | $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
620 | - $i = 0; |
|
621 | - $j =0; |
|
620 | + $i = 0; |
|
621 | + $j =0; |
|
622 | 622 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
623 | 623 | foreach($all as $row) |
624 | 624 | { |
@@ -626,20 +626,20 @@ discard block |
||
626 | 626 | $j++; |
627 | 627 | if ($j == 30) { |
628 | 628 | if ($globalDebug) echo "."; |
629 | - try { |
|
629 | + try { |
|
630 | 630 | |
631 | 631 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
632 | 632 | $sth->execute(); |
633 | 633 | } catch(PDOException $e) { |
634 | 634 | return "error"; |
635 | 635 | } |
636 | - $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | - $j = 0; |
|
636 | + $query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN ('; |
|
637 | + $j = 0; |
|
638 | 638 | } |
639 | 639 | $query_delete .= "'".$row['fammarine_id']."',"; |
640 | 640 | } |
641 | 641 | if ($i > 0) { |
642 | - try { |
|
642 | + try { |
|
643 | 643 | |
644 | 644 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
645 | 645 | $sth->execute(); |
@@ -650,9 +650,9 @@ discard block |
||
650 | 650 | return "success"; |
651 | 651 | } elseif ($globalDBdriver == 'pgsql') { |
652 | 652 | //$query = "SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= marine_live.date AND marine_live.fammarine_id NOT IN (SELECT fammarine_id FROM marine_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < marine_live.date) LIMIT 800 OFFSET 0"; |
653 | - //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | - $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | - try { |
|
653 | + //$query = "SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0"; |
|
654 | + $query = "DELETE FROM marine_live WHERE fammarine_id IN (SELECT marine_live.fammarine_id FROM marine_live INNER JOIN (SELECT fammarine_id,MAX(date) as max_date FROM marine_live GROUP BY fammarine_id) s ON s.fammarine_id = marine_live.fammarine_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0)"; |
|
655 | + try { |
|
656 | 656 | |
657 | 657 | $sth = $this->db->prepare($query); |
658 | 658 | $sth->execute(); |
@@ -696,17 +696,17 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
699 | - * Deletes all info in the table for an ident |
|
700 | - * |
|
701 | - * @return String success or false |
|
702 | - * |
|
703 | - */ |
|
699 | + * Deletes all info in the table for an ident |
|
700 | + * |
|
701 | + * @return String success or false |
|
702 | + * |
|
703 | + */ |
|
704 | 704 | public function deleteLiveMarineDataByIdent($ident) |
705 | 705 | { |
706 | 706 | $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
707 | 707 | $query = 'DELETE FROM marine_live WHERE ident = :ident'; |
708 | 708 | |
709 | - try { |
|
709 | + try { |
|
710 | 710 | |
711 | 711 | $sth = $this->db->prepare($query); |
712 | 712 | $sth->execute(array(':ident' => $ident)); |
@@ -718,17 +718,17 @@ discard block |
||
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
721 | - * Deletes all info in the table for an id |
|
722 | - * |
|
723 | - * @return String success or false |
|
724 | - * |
|
725 | - */ |
|
721 | + * Deletes all info in the table for an id |
|
722 | + * |
|
723 | + * @return String success or false |
|
724 | + * |
|
725 | + */ |
|
726 | 726 | public function deleteLiveMarineDataById($id) |
727 | 727 | { |
728 | 728 | $id = filter_var($id, FILTER_SANITIZE_STRING); |
729 | 729 | $query = 'DELETE FROM marine_live WHERE fammarine_id = :id'; |
730 | 730 | |
731 | - try { |
|
731 | + try { |
|
732 | 732 | |
733 | 733 | $sth = $this->db->prepare($query); |
734 | 734 | $sth->execute(array(':id' => $id)); |
@@ -741,11 +741,11 @@ discard block |
||
741 | 741 | |
742 | 742 | |
743 | 743 | /** |
744 | - * Gets the aircraft ident within the last hour |
|
745 | - * |
|
746 | - * @return String the ident |
|
747 | - * |
|
748 | - */ |
|
744 | + * Gets the aircraft ident within the last hour |
|
745 | + * |
|
746 | + * @return String the ident |
|
747 | + * |
|
748 | + */ |
|
749 | 749 | public function getIdentFromLastHour($ident) |
750 | 750 | { |
751 | 751 | global $globalDBdriver, $globalTimezone; |
@@ -771,14 +771,14 @@ discard block |
||
771 | 771 | $ident_result = $row['ident']; |
772 | 772 | } |
773 | 773 | return $ident_result; |
774 | - } |
|
774 | + } |
|
775 | 775 | |
776 | 776 | /** |
777 | - * Check recent aircraft |
|
778 | - * |
|
779 | - * @return String the ident |
|
780 | - * |
|
781 | - */ |
|
777 | + * Check recent aircraft |
|
778 | + * |
|
779 | + * @return String the ident |
|
780 | + * |
|
781 | + */ |
|
782 | 782 | public function checkIdentRecent($ident) |
783 | 783 | { |
784 | 784 | global $globalDBdriver, $globalTimezone; |
@@ -804,14 +804,14 @@ discard block |
||
804 | 804 | $ident_result = $row['fammarine_id']; |
805 | 805 | } |
806 | 806 | return $ident_result; |
807 | - } |
|
807 | + } |
|
808 | 808 | |
809 | 809 | /** |
810 | - * Check recent aircraft by id |
|
811 | - * |
|
812 | - * @return String the ident |
|
813 | - * |
|
814 | - */ |
|
810 | + * Check recent aircraft by id |
|
811 | + * |
|
812 | + * @return String the ident |
|
813 | + * |
|
814 | + */ |
|
815 | 815 | public function checkIdRecent($id) |
816 | 816 | { |
817 | 817 | global $globalDBdriver, $globalTimezone; |
@@ -837,14 +837,14 @@ discard block |
||
837 | 837 | $ident_result = $row['fammarine_id']; |
838 | 838 | } |
839 | 839 | return $ident_result; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | 842 | /** |
843 | - * Check recent aircraft by mmsi |
|
844 | - * |
|
845 | - * @return String the ident |
|
846 | - * |
|
847 | - */ |
|
843 | + * Check recent aircraft by mmsi |
|
844 | + * |
|
845 | + * @return String the ident |
|
846 | + * |
|
847 | + */ |
|
848 | 848 | public function checkMMSIRecent($mmsi) |
849 | 849 | { |
850 | 850 | global $globalDBdriver, $globalTimezone; |
@@ -870,19 +870,19 @@ discard block |
||
870 | 870 | $ident_result = $row['fammarine_id']; |
871 | 871 | } |
872 | 872 | return $ident_result; |
873 | - } |
|
873 | + } |
|
874 | 874 | |
875 | 875 | /** |
876 | - * Adds a new spotter data |
|
877 | - * |
|
878 | - * @param String $fammarine_id the ID from flightaware |
|
879 | - * @param String $ident the flight ident |
|
880 | - * @param String $aircraft_icao the aircraft type |
|
881 | - * @param String $departure_airport_icao the departure airport |
|
882 | - * @param String $arrival_airport_icao the arrival airport |
|
883 | - * @return String success or false |
|
884 | - * |
|
885 | - */ |
|
876 | + * Adds a new spotter data |
|
877 | + * |
|
878 | + * @param String $fammarine_id the ID from flightaware |
|
879 | + * @param String $ident the flight ident |
|
880 | + * @param String $aircraft_icao the aircraft type |
|
881 | + * @param String $departure_airport_icao the departure airport |
|
882 | + * @param String $arrival_airport_icao the arrival airport |
|
883 | + * @return String success or false |
|
884 | + * |
|
885 | + */ |
|
886 | 886 | public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '') |
887 | 887 | { |
888 | 888 | global $globalURL, $globalArchive, $globalDebug; |
@@ -953,10 +953,10 @@ discard block |
||
953 | 953 | $arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING); |
954 | 954 | |
955 | 955 | |
956 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | - if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | - if ($arrival_date == '') $arrival_date = NULL; |
|
959 | - $query = ''; |
|
956 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0; |
|
957 | + if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0; |
|
958 | + if ($arrival_date == '') $arrival_date = NULL; |
|
959 | + $query = ''; |
|
960 | 960 | if ($globalArchive) { |
961 | 961 | if ($globalDebug) echo '-- Delete previous data -- '; |
962 | 962 | $query .= 'DELETE FROM marine_live WHERE fammarine_id = :fammarine_id;'; |
@@ -553,8 +553,8 @@ discard block |
||
553 | 553 | } |
554 | 554 | } |
555 | 555 | <?php |
556 | - } else { |
|
557 | - ?> |
|
556 | + } else { |
|
557 | + ?> |
|
558 | 558 | if (map.getZoom() > 7) { |
559 | 559 | var style = { |
560 | 560 | "color": "#1a3151", |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | layer_marine_data.addLayer(layer); |
574 | 574 | } |
575 | 575 | <?php |
576 | - } |
|
576 | + } |
|
577 | 577 | ?> |
578 | 578 | } |
579 | 579 | } |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | $( document ).ready(function() { |
599 | 599 | map.on('moveend', function() { |
600 | 600 | <?php |
601 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
601 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
602 | 602 | ?> |
603 | 603 | getLiveMarineData(1); |
604 | 604 | <?php |
605 | - } |
|
605 | + } |
|
606 | 606 | ?> |
607 | 607 | }); |
608 | 608 | //load the function on startup |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | var entityid = entity.id; |
39 | 39 | var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value; |
40 | 40 | <?php |
41 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
41 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
42 | 42 | ?> |
43 | 43 | if (lastupdateentity != lastupdatemarine) { |
44 | 44 | viewer.dataSources.get(dsn).entities.remove(entity); |
45 | 45 | czmldsmarine.entities.removeById(entityid); |
46 | 46 | } |
47 | 47 | <?php |
48 | - } else { |
|
48 | + } else { |
|
49 | 49 | ?> |
50 | 50 | if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
51 | 51 | viewer.dataSources.get(dsn).entities.remove(entity); |
52 | 52 | } |
53 | 53 | <?php |
54 | - } |
|
54 | + } |
|
55 | 55 | ?> |
56 | 56 | } |
57 | 57 | } |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | function updateMarineData() { |
74 | 74 | lastupdatemarine = Date.now(); |
75 | 75 | <?php |
76 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
76 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
77 | 77 | ?> |
78 | 78 | var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&coord='+bbox()+'&update=' + lastupdatemarine); |
79 | 79 | <?php |
80 | - } else { |
|
80 | + } else { |
|
81 | 81 | ?> |
82 | 82 | var livemarinedata = czmldsmarine.process('<?php print $globalURL; ?>/live-czml.php?marine&update=' + lastupdatemarine); |
83 | 83 | <?php |
84 | - } |
|
84 | + } |
|
85 | 85 | ?> |
86 | 86 | livemarinedata.then(function (data) { |
87 | 87 | displayMarineData(data); |
@@ -128,11 +128,11 @@ discard block |
||
128 | 128 | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
129 | 129 | camera.moveEnd.addEventListener(function() { |
130 | 130 | <?php |
131 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
131 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
132 | 132 | ?> |
133 | 133 | updateMarineData(); |
134 | 134 | <?php |
135 | - } |
|
135 | + } |
|
136 | 136 | ?> |
137 | 137 | }); |
138 | 138 |
@@ -81,21 +81,21 @@ discard block |
||
81 | 81 | var entityid = entity.id; |
82 | 82 | var lastupdateentity = entity.properties.valueOf('lastupdate')._lastupdate._value; |
83 | 83 | <?php |
84 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
84 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
85 | 85 | ?> |
86 | 86 | if (lastupdateentity != lastupdatetracker) { |
87 | 87 | viewer.dataSources.get(dsn).entities.remove(entity); |
88 | 88 | czmldstracker.entities.removeById(entityid); |
89 | 89 | } |
90 | 90 | <?php |
91 | - } else { |
|
91 | + } else { |
|
92 | 92 | ?> |
93 | 93 | if (parseInt(lastupdateentity) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) { |
94 | 94 | viewer.dataSources.get(dsn).entities.remove(entity); |
95 | 95 | czmldstracker.entities.removeById(entityid); |
96 | 96 | } |
97 | 97 | <?php |
98 | - } |
|
98 | + } |
|
99 | 99 | ?> |
100 | 100 | } |
101 | 101 | } |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | function updateTrackerData() { |
117 | 117 | lastupdatetracker = Date.now(); |
118 | 118 | <?php |
119 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
119 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
120 | 120 | ?> |
121 | 121 | var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&coord='+bbox()+'&update=' + lastupdatetracker); |
122 | 122 | <?php |
123 | - } else { |
|
123 | + } else { |
|
124 | 124 | ?> |
125 | 125 | var livetrackerdata = czmldstracker.process('<?php print $globalURL; ?>/live-czml.php?tracker&update=' + lastupdatetracker); |
126 | 126 | <?php |
127 | - } |
|
127 | + } |
|
128 | 128 | ?> |
129 | 129 | livetrackerdata.then(function (data) { |
130 | 130 | displayTrackerData(data); |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | }, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
172 | 172 | camera.moveEnd.addEventListener(function() { |
173 | 173 | <?php |
174 | - if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
174 | + if (isset($globalMapUseBbox) && $globalMapUseBbox) { |
|
175 | 175 | ?> |
176 | 176 | updateTrackerData(); |
177 | 177 | <?php |
178 | - } |
|
178 | + } |
|
179 | 179 | ?> |
180 | 180 | }); |
181 | 181 |
@@ -9,20 +9,20 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.GeoidHeight.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class SpotterImport { |
16 | - private $all_flights = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_flights = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid; |
27 | 27 | if (!(isset($globalNoDB) && $globalNoDB)) { |
28 | 28 | $Connection = new Connection($dbc); |
@@ -34,14 +34,14 @@ discard block |
||
34 | 34 | $currentdate = date('Y-m-d'); |
35 | 35 | $sourcestat = $Stats->getStatsSource($currentdate); |
36 | 36 | if (!empty($sourcestat)) { |
37 | - foreach($sourcestat as $srcst) { |
|
38 | - $type = $srcst['stats_type']; |
|
37 | + foreach($sourcestat as $srcst) { |
|
38 | + $type = $srcst['stats_type']; |
|
39 | 39 | if ($type == 'polar' || $type == 'hist') { |
40 | - $source = $srcst['source_name']; |
|
41 | - $data = $srcst['source_data']; |
|
42 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | - } |
|
44 | - } |
|
40 | + $source = $srcst['source_name']; |
|
41 | + $data = $srcst['source_data']; |
|
42 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | $GeoidClass = FALSE; |
57 | 57 | } |
58 | 58 | } |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - public function get_Schedule($id,$ident) { |
|
61 | + public function get_Schedule($id,$ident) { |
|
62 | 62 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
63 | 63 | // Get schedule here, so it's done only one time |
64 | 64 | |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | $operator = $Spotter->getOperator($ident); |
79 | 79 | $scheduleexist = false; |
80 | 80 | if ($Schedule->checkSchedule($operator) == 0) { |
81 | - $operator = $Translation->checkTranslation($ident); |
|
82 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
81 | + $operator = $Translation->checkTranslation($ident); |
|
82 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
83 | 83 | $schedule = $Schedule->fetchSchedule($operator); |
84 | 84 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
85 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | - // Should also check if route schedule = route from DB |
|
89 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
85 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
86 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
87 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
88 | + // Should also check if route schedule = route from DB |
|
89 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
90 | 90 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
91 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | - if (trim($airport_icao) != '') { |
|
91 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
92 | + if (trim($airport_icao) != '') { |
|
93 | 93 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
94 | 94 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
95 | - } |
|
95 | + } |
|
96 | + } |
|
96 | 97 | } |
97 | - } |
|
98 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
98 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
99 | 99 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
100 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | - if (trim($airport_icao) != '') { |
|
100 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
101 | + if (trim($airport_icao) != '') { |
|
102 | 102 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
103 | 103 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
104 | - } |
|
104 | + } |
|
105 | 105 | } |
106 | - } |
|
107 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
106 | + } |
|
107 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
108 | 108 | } |
109 | - } else $scheduleexist = true; |
|
109 | + } else $scheduleexist = true; |
|
110 | 110 | } else $scheduleexist = true; |
111 | 111 | // close connection, at least one way will work ? |
112 | - if ($scheduleexist) { |
|
112 | + if ($scheduleexist) { |
|
113 | 113 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
114 | - $sch = $Schedule->getSchedule($operator); |
|
114 | + $sch = $Schedule->getSchedule($operator); |
|
115 | 115 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
116 | - } |
|
116 | + } |
|
117 | 117 | $Spotter->db = null; |
118 | 118 | $Schedule->db = null; |
119 | 119 | $Translation->db = null; |
@@ -128,78 +128,78 @@ discard block |
||
128 | 128 | } |
129 | 129 | */ |
130 | 130 | } |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - public function checkAll() { |
|
133 | + public function checkAll() { |
|
134 | 134 | global $globalDebug, $globalNoImport; |
135 | 135 | if ($globalDebug) echo "Update last seen flights data...\n"; |
136 | 136 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
137 | - foreach ($this->all_flights as $key => $flight) { |
|
137 | + foreach ($this->all_flights as $key => $flight) { |
|
138 | 138 | if (isset($this->all_flights[$key]['id'])) { |
139 | - //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | - $Spotter = new Spotter($this->db); |
|
141 | - $real_arrival = $this->arrival($key); |
|
142 | - if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | - } |
|
144 | - } |
|
139 | + //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
|
140 | + $Spotter = new Spotter($this->db); |
|
141 | + $real_arrival = $this->arrival($key); |
|
142 | + if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
145 | 146 | } |
146 | - } |
|
147 | 147 | |
148 | - public function arrival($key) { |
|
148 | + public function arrival($key) { |
|
149 | 149 | global $globalClosestMinDist, $globalDebug; |
150 | 150 | if ($globalDebug) echo 'Update arrival...'."\n"; |
151 | 151 | $Spotter = new Spotter($this->db); |
152 | - $airport_icao = ''; |
|
153 | - $airport_time = ''; |
|
154 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
152 | + $airport_icao = ''; |
|
153 | + $airport_time = ''; |
|
154 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
155 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
156 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | - if (isset($closestAirports[0])) { |
|
158 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | - $airport_icao = $closestAirports[0]['icao']; |
|
160 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | - foreach ($closestAirports as $airport) { |
|
164 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | - $airport_icao = $airport['icao']; |
|
166 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | - break; |
|
169 | - } |
|
170 | - } |
|
171 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | - $airport_icao = $closestAirports[0]['icao']; |
|
173 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | - } else { |
|
175 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | - } |
|
177 | - } else { |
|
178 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | - } |
|
156 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
157 | + if (isset($closestAirports[0])) { |
|
158 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
159 | + $airport_icao = $closestAirports[0]['icao']; |
|
160 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
161 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
162 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
163 | + foreach ($closestAirports as $airport) { |
|
164 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
165 | + $airport_icao = $airport['icao']; |
|
166 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
167 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
168 | + break; |
|
169 | + } |
|
170 | + } |
|
171 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
172 | + $airport_icao = $closestAirports[0]['icao']; |
|
173 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
174 | + } else { |
|
175 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
176 | + } |
|
177 | + } else { |
|
178 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
179 | + } |
|
180 | 180 | |
181 | - } else { |
|
182 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | - } |
|
184 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | - } |
|
181 | + } else { |
|
182 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
183 | + } |
|
184 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
185 | + } |
|
186 | 186 | |
187 | 187 | |
188 | 188 | |
189 | - public function del() { |
|
189 | + public function del() { |
|
190 | 190 | global $globalDebug, $globalNoImport, $globalNoDB; |
191 | 191 | // Delete old infos |
192 | 192 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
193 | 193 | foreach ($this->all_flights as $key => $flight) { |
194 | - if (isset($flight['lastupdate'])) { |
|
194 | + if (isset($flight['lastupdate'])) { |
|
195 | 195 | if ($flight['lastupdate'] < (time()-5900)) { |
196 | - $this->delKey($key); |
|
196 | + $this->delKey($key); |
|
197 | 197 | } |
198 | - } |
|
198 | + } |
|
199 | + } |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - public function delKey($key) { |
|
202 | + public function delKey($key) { |
|
203 | 203 | global $globalDebug, $globalNoImport, $globalNoDB; |
204 | 204 | // Delete old infos |
205 | 205 | if (isset($this->all_flights[$key]['id'])) { |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | unset($this->all_flights[$key]); |
217 | - } |
|
217 | + } |
|
218 | 218 | |
219 | - public function add($line) { |
|
219 | + public function add($line) { |
|
220 | 220 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass; |
221 | 221 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
222 | 222 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01'; |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | |
243 | 243 | // SBS format is CSV format |
244 | 244 | if(is_array($line) && (isset($line['hex']) || isset($line['id']))) { |
245 | - //print_r($line); |
|
246 | - if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
245 | + //print_r($line); |
|
246 | + if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']); |
|
247 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
248 | 248 | |
249 | 249 | // Increment message number |
250 | 250 | if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) { |
251 | - $current_date = date('Y-m-d'); |
|
252 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | - else $source = ''; |
|
254 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
251 | + $current_date = date('Y-m-d'); |
|
252 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
253 | + else $source = ''; |
|
254 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
255 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
256 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
257 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
258 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /* |
@@ -271,54 +271,54 @@ discard block |
||
271 | 271 | //$this->db = $dbc; |
272 | 272 | |
273 | 273 | //$hex = trim($line['hex']); |
274 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | - else $id = trim($line['id']); |
|
274 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
275 | + else $id = trim($line['id']); |
|
276 | 276 | |
277 | 277 | if (!isset($this->all_flights[$id])) { |
278 | - if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | - $this->all_flights[$id] = array(); |
|
280 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | - if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | - if (!isset($line['id'])) { |
|
278 | + if ($globalDebug) echo 'New flight...'."\n"; |
|
279 | + $this->all_flights[$id] = array(); |
|
280 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
281 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => '')); |
|
282 | + if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
283 | + if (!isset($line['id'])) { |
|
284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
285 | 285 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
286 | 286 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
287 | 287 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
288 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
288 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
289 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
290 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
291 | 291 | } |
292 | 292 | if (isset($line['source_type']) && $line['source_type'] != '') { |
293 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
293 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type'])); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | //print_r($this->all_flights); |
297 | 297 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
298 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
298 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
299 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
300 | 300 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
301 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
301 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
302 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
303 | 303 | $timeelapsed = microtime(true); |
304 | 304 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
305 | - $Spotter = new Spotter($this->db); |
|
306 | - if (isset($this->all_flights[$id]['source_type'])) { |
|
305 | + $Spotter = new Spotter($this->db); |
|
306 | + if (isset($this->all_flights[$id]['source_type'])) { |
|
307 | 307 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']); |
308 | - } else { |
|
308 | + } else { |
|
309 | 309 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
310 | - } |
|
311 | - $Spotter->db = null; |
|
312 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
310 | + } |
|
311 | + $Spotter->db = null; |
|
312 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
313 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
314 | 314 | } |
315 | - } |
|
316 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
315 | + } |
|
316 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
317 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
318 | 318 | } |
319 | - if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | - } |
|
319 | + if (isset($line['id']) && !isset($line['hex'])) { |
|
320 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => '')); |
|
321 | + } |
|
322 | 322 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
323 | 323 | $icao = $line['aircraft_icao']; |
324 | 324 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
@@ -349,9 +349,9 @@ discard block |
||
349 | 349 | } |
350 | 350 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
351 | 351 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) { |
352 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
352 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
353 | 353 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
356 | 356 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
357 | 357 | /* |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | print_r($line); |
361 | 361 | */ |
362 | 362 | return ''; |
363 | - } |
|
363 | + } |
|
364 | 364 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) { |
365 | 365 | if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n"; |
366 | 366 | return ''; |
@@ -376,21 +376,21 @@ discard block |
||
376 | 376 | } |
377 | 377 | |
378 | 378 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
379 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
379 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
380 | 380 | } |
381 | 381 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
382 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
382 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
383 | 383 | } |
384 | 384 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
385 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
385 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id']))); |
|
386 | 386 | } |
387 | 387 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
388 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
388 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name']))); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
392 | 392 | |
393 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
393 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
394 | 394 | if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
395 | 395 | if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n"; |
396 | 396 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -399,23 +399,23 @@ discard block |
||
399 | 399 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
400 | 400 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
401 | 401 | } else { |
402 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
402 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
403 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
404 | 404 | $timeelapsed = microtime(true); |
405 | - $Spotter = new Spotter($this->db); |
|
406 | - $fromsource = NULL; |
|
407 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
405 | + $Spotter = new Spotter($this->db); |
|
406 | + $fromsource = NULL; |
|
407 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
408 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
409 | 409 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
410 | 410 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
411 | 411 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
412 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
412 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
413 | 413 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
414 | 414 | $Spotter->db = null; |
415 | 415 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
416 | - } |
|
416 | + } |
|
417 | 417 | } |
418 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
418 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
419 | 419 | |
420 | 420 | /* |
421 | 421 | if (!isset($line['id'])) { |
@@ -425,63 +425,63 @@ discard block |
||
425 | 425 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
426 | 426 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
427 | 427 | */ |
428 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
428 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
429 | 429 | |
430 | - //$putinarchive = true; |
|
431 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
430 | + //$putinarchive = true; |
|
431 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
432 | 432 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
433 | - } |
|
434 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
433 | + } |
|
434 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
435 | 435 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
436 | - } |
|
437 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
439 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
436 | + } |
|
437 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
438 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
439 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
440 | 440 | $timeelapsed = microtime(true); |
441 | 441 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
442 | 442 | $Spotter = new Spotter($this->db); |
443 | 443 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
444 | 444 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
445 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
445 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
446 | 446 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
447 | - } |
|
448 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
447 | + } |
|
448 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
449 | 449 | $timeelapsed = microtime(true); |
450 | 450 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
451 | - $Spotter = new Spotter($this->db); |
|
452 | - $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | - if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
451 | + $Spotter = new Spotter($this->db); |
|
452 | + $route = $Spotter->getRouteInfo(trim($line['ident'])); |
|
453 | + if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) { |
|
454 | 454 | $Translation = new Translation($this->db); |
455 | 455 | $ident = $Translation->checkTranslation(trim($line['ident'])); |
456 | 456 | $route = $Spotter->getRouteInfo($ident); |
457 | 457 | $Translation->db = null; |
458 | - } |
|
459 | - $Spotter->db = null; |
|
460 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | - } |
|
458 | + } |
|
459 | + $Spotter->db = null; |
|
460 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
461 | + } |
|
462 | 462 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
463 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
463 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
464 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
465 | 465 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
466 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
467 | - } |
|
466 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
467 | + } |
|
468 | 468 | } |
469 | 469 | if (!isset($globalFork)) $globalFork = TRUE; |
470 | 470 | if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
471 | 471 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
472 | 472 | } |
473 | - } |
|
473 | + } |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) { |
477 | 477 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
478 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | - //$dataFound = true; |
|
478 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
479 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
480 | + //$dataFound = true; |
|
481 | 481 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
482 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | - if ($distance > 1000 && $distance < 10000) { |
|
484 | - // use datetime |
|
482 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
483 | + if ($distance > 1000 && $distance < 10000) { |
|
484 | + // use datetime |
|
485 | 485 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
486 | 486 | $speed = $speed*3.6; |
487 | 487 | if ($speed < 1000) { |
@@ -490,48 +490,48 @@ discard block |
||
490 | 490 | } else { |
491 | 491 | if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n"; |
492 | 492 | } |
493 | - } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
497 | 497 | |
498 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | - if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | - if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | - return false; |
|
502 | - } |
|
503 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | - else unset($timediff); |
|
505 | - if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | - else unset($timediff_archive); |
|
507 | - if ($this->tmd > 5 |
|
508 | - || (isset($line['format_source']) |
|
509 | - && $line['format_source'] == 'airwhere' |
|
510 | - && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | - || !isset($this->all_flights[$id]['longitude'])) |
|
512 | - || (isset($this->all_flights[$id]['latitude']) |
|
513 | - && isset($this->all_flights[$id]['longitude']) |
|
514 | - && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | - && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | - ) |
|
517 | - ) |
|
518 | - ) |
|
519 | - || (isset($globalVA) && $globalVA) |
|
520 | - || (isset($globalIVAO) && $globalIVAO) |
|
521 | - || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | - || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | - || (isset($globalVAM) && $globalVAM) |
|
524 | - || !isset($timediff) |
|
525 | - || $timediff > $globalLiveInterval |
|
526 | - || ($timediff > 30 |
|
527 | - && isset($this->all_flights[$id]['latitude']) |
|
528 | - && isset($this->all_flights[$id]['longitude']) |
|
529 | - && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
530 | - ) |
|
531 | - ) { |
|
498 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
499 | + if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) { |
|
500 | + if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n"; |
|
501 | + return false; |
|
502 | + } |
|
503 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
504 | + else unset($timediff); |
|
505 | + if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']); |
|
506 | + else unset($timediff_archive); |
|
507 | + if ($this->tmd > 5 |
|
508 | + || (isset($line['format_source']) |
|
509 | + && $line['format_source'] == 'airwhere' |
|
510 | + && ((!isset($this->all_flights[$id]['latitude']) |
|
511 | + || !isset($this->all_flights[$id]['longitude'])) |
|
512 | + || (isset($this->all_flights[$id]['latitude']) |
|
513 | + && isset($this->all_flights[$id]['longitude']) |
|
514 | + && $this->all_flights[$id]['latitude'] != $line['latitude'] |
|
515 | + && $this->all_flights[$id]['longitude'] != $line['longitude'] |
|
516 | + ) |
|
517 | + ) |
|
518 | + ) |
|
519 | + || (isset($globalVA) && $globalVA) |
|
520 | + || (isset($globalIVAO) && $globalIVAO) |
|
521 | + || (isset($globalVATSIM) && $globalVATSIM) |
|
522 | + || (isset($globalphpVMS) && $globalphpVMS) |
|
523 | + || (isset($globalVAM) && $globalVAM) |
|
524 | + || !isset($timediff) |
|
525 | + || $timediff > $globalLiveInterval |
|
526 | + || ($timediff > 30 |
|
527 | + && isset($this->all_flights[$id]['latitude']) |
|
528 | + && isset($this->all_flights[$id]['longitude']) |
|
529 | + && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')) |
|
530 | + ) |
|
531 | + ) { |
|
532 | 532 | |
533 | 533 | if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) { |
534 | - if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
534 | + if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate) |
|
535 | 535 | || (isset($line['format_source']) && $line['format_source'] == 'airwhere') |
536 | 536 | || !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
537 | 537 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -539,9 +539,9 @@ discard block |
||
539 | 539 | $this->all_flights[$id]['putinarchive'] = true; |
540 | 540 | $this->tmd = 0; |
541 | 541 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
542 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
543 | - $timeelapsed = microtime(true); |
|
544 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
542 | + if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
543 | + $timeelapsed = microtime(true); |
|
544 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
545 | 545 | $Spotter = new Spotter($this->db); |
546 | 546 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
547 | 547 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | $Spotter->db = null; |
550 | 550 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
551 | 551 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
552 | - } |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | $this->all_flights[$id]['time_last_archive_coord'] = time(); |
555 | - } |
|
556 | - /* |
|
555 | + } |
|
556 | + /* |
|
557 | 557 | else { |
558 | 558 | if (!isset($timediff)) echo 'NO TIMEDIFF'; |
559 | 559 | else { |
@@ -567,16 +567,16 @@ discard block |
||
567 | 567 | } |
568 | 568 | |
569 | 569 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
570 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
570 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
571 | 571 | if (!isset($this->all_flights[$id]['archive_latitude'])) { |
572 | 572 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
573 | 573 | $this->all_flights[$id]['time_last_coord'] = time(); |
574 | 574 | } |
575 | 575 | //if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
576 | 576 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) { |
577 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
578 | - $dataFound = true; |
|
579 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
577 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
578 | + $dataFound = true; |
|
579 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
580 | 580 | } |
581 | 581 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
582 | 582 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -587,24 +587,24 @@ discard block |
||
587 | 587 | //$putinarchive = true; |
588 | 588 | } |
589 | 589 | */ |
590 | - /* |
|
590 | + /* |
|
591 | 591 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
592 | 592 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
593 | 593 | } |
594 | 594 | */ |
595 | 595 | } |
596 | 596 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
597 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
598 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
597 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
598 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
599 | 599 | if (!isset($this->all_flights[$id]['archive_longitude'])) { |
600 | 600 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
601 | 601 | $this->all_flights[$id]['time_last_coord'] = time(); |
602 | 602 | } |
603 | 603 | //if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
604 | 604 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) { |
605 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
606 | - $dataFound = true; |
|
607 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
605 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
606 | + $dataFound = true; |
|
607 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
608 | 608 | } |
609 | 609 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
610 | 610 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -622,67 +622,67 @@ discard block |
||
622 | 622 | */ |
623 | 623 | } |
624 | 624 | |
625 | - } else if ($globalDebug && $timediff > 30) { |
|
625 | + } else if ($globalDebug && $timediff > 30) { |
|
626 | 626 | $this->tmd = $this->tmd + 1; |
627 | 627 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
628 | 628 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
629 | 629 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
630 | 630 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
631 | - } |
|
631 | + } |
|
632 | 632 | } |
633 | 633 | if (isset($line['last_update']) && $line['last_update'] != '') { |
634 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
635 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
634 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
635 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
636 | 636 | } |
637 | 637 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
638 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
639 | - //$dataFound = true; |
|
638 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
639 | + //$dataFound = true; |
|
640 | 640 | } |
641 | 641 | if (isset($line['format_source']) && $line['format_source'] != '') { |
642 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
642 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
643 | 643 | } |
644 | 644 | if (isset($line['source_name']) && $line['source_name'] != '') { |
645 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
645 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
646 | 646 | } |
647 | 647 | if (isset($line['emergency']) && $line['emergency'] != '') { |
648 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
649 | - //$dataFound = true; |
|
648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
649 | + //$dataFound = true; |
|
650 | 650 | } |
651 | 651 | if (isset($line['ground']) && $line['ground'] != '') { |
652 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
652 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
653 | 653 | // Here we force archive of flight because after ground it's a new one (or should be) |
654 | 654 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
655 | 655 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
656 | 656 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
657 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
657 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
658 | 658 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
659 | - } |
|
660 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
662 | - //$dataFound = true; |
|
659 | + } |
|
660 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
661 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
662 | + //$dataFound = true; |
|
663 | 663 | } |
664 | 664 | if (isset($line['squawk']) && $line['squawk'] != '') { |
665 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
667 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
668 | - $highlight = ''; |
|
669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
672 | - if ($highlight != '') { |
|
665 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
666 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
667 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
668 | + $highlight = ''; |
|
669 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
670 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
671 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
672 | + if ($highlight != '') { |
|
673 | 673 | $timeelapsed = microtime(true); |
674 | 674 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
675 | - $Spotter = new Spotter($this->db); |
|
676 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
677 | - $Spotter->db = null; |
|
678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
675 | + $Spotter = new Spotter($this->db); |
|
676 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
677 | + $Spotter->db = null; |
|
678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
679 | 679 | } |
680 | 680 | //$putinarchive = true; |
681 | 681 | //$highlight = ''; |
682 | - } |
|
682 | + } |
|
683 | 683 | |
684 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
685 | - //$dataFound = true; |
|
684 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
685 | + //$dataFound = true; |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | if (isset($line['altitude']) && $line['altitude'] != '') { |
@@ -693,13 +693,13 @@ discard block |
||
693 | 693 | $line['altitude'] = $line['altitude'] - $geoid; |
694 | 694 | } |
695 | 695 | } |
696 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
696 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
697 | 697 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
698 | 698 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
699 | 699 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
700 | 700 | //$dataFound = true; |
701 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702 | - if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
701 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
702 | + if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) { |
|
703 | 703 | if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) { |
704 | 704 | if ($globalDebug) echo '--- Reset because of altitude'."\n"; |
705 | 705 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
@@ -708,27 +708,27 @@ discard block |
||
708 | 708 | elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
709 | 709 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
710 | 710 | } |
711 | - } |
|
712 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
711 | + } |
|
712 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude'])); |
|
713 | 713 | } |
714 | 714 | |
715 | 715 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
716 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
716 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | if (isset($line['heading']) && $line['heading'] != '') { |
720 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
723 | - //$dataFound = true; |
|
720 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
721 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
722 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
723 | + //$dataFound = true; |
|
724 | 724 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
725 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
725 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
726 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
727 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
728 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
729 | 729 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
730 | - // If not enough messages and ACARS set heading to 0 |
|
731 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
730 | + // If not enough messages and ACARS set heading to 0 |
|
731 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
732 | 732 | } |
733 | 733 | if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
734 | 734 | elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -741,125 +741,125 @@ discard block |
||
741 | 741 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
742 | 742 | //if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
743 | 743 | if ($dataFound === true && isset($this->all_flights[$id]['id'])) { |
744 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
745 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
746 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | - //print_r($this->all_flights); |
|
748 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
749 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
750 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
744 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
745 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) { |
|
746 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
747 | + //print_r($this->all_flights); |
|
748 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
749 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
750 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
751 | 751 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
752 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
753 | - $timeelapsed = microtime(true); |
|
754 | - $SpotterLive = new SpotterLive($this->db); |
|
755 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
752 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
753 | + $timeelapsed = microtime(true); |
|
754 | + $SpotterLive = new SpotterLive($this->db); |
|
755 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) { |
|
756 | 756 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
757 | 757 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
758 | - } elseif (isset($line['id'])) { |
|
758 | + } elseif (isset($line['id'])) { |
|
759 | 759 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
760 | 760 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
761 | - } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
761 | + } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
|
762 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
763 | 763 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
764 | - } else $recent_ident = ''; |
|
765 | - $SpotterLive->db=null; |
|
766 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
764 | + } else $recent_ident = ''; |
|
765 | + $SpotterLive->db=null; |
|
766 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
767 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
768 | 768 | } else $recent_ident = ''; |
769 | - } else { |
|
769 | + } else { |
|
770 | 770 | $recent_ident = ''; |
771 | 771 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
772 | - } |
|
773 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774 | - if($recent_ident == "") |
|
775 | - { |
|
772 | + } |
|
773 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
774 | + if($recent_ident == "") |
|
775 | + { |
|
776 | 776 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
777 | 777 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
778 | 778 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
779 | 779 | //adds the spotter data for the archive |
780 | 780 | $ignoreImport = false; |
781 | 781 | foreach($globalAirportIgnore as $airportIgnore) { |
782 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
782 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
783 | 783 | $ignoreImport = true; |
784 | - } |
|
784 | + } |
|
785 | 785 | } |
786 | 786 | if (count($globalAirportAccept) > 0) { |
787 | - $ignoreImport = true; |
|
788 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
787 | + $ignoreImport = true; |
|
788 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
789 | 789 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
790 | - $ignoreImport = false; |
|
790 | + $ignoreImport = false; |
|
791 | + } |
|
791 | 792 | } |
792 | - } |
|
793 | 793 | } |
794 | 794 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
795 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
795 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
796 | 796 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
797 | - $ignoreImport = true; |
|
797 | + $ignoreImport = true; |
|
798 | + } |
|
798 | 799 | } |
799 | - } |
|
800 | 800 | } |
801 | 801 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
802 | - $ignoreImport = true; |
|
803 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
802 | + $ignoreImport = true; |
|
803 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
804 | 804 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
805 | - $ignoreImport = false; |
|
805 | + $ignoreImport = false; |
|
806 | + } |
|
806 | 807 | } |
807 | - } |
|
808 | 808 | } |
809 | 809 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
810 | - $ignoreImport = true; |
|
811 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
810 | + $ignoreImport = true; |
|
811 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
812 | 812 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
813 | - $ignoreImport = false; |
|
813 | + $ignoreImport = false; |
|
814 | + } |
|
814 | 815 | } |
815 | - } |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | if (!$ignoreImport) { |
819 | - $highlight = ''; |
|
820 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | - $timeelapsed = microtime(true); |
|
825 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
819 | + $highlight = ''; |
|
820 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
821 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
822 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
823 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
824 | + $timeelapsed = microtime(true); |
|
825 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
826 | 826 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
827 | - $Spotter = new Spotter($this->db); |
|
828 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
829 | - $Spotter->db = null; |
|
830 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
827 | + $Spotter = new Spotter($this->db); |
|
828 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']); |
|
829 | + $Spotter->db = null; |
|
830 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
831 | 831 | } |
832 | - } |
|
833 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
834 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
832 | + } |
|
833 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
834 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
835 | 835 | |
836 | - // Add source stat in DB |
|
837 | - $Stats = new Stats($this->db); |
|
838 | - if (!empty($this->stats)) { |
|
836 | + // Add source stat in DB |
|
837 | + $Stats = new Stats($this->db); |
|
838 | + if (!empty($this->stats)) { |
|
839 | 839 | if ($globalDebug) echo 'Add source stats : '; |
840 | - foreach($this->stats as $date => $data) { |
|
841 | - foreach($data as $source => $sourced) { |
|
842 | - //print_r($sourced); |
|
843 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
845 | - if (isset($sourced['msg'])) { |
|
846 | - if (time() - $sourced['msg']['date'] > 10) { |
|
847 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
848 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
849 | - unset($this->stats[$date][$source]['msg']); |
|
850 | - } |
|
851 | - } |
|
852 | - } |
|
853 | - if ($date != date('Y-m-d')) { |
|
854 | - unset($this->stats[$date]); |
|
855 | - } |
|
856 | - } |
|
857 | - if ($globalDebug) echo 'Done'."\n"; |
|
840 | + foreach($this->stats as $date => $data) { |
|
841 | + foreach($data as $source => $sourced) { |
|
842 | + //print_r($sourced); |
|
843 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
844 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
845 | + if (isset($sourced['msg'])) { |
|
846 | + if (time() - $sourced['msg']['date'] > 10) { |
|
847 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
848 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
849 | + unset($this->stats[$date][$source]['msg']); |
|
850 | + } |
|
851 | + } |
|
852 | + } |
|
853 | + if ($date != date('Y-m-d')) { |
|
854 | + unset($this->stats[$date]); |
|
855 | + } |
|
856 | + } |
|
857 | + if ($globalDebug) echo 'Done'."\n"; |
|
858 | 858 | |
859 | - } |
|
860 | - $Stats->db = null; |
|
861 | - } |
|
862 | - $this->del(); |
|
859 | + } |
|
860 | + $Stats->db = null; |
|
861 | + } |
|
862 | + $this->del(); |
|
863 | 863 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
864 | 864 | //$ignoreImport = false; |
865 | 865 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -877,41 +877,41 @@ discard block |
||
877 | 877 | */ |
878 | 878 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
879 | 879 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
880 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
881 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
882 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
880 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
881 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
882 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
883 | 883 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
884 | - $SpotterLive = new SpotterLive($this->db); |
|
885 | - $SpotterLive->deleteLiveSpotterData(); |
|
886 | - $SpotterLive->db=null; |
|
884 | + $SpotterLive = new SpotterLive($this->db); |
|
885 | + $SpotterLive->deleteLiveSpotterData(); |
|
886 | + $SpotterLive->db=null; |
|
887 | 887 | } |
888 | - } |
|
889 | - if ($globalDebug) echo " Done\n"; |
|
890 | - $this->last_delete = time(); |
|
888 | + } |
|
889 | + if ($globalDebug) echo " Done\n"; |
|
890 | + $this->last_delete = time(); |
|
891 | 891 | } |
892 | - } else { |
|
892 | + } else { |
|
893 | 893 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) { |
894 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
895 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
894 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
895 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
896 | 896 | } |
897 | 897 | if (isset($globalDaemon) && !$globalDaemon) { |
898 | - if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
898 | + if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
|
899 | 899 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
900 | - $Spotter = new Spotter($this->db); |
|
901 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
902 | - $Spotter->db = null; |
|
900 | + $Spotter = new Spotter($this->db); |
|
901 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
902 | + $Spotter->db = null; |
|
903 | + } |
|
903 | 904 | } |
904 | - } |
|
905 | 905 | } |
906 | 906 | |
907 | - } |
|
907 | + } |
|
908 | 908 | } |
909 | - } |
|
910 | - //adds the spotter LIVE data |
|
911 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
912 | - //echo "\nAdd in Live !! \n"; |
|
913 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
914 | - if ($globalDebug) { |
|
909 | + } |
|
910 | + //adds the spotter LIVE data |
|
911 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
912 | + //echo "\nAdd in Live !! \n"; |
|
913 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
914 | + if ($globalDebug) { |
|
915 | 915 | if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
916 | 916 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
917 | 917 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -919,60 +919,60 @@ discard block |
||
919 | 919 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
920 | 920 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
921 | 921 | } |
922 | - } |
|
923 | - $ignoreImport = false; |
|
924 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
925 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
922 | + } |
|
923 | + $ignoreImport = false; |
|
924 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
925 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
926 | 926 | |
927 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
928 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
929 | - $ignoreImport = true; |
|
927 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
928 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
929 | + $ignoreImport = true; |
|
930 | + } |
|
930 | 931 | } |
931 | - } |
|
932 | - if (count($globalAirportAccept) > 0) { |
|
933 | - $ignoreImport = true; |
|
934 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
935 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
932 | + if (count($globalAirportAccept) > 0) { |
|
933 | + $ignoreImport = true; |
|
934 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
935 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
936 | 936 | $ignoreImport = false; |
937 | - } |
|
937 | + } |
|
938 | 938 | } |
939 | - } |
|
940 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
939 | + } |
|
940 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
941 | 941 | foreach($globalAirlineIgnore as $airlineIgnore) { |
942 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
942 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
943 | 943 | $ignoreImport = true; |
944 | - } |
|
944 | + } |
|
945 | 945 | } |
946 | - } |
|
947 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
946 | + } |
|
947 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
948 | 948 | $ignoreImport = true; |
949 | 949 | foreach($globalAirlineAccept as $airlineAccept) { |
950 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
950 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
951 | 951 | $ignoreImport = false; |
952 | - } |
|
952 | + } |
|
953 | + } |
|
953 | 954 | } |
954 | - } |
|
955 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
955 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
956 | 956 | $ignoreImport = true; |
957 | 957 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
958 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
959 | - $ignoreImport = false; |
|
960 | - } |
|
958 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
959 | + $ignoreImport = false; |
|
960 | + } |
|
961 | + } |
|
961 | 962 | } |
962 | - } |
|
963 | 963 | |
964 | - if (!$ignoreImport) { |
|
964 | + if (!$ignoreImport) { |
|
965 | 965 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
966 | 966 | if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
967 | 967 | $timeelapsed = microtime(true); |
968 | 968 | if (!isset($globalNoImport) || $globalNoImport === FALSE) { |
969 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
969 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
970 | 970 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
971 | 971 | $SpotterLive = new SpotterLive($this->db); |
972 | 972 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
973 | 973 | $SpotterLive->db = null; |
974 | 974 | if ($globalDebug) echo $result."\n"; |
975 | - } |
|
975 | + } |
|
976 | 976 | } |
977 | 977 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) { |
978 | 978 | $APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
@@ -984,7 +984,7 @@ discard block |
||
984 | 984 | //if ($line['format_source'] != 'aprs') { |
985 | 985 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
986 | 986 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
987 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
987 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
|
988 | 988 | $source = $this->all_flights[$id]['source_name']; |
989 | 989 | if ($source == '') $source = $this->all_flights[$id]['format_source']; |
990 | 990 | if (!isset($this->source_location[$source])) { |
@@ -1010,7 +1010,7 @@ discard block |
||
1010 | 1010 | if ($stats_heading == 16) $stats_heading = 0; |
1011 | 1011 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
1012 | 1012 | for ($i=0;$i<=15;$i++) { |
1013 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1013 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
1014 | 1014 | } |
1015 | 1015 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
1016 | 1016 | } else { |
@@ -1023,17 +1023,17 @@ discard block |
||
1023 | 1023 | //var_dump($this->stats); |
1024 | 1024 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
1025 | 1025 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
1026 | - end($this->stats[$current_date][$source]['hist']); |
|
1027 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1026 | + end($this->stats[$current_date][$source]['hist']); |
|
1027 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
1028 | 1028 | } else $mini = 0; |
1029 | 1029 | for ($i=$mini;$i<=$distance;$i+=10) { |
1030 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1030 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
1031 | 1031 | } |
1032 | 1032 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
1033 | 1033 | } else { |
1034 | 1034 | $this->stats[$current_date][$source]['hist'][$distance] += 1; |
1035 | 1035 | } |
1036 | - } |
|
1036 | + } |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | $this->all_flights[$id]['lastupdate'] = time(); |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | //$this->del(); |
1044 | 1044 | |
1045 | 1045 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
1046 | - if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1046 | + if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
1047 | 1047 | if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
1048 | 1048 | $SpotterLive = new SpotterLive($this->db); |
1049 | 1049 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
@@ -1051,19 +1051,19 @@ discard block |
||
1051 | 1051 | //SpotterLive->deleteLiveSpotterData(); |
1052 | 1052 | if ($globalDebug) echo " Done\n"; |
1053 | 1053 | $this->last_delete_hourly = time(); |
1054 | - } else { |
|
1054 | + } else { |
|
1055 | 1055 | $this->del(); |
1056 | 1056 | $this->last_delete_hourly = time(); |
1057 | - } |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | - } |
|
1061 | - //$ignoreImport = false; |
|
1060 | + } |
|
1061 | + //$ignoreImport = false; |
|
1062 | 1062 | } |
1063 | 1063 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
1064 | 1064 | if ($send) return $this->all_flights[$id]; |
1065 | - } |
|
1065 | + } |
|
1066 | + } |
|
1066 | 1067 | } |
1067 | - } |
|
1068 | 1068 | } |
1069 | 1069 | ?> |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | foreach($spotter_array as $spotter_item) |
22 | 22 | { |
23 | 23 | $output .= '<url>'; |
24 | - $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>'; |
|
25 | - $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
26 | - $output .= '<changefreq>weekly</changefreq>'; |
|
24 | + $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/flightid/'.$spotter_item['spotter_id'].'</loc>'; |
|
25 | + $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
26 | + $output .= '<changefreq>weekly</changefreq>'; |
|
27 | 27 | $output .= '</url>'; |
28 | 28 | } |
29 | 29 | $output .= '</urlset>'; |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | foreach($aircraft_types as $aircraft_item) |
39 | 39 | { |
40 | 40 | $output .= '<url>'; |
41 | - $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.urlencode($aircraft_item['aircraft_icao']).'</loc>'; |
|
42 | - $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
43 | - $output .= '<changefreq>daily</changefreq>'; |
|
41 | + $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/aircraft/'.urlencode($aircraft_item['aircraft_icao']).'</loc>'; |
|
42 | + $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
43 | + $output .= '<changefreq>daily</changefreq>'; |
|
44 | 44 | $output .= '</url>'; |
45 | 45 | } |
46 | 46 | $output .= '</urlset>'; |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | foreach($aircraft_registrations as $aircraft_item) |
56 | 56 | { |
57 | 57 | $output .= '<url>'; |
58 | - $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.urlencode($aircraft_item['registration']).'</loc>'; |
|
59 | - $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
60 | - $output .= '<changefreq>daily</changefreq>'; |
|
58 | + $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/registration/'.urlencode($aircraft_item['registration']).'</loc>'; |
|
59 | + $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
60 | + $output .= '<changefreq>daily</changefreq>'; |
|
61 | 61 | $output .= '</url>'; |
62 | 62 | } |
63 | 63 | $output .= '</urlset>'; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | foreach($airline_names as $airline_item) |
72 | 72 | { |
73 | 73 | $output .= '<url>'; |
74 | - $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.urlencode($airline_item['airline_icao']).'</loc>'; |
|
75 | - $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
76 | - $output .= '<changefreq>daily</changefreq>'; |
|
74 | + $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airline/'.urlencode($airline_item['airline_icao']).'</loc>'; |
|
75 | + $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
76 | + $output .= '<changefreq>daily</changefreq>'; |
|
77 | 77 | $output .= '</url>'; |
78 | 78 | } |
79 | 79 | $output .= '</urlset>'; |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | foreach($airport_names as $airport_item) |
89 | 89 | { |
90 | 90 | $output .= '<url>'; |
91 | - $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>'; |
|
92 | - $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
93 | - $output .= '<changefreq>daily</changefreq>'; |
|
91 | + $output .= '<loc>'.'http://'.$_SERVER['HTTP_HOST'].$globalURL.'/airport/'.$airport_item['airport_icao'].'</loc>'; |
|
92 | + $output .= '<lastmod>'.date("c", time()).'</lastmod>'; |
|
93 | + $output .= '<changefreq>daily</changefreq>'; |
|
94 | 94 | $output .= '</url>'; |
95 | 95 | } |
96 | 96 | $output .= '</urlset>'; |
@@ -9,25 +9,25 @@ discard block |
||
9 | 9 | require_once(dirname(__FILE__).'/class.Stats.php'); |
10 | 10 | require_once(dirname(__FILE__).'/class.Source.php'); |
11 | 11 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
12 | - require_once(dirname(__FILE__).'/class.APRS.php'); |
|
12 | + require_once(dirname(__FILE__).'/class.APRS.php'); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | class MarineImport { |
16 | - private $all_tracked = array(); |
|
17 | - private $last_delete_hourly = 0; |
|
18 | - private $last_delete = 0; |
|
19 | - private $stats = array(); |
|
20 | - private $tmd = 0; |
|
21 | - private $source_location = array(); |
|
22 | - public $db = null; |
|
23 | - public $nb = 0; |
|
16 | + private $all_tracked = array(); |
|
17 | + private $last_delete_hourly = 0; |
|
18 | + private $last_delete = 0; |
|
19 | + private $stats = array(); |
|
20 | + private $tmd = 0; |
|
21 | + private $source_location = array(); |
|
22 | + public $db = null; |
|
23 | + public $nb = 0; |
|
24 | 24 | |
25 | - public function __construct($dbc = null) { |
|
25 | + public function __construct($dbc = null) { |
|
26 | 26 | global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB; |
27 | 27 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
28 | - $Connection = new Connection($dbc); |
|
29 | - $this->db = $Connection->db(); |
|
30 | - date_default_timezone_set('UTC'); |
|
28 | + $Connection = new Connection($dbc); |
|
29 | + $this->db = $Connection->db(); |
|
30 | + date_default_timezone_set('UTC'); |
|
31 | 31 | } |
32 | 32 | // Get previous source stats |
33 | 33 | /* |
@@ -46,57 +46,57 @@ discard block |
||
46 | 46 | } |
47 | 47 | */ |
48 | 48 | if (isset($globalServerAPRS) && $globalServerAPRS) { |
49 | - $APRSMarine = new APRSMarine(); |
|
50 | - //$APRSSpotter->connect(); |
|
49 | + $APRSMarine = new APRSMarine(); |
|
50 | + //$APRSSpotter->connect(); |
|
51 | + } |
|
51 | 52 | } |
52 | - } |
|
53 | 53 | |
54 | - public function checkAll() { |
|
54 | + public function checkAll() { |
|
55 | 55 | global $globalDebug, $globalNoDB; |
56 | 56 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
57 | - if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | - foreach ($this->all_tracked as $key => $flight) { |
|
57 | + if ($globalDebug) echo "Update last seen tracked data...\n"; |
|
58 | + foreach ($this->all_tracked as $key => $flight) { |
|
59 | 59 | if (isset($this->all_tracked[$key]['id'])) { |
60 | - //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | - $Marine = new Marine($this->db); |
|
62 | - $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
60 | + //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].' '.$this->all_tracked[$key]['longitude']."\n"; |
|
61 | + $Marine = new Marine($this->db); |
|
62 | + $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
|
63 | 63 | } |
64 | - } |
|
64 | + } |
|
65 | + } |
|
65 | 66 | } |
66 | - } |
|
67 | 67 | |
68 | - public function del() { |
|
68 | + public function del() { |
|
69 | 69 | global $globalDebug, $globalNoDB, $globalNoImport; |
70 | 70 | // Delete old infos |
71 | 71 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
72 | 72 | foreach ($this->all_tracked as $key => $flight) { |
73 | - if (isset($flight['lastupdate'])) { |
|
74 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | - if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | - if (isset($this->all_tracked[$key]['id'])) { |
|
77 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | - /* |
|
73 | + if (isset($flight['lastupdate'])) { |
|
74 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
75 | + if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) { |
|
76 | + if (isset($this->all_tracked[$key]['id'])) { |
|
77 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n"; |
|
78 | + /* |
|
79 | 79 | $MarineLive = new MarineLive(); |
80 | 80 | $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']); |
81 | 81 | $MarineLive->db = null; |
82 | 82 | */ |
83 | - //$real_arrival = $this->arrival($key); |
|
84 | - $Marine = new Marine($this->db); |
|
85 | - if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
83 | + //$real_arrival = $this->arrival($key); |
|
84 | + $Marine = new Marine($this->db); |
|
85 | + if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') { |
|
86 | 86 | $result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']); |
87 | 87 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
88 | - } |
|
89 | - // Put in archive |
|
88 | + } |
|
89 | + // Put in archive |
|
90 | 90 | // $Marine->db = null; |
91 | 91 | } |
92 | - } |
|
93 | - unset($this->all_tracked[$key]); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
92 | + } |
|
93 | + unset($this->all_tracked[$key]); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - public function add($line) { |
|
99 | + public function add($line) { |
|
100 | 100 | global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine; |
101 | 101 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
102 | 102 | date_default_timezone_set('UTC'); |
@@ -105,83 +105,83 @@ discard block |
||
105 | 105 | |
106 | 106 | // SBS format is CSV format |
107 | 107 | if(is_array($line) && isset($line['mmsi'])) { |
108 | - //print_r($line); |
|
109 | - if (isset($line['mmsi'])) { |
|
108 | + //print_r($line); |
|
109 | + if (isset($line['mmsi'])) { |
|
110 | 110 | |
111 | 111 | |
112 | 112 | // Increment message number |
113 | 113 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
114 | - $current_date = date('Y-m-d'); |
|
115 | - if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | - else $source = ''; |
|
117 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
114 | + $current_date = date('Y-m-d'); |
|
115 | + if (isset($line['source_name'])) $source = $line['source_name']; |
|
116 | + else $source = ''; |
|
117 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
118 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
119 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
120 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
121 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | |
125 | 125 | $Common = new Common(); |
126 | 126 | $AIS = new AIS(); |
127 | - if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | - else $id = trim($line['id']); |
|
127 | + if (!isset($line['id'])) $id = trim($line['mmsi']); |
|
128 | + else $id = trim($line['id']); |
|
129 | 129 | |
130 | 130 | if (!isset($this->all_tracked[$id])) { |
131 | - $this->all_tracked[$id] = array(); |
|
132 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | - if (!isset($line['id'])) { |
|
131 | + $this->all_tracked[$id] = array(); |
|
132 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0)); |
|
133 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => '')); |
|
134 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time())); |
|
135 | + if (!isset($line['id'])) { |
|
136 | 136 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
137 | 137 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi'))); |
138 | - } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | - if ($globalAllTracked !== FALSE) $dataFound = true; |
|
138 | + } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id'])); |
|
139 | + if ($globalAllTracked !== FALSE) $dataFound = true; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) { |
143 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
143 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi'])); |
|
144 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
145 | 145 | $Marine = new Marine($this->db); |
146 | 146 | $identity = $Marine->getIdentity($line['mmsi']); |
147 | 147 | if (!empty($identity)) { |
148 | - $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | - $this->all_tracked[$id]['type'] = $identity['type']; |
|
148 | + $this->all_tracked[$id]['ident'] = $identity['ship_name']; |
|
149 | + $this->all_tracked[$id]['type'] = $identity['type']; |
|
150 | 150 | } |
151 | 151 | //print_r($identity); |
152 | 152 | unset($Marine); |
153 | 153 | //$dataFound = true; |
154 | - } |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | if (isset($line['type_id'])) { |
157 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
157 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id']))); |
|
158 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id'])); |
|
159 | 159 | } |
160 | 160 | if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') { |
161 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
161 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type'])); |
|
162 | 162 | } |
163 | 163 | if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') { |
164 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
164 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type'])); |
|
165 | 165 | } |
166 | 166 | if (isset($line['imo']) && $line['imo'] != '') { |
167 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
167 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo'])); |
|
168 | 168 | } |
169 | 169 | if (isset($line['callsign']) && $line['callsign'] != '') { |
170 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
170 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign'])); |
|
171 | 171 | } |
172 | 172 | if (isset($line['arrival_code']) && $line['arrival_code'] != '') { |
173 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
173 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code'])); |
|
174 | 174 | } |
175 | 175 | if (isset($line['arrival_date']) && $line['arrival_date'] != '') { |
176 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
176 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date'])); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | //if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) { |
180 | 180 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) { |
181 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
181 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident']))); |
|
182 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
183 | 183 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
184 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
184 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
185 | 185 | $timeelapsed = microtime(true); |
186 | 186 | $Marine = new Marine($this->db); |
187 | 187 | $fromsource = NULL; |
@@ -189,20 +189,20 @@ discard block |
||
189 | 189 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
190 | 190 | $Marine->db = null; |
191 | 191 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
192 | - } |
|
192 | + } |
|
193 | 193 | } |
194 | - } |
|
195 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
194 | + } |
|
195 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'])); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) { |
199 | - if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
199 | + if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) { |
|
200 | 200 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime'])); |
201 | - } else { |
|
201 | + } else { |
|
202 | 202 | if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n"; |
203 | 203 | elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n"; |
204 | 204 | return ''; |
205 | - } |
|
205 | + } |
|
206 | 206 | } elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) { |
207 | 207 | if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!"; |
208 | 208 | return ''; |
@@ -219,24 +219,24 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | if (isset($line['speed'])) { |
222 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
222 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed']))); |
|
223 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true)); |
|
224 | 224 | } else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
225 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | - if ($distance > 1000 && $distance < 10000) { |
|
225 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m'); |
|
226 | + if ($distance > 1000 && $distance < 10000) { |
|
227 | 227 | $speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']); |
228 | 228 | $speed = $speed*3.6; |
229 | 229 | if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed))); |
230 | 230 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
231 | - } |
|
231 | + } |
|
232 | 232 | } |
233 | 233 | |
234 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | - if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | - else unset($timediff); |
|
237 | - if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
234 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
235 | + if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']); |
|
236 | + else unset($timediff); |
|
237 | + if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) { |
|
238 | 238 | if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) { |
239 | - if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
239 | + if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
240 | 240 | $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
241 | 241 | $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
242 | 242 | $this->all_tracked[$id]['putinarchive'] = true; |
@@ -244,211 +244,211 @@ discard block |
||
244 | 244 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
245 | 245 | $timeelapsed = microtime(true); |
246 | 246 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
247 | - $Marine = new Marine($this->db); |
|
248 | - $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | - if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | - $Marine->db = null; |
|
251 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
247 | + $Marine = new Marine($this->db); |
|
248 | + $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
249 | + if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2']; |
|
250 | + $Marine->db = null; |
|
251 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
252 | 252 | } |
253 | 253 | $this->tmd = 0; |
254 | 254 | if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n"; |
255 | - } |
|
255 | + } |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
259 | 259 | if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude']; |
260 | 260 | if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
261 | - $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | - $dataFound = true; |
|
263 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
261 | + $this->all_tracked[$id]['livedb_latitude'] = $line['latitude']; |
|
262 | + $dataFound = true; |
|
263 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
264 | 264 | } |
265 | 265 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude'])); |
266 | 266 | } |
267 | 267 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
268 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
268 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
269 | 269 | if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude']; |
270 | 270 | if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') { |
271 | - $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | - $dataFound = true; |
|
273 | - $this->all_tracked[$id]['time_last_coord'] = time(); |
|
271 | + $this->all_tracked[$id]['livedb_longitude'] = $line['longitude']; |
|
272 | + $dataFound = true; |
|
273 | + $this->all_tracked[$id]['time_last_coord'] = time(); |
|
274 | 274 | } |
275 | 275 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude'])); |
276 | 276 | } |
277 | 277 | |
278 | - } else if ($globalDebug && $timediff > 20) { |
|
278 | + } else if ($globalDebug && $timediff > 20) { |
|
279 | 279 | $this->tmd = $this->tmd + 1; |
280 | 280 | echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n"; |
281 | 281 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -"; |
282 | 282 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
283 | 283 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n"; |
284 | - } |
|
284 | + } |
|
285 | 285 | } |
286 | 286 | if (isset($line['last_update']) && $line['last_update'] != '') { |
287 | - if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
287 | + if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
288 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update'])); |
|
289 | 289 | } |
290 | 290 | if (isset($line['format_source']) && $line['format_source'] != '') { |
291 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
291 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source'])); |
|
292 | 292 | } |
293 | 293 | if (isset($line['source_name']) && $line['source_name'] != '') { |
294 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
294 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name'])); |
|
295 | 295 | } |
296 | 296 | if (isset($line['status']) && $line['status'] != '') { |
297 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
297 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status'])); |
|
298 | 298 | } |
299 | 299 | if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) { |
300 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | - if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
300 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id'])); |
|
301 | + if ($this->all_tracked[$id]['addedMarine'] == 1) { |
|
302 | 302 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
303 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
303 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
304 | 304 | $Marine = new Marine($this->db); |
305 | 305 | $Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']); |
306 | 306 | unset($Marine); |
307 | - } |
|
307 | + } |
|
308 | + } |
|
308 | 309 | } |
309 | - } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
313 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
313 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true)); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | if (isset($line['heading']) && $line['heading'] != '') { |
317 | - if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | - //$dataFound = true; |
|
317 | + if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
318 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading']))); |
|
319 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true)); |
|
320 | + //$dataFound = true; |
|
321 | 321 | } elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) { |
322 | - $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | - $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | - if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
322 | + $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']); |
|
323 | + $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading))); |
|
324 | + if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true; |
|
325 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n"; |
|
326 | 326 | } |
327 | 327 | //if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
328 | 328 | |
329 | 329 | |
330 | 330 | |
331 | 331 | if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) { |
332 | - $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | - if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | - if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
332 | + $this->all_tracked[$id]['lastupdate'] = time(); |
|
333 | + if ($this->all_tracked[$id]['addedMarine'] == 0) { |
|
334 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
335 | + if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) { |
|
336 | 336 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
337 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | - $timeelapsed = microtime(true); |
|
339 | - $MarineLive = new MarineLive($this->db); |
|
340 | - if (isset($line['id'])) { |
|
337 | + if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
338 | + $timeelapsed = microtime(true); |
|
339 | + $MarineLive = new MarineLive($this->db); |
|
340 | + if (isset($line['id'])) { |
|
341 | 341 | $recent_ident = $MarineLive->checkIdRecent($line['id']); |
342 | 342 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
343 | - } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
343 | + } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') { |
|
344 | 344 | $recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']); |
345 | 345 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
346 | - } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
346 | + } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') { |
|
347 | 347 | $recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']); |
348 | 348 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
349 | - } else $recent_ident = ''; |
|
350 | - $MarineLive->db=null; |
|
351 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
349 | + } else $recent_ident = ''; |
|
350 | + $MarineLive->db=null; |
|
351 | + if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
352 | + elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
353 | 353 | } else $recent_ident = ''; |
354 | - } else { |
|
354 | + } else { |
|
355 | 355 | $recent_ident = ''; |
356 | 356 | $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0)); |
357 | - } |
|
358 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | - if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | - { |
|
357 | + } |
|
358 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
359 | + if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') |
|
360 | + { |
|
361 | 361 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : "; |
362 | 362 | //adds the spotter data for the archive |
363 | - $highlight = ''; |
|
364 | - if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | - if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
363 | + $highlight = ''; |
|
364 | + if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi'))); |
|
365 | + if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
|
366 | 366 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
367 | - $timeelapsed = microtime(true); |
|
368 | - $Marine = new Marine($this->db); |
|
369 | - $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | - $Marine->db = null; |
|
371 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
367 | + $timeelapsed = microtime(true); |
|
368 | + $Marine = new Marine($this->db); |
|
369 | + $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']); |
|
370 | + $Marine->db = null; |
|
371 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
372 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
373 | + } |
|
373 | 374 | } |
374 | - } |
|
375 | - if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
375 | + if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') { |
|
376 | 376 | // Add source stat in DB |
377 | 377 | $Stats = new Stats($this->db); |
378 | 378 | if (!empty($this->stats)) { |
379 | - if ($globalDebug) echo 'Add source stats : '; |
|
380 | - foreach($this->stats as $date => $data) { |
|
379 | + if ($globalDebug) echo 'Add source stats : '; |
|
380 | + foreach($this->stats as $date => $data) { |
|
381 | 381 | foreach($data as $source => $sourced) { |
382 | - //print_r($sourced); |
|
383 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | - if (isset($sourced['msg'])) { |
|
386 | - if (time() - $sourced['msg']['date'] > 10) { |
|
387 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | - echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | - unset($this->stats[$date][$source]['msg']); |
|
390 | - } |
|
391 | - } |
|
392 | - } |
|
393 | - if ($date != date('Y-m-d')) { |
|
394 | - unset($this->stats[$date]); |
|
395 | - } |
|
396 | - } |
|
397 | - if ($globalDebug) echo 'Done'."\n"; |
|
382 | + //print_r($sourced); |
|
383 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date); |
|
384 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date); |
|
385 | + if (isset($sourced['msg'])) { |
|
386 | + if (time() - $sourced['msg']['date'] > 10) { |
|
387 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
388 | + echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date); |
|
389 | + unset($this->stats[$date][$source]['msg']); |
|
390 | + } |
|
391 | + } |
|
392 | + } |
|
393 | + if ($date != date('Y-m-d')) { |
|
394 | + unset($this->stats[$date]); |
|
395 | + } |
|
396 | + } |
|
397 | + if ($globalDebug) echo 'Done'."\n"; |
|
398 | 398 | } |
399 | 399 | $Stats->db = null; |
400 | - } |
|
400 | + } |
|
401 | 401 | |
402 | - $this->del(); |
|
402 | + $this->del(); |
|
403 | 403 | //$ignoreImport = false; |
404 | 404 | $this->all_tracked[$id]['addedMarine'] = 1; |
405 | 405 | //print_r($this->all_tracked[$id]); |
406 | 406 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
407 | - if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | - //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
407 | + if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours..."; |
|
408 | + //MarineLive->deleteLiveMarineDataNotUpdated(); |
|
409 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
410 | 410 | $MarineLive = new MarineLive($this->db); |
411 | 411 | $MarineLive->deleteLiveMarineData(); |
412 | 412 | $MarineLive->db=null; |
413 | 413 | if ($globalDebug) echo " Done\n"; |
414 | - } |
|
415 | - $this->last_delete = time(); |
|
414 | + } |
|
415 | + $this->last_delete = time(); |
|
416 | 416 | } |
417 | - } elseif ($recent_ident != '') { |
|
417 | + } elseif ($recent_ident != '') { |
|
418 | 418 | $this->all_tracked[$id]['id'] = $recent_ident; |
419 | 419 | $this->all_tracked[$id]['addedMarine'] = 1; |
420 | 420 | if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
421 | - if (isset($globalDaemon) && !$globalDaemon) { |
|
421 | + if (isset($globalDaemon) && !$globalDaemon) { |
|
422 | 422 | $Marine = new Marine($this->db); |
423 | 423 | $Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']); |
424 | 424 | $Marine->db = null; |
425 | - } |
|
425 | + } |
|
426 | 426 | } |
427 | 427 | |
428 | - } |
|
428 | + } |
|
429 | + } |
|
429 | 430 | } |
430 | - } |
|
431 | - //adds the spotter LIVE data |
|
432 | - if ($globalDebug) { |
|
431 | + //adds the spotter LIVE data |
|
432 | + if ($globalDebug) { |
|
433 | 433 | echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n"; |
434 | - } |
|
435 | - $ignoreImport = false; |
|
434 | + } |
|
435 | + $ignoreImport = false; |
|
436 | 436 | |
437 | - if (!$ignoreImport) { |
|
437 | + if (!$ignoreImport) { |
|
438 | 438 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
439 | 439 | if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : "; |
440 | 440 | if (!isset($globalNoImport) || $globalNoImport !== TRUE) { |
441 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
441 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
442 | 442 | $timeelapsed = microtime(true); |
443 | 443 | $MarineLive = new MarineLive($this->db); |
444 | 444 | $result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
445 | 445 | $MarineLive->db = null; |
446 | 446 | if ($globalDebug) echo $result."\n"; |
447 | 447 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
448 | - } |
|
448 | + } |
|
449 | 449 | } |
450 | 450 | if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) { |
451 | - $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
451 | + $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']); |
|
452 | 452 | } |
453 | 453 | $this->all_tracked[$id]['putinarchive'] = false; |
454 | 454 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | if ($stats_heading == 16) $stats_heading = 0; |
481 | 481 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
482 | 482 | for ($i=0;$i<=15;$i++) { |
483 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
483 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
484 | 484 | } |
485 | 485 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
486 | 486 | } else { |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | //var_dump($this->stats); |
494 | 494 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
495 | 495 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
496 | - end($this->stats[$current_date][$source]['hist']); |
|
497 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
496 | + end($this->stats[$current_date][$source]['hist']); |
|
497 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
498 | 498 | } else $mini = 0; |
499 | 499 | for ($i=$mini;$i<=$distance;$i+=10) { |
500 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
500 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
501 | 501 | } |
502 | 502 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
503 | 503 | } else { |
@@ -513,24 +513,24 @@ discard block |
||
513 | 513 | |
514 | 514 | |
515 | 515 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
516 | - if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
516 | + if (!isset($globalNoDB) || $globalNoDB !== TRUE) { |
|
517 | 517 | if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour..."; |
518 | 518 | $MarineLive = new MarineLive($this->db); |
519 | 519 | $MarineLive->deleteLiveMarineDataNotUpdated(); |
520 | 520 | $MarineLive->db = null; |
521 | 521 | //MarineLive->deleteLiveMarineData(); |
522 | 522 | if ($globalDebug) echo " Done\n"; |
523 | - } |
|
524 | - $this->last_delete_hourly = time(); |
|
523 | + } |
|
524 | + $this->last_delete_hourly = time(); |
|
525 | 525 | } |
526 | 526 | |
527 | - } |
|
528 | - //$ignoreImport = false; |
|
527 | + } |
|
528 | + //$ignoreImport = false; |
|
529 | 529 | } |
530 | 530 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
531 | 531 | if ($send) return $this->all_tracked[$id]; |
532 | - } |
|
532 | + } |
|
533 | + } |
|
533 | 534 | } |
534 | - } |
|
535 | 535 | } |
536 | 536 | ?> |